diff options
-rw-r--r-- | services/java/com/android/server/WifiService.java | 15 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 2 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 13 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 12 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 21 |
5 files changed, 63 insertions, 0 deletions
diff --git a/services/java/com/android/server/WifiService.java b/services/java/com/android/server/WifiService.java index 2104097..0fbf1b6 100644 --- a/services/java/com/android/server/WifiService.java +++ b/services/java/com/android/server/WifiService.java @@ -929,6 +929,21 @@ public class WifiService extends IWifiManager.Stub { } /** + * Is Ad-Hoc (IBSS) mode supported by the driver? + * Will only return correct results when we have reached WIFI_STATE_ENABLED + * @return {@code true} if IBSS mode is supported, {@code false} if not + */ + public boolean isIbssSupported() { + enforceAccessPermission(); + if (mWifiStateMachineChannel != null) { + return (mWifiStateMachine.syncIsIbssSupported(mWifiStateMachineChannel) == 1); + } else { + Slog.e(TAG, "mWifiStateMachineChannel is not initialized"); + return false; + } + } + + /** * Return the DHCP-assigned addresses from the last successful DHCP request, * if any. * @return the DHCP information diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 1e67938..8049988 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -69,6 +69,8 @@ interface IWifiManager boolean isDualBandSupported(); + boolean isIbssSupported(); + boolean saveConfiguration(); DhcpInfo getDhcpInfo(); diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index e3ef913..f74dfe1 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -871,6 +871,19 @@ public class WifiManager { } /** + * Check if the chipset supports IBSS (Adhoc) mode + * @return {@code true} if supported, {@code false} otherwise. + * @hide + */ + public boolean isIbssSupported() { + try { + return mService.isIbssSupported(); + } catch (RemoteException e) { + return false; + } + } + + /** * Return the DHCP-assigned addresses from the last successful DHCP request, * if any. * @return the DHCP information diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index 733fb91..66bd90b 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -799,5 +799,17 @@ public class WifiNative { return doBooleanCommand("P2P_SERV_DISC_CANCEL_REQ " + id); } + public boolean getModeCapability(String mode) { + String ret = doStringCommand("GET_CAPABILITY modes"); + if (!TextUtils.isEmpty(ret)) { + String[] tokens = ret.split(" "); + for (String t : tokens) { + if (t.compareTo(mode) == 0) + return true; + } + } + return false; + } + public native static boolean setMode(int mode); } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 67e8ac9..2eed0c2 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -113,6 +113,7 @@ public class WifiStateMachine extends StateMachine { private ConnectivityManager mCm; private final boolean mP2pSupported; + private boolean mIbssSupported; private final AtomicBoolean mP2pConnected = new AtomicBoolean(false); private boolean mTemporarilyDisconnectWifi = false; private final String mPrimaryDeviceType; @@ -369,6 +370,9 @@ public class WifiStateMachine extends StateMachine { public static final int CMD_DISABLE_P2P_REQ = BASE + 132; public static final int CMD_DISABLE_P2P_RSP = BASE + 133; + /* Is IBSS mode supported by the driver? */ + public static final int CMD_GET_IBSS_SUPPORTED = BASE + 134; + private static final int CONNECT_MODE = 1; private static final int SCAN_ONLY_MODE = 2; @@ -1090,6 +1094,13 @@ public class WifiStateMachine extends StateMachine { return mCountryCode; } + public int syncIsIbssSupported(AsyncChannel channel) { + Message resultMsg = channel.sendMessageSynchronously(CMD_GET_IBSS_SUPPORTED); + int result = resultMsg.arg1; + resultMsg.recycle(); + return result; + } + /** * Set the operational frequency band * @param band @@ -1936,6 +1947,7 @@ public class WifiStateMachine extends StateMachine { case CMD_ADD_OR_UPDATE_NETWORK: case CMD_REMOVE_NETWORK: case CMD_SAVE_CONFIG: + case CMD_GET_IBSS_SUPPORTED: replyToMessage(message, message.what, FAILURE); break; case CMD_GET_CONFIGURED_NETWORKS: @@ -2406,6 +2418,8 @@ public class WifiStateMachine extends StateMachine { mWifiConfigStore.initialize(); initializeWpsDetails(); + mIbssSupported = mWifiNative.getModeCapability("IBSS"); + sendSupplicantConnectionChangedBroadcast(true); transitionTo(mDriverStartedState); break; @@ -2437,6 +2451,7 @@ public class WifiStateMachine extends StateMachine { case CMD_SET_FREQUENCY_BAND: case CMD_START_PACKET_FILTERING: case CMD_STOP_PACKET_FILTERING: + case CMD_GET_IBSS_SUPPORTED: deferMessage(message); break; default: @@ -2583,6 +2598,9 @@ public class WifiStateMachine extends StateMachine { WifiManager.ERROR); } break; + case CMD_GET_IBSS_SUPPORTED: + deferMessage(message); + break; default: return NOT_HANDLED; } @@ -2927,6 +2945,9 @@ public class WifiStateMachine extends StateMachine { setSuspendOptimizationsNative(SUSPEND_DUE_TO_HIGH_PERF, true); } break; + case CMD_GET_IBSS_SUPPORTED: + replyToMessage(message, message.what, mIbssSupported ? 1 : 0); + break; default: return NOT_HANDLED; } |