summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java15
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java17
-rw-r--r--libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java11
3 files changed, 29 insertions, 14 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
index e2d7acc8e..9ec431736 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java
@@ -45,7 +45,6 @@ import androidx.annotation.WorkerThread;
import androidx.lifecycle.Lifecycle;
import java.time.Clock;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -59,6 +58,7 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
private final PasspointWifiEntry mChosenEntry;
private OsuWifiEntry mOsuWifiEntry;
private NetworkInfo mCurrentNetworkInfo;
+ private WifiConfiguration mCurrentWifiConfig;
PasspointNetworkDetailsTracker(@NonNull Lifecycle lifecycle,
@NonNull Context context,
@@ -180,14 +180,16 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
final String key = uniqueIdToPasspointWifiEntryKey(wifiConfig.getKey());
if (TextUtils.equals(key, mChosenEntry.getKey())) {
- mChosenEntry.updateScanResultInfo(wifiConfig,
+ mCurrentWifiConfig = wifiConfig;
+ mChosenEntry.updateScanResultInfo(mCurrentWifiConfig,
pair.second.get(WifiManager.PASSPOINT_HOME_NETWORK),
pair.second.get(WifiManager.PASSPOINT_ROAMING_NETWORK));
return;
}
}
- // No AP in range; set scan results and connection config to null.
- mChosenEntry.updateScanResultInfo(null /* wifiConfig */,
+ // No AP in range; set scan results to null but keep the last seen WifiConfig to display
+ // the previous information while out of range.
+ mChosenEntry.updateScanResultInfo(mCurrentWifiConfig,
null /* homeScanResults */,
null /* roamingScanResults */);
}
@@ -235,8 +237,9 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker {
*/
private void conditionallyUpdateScanResults(boolean lastScanSucceeded) {
if (mWifiManager.getWifiState() == WifiManager.WIFI_STATE_DISABLED) {
- mChosenEntry.updateScanResultInfo(null /* wifiConfig */,
- Collections.emptyList(), Collections.emptyList());
+ mChosenEntry.updateScanResultInfo(mCurrentWifiConfig,
+ null /* homeScanResults */,
+ null /* roamingScanResults */);
return;
}
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index 36c855898..1fca6a4e5 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -476,26 +476,27 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry
@Override
public boolean isAutoJoinEnabled() {
// Suggestion network; use WifiConfig instead
- if (mPasspointConfig == null && mWifiConfig != null) {
+ if (mPasspointConfig != null) {
+ return mPasspointConfig.isAutojoinEnabled();
+ }
+ if (mWifiConfig != null) {
return mWifiConfig.allowAutojoin;
}
-
- return mPasspointConfig.isAutojoinEnabled();
+ return false;
}
@Override
public boolean canSetAutoJoinEnabled() {
- return true;
+ return mPasspointConfig != null || mWifiConfig != null;
}
@Override
public void setAutoJoinEnabled(boolean enabled) {
- if (mPasspointConfig == null && mWifiConfig != null) {
+ if (mPasspointConfig != null) {
+ mWifiManager.allowAutojoinPasspoint(mPasspointConfig.getHomeSp().getFqdn(), enabled);
+ } else if (mWifiConfig != null) {
mWifiManager.allowAutojoin(mWifiConfig.networkId, enabled);
- return;
}
-
- mWifiManager.allowAutojoinPasspoint(mPasspointConfig.getHomeSp().getFqdn(), enabled);
}
@Override
diff --git a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
index fa7812fe6..9fa6a2f40 100644
--- a/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
+++ b/libs/WifiTrackerLib/tests/src/com/android/wifitrackerlib/PasspointWifiEntryTest.java
@@ -246,4 +246,15 @@ public class PasspointWifiEntryTest {
assertThat(entry.getMacAddress()).isEqualTo(wifiInfoMac);
}
+
+ @Test
+ public void testIsAutoJoinEnabled_nullConfigs_returnsFalse() {
+ PasspointWifiEntry entry = new PasspointWifiEntry(mMockContext, mTestHandler,
+ getPasspointConfiguration(), mMockWifiManager, mMockScoreCache,
+ false /* forSavedNetworksPage */);
+
+ entry.updatePasspointConfig(null);
+
+ assertThat(entry.isAutoJoinEnabled()).isFalse();
+ }
}