diff options
author | Quang Luong <qal@google.com> | 2020-06-10 22:24:49 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-06-10 22:24:49 +0000 |
commit | 21560a0020f7524fe6349daedfa466234567cc39 (patch) | |
tree | 9762398a364670562dbb9a4356163a3cfa00f144 /libs | |
parent | 05bd71f307cf064ae0d49b816b936dddc965f7a6 (diff) | |
parent | c4e56247667a5920512c0eb7c2856b6ab64f6e78 (diff) |
Merge "[WifiTrackerLib] Passpoint R2 expiration handling in network details" into rvc-dev am: 26f3012897 am: c4e5624766
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/net/wifi/+/11813173
Change-Id: Ief8b0dcf04600d835850359f456fb784cc3c6eb9
Diffstat (limited to 'libs')
3 files changed, 46 insertions, 3 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java index c6cd574d0..89d780eba 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java @@ -96,7 +96,8 @@ class OsuWifiEntry extends WifiEntry { if (mOsuStatusString != null) { return mOsuStatusString; } else if (isAlreadyProvisioned()) { - return mContext.getString(R.string.tap_to_renew_subscription_and_connect); + return concise ? mContext.getString(R.string.wifi_passpoint_expired) + : mContext.getString(R.string.tap_to_renew_subscription_and_connect); } else { return mContext.getString(R.string.tap_to_sign_up); } diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java index 00c786fac..9bd2a5905 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointNetworkDetailsTracker.java @@ -20,6 +20,7 @@ import static androidx.core.util.Preconditions.checkNotNull; import static com.android.wifitrackerlib.PasspointWifiEntry.uniqueIdToPasspointWifiEntryKey; import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTED; +import static com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_UNREACHABLE; import android.content.Context; import android.content.Intent; @@ -31,6 +32,7 @@ import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; +import android.net.wifi.hotspot2.OsuProvider; import android.net.wifi.hotspot2.PasspointConfiguration; import android.os.Handler; import android.text.TextUtils; @@ -54,6 +56,7 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { private static final String TAG = "PasspointNetworkDetailsTracker"; private final PasspointWifiEntry mChosenEntry; + private OsuWifiEntry mOsuWifiEntry; PasspointNetworkDetailsTracker(@NonNull Lifecycle lifecycle, @NonNull Context context, @@ -187,6 +190,43 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { null /* roamingScanResults */); } + @WorkerThread + private void updateOsuWifiEntryScans(@NonNull List<ScanResult> scanResults) { + checkNotNull(scanResults, "Scan Result list should not be null!"); + + Map<OsuProvider, List<ScanResult>> osuProviderToScans = + mWifiManager.getMatchingOsuProviders(scanResults); + Map<OsuProvider, PasspointConfiguration> osuProviderToPasspointConfig = + mWifiManager.getMatchingPasspointConfigsForOsuProviders( + osuProviderToScans.keySet()); + + if (mOsuWifiEntry != null) { + mOsuWifiEntry.updateScanResultInfo(osuProviderToScans.get( + mOsuWifiEntry.getOsuProvider())); + } else { + // Create a new OsuWifiEntry to link to the chosen PasspointWifiEntry + for (OsuProvider provider : osuProviderToScans.keySet()) { + PasspointConfiguration provisionedConfig = + osuProviderToPasspointConfig.get(provider); + if (provisionedConfig != null && TextUtils.equals(mChosenEntry.getKey(), + uniqueIdToPasspointWifiEntryKey(provisionedConfig.getUniqueId()))) { + mOsuWifiEntry = new OsuWifiEntry(mContext, mMainHandler, provider, mWifiManager, + mWifiNetworkScoreCache, false /* forSavedNetworksPage */); + mOsuWifiEntry.updateScanResultInfo(osuProviderToScans.get(provider)); + mOsuWifiEntry.setAlreadyProvisioned(true); + mChosenEntry.setOsuWifiEntry(mOsuWifiEntry); + return; + } + } + } + + // Remove mOsuWifiEntry if it is no longer reachable + if (mOsuWifiEntry != null && mOsuWifiEntry.getLevel() == WIFI_LEVEL_UNREACHABLE) { + mChosenEntry.setOsuWifiEntry(null); + mOsuWifiEntry = null; + } + } + /** * Updates the tracked entry's scan results up to the max scan age (or more, if the last scan * was unsuccessful). If Wifi is disabled, the tracked entry's level will be cleared. @@ -207,7 +247,9 @@ class PasspointNetworkDetailsTracker extends NetworkDetailsTracker { scanAgeWindow += mScanIntervalMillis; } - updatePasspointWifiEntryScans(mScanResultUpdater.getScanResults(scanAgeWindow)); + List<ScanResult> currentScans = mScanResultUpdater.getScanResults(scanAgeWindow); + updatePasspointWifiEntryScans(currentScans); + updateOsuWifiEntryScans(currentScans); } /** diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java index 2c0134d5a..20a87e760 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java @@ -166,7 +166,7 @@ public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntry if (isExpired()) { if (mOsuWifiEntry != null) { - sj.add(mOsuWifiEntry.getSummary()); + sj.add(mOsuWifiEntry.getSummary(concise)); } else { sj.add(mContext.getString(R.string.wifi_passpoint_expired)); } |