Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Wifi: Add IBSS supported method

Add method isIbssSupported() to WifiManager and related classes to query wether
the driver supports IBSS mode. The query is answered by wpa_supplicants new
command "get_capability modes".

It will only return a correct result after WIFI_STATE_ENABLED has been
reached.

Change-Id: I93aa2fdff94cd897c91ec3beb7e58940d1de7b72
  • Loading branch information...
commit 7ade1fa2b4b22d0455f5e42b8853d4bc325120f0 1 parent 5072ab7
@br101 br101 authored Whitehawkx committed
View
15 services/java/com/android/server/WifiService.java
@@ -938,6 +938,21 @@ public boolean isDualBandSupported() {
}
/**
+ * 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
View
2  wifi/java/android/net/wifi/IWifiManager.aidl
@@ -69,6 +69,8 @@ interface IWifiManager
boolean isDualBandSupported();
+ boolean isIbssSupported();
+
boolean saveConfiguration();
DhcpInfo getDhcpInfo();
View
13 wifi/java/android/net/wifi/WifiManager.java
@@ -871,6 +871,19 @@ public boolean isDualBandSupported() {
}
/**
+ * 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
View
12 wifi/java/android/net/wifi/WifiNative.java
@@ -799,5 +799,17 @@ public boolean p2pServDiscCancelReq(String id) {
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);
}
View
21 wifi/java/android/net/wifi/WifiStateMachine.java
@@ -113,6 +113,7 @@
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 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 String getCountryCode() {
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 boolean processMessage(Message message) {
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 boolean processMessage(Message message) {
mWifiConfigStore.initialize();
initializeWpsDetails();
+ mIbssSupported = mWifiNative.getModeCapability("IBSS");
+
sendSupplicantConnectionChangedBroadcast(true);
transitionTo(mDriverStartedState);
break;
@@ -2437,6 +2451,7 @@ public boolean processMessage(Message message) {
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 boolean processMessage(Message message) {
WifiManager.ERROR);
}
break;
+ case CMD_GET_IBSS_SUPPORTED:
+ deferMessage(message);
+ break;
default:
return NOT_HANDLED;
}
@@ -2927,6 +2945,9 @@ public boolean processMessage(Message message) {
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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.