am e69acd7a: am 104999b9: am d14c4844: Merge "Pass connection configuration when setting wifi info" into mnc-dev
* commit 'e69acd7a456fb97d7c816629dedb42026eabdd2e': Pass connection configuration when setting wifi info
This commit is contained in:
@@ -151,7 +151,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
mScanResultCache.put(result.BSSID, result);
|
mScanResultCache.put(result.BSSID, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update(mInfo, mNetworkInfo);
|
update(mConfig, mInfo, mNetworkInfo);
|
||||||
mRssi = getRssi();
|
mRssi = getRssi();
|
||||||
mSeen = getSeen();
|
mSeen = getSeen();
|
||||||
}
|
}
|
||||||
@@ -629,11 +629,18 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
return mConfig != null && mConfig.isPasspoint();
|
return mConfig != null && mConfig.isPasspoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return whether the given {@link WifiInfo} is for this access point. */
|
/**
|
||||||
private boolean isInfoForThisAccessPoint(WifiInfo info) {
|
* Return whether the given {@link WifiInfo} is for this access point.
|
||||||
|
* If the current AP does not have a network Id then the config is used to
|
||||||
|
* match based on SSID and security.
|
||||||
|
*/
|
||||||
|
private boolean isInfoForThisAccessPoint(WifiConfiguration config, WifiInfo info) {
|
||||||
if (isPasspoint() == false && networkId != WifiConfiguration.INVALID_NETWORK_ID) {
|
if (isPasspoint() == false && networkId != WifiConfiguration.INVALID_NETWORK_ID) {
|
||||||
return networkId == info.getNetworkId();
|
return networkId == info.getNetworkId();
|
||||||
} else {
|
} else if (config != null) {
|
||||||
|
return matches(config);
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Might be an ephemeral connection with no WifiConfiguration. Try matching on SSID.
|
// Might be an ephemeral connection with no WifiConfiguration. Try matching on SSID.
|
||||||
// (Note that we only do this if the WifiConfiguration explicitly equals INVALID).
|
// (Note that we only do this if the WifiConfiguration explicitly equals INVALID).
|
||||||
// TODO: Handle hex string SSIDs.
|
// TODO: Handle hex string SSIDs.
|
||||||
@@ -705,7 +712,7 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean update(ScanResult result) {
|
boolean update(ScanResult result) {
|
||||||
if (ssid.equals(result.SSID) && security == getSecurity(result)) {
|
if (matches(result)) {
|
||||||
/* Update the LRU timestamp, if BSSID exists */
|
/* Update the LRU timestamp, if BSSID exists */
|
||||||
mScanResultCache.get(result.BSSID);
|
mScanResultCache.get(result.BSSID);
|
||||||
|
|
||||||
@@ -735,9 +742,9 @@ public class AccessPoint implements Comparable<AccessPoint> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean update(WifiInfo info, NetworkInfo networkInfo) {
|
boolean update(WifiConfiguration config, WifiInfo info, NetworkInfo networkInfo) {
|
||||||
boolean reorder = false;
|
boolean reorder = false;
|
||||||
if (info != null && isInfoForThisAccessPoint(info)) {
|
if (info != null && isInfoForThisAccessPoint(config, info)) {
|
||||||
reorder = (mInfo == null);
|
reorder = (mInfo == null);
|
||||||
mRssi = info.getRssi();
|
mRssi = info.getRssi();
|
||||||
mInfo = info;
|
mInfo = info;
|
||||||
|
|||||||
@@ -281,6 +281,19 @@ public class WifiTracker {
|
|||||||
return mScanResultCache.values();
|
return mScanResultCache.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WifiConfiguration getWifiConfigurationForNetworkId(int networkId) {
|
||||||
|
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
|
||||||
|
if (configs != null) {
|
||||||
|
for (WifiConfiguration config : configs) {
|
||||||
|
if (mLastInfo != null && networkId == config.networkId &&
|
||||||
|
!(config.selfAdded && config.numAssociation == 0)) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateAccessPoints() {
|
private void updateAccessPoints() {
|
||||||
// Swap the current access points into a cached list.
|
// Swap the current access points into a cached list.
|
||||||
List<AccessPoint> cachedAccessPoints = getAccessPoints();
|
List<AccessPoint> cachedAccessPoints = getAccessPoints();
|
||||||
@@ -295,21 +308,21 @@ public class WifiTracker {
|
|||||||
* correct SSID. Maps SSID -> List of AccessPoints with the given SSID. */
|
* correct SSID. Maps SSID -> List of AccessPoints with the given SSID. */
|
||||||
Multimap<String, AccessPoint> apMap = new Multimap<String, AccessPoint>();
|
Multimap<String, AccessPoint> apMap = new Multimap<String, AccessPoint>();
|
||||||
WifiConfiguration connectionConfig = null;
|
WifiConfiguration connectionConfig = null;
|
||||||
|
if (mLastInfo != null) {
|
||||||
|
connectionConfig = getWifiConfigurationForNetworkId(mLastInfo.getNetworkId());
|
||||||
|
}
|
||||||
|
|
||||||
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
|
final List<WifiConfiguration> configs = mWifiManager.getConfiguredNetworks();
|
||||||
if (configs != null) {
|
if (configs != null) {
|
||||||
mSavedNetworksExist = configs.size() != 0;
|
mSavedNetworksExist = configs.size() != 0;
|
||||||
for (WifiConfiguration config : configs) {
|
for (WifiConfiguration config : configs) {
|
||||||
if (mLastInfo != null && mLastInfo.getNetworkId() == config.networkId) {
|
|
||||||
connectionConfig = config;
|
|
||||||
}
|
|
||||||
if (config.selfAdded && config.numAssociation == 0) {
|
if (config.selfAdded && config.numAssociation == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AccessPoint accessPoint = getCachedOrCreate(config, cachedAccessPoints);
|
AccessPoint accessPoint = getCachedOrCreate(config, cachedAccessPoints);
|
||||||
if (mLastInfo != null && mLastNetworkInfo != null) {
|
if (mLastInfo != null && mLastNetworkInfo != null) {
|
||||||
if (config.isPasspoint() == false) {
|
if (config.isPasspoint() == false) {
|
||||||
accessPoint.update(mLastInfo, mLastNetworkInfo);
|
accessPoint.update(connectionConfig, mLastInfo, mLastNetworkInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mIncludeSaved) {
|
if (mIncludeSaved) {
|
||||||
@@ -346,7 +359,7 @@ public class WifiTracker {
|
|||||||
if (!found && mIncludeScans) {
|
if (!found && mIncludeScans) {
|
||||||
AccessPoint accessPoint = getCachedOrCreate(result, cachedAccessPoints);
|
AccessPoint accessPoint = getCachedOrCreate(result, cachedAccessPoints);
|
||||||
if (mLastInfo != null && mLastNetworkInfo != null) {
|
if (mLastInfo != null && mLastNetworkInfo != null) {
|
||||||
accessPoint.update(mLastInfo, mLastNetworkInfo);
|
accessPoint.update(connectionConfig, mLastInfo, mLastNetworkInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isPasspointNetwork()) {
|
if (result.isPasspointNetwork()) {
|
||||||
@@ -437,9 +450,14 @@ public class WifiTracker {
|
|||||||
mLastNetworkInfo = networkInfo;
|
mLastNetworkInfo = networkInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WifiConfiguration connectionConfig = null;
|
||||||
|
if (mLastInfo != null) {
|
||||||
|
connectionConfig = getWifiConfigurationForNetworkId(mLastInfo.getNetworkId());
|
||||||
|
}
|
||||||
|
|
||||||
boolean reorder = false;
|
boolean reorder = false;
|
||||||
for (int i = mAccessPoints.size() - 1; i >= 0; --i) {
|
for (int i = mAccessPoints.size() - 1; i >= 0; --i) {
|
||||||
if (mAccessPoints.get(i).update(mLastInfo, mLastNetworkInfo)) {
|
if (mAccessPoints.get(i).update(connectionConfig, mLastInfo, mLastNetworkInfo)) {
|
||||||
reorder = true;
|
reorder = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user