am e5454d57: am f8a3b8e0: Merge "Fix WifiTile\'s Connected indicator for ephemeral networks." into lmp-mr1-dev

* commit 'e5454d5733a4216a5ad0efb158fe090b19faddf1':
  Fix WifiTile's Connected indicator for ephemeral networks.
This commit is contained in:
Jeff Davidson
2014-11-26 18:44:46 +00:00
committed by Android Git Automerger

View File

@@ -42,6 +42,9 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
// TODO: Unify this logic with platform settings (see WifiSettings and AccessPoint). There is a
// fair amount of complexity here in statuses and logic beyond just connected/disconnected.
public class AccessPointControllerImpl implements NetworkController.AccessPointController { public class AccessPointControllerImpl implements NetworkController.AccessPointController {
private static final String TAG = "AccessPointController"; private static final String TAG = "AccessPointController";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
@@ -142,8 +145,7 @@ public class AccessPointControllerImpl implements NetworkController.AccessPointC
&& v.charAt(v.length() - 1) == '\"' ? v.substring(1, v.length() - 1) : v; && v.charAt(v.length() - 1) == '\"' ? v.substring(1, v.length() - 1) : v;
} }
private int getConnectedNetworkId() { private int getConnectedNetworkId(WifiInfo wifiInfo) {
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
return wifiInfo != null ? wifiInfo.getNetworkId() : AccessPoint.NO_NETWORK; return wifiInfo != null ? wifiInfo.getNetworkId() : AccessPoint.NO_NETWORK;
} }
@@ -158,7 +160,8 @@ public class AccessPointControllerImpl implements NetworkController.AccessPointC
} }
private void updateAccessPoints() { private void updateAccessPoints() {
final int connectedNetworkId = getConnectedNetworkId(); final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
final int connectedNetworkId = getConnectedNetworkId(wifiInfo);
if (DEBUG) Log.d(TAG, "connectedNetworkId: " + connectedNetworkId); if (DEBUG) Log.d(TAG, "connectedNetworkId: " + connectedNetworkId);
final List<ScanResult> scanResults = mWifiManager.getScanResults(); final List<ScanResult> scanResults = mWifiManager.getScanResults();
final ArrayMap<String, WifiConfiguration> configured = getConfiguredNetworksBySsid(); final ArrayMap<String, WifiConfiguration> configured = getConfiguredNetworksBySsid();
@@ -179,8 +182,13 @@ public class AccessPointControllerImpl implements NetworkController.AccessPointC
ap.networkId = config != null ? config.networkId : AccessPoint.NO_NETWORK; ap.networkId = config != null ? config.networkId : AccessPoint.NO_NETWORK;
ap.ssid = ssid; ap.ssid = ssid;
ap.iconId = ICONS[level]; ap.iconId = ICONS[level];
ap.isConnected = ap.networkId != AccessPoint.NO_NETWORK // Connected if either:
&& ap.networkId == connectedNetworkId; // -The network ID in the active WifiInfo matches this network's ID.
// -The network is ephemeral (no configuration) but the SSID matches.
ap.isConnected = (ap.networkId != AccessPoint.NO_NETWORK
&& ap.networkId == connectedNetworkId) ||
(ap.networkId == WifiConfiguration.INVALID_NETWORK_ID && wifiInfo != null &&
ap.ssid.equals(trimDoubleQuotes(wifiInfo.getSSID())));
ap.level = level; ap.level = level;
// Based on Settings AccessPoint#getSecurity, keep up to date // Based on Settings AccessPoint#getSecurity, keep up to date
// with better methods of determining no security or not. // with better methods of determining no security or not.