summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2013-02-28 23:19:28 +0000
committerGerrit Code Review <gerrit@cyanogenmod.org>2013-03-24 16:13:07 -0700
commitf1d4a07494c7772c7974d0d4416455a713c1aff0 (patch)
tree38b7c8811cb8f4cfd11c35d0c76936de9911eac5 /wifi
parentd464e60ad07cf0bdb424ffa83e98756ecfd678e8 (diff)
downloadframeworks_base-f1d4a07494c7772c7974d0d4416455a713c1aff0.zip
frameworks_base-f1d4a07494c7772c7974d0d4416455a713c1aff0.tar.gz
frameworks_base-f1d4a07494c7772c7974d0d4416455a713c1aff0.tar.bz2
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
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/IWifiManager.aidl2
-rw-r--r--wifi/java/android/net/wifi/WifiManager.java13
-rw-r--r--wifi/java/android/net/wifi/WifiNative.java12
-rw-r--r--wifi/java/android/net/wifi/WifiStateMachine.java21
4 files changed, 48 insertions, 0 deletions
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;
}