diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-04-25 23:19:29 +0700 |
---|---|---|
committer | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-05-01 11:47:01 +0700 |
commit | aff66a2b35cdb71750bc3ba715972b382d7fa73a (patch) | |
tree | f526ae30769bd5ab8f52e945d1402cec80b262f2 /wifi | |
parent | c901f3c06b611f097d825f08dddde2c627039e3a (diff) | |
download | frameworks_base-aff66a2b35cdb71750bc3ba715972b382d7fa73a.zip frameworks_base-aff66a2b35cdb71750bc3ba715972b382d7fa73a.tar.gz frameworks_base-aff66a2b35cdb71750bc3ba715972b382d7fa73a.tar.bz2 |
Ad-hoc network support (framework part)
Based on GB patch by havlenapetr
Change-Id: I588b6b46c00b883a6a85317cdefdf5626bebae43
Diffstat (limited to 'wifi')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 35 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 27 |
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); |