summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiConfigStore.java
diff options
context:
space:
mode:
Diffstat (limited to 'service/java/com/android/server/wifi/WifiConfigStore.java')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStore.java440
1 files changed, 373 insertions, 67 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index d6e41a13d..767607b90 100644
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -71,6 +71,8 @@ import com.android.server.wifi.hotspot2.omadm.MOManager;
import com.android.server.wifi.hotspot2.pps.Credential;
import com.android.server.wifi.hotspot2.pps.HomeSP;
+import cyanogenmod.providers.CMSettings;
+
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
@@ -387,6 +389,7 @@ public class WifiConfigStore extends IpConfigStore {
public boolean enable5GHzPreference = true;
public boolean enableWifiCellularHandoverUserTriggeredAdjustment = true;
+ private int mConfiguredBand = 0;
public int currentNetworkBoost = 25;
public int scanResultRssiLevelPatchUp = -85;
@@ -834,7 +837,7 @@ public class WifiConfigStore extends IpConfigStore {
if (cache == null) {
continue;
}
- config.setVisibility(cache.getVisibility(milli));
+ config.setVisibility(cache.getVisibility(milli, mConfiguredBand));
if (config.visibility == null) {
continue;
}
@@ -985,24 +988,42 @@ public class WifiConfigStore extends IpConfigStore {
if (VDBG) localLog("selectNetwork", config.networkId);
if (config.networkId == INVALID_NETWORK_ID) return false;
- // Reset the priority of each network at start or if it goes too high.
- if (mLastPriority == -1 || mLastPriority > 1000000) {
- for(WifiConfiguration config2 : mConfiguredNetworks.values()) {
- if (updatePriorities) {
- if (config2.networkId != INVALID_NETWORK_ID) {
- config2.priority = 0;
- setNetworkPriorityNative(config2.networkId, config.priority);
+ final boolean autoConfigure = isAutoConfigPriorities();
+ if (autoConfigure) {
+ // Reset the priority of each network at start or if it goes too high.
+ if (mLastPriority == -1 || mLastPriority > 1000000) {
+ for (WifiConfiguration config2 : mConfiguredNetworks.values()) {
+ if (updatePriorities) {
+ if (config2.networkId != INVALID_NETWORK_ID) {
+ config2.priority = 0;
+ setNetworkPriorityNative(config2.networkId, config.priority);
+ }
}
}
}
- mLastPriority = 0;
+ } else {
+ // Ensure that last priority is reestablished if auto configuration is reenabled
+ for (WifiConfiguration wifiConfiguration : mConfiguredNetworks.values()) {
+ if (wifiConfiguration != null && wifiConfiguration.priority > mLastPriority) {
+ mLastPriority = wifiConfiguration.priority;
+ }
+ }
}
+
// Set to the highest priority and save the configuration.
- if (updatePriorities) {
- config.priority = ++mLastPriority;
- setNetworkPriorityNative(config.networkId, config.priority);
- buildPnoList();
+ if (autoConfigure) {
+ if (updatePriorities) {
+ config.priority = ++mLastPriority;
+ setNetworkPriorityNative(config.networkId, config.priority);
+ buildPnoList();
+ }
+ } else {
+ // Use the lastknown configuration to recover the priority
+ WifiConfiguration lastKnown = mConfiguredNetworks.get(config.networkId);
+ if (lastKnown != null) {
+ config.priority = lastKnown.priority;
+ }
}
if (config.isPasspoint()) {
@@ -1033,7 +1054,7 @@ public class WifiConfigStore extends IpConfigStore {
writeKnownNetworkHistory(false);
/* Enable the given network while disabling all other networks */
- enableNetworkWithoutBroadcast(config.networkId, true);
+ enableNetworkWithoutBroadcast(config.networkId, autoConfigure);
/* Avoid saving the config & sending a broadcast to prevent settings
* from displaying a disabled list of networks */
@@ -1135,6 +1156,24 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ void unblackListDriverRoamedBSSID(String bssid) {
+ for (WifiConfiguration config : mConfiguredNetworks.values()) {
+ ScanDetailCache cache = getScanDetailCache(config);
+ if (cache != null) {
+ ScanResult result = cache.get(bssid);
+ if (result != null) {
+ if (result.autoJoinStatus == (ScanResult.AUTO_ROAM_DISABLED + 1)) {
+ if (DBG) {
+ Log.d(TAG,"unblacklisted driver roamed BSSID = "+result.BSSID);
+ }
+ result.setAutoJoinStatus(ScanResult.ENABLED);
+ }
+ }
+ }
+ }
+ }
+
+
void noteRoamingFailure(WifiConfiguration config, int reason) {
if (config == null) return;
config.lastRoamingFailure = System.currentTimeMillis();
@@ -1895,6 +1934,7 @@ public class WifiConfigStore extends IpConfigStore {
mLastPriority = 0;
mConfiguredNetworks.clear();
+ mScanDetailCaches.clear();
List<WifiConfiguration> configTlsResetList = new ArrayList<WifiConfiguration>();
int last_id = -1;
boolean done = false;
@@ -1951,8 +1991,8 @@ public class WifiConfigStore extends IpConfigStore {
mLastPriority = config.priority;
}
- config.setIpAssignment(IpAssignment.DHCP);
- config.setProxySettings(ProxySettings.NONE);
+ config.setIpAssignment(IpAssignment.DHCP);
+ config.setProxySettings(ProxySettings.NONE);
if (mConfiguredNetworks.getByConfigKey(config.configKey()) != null) {
// That SSID is already known, just ignore this duplicate entry
@@ -2172,6 +2212,14 @@ public class WifiConfigStore extends IpConfigStore {
needUpdate = true;
}
}
+ final List<Long> deletedSSIDs = new ArrayList<Long>();
+ for (Long csum : mDeletedSSIDs) {
+ deletedSSIDs.add(new Long(csum));
+ }
+ final List<String> deletedEphemeralSSIDs = new ArrayList<String>();
+ for (String ssid: mDeletedEphemeralSSIDs) {
+ deletedEphemeralSSIDs.add(new String(ssid));
+ }
if (VDBG) {
loge(" writeKnownNetworkHistory() num networks:" +
mConfiguredNetworks.size() + " needWrite=" + needUpdate);
@@ -2313,8 +2361,9 @@ public class WifiConfigStore extends IpConfigStore {
out.writeUTF(DEFAULT_GW_KEY + SEPARATOR + macAddress + NL);
}
- if (getScanDetailCache(config) != null) {
- for (ScanDetail scanDetail : getScanDetailCache(config).values()) {
+ ScanDetailCache cache = getScanDetailCacheIfExist(config);
+ if (cache != null) {
+ for (ScanDetail scanDetail : cache.values()) {
ScanResult result = scanDetail.getScanResult();
out.writeUTF(BSSID_KEY + SEPARATOR +
result.BSSID + NL);
@@ -2343,15 +2392,15 @@ public class WifiConfigStore extends IpConfigStore {
out.writeUTF(NL);
out.writeUTF(NL);
}
- if (mDeletedSSIDs != null && mDeletedSSIDs.size() > 0) {
- for (Long i : mDeletedSSIDs) {
+ if (deletedSSIDs.size() > 0) {
+ for (Long i : deletedSSIDs) {
out.writeUTF(DELETED_CRC32_KEY);
out.writeUTF(String.valueOf(i));
out.writeUTF(NL);
}
}
- if (mDeletedEphemeralSSIDs != null && mDeletedEphemeralSSIDs.size() > 0) {
- for (String ssid : mDeletedEphemeralSSIDs) {
+ if (deletedEphemeralSSIDs.size() > 0) {
+ for (String ssid : deletedEphemeralSSIDs) {
out.writeUTF(DELETED_EPHEMERAL_KEY);
out.writeUTF(ssid);
out.writeUTF(NL);
@@ -2388,6 +2437,10 @@ public class WifiConfigStore extends IpConfigStore {
return lastSelectedConfiguration;
}
+ public void setConfiguredBand(int band) {
+ mConfiguredBand = band;
+ }
+
public boolean isLastSelectedConfiguration(WifiConfiguration config) {
return (lastSelectedConfiguration != null
&& config != null
@@ -2405,6 +2458,8 @@ public class WifiConfigStore extends IpConfigStore {
String bssid = null;
String ssid = null;
+ String key = null;
+ String value = null;
int freq = 0;
int status = 0;
@@ -2419,17 +2474,21 @@ public class WifiConfigStore extends IpConfigStore {
break;
}
int colon = line.indexOf(':');
- if (colon < 0) {
+ char slash = line.charAt(0);
+ if ((colon < 0)&& (slash != '/')) {
continue;
}
-
- String key = line.substring(0, colon).trim();
- String value = line.substring(colon + 1).trim();
+ if (slash == '/') {
+ key = line.trim();
+ } else {
+ key = line.substring(0, colon).trim();
+ value = line.substring(colon + 1).trim();
+ }
if (key.equals(CONFIG_KEY)) {
config = mConfiguredNetworks.getByConfigKey(value);
-
+
// skip reading that configuration data
// since we don't have a corresponding network ID
if (config == null) {
@@ -2570,8 +2629,15 @@ public class WifiConfigStore extends IpConfigStore {
break;
case BSSID_KEY:
status = 0;
- ssid = null;
- bssid = null;
+ /*
+ * The intention here is to put the scanDetail in to
+ * the scanDetailCache per config , as done in
+ * BSSID_KEY_END . Thus store bssid value and
+ * comment ssid = null to ensure the code in the if
+ * loop is executed for the case BSSID_KEY_END.
+ */
+ // ssid = null;
+ bssid = value;
freq = 0;
seen = 0;
rssi = WifiConfiguration.INVALID_RSSI;
@@ -2756,14 +2822,24 @@ public class WifiConfigStore extends IpConfigStore {
}
boolean updateFailed = true;
+ WifiConfiguration savedConfig = null;
setVariables: {
+ if (newNetwork == false ) {
+ savedConfig = mConfiguredNetworks.get(netId);
+ if (savedConfig != null) {
+ readNetworkVariables(savedConfig);
+ }
+ }
- if (config.SSID != null &&
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.SSID != null) && (config.SSID != null) &&
+ (savedConfig.SSID.equals(config.SSID))) &&
+ (config.SSID != null &&
!mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.ssidVarName,
- encodeSSID(config.SSID))) {
+ encodeSSID(config.SSID)))) {
loge("failed to set SSID: "+config.SSID);
break setVariables;
}
@@ -2778,7 +2854,10 @@ public class WifiConfigStore extends IpConfigStore {
}
}
- if (config.BSSID != null) {
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.BSSID != null) && (config.BSSID != null) &&
+ (savedConfig.BSSID.equals(config.BSSID)))
+ && (config.BSSID != null)) {
log("Setting BSSID for " + config.configKey() + " to " + config.BSSID);
if (!mWifiNative.setNetworkVariable(
netId,
@@ -2789,13 +2868,46 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.SIMNum == config.SIMNum)) && (config.SIMNum != 0)){
+ if (!mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.SIMNumVarName,
+ Integer.toString(config.SIMNum))) {
+ loge(config.SIMNum + ": failed to set sim no: "
+ +config.SIMNum);
+ break setVariables;
+ }
+ }
+
+ 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 &&
- !mWifiNative.setNetworkVariable(
- netId,
- WifiConfiguration.KeyMgmt.varName,
- allowedKeyManagementString)) {
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (allowedKeyManagementString != null) &&
+ (savedConfig.allowedKeyManagement.equals(
+ config.allowedKeyManagement))) &&
+ config.allowedKeyManagement.cardinality() != 0 &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.KeyMgmt.varName,
+ allowedKeyManagementString)) {
loge("failed to set key_mgmt: "+
allowedKeyManagementString);
break setVariables;
@@ -2803,8 +2915,11 @@ public class WifiConfigStore extends IpConfigStore {
String allowedProtocolsString =
makeString(config.allowedProtocols, WifiConfiguration.Protocol.strings);
- if (config.allowedProtocols.cardinality() != 0 &&
- !mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (allowedProtocolsString != null) &&
+ (savedConfig.allowedProtocols.equals(config.allowedProtocols)))
+ && config.allowedProtocols.cardinality() != 0 &&
+ !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.Protocol.varName,
allowedProtocolsString)) {
@@ -2815,11 +2930,15 @@ public class WifiConfigStore extends IpConfigStore {
String allowedAuthAlgorithmsString =
makeString(config.allowedAuthAlgorithms, WifiConfiguration.AuthAlgorithm.strings);
- if (config.allowedAuthAlgorithms.cardinality() != 0 &&
- !mWifiNative.setNetworkVariable(
- netId,
- WifiConfiguration.AuthAlgorithm.varName,
- allowedAuthAlgorithmsString)) {
+ if (!((newNetwork == false) && (savedConfig != null)
+ && (allowedAuthAlgorithmsString != null) &&
+ (savedConfig.allowedAuthAlgorithms.equals(
+ config.allowedAuthAlgorithms))) &&
+ config.allowedAuthAlgorithms.cardinality() != 0 &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.AuthAlgorithm.varName,
+ allowedAuthAlgorithmsString)) {
loge("failed to set auth_alg: "+
allowedAuthAlgorithmsString);
break setVariables;
@@ -2828,11 +2947,15 @@ public class WifiConfigStore extends IpConfigStore {
String allowedPairwiseCiphersString =
makeString(config.allowedPairwiseCiphers,
WifiConfiguration.PairwiseCipher.strings);
- if (config.allowedPairwiseCiphers.cardinality() != 0 &&
- !mWifiNative.setNetworkVariable(
- netId,
- WifiConfiguration.PairwiseCipher.varName,
- allowedPairwiseCiphersString)) {
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (allowedPairwiseCiphersString != null) &&
+ (savedConfig.allowedPairwiseCiphers.equals(
+ config.allowedPairwiseCiphers))) &&
+ config.allowedPairwiseCiphers.cardinality() != 0 &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.PairwiseCipher.varName,
+ allowedPairwiseCiphersString)) {
loge("failed to set pairwise: "+
allowedPairwiseCiphersString);
break setVariables;
@@ -2840,11 +2963,15 @@ public class WifiConfigStore extends IpConfigStore {
String allowedGroupCiphersString =
makeString(config.allowedGroupCiphers, WifiConfiguration.GroupCipher.strings);
- if (config.allowedGroupCiphers.cardinality() != 0 &&
- !mWifiNative.setNetworkVariable(
- netId,
- WifiConfiguration.GroupCipher.varName,
- allowedGroupCiphersString)) {
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (allowedGroupCiphersString != null) &&
+ (savedConfig.allowedGroupCiphers.equals(
+ config.allowedGroupCiphers))) &&
+ config.allowedGroupCiphers.cardinality() != 0 &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ WifiConfiguration.GroupCipher.varName,
+ allowedGroupCiphersString)) {
loge("failed to set group: "+
allowedGroupCiphersString);
break setVariables;
@@ -2852,8 +2979,13 @@ public class WifiConfigStore extends IpConfigStore {
// Prevent client screw-up by passing in a WifiConfiguration we gave it
// by preventing "*" as a key.
- if (config.preSharedKey != null && !config.preSharedKey.equals("*") &&
- !mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.preSharedKey != null) &&
+ (config.preSharedKey != null) &&
+ (savedConfig.preSharedKey.equals(config.preSharedKey)))
+ && config.preSharedKey != null &&
+ !config.preSharedKey.equals("*") &&
+ !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.pskVarName,
config.preSharedKey)) {
@@ -2866,15 +2998,20 @@ public class WifiConfigStore extends IpConfigStore {
for (int i = 0; i < config.wepKeys.length; i++) {
// Prevent client screw-up by passing in a WifiConfiguration we gave it
// by preventing "*" as a key.
- if (config.wepKeys[i] != null && !config.wepKeys[i].equals("*")) {
- if (!mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (config.wepKeys[i] != null) &&
+ (savedConfig.wepKeys[i] != null) &&
+ (savedConfig.wepKeys[i].equals(config.wepKeys[i])))) {
+ if (config.wepKeys[i] != null && !config.wepKeys[i].equals("*")) {
+ if (!mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.wepKeyVarNames[i],
config.wepKeys[i])) {
- loge("failed to set wep_key" + i + ": " + config.wepKeys[i]);
- break setVariables;
+ loge("failed to set wep_key" + i + ": " + config.wepKeys[i]);
+ break setVariables;
+ }
+ hasSetKey = true;
}
- hasSetKey = true;
}
}
}
@@ -2889,7 +3026,9 @@ public class WifiConfigStore extends IpConfigStore {
}
}
- if (!mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (config.priority == savedConfig.priority )) &&
+ !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.priorityVarName,
Integer.toString(config.priority))) {
@@ -2898,7 +3037,9 @@ public class WifiConfigStore extends IpConfigStore {
break setVariables;
}
- if (config.hiddenSSID && !mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.hiddenSSID == config.hiddenSSID)) &&
+ config.hiddenSSID && !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.hiddenSSIDVarName,
Integer.toString(config.hiddenSSID ? 1 : 0))) {
@@ -2907,7 +3048,9 @@ public class WifiConfigStore extends IpConfigStore {
break setVariables;
}
- if (config.requirePMF && !mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.requirePMF == config.requirePMF)) &&
+ config.requirePMF && !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.pmfVarName,
"2")) {
@@ -2916,7 +3059,11 @@ public class WifiConfigStore extends IpConfigStore {
break setVariables;
}
- if (config.updateIdentifier != null && !mWifiNative.setNetworkVariable(
+ if (!((newNetwork == false) && (savedConfig != null) &&
+ (savedConfig.updateIdentifier != null) &&
+ (config.updateIdentifier != null) &&
+ (savedConfig.updateIdentifier.equals(config.updateIdentifier)))
+ && config.updateIdentifier != null && !mWifiNative.setNetworkVariable(
netId,
WifiConfiguration.updateIdentiferVarName,
config.updateIdentifier)) {
@@ -2926,7 +3073,7 @@ public class WifiConfigStore extends IpConfigStore {
}
if (config.enterpriseConfig != null &&
- config.enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE) {
+ config.enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE) {
WifiEnterpriseConfig enterpriseConfig = config.enterpriseConfig;
@@ -2961,8 +3108,16 @@ public class WifiConfigStore extends IpConfigStore {
}
HashMap<String, String> enterpriseFields = enterpriseConfig.getFields();
+ HashMap<String, String> savedEnterpriseFields = null;
+ String savedValue = null;
+ if (savedConfig != null && savedConfig.enterpriseConfig != null) {
+ savedEnterpriseFields = savedConfig.enterpriseConfig.getFields();
+ }
for (String key : enterpriseFields.keySet()) {
String value = enterpriseFields.get(key);
+ if (savedEnterpriseFields != null) {
+ savedValue = savedEnterpriseFields.get(key);
+ }
if (key.equals("password") && value != null && value.equals("*")) {
// No need to try to set an obfuscated password, which will fail
continue;
@@ -2972,7 +3127,63 @@ public class WifiConfigStore extends IpConfigStore {
// No need to save realm or PLMN in supplicant
continue;
}
- if (!mWifiNative.setNetworkVariable(
+ if (key.equals(WifiEnterpriseConfig.IDENTITY_KEY)) {
+ if ((config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.SIM)||
+ (config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.AKA)||
+ (config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.AKA_PRIME)) {
+ if ( (!newNetwork) && (value != null) && !mWifiNative.setNetworkVariable(
+ netId,
+ key,
+ "NULL")) {
+ loge(config.SSID + ": failed to set " + key +
+ ": " + value);
+ break setVariables;
+ }
+ } else {
+ if (!((newNetwork == false) && (savedValue != null) &&
+ (value != null) && value.equals(savedValue)) &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ key,
+ value)) {
+ removeKeys(enterpriseConfig);
+ loge(config.SSID + ": failed to set " + key +
+ ": " + value);
+ break setVariables;
+ }
+ }
+ continue;
+ }
+ if (key.equals(WifiEnterpriseConfig.ANON_IDENTITY_KEY)) {
+ if ((config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.SIM)||
+ (config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.AKA)||
+ (config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.AKA_PRIME)) {
+ if ( (!newNetwork) && (value != null) && !mWifiNative.setNetworkVariable(
+ netId,
+ key,
+ "NULL")) {
+ loge(config.SSID + ": failed to set " + key +
+ ": " + value);
+ break setVariables;
+ }
+ } else {
+ if (!((newNetwork == false) && (savedValue != null) &&
+ (value != null) && value.equals(savedValue)) &&
+ !mWifiNative.setNetworkVariable(
+ netId,
+ key,
+ value)) {
+ removeKeys(enterpriseConfig);
+ loge(config.SSID + ": failed to set " + key +
+ ": " + value);
+ break setVariables;
+ }
+ }
+ continue;
+ }
+ if (!((newNetwork == false) && (savedValue != null) &&
+ (value != null) && value.equals(savedValue)) &&
+ !mWifiNative.setNetworkVariable(
netId,
key,
value)) {
@@ -3161,6 +3372,12 @@ public class WifiConfigStore extends IpConfigStore {
return cache;
}
+ public ScanDetailCache getScanDetailCacheIfExist(WifiConfiguration config) {
+ if (config == null) return null;
+ return mScanDetailCaches.get(config.networkId);
+ }
+
+
/**
* This function run thru the Saved WifiConfigurations and check if some should be linked.
* @param config
@@ -3773,6 +3990,15 @@ public class WifiConfigStore extends IpConfigStore {
}
}
+ value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.SIMNumVarName);
+ if (!TextUtils.isEmpty(value)) {
+ try {
+ config.SIMNum = Integer.parseInt(value);
+ } catch (NumberFormatException ignore) {
+ Log.e(TAG,"error in parsing Selected Sim number " + config.SIMNum);
+ }
+ }
+
value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.hiddenSSIDVarName);
config.hiddenSSID = false;
if (!TextUtils.isEmpty(value)) {
@@ -3782,6 +4008,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)) {
@@ -4094,6 +4338,31 @@ public class WifiConfigStore extends IpConfigStore {
return false;
}
+ static boolean isSimConfig(WifiConfiguration config) {
+ if (config == null) {
+ return false;
+ }
+
+ if (config.enterpriseConfig == null) {
+ return false;
+ }
+
+ int method = config.enterpriseConfig.getEapMethod();
+ return (method == WifiEnterpriseConfig.Eap.SIM
+ || method == WifiEnterpriseConfig.Eap.AKA
+ || method == WifiEnterpriseConfig.Eap.AKA_PRIME);
+ }
+
+ void resetSimNetworks() {
+ for(WifiConfiguration config : mConfiguredNetworks.values()) {
+ if (isSimConfig(config)) {
+ /* This configuration may have cached Pseudonym IDs; lets remove them */
+ mWifiNative.setNetworkVariable(config.networkId, "identity", "NULL");
+ mWifiNative.setNetworkVariable(config.networkId, "anonymous_identity", "NULL");
+ }
+ }
+ }
+
boolean isNetworkConfigured(WifiConfiguration config) {
// Check if either we have a network Id or a WifiConfiguration
// matching the one we are trying to add.
@@ -4254,6 +4523,38 @@ public class WifiConfigStore extends IpConfigStore {
return found;
}
+ /**
+ * Handle blacklisting per BSSID and unblacklisting
+ *
+ * @param enable
+ * @param BSSID
+ * @param reason
+ */
+ void handleDisabledAPs( boolean enable, String BSSID, int reason) {
+ if (BSSID == null)
+ return;
+ for (WifiConfiguration config : mConfiguredNetworks.values()) {
+ if (getScanDetailCache(config) != null) {
+ for (ScanDetail scanDetail : getScanDetailCache(config).values()) {
+ if (scanDetail.getBSSIDString().equals(BSSID)) {
+ if (enable) {
+ config.BSSID = "any";
+ scanDetail.getScanResult().setAutoJoinStatus(ScanResult.ENABLED);
+ // enable auto join for the blacklisted BSSID
+ config.setAutoJoinStatus(WifiConfiguration.AUTO_JOIN_ENABLED);
+ } else {
+ // blacklist only the specified BSSID
+ scanDetail.getScanResult().setAutoJoinStatus(ScanResult.AUTO_ROAM_DISABLED);
+ config.BSSID = BSSID;
+ config.setAutoJoinStatus(WifiConfiguration.AUTO_JOIN_TEMPORARY_DISABLED);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
int getMaxDhcpRetries() {
return Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.WIFI_MAX_DHCP_RETRY_COUNT,
@@ -4584,4 +4885,9 @@ public class WifiConfigStore extends IpConfigStore {
}
}
}
+
+ private boolean isAutoConfigPriorities() {
+ return CMSettings.Global.getInt(mContext.getContentResolver(),
+ CMSettings.Global.WIFI_AUTO_PRIORITIES_CONFIGURATION, 1) != 0;
+ }
}