summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2014-12-13 13:34:55 -0800
committerSteve Kondik <steve@cyngn.com>2014-12-13 13:34:55 -0800
commitb236cf38b2616d882bcfa4ee75429d7611d65743 (patch)
treee6a9f39cdc30853f7cb54ac54982fe78b9d36034
parent51e9cb054e00e021ba7a83f567c99b8c80157596 (diff)
parentec3b0576ae1f1d63f8f6e870088fe738e92425ed (diff)
downloadandroid_frameworks_opt_net_wifi-b236cf38b2616d882bcfa4ee75429d7611d65743.tar.gz
android_frameworks_opt_net_wifi-b236cf38b2616d882bcfa4ee75429d7611d65743.tar.bz2
android_frameworks_opt_net_wifi-b236cf38b2616d882bcfa4ee75429d7611d65743.zip
Merge branch 'LA.BF.1.1_rb1.16' of git://codeaurora.org/platform/frameworks/opt/net/wifi into cm-12.0
-rw-r--r--service/java/com/android/server/wifi/WifiAutoJoinController.java27
-rwxr-xr-xservice/java/com/android/server/wifi/WifiConfigStore.java35
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java4
-rw-r--r--[-rwxr-xr-x]service/java/com/android/server/wifi/WifiStateMachine.java61
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java3
5 files changed, 81 insertions, 49 deletions
diff --git a/service/java/com/android/server/wifi/WifiAutoJoinController.java b/service/java/com/android/server/wifi/WifiAutoJoinController.java
index 90be22142..50bc374f0 100644
--- a/service/java/com/android/server/wifi/WifiAutoJoinController.java
+++ b/service/java/com/android/server/wifi/WifiAutoJoinController.java
@@ -50,7 +50,6 @@ public class WifiAutoJoinController {
private WifiNetworkScoreCache mNetworkScoreCache;
private static final String TAG = "WifiAutoJoinController ";
- private static boolean mRssiThreshold = false;
private static boolean DBG = false;
private static boolean VDBG = false;
private static final boolean mStaStaSupported = false;
@@ -123,14 +122,6 @@ public class WifiAutoJoinController {
mBlacklistedBssids = new ArrayList<String>();
}
- void enableRssiThreshold(int enabled) {
- if (enabled > 0 ) {
- mRssiThreshold = true;
- } else {
- mRssiThreshold = false;
- }
- }
-
void enableVerboseLogging(int verbose) {
if (verbose > 0 ) {
DBG = true;
@@ -1302,12 +1293,10 @@ public class WifiAutoJoinController {
}
}
- if (DBG) logDbg("Rssi Threshold check " + mRssiThreshold);
-
// Try to unblacklist based on good visibility
- if ((mRssiThreshold) &&
- (config.visibility.rssi5 < mWifiConfigStore.thresholdUnblacklistThreshold5Soft
- && config.visibility.rssi24 < mWifiConfigStore.thresholdUnblacklistThreshold24Soft)) {
+ if (config.visibility.rssi5 < mWifiConfigStore.thresholdUnblacklistThreshold5Soft
+ && config.visibility.rssi24
+ < mWifiConfigStore.thresholdUnblacklistThreshold24Soft) {
if (DBG) {
logDbg("attemptAutoJoin do not unblacklist due to low visibility "
+ config.autoJoinStatus
@@ -1317,9 +1306,9 @@ public class WifiAutoJoinController {
+ ") num=(" + config.visibility.num24
+ "," + config.visibility.num5 + ")");
}
- } else if ((mRssiThreshold) &&
- (config.visibility.rssi5 < mWifiConfigStore.thresholdUnblacklistThreshold5Hard
- && config.visibility.rssi24 < mWifiConfigStore.thresholdUnblacklistThreshold24Hard)) {
+ } else if (config.visibility.rssi5 < mWifiConfigStore.thresholdUnblacklistThreshold5Hard
+ && config.visibility.rssi24
+ < mWifiConfigStore.thresholdUnblacklistThreshold24Hard) {
// If the network is simply temporary disabled, don't allow reconnect until
// RSSI becomes good enough
config.setAutoJoinStatus(config.autoJoinStatus - 1);
@@ -1375,10 +1364,10 @@ public class WifiAutoJoinController {
continue;
}
int boost = config.autoJoinUseAggressiveJoinAttemptThreshold + weakRssiBailCount;
- if ((mRssiThreshold) && ((config.visibility.rssi5 + boost)
+ if ((config.visibility.rssi5 + boost)
< mWifiConfigStore.thresholdInitialAutoJoinAttemptMin5RSSI
&& (config.visibility.rssi24 + boost)
- < mWifiConfigStore.thresholdInitialAutoJoinAttemptMin24RSSI)) {
+ < mWifiConfigStore.thresholdInitialAutoJoinAttemptMin24RSSI) {
if (DBG) {
logDbg("attemptAutoJoin skip due to low visibility -> status="
+ config.autoJoinStatus
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index 959c3f8be..76255d46e 100755
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -1410,8 +1410,32 @@ public class WifiConfigStore extends IpConfigStore {
if (mNetworkIds.containsKey(configKey(config))) {
// That SSID is already known, just ignore this duplicate entry
- if (showNetworks) localLog("discarded duplicate network ", config.networkId);
- } else if(config.isValid()){
+ if (showNetworks)
+ localLog("Duplicate network found ", config.networkId);
+
+ Integer n = mNetworkIds.get(configKey(config));
+ WifiConfiguration tempCfg = mConfiguredNetworks.get(n);
+
+ if ( (tempCfg != null &&
+ tempCfg.status != WifiConfiguration.Status.CURRENT) &&
+ config.status == WifiConfiguration.Status.CURRENT) {
+
+ // Clear the existing entry, we don't need it
+ mConfiguredNetworks.remove(tempCfg.networkId);
+ mNetworkIds.remove(configKey(tempCfg));
+
+ // Add current entry to the list
+ mConfiguredNetworks.put(config.networkId, config);
+ mNetworkIds.put(configKey(config), config.networkId);
+
+ // Enable AutoJoin status and indicate the network as
+ // duplicate The duplicateNetwork flag will be used
+ // to decide whether to restore network configurations
+ // in readNetworkHistory() along with IP and proxy settings
+ config.setAutoJoinStatus(WifiConfiguration.AUTO_JOIN_ENABLED);
+ config.duplicateNetwork = true;
+ }
+ } else if (config.isValid()) {
mConfiguredNetworks.put(config.networkId, config);
mNetworkIds.put(configKey(config), config.networkId);
if (showNetworks) localLog("loaded configured network", config.networkId);
@@ -1840,7 +1864,7 @@ public class WifiConfigStore extends IpConfigStore {
rssi = WifiConfiguration.INVALID_RSSI;
caps = null;
- } else if (config != null) {
+ } else if (config != null && config.duplicateNetwork == false) {
if (key.startsWith(SSID_KEY)) {
ssid = key.replace(SSID_KEY, "");
ssid = ssid.replace(SEPARATOR_KEY, "");
@@ -2540,10 +2564,13 @@ public class WifiConfigStore extends IpConfigStore {
int id = networks.keyAt(i);
WifiConfiguration config = mConfiguredNetworks.get(mNetworkIds.get(id));
-
if (config == null || config.autoJoinStatus == WifiConfiguration.AUTO_JOIN_DELETED) {
loge("configuration found for missing network, nid=" + id
+", ignored, networks.size=" + Integer.toString(networks.size()));
+ } else if (config != null && config.duplicateNetwork == true) {
+ if (VDBG)
+ loge("Network configuration is not updated for duplicate network id="
+ + config.networkId + " SSID=" + config.SSID);
} else {
config.setIpConfiguration(networks.valueAt(i));
}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 30500c6fa..8de6c0fb6 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -1782,10 +1782,6 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
mWifiStateMachine.enableVerboseLogging(verbose);
}
- public void enableRssiThreshold(int enabled) {
- mWifiStateMachine.enableRssiThreshold(enabled);
- }
-
public int getVerboseLoggingLevel() {
enforceAccessPermission();
return mWifiStateMachine.getVerboseLoggingLevel();
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 08f67d4cd..d7ac7d7f7 100755..100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -903,8 +903,8 @@ public class WifiStateMachine extends StateMachine {
mLastSignalLevel = -1;
mNetlinkTracker = new NetlinkTracker(mInterfaceName, new NetlinkTracker.Callback() {
- public void update() {
- sendMessage(CMD_UPDATE_LINKPROPERTIES);
+ public void update(LinkProperties lp) {
+ sendMessage(CMD_UPDATE_LINKPROPERTIES, lp);
}
});
try {
@@ -1097,10 +1097,6 @@ public class WifiStateMachine extends StateMachine {
return mVerboseLoggingLevel;
}
- void enableRssiThreshold(int enabled) {
- mWifiAutoJoinController.enableRssiThreshold(enabled);
- }
-
void enableVerboseLogging(int verbose) {
mVerboseLoggingLevel = verbose;
if (verbose > 0) {
@@ -3031,7 +3027,19 @@ public class WifiStateMachine extends StateMachine {
// Scan after 200ms
setScanAlarm(true, 200);
} else if (getCurrentState() == mDisconnectedState) {
- mCurrentScanAlarmMs = mDisconnectedScanPeriodMs;
+
+ // Configure the scan alarm time to mFrameworkScanIntervalMs
+ // (5 minutes) if there are no saved profiles as there is
+ // already a periodic scan getting issued for every
+ // mSupplicantScanIntervalMs seconds. However keep the
+ // scan frequency by setting it to mDisconnectedScanPeriodMs
+ // (10 seconds) when there are configured profiles.
+ if (mWifiConfigStore.getConfiguredNetworks().size() != 0) {
+ mCurrentScanAlarmMs = mDisconnectedScanPeriodMs;
+ } else {
+ mCurrentScanAlarmMs = mFrameworkScanIntervalMs;
+ }
+
// Scan after 200ms
setScanAlarm(true, 200);
}
@@ -3940,7 +3948,7 @@ public class WifiStateMachine extends StateMachine {
* - IPv6 routes and DNS servers: netlink, passed in by mNetlinkTracker.
* - HTTP proxy: the wifi config store.
*/
- private void updateLinkProperties(int reason) {
+ private void updateLinkProperties(int reason, LinkProperties lp) {
LinkProperties newLp = new LinkProperties();
// Interface name and proxy are locally configured.
@@ -3948,12 +3956,11 @@ public class WifiStateMachine extends StateMachine {
newLp.setHttpProxy(mWifiConfigStore.getProxyProperties(mLastNetworkId));
// IPv4/v6 addresses, IPv6 routes and IPv6 DNS servers come from netlink.
- LinkProperties netlinkLinkProperties = mNetlinkTracker.getLinkProperties();
- newLp.setLinkAddresses(netlinkLinkProperties.getLinkAddresses());
- for (RouteInfo route : netlinkLinkProperties.getRoutes()) {
+ newLp.setLinkAddresses(lp.getLinkAddresses());
+ for (RouteInfo route : lp.getRoutes()) {
newLp.addRoute(route);
}
- for (InetAddress dns : netlinkLinkProperties.getDnsServers()) {
+ for (InetAddress dns : lp.getDnsServers()) {
newLp.addDnsServer(dns);
}
@@ -3961,7 +3968,7 @@ public class WifiStateMachine extends StateMachine {
synchronized (mDhcpResultsLock) {
// Even when we're using static configuration, we don't need to look at the config
// store, because static IP configuration also populates mDhcpResults.
- if ((mDhcpResults != null)) {
+ if ((mDhcpResults != null) && lp.hasIPv4Address()) {
for (RouteInfo route : mDhcpResults.getRoutes(mInterfaceName)) {
newLp.addRoute(route);
}
@@ -4075,7 +4082,8 @@ public class WifiStateMachine extends StateMachine {
case CMD_UPDATE_LINKPROPERTIES:
// IP addresses, DNS servers, etc. changed. Act accordingly.
- if (wasProvisioned && !isProvisioned) {
+ boolean isStatic = mWifiConfigStore.isUsingStaticIp(mLastNetworkId);
+ if (wasProvisioned && !isProvisioned && !isStatic) {
// We no longer have a usable network configuration. Disconnect.
sendMessage(CMD_IP_CONFIGURATION_LOST);
} else if (!wasProvisioned && isProvisioned) {
@@ -4440,7 +4448,7 @@ public class WifiStateMachine extends StateMachine {
}
mWifiInfo.setInetAddress(addr);
mWifiInfo.setMeteredHint(dhcpResults.hasMeteredHint());
- updateLinkProperties(reason);
+ updateLinkProperties(reason, mNetlinkTracker.getLinkProperties());
}
private void handleSuccessfulIpConfiguration() {
@@ -4477,7 +4485,7 @@ public class WifiStateMachine extends StateMachine {
if (PDBG) {
loge("wifistatemachine handleIPv4Failure");
}
- updateLinkProperties(reason);
+ updateLinkProperties(reason, mNetlinkTracker.getLinkProperties());
}
private void handleIpConfigurationLost() {
@@ -4815,7 +4823,7 @@ public class WifiStateMachine extends StateMachine {
break;
/* Link configuration (IP address, DNS, ...) changes notified via netlink */
case CMD_UPDATE_LINKPROPERTIES:
- updateLinkProperties(CMD_UPDATE_LINKPROPERTIES);
+ updateLinkProperties(CMD_UPDATE_LINKPROPERTIES, (LinkProperties)message.obj);
break;
case CMD_IP_CONFIGURATION_SUCCESSFUL:
case CMD_IP_CONFIGURATION_LOST:
@@ -6564,7 +6572,8 @@ public class WifiStateMachine extends StateMachine {
}
if (result.hasProxyChanged()) {
log("Reconfiguring proxy on connection");
- updateLinkProperties(CMD_UPDATE_LINKPROPERTIES);
+ updateLinkProperties(CMD_UPDATE_LINKPROPERTIES,
+ mNetlinkTracker.getLinkProperties());
}
}
replyToMessage(message, WifiManager.SAVE_NETWORK_SUCCEEDED);
@@ -7694,9 +7703,19 @@ public class WifiStateMachine extends StateMachine {
Settings.Global.WIFI_FRAMEWORK_SCAN_INTERVAL_MS,
mDefaultFrameworkScanIntervalMs);
- if (mScreenOn)
- mCurrentScanAlarmMs = mDisconnectedScanPeriodMs;
-
+ // Configure the scan alarm time to mFrameworkScanIntervalMs
+ // (5 minutes) if there are no saved profiles as there is
+ // already a periodic scan getting issued for every
+ // mSupplicantScanIntervalMs seconds. However keep the
+ // scan frequency by setting it to mDisconnectedScanPeriodMs
+ // (10 seconds) when there are configured profiles.
+ if (mScreenOn) {
+ if (mWifiConfigStore.getConfiguredNetworks().size() != 0) {
+ mCurrentScanAlarmMs = mDisconnectedScanPeriodMs;
+ } else {
+ mCurrentScanAlarmMs = mFrameworkScanIntervalMs;
+ }
+ }
if (PDBG) {
loge(" Enter disconnected State scan interval " + mFrameworkScanIntervalMs
+ " mEnableBackgroundScan= " + mEnableBackgroundScan
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index 7dcaaa683..9e4149164 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -1221,6 +1221,7 @@ public final class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
@Override
public void enter() {
if (DBG) logd(getName());
+ mIsInvite = false;
mSavedPeerConfig.invalidate();
}
@@ -1275,7 +1276,6 @@ public final class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case WifiMonitor.P2P_INVITATION_RECEIVED_EVENT:
WifiP2pGroup group = (WifiP2pGroup) message.obj;
WifiP2pDevice owner = group.getOwner();
- mIsInvite = true;
if (owner == null) {
loge("Ignored invitation from null owner");
@@ -1305,6 +1305,7 @@ public final class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
mAutonomousGroup = false;
mJoinExistingGroup = true;
+ mIsInvite = true;
transitionTo(mUserAuthorizingInviteRequestState);
break;
case WifiMonitor.P2P_PROV_DISC_PBC_REQ_EVENT: