summaryrefslogtreecommitdiffstats
path: root/wifi
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2012-05-05 14:09:11 +0400
committerGerrit Code Review <gerrit@review.cyanogenmod.com>2012-05-05 14:09:11 +0400
commit68ef972e534cd13f0344dee38d1a8b7206b5ef0a (patch)
treec1d07b6708bdde06859db48d499b171a87ff19ce /wifi
parent0fc18594e5a56c93f5afc6a13a38d8f55c8e5042 (diff)
parentaff66a2b35cdb71750bc3ba715972b382d7fa73a (diff)
downloadframeworks_base-68ef972e534cd13f0344dee38d1a8b7206b5ef0a.zip
frameworks_base-68ef972e534cd13f0344dee38d1a8b7206b5ef0a.tar.gz
frameworks_base-68ef972e534cd13f0344dee38d1a8b7206b5ef0a.tar.bz2
Merge "Ad-hoc network support (framework part)" into ics
Diffstat (limited to 'wifi')
-rw-r--r--wifi/java/android/net/wifi/WifiConfigStore.java35
-rw-r--r--wifi/java/android/net/wifi/WifiConfiguration.java27
2 files changed, 62 insertions, 0 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java
index 568a485..54b760f 100644
--- a/wifi/java/android/net/wifi/WifiConfigStore.java
+++ b/wifi/java/android/net/wifi/WifiConfigStore.java
@@ -1025,6 +1025,32 @@ class WifiConfigStore {
break setVariables;
}
+ // Android sometimes call this function with infrastructure
+ // configuration for ad-hoc networks (from selectNetwork),
+ // so we only set the variable if the mode is ad-hoc.
+ // (Infrastructure is default and does not have to be set.)
+ if (config.mode == WifiConfiguration.Mode.ADHOC) {
+ if (!WifiNative.setNetworkVariableCommand(
+ netId,
+ WifiConfiguration.Mode.varName,
+ Integer.toString(config.mode))) {
+ loge(config.SSID + ": failed to set mode: "
+ +config.mode);
+ break setVariables;
+ }
+
+ // Some drivers/wpa_supplicant require the frequency
+ // to be set for ad-hoc networks, even though it will
+ // not actually be used. Set it to Channel 11.
+ if (!WifiNative.setNetworkVariableCommand(
+ netId,
+ "frequency",
+ "2462")) {
+ loge(config.SSID + ": failed to set frequency: 2462");
+ break setVariables;
+ }
+ }
+
for (WifiConfiguration.EnterpriseField field
: config.enterpriseFields) {
String varName = field.varName();
@@ -1246,6 +1272,15 @@ class WifiConfigStore {
}
}
+ value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.Mode.varName);
+ config.mode = WifiConfiguration.Mode.INFRASTRUCTURE;
+ if (!TextUtils.isEmpty(value)) {
+ try {
+ config.mode = Integer.parseInt(value);
+ } catch (NumberFormatException ignore) {
+ }
+ }
+
value = WifiNative.getNetworkVariableCommand(netId, WifiConfiguration.wepTxKeyIdxVarName);
config.wepTxKeyIndex = -1;
if (!TextUtils.isEmpty(value)) {
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index 85a6f27..01125c5 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -211,6 +211,23 @@ public class WifiConfiguration implements Parcelable {
public static final String[] strings = { "current", "disabled", "enabled" };
}
+ /**
+ * Possible modes of a network configuration.
+ * @hide
+ */
+ public static class Mode {
+ private Mode() { }
+
+ /** this is an infrastructure network */
+ public static final int INFRASTRUCTURE = 0;
+ /** this is an ad-hoc network */
+ public static final int ADHOC = 1;
+
+ public static final String varName = "mode";
+
+ public static final String[] strings = { "infrastructure", "ad-hoc" };
+ }
+
/** @hide */
public static final int DISABLED_UNKNOWN_REASON = 0;
/** @hide */
@@ -291,6 +308,12 @@ public class WifiConfiguration implements Parcelable {
public boolean hiddenSSID;
/**
+ * The mode this access point operates on (infrastructure or ad-hoc)
+ * @hide
+ */
+ public int mode;
+
+ /**
* The set of key management protocols supported by this configuration.
* See {@link KeyMgmt} for descriptions of the values.
* Defaults to WPA-PSK WPA-EAP.
@@ -368,6 +391,7 @@ public class WifiConfiguration implements Parcelable {
BSSID = null;
priority = 0;
hiddenSSID = false;
+ mode = Mode.INFRASTRUCTURE;
disableReason = DISABLED_UNKNOWN_REASON;
allowedKeyManagement = new BitSet();
allowedProtocols = new BitSet();
@@ -542,6 +566,7 @@ public class WifiConfiguration implements Parcelable {
wepTxKeyIndex = source.wepTxKeyIndex;
priority = source.priority;
hiddenSSID = source.hiddenSSID;
+ mode = source.mode;
allowedKeyManagement = (BitSet) source.allowedKeyManagement.clone();
allowedProtocols = (BitSet) source.allowedProtocols.clone();
allowedAuthAlgorithms = (BitSet) source.allowedAuthAlgorithms.clone();
@@ -570,6 +595,7 @@ public class WifiConfiguration implements Parcelable {
dest.writeInt(wepTxKeyIndex);
dest.writeInt(priority);
dest.writeInt(hiddenSSID ? 1 : 0);
+ dest.writeInt(mode);
writeBitSet(dest, allowedKeyManagement);
writeBitSet(dest, allowedProtocols);
@@ -601,6 +627,7 @@ public class WifiConfiguration implements Parcelable {
config.wepTxKeyIndex = in.readInt();
config.priority = in.readInt();
config.hiddenSSID = in.readInt() != 0;
+ config.mode = in.readInt();
config.allowedKeyManagement = readBitSet(in);
config.allowedProtocols = readBitSet(in);
config.allowedAuthAlgorithms = readBitSet(in);