Make wifi dialog persist after orientation change

Wifi "cancel/forget/connect" pop-up window does not persist after orientation
changes. Specifically, after orientation changes, the connect button disappears.

This is because dialog information is not saved properly. When a saved wifi
config is found in the scan results, this entry is BOTH a wifi config AND a scan
result. Previous implementation has 2 issues:

1. Scan result part isn't saved. That's why the connect button after orientation
   changes, as UI didn't see a scan result section and thought it's not in range.

2. When both wifi config and scan result are saved, they are not restored
   correctly. Restoring wifi config will reset mRssi field in scan result part,
   while restoring scan result will reset netowrkId in wifi config part.

Both issuses are fixed.

bug: 9053186
Change-Id: Ic3ee7b5931c91d4b2f5c723fb8718cf752463109
This commit is contained in:
Yuhao Zheng
2014-01-07 10:59:30 -08:00
parent d954e2cc1c
commit 6c81d90be3

View File

@@ -60,7 +60,7 @@ class AccessPoint extends Preference {
String ssid;
String bssid;
int security;
int networkId;
int networkId = -1;
boolean wpsAvailable = false;
PskType pskType = PskType.UNKNOWN;
@@ -68,7 +68,7 @@ class AccessPoint extends Preference {
private WifiConfiguration mConfig;
/* package */ScanResult mScanResult;
private int mRssi;
private int mRssi = Integer.MAX_VALUE;
private WifiInfo mInfo;
private DetailedState mState;
@@ -187,7 +187,6 @@ class AccessPoint extends Preference {
bssid = config.BSSID;
security = getSecurity(config);
networkId = config.networkId;
mRssi = Integer.MAX_VALUE;
mConfig = config;
}
@@ -198,7 +197,6 @@ class AccessPoint extends Preference {
wpsAvailable = security != SECURITY_EAP && result.capabilities.contains("WPS");
if (security == SECURITY_PSK)
pskType = getPskType(result);
networkId = -1;
mRssi = result.level;
mScanResult = result;
}
@@ -276,6 +274,7 @@ class AccessPoint extends Preference {
if (security == SECURITY_PSK) {
pskType = getPskType(result);
}
mScanResult = result;
refresh();
return true;
}