summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Randolf <br1@einfach.org>2015-01-13 16:53:00 -0800
committerSteve Kondik <steve@cyngn.com>2015-03-12 06:19:15 -0700
commit84be3614fb1ffc3aee97e4f7bb66139a776f8faf (patch)
treeec056486e807301e96e680c1c19422520b75f13c
parentbf1c31f4a392459c077adb76a072fe2325894bc9 (diff)
downloadandroid_frameworks_opt_net_wifi-84be3614fb1ffc3aee97e4f7bb66139a776f8faf.tar.gz
android_frameworks_opt_net_wifi-84be3614fb1ffc3aee97e4f7bb66139a776f8faf.tar.bz2
android_frameworks_opt_net_wifi-84be3614fb1ffc3aee97e4f7bb66139a776f8faf.zip
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". Change-Id: Idbccdf9d3b60855a0067032a0073f5aa001be224
-rwxr-xr-xservice/java/com/android/server/wifi/WifiConfigStore.java35
-rw-r--r--service/java/com/android/server/wifi/WifiNative.java12
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java15
-rwxr-xr-xservice/java/com/android/server/wifi/WifiStateMachine.java22
4 files changed, 84 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index 4959ce7c5..5478d144b 100755
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -2781,6 +2781,23 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ if (config.isIBSS) {
+ if(!mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.modeVarName,
+ "1")) {
+ loge("failed to set adhoc mode");
+ break setVariables;
+ }
+ if(!mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.frequencyVarName,
+ Integer.toString(config.frequency))) {
+ loge("failed to set frequency");
+ break setVariables;
+ }
+ }
+
String allowedKeyManagementString =
makeString(config.allowedKeyManagement, WifiConfiguration.KeyMgmt.strings);
if (config.allowedKeyManagement.cardinality() != 0 &&
@@ -3689,6 +3706,24 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.modeVarName);
+ config.isIBSS = false;
+ if (!TextUtils.isEmpty(value)) {
+ try {
+ config.isIBSS = Integer.parseInt(value) != 0;
+ } catch (NumberFormatException ignore) {
+ }
+ }
+
+ value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.frequencyVarName);
+ config.frequency = 0;
+ if (!TextUtils.isEmpty(value)) {
+ try {
+ config.frequency = Integer.parseInt(value);
+ } catch (NumberFormatException ignore) {
+ }
+ }
+
value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.wepTxKeyIdxVarName);
config.wepTxKeyIndex = -1;
if (!TextUtils.isEmpty(value)) {
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 59968274c..e555d921c 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -1131,6 +1131,18 @@ public class WifiNative {
doBooleanCommand("DRIVER MIRACAST " + mode);
}
+ 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 boolean fetchAnqp(String bssid, String subtypes) {
return doBooleanCommand("ANQP_GET " + bssid + " " + subtypes);
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 586eae2a7..5d5cd2571 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1142,6 +1142,21 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
com.android.internal.R.bool.config_wifi_dual_band_support);
}
+ /**
+ * 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.
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 5fd8331b8..95d06fdd5 100755
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -193,6 +193,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;
@@ -665,6 +666,9 @@ public class WifiStateMachine extends StateMachine {
static final int CMD_GET_SIM_INFO = BASE + 150;
+ /* Is IBSS mode supported by the driver? */
+ static final int CMD_GET_IBSS_SUPPORTED = BASE + 149;
+
/* Wifi state machine modes of operation */
/* CONNECT_MODE - connect to any 'known' AP when it becomes available */
public static final int CONNECT_MODE = 1;
@@ -1325,6 +1329,7 @@ public class WifiStateMachine extends StateMachine {
c.freqMHz = Integer.parseInt(prop[3]);
} catch (NumberFormatException e) { }
c.isDFS = line.contains("(DFS)");
+ c.ibssAllowed = !line.contains("(NO_IBSS)");
list.add(c);
} else if (line.contains("Mode[B] Channels:")) {
// B channels are the same as G channels, skipped
@@ -2433,6 +2438,13 @@ public class WifiStateMachine extends StateMachine {
}
}
+ 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
@@ -4863,6 +4875,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_CAPABILITY_FREQ:
@@ -5210,6 +5223,8 @@ public class WifiStateMachine extends StateMachine {
}
initializeWpsDetails();
+ mIbssSupported = mWifiNative.getModeCapability("IBSS");
+
sendSupplicantConnectionChangedBroadcast(true);
transitionTo(mDriverStartedState);
break;
@@ -5238,6 +5253,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:
messageHandlingStatus = MESSAGE_HANDLING_STATUS_DEFERRED;
deferMessage(message);
break;
@@ -5346,6 +5362,9 @@ public class WifiStateMachine extends StateMachine {
}
replyToMessage(message, message.what, stats);
break;
+ case CMD_GET_IBSS_SUPPORTED:
+ deferMessage(message);
+ break;
default:
return NOT_HANDLED;
}
@@ -5764,6 +5783,9 @@ public class WifiStateMachine extends StateMachine {
mWifiNative.startTdls(remoteAddress, enable);
}
break;
+ case CMD_GET_IBSS_SUPPORTED:
+ replyToMessage(message, message.what, mIbssSupported ? 1 : 0);
+ break;
default:
return NOT_HANDLED;
}