Fix Wi-Fi list adds same AP repeatedly

When switch AP security mode, several same APs are shown.

To fix this issue, append security type to preference
key for avoiding different APs have same key.
git fetch

Cherrypick of:
https://partner-android-review.googlesource.com/#/c/799829/

Bug: 37558394
Test: runtest --path
packages/apps/Settings/tests/unit/src/com/android/settings/wifi/WifiSettingsUiTest.java

Change-Id: I39621636f14b29e45ba96ff76dc3c21a4996a136
This commit is contained in:
Shunta Sato
2016-12-19 19:30:46 +08:00
committed by Sundeep Ghuman
parent 0e393d4163
commit 22080a1df5
2 changed files with 62 additions and 23 deletions

View File

@@ -749,10 +749,7 @@ public class WifiSettings extends RestrictedSettingsFragment
AccessPoint accessPoint = accessPoints.get(index);
// Ignore access points that are out of range.
if (accessPoint.isReachable()) {
String key = accessPoint.getBssid();
if (TextUtils.isEmpty(key)) {
key = accessPoint.getSsidStr();
}
String key = generateKey(accessPoint);
hasAvailableAccessPoints = true;
LongPressAccessPointPreference pref =
(LongPressAccessPointPreference) getCachedPreference(key);
@@ -794,6 +791,18 @@ public class WifiSettings extends RestrictedSettingsFragment
}
}
private String generateKey(AccessPoint accessPoint) {
StringBuilder key = new StringBuilder();
String bssid = accessPoint.getBssid();
if (TextUtils.isEmpty(bssid)) {
key.append(accessPoint.getSsidStr());
} else {
key.append(bssid);
}
key.append(',').append(accessPoint.getSecurity());
return key.toString();
}
@NonNull
private LongPressAccessPointPreference createLongPressActionPointPreference(
AccessPoint accessPoint) {