diff options
author | Quang Luong <qal@google.com> | 2020-04-30 19:48:04 -0700 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2020-06-10 10:37:52 -0700 |
commit | 6151647754280820ff82760e4111cf6b484f360b (patch) | |
tree | eb25b494a32ca2bc4cc8449b2e4c7e5fd078129e /libs | |
parent | d76b48bec014fc254c6f4312cdc1d3a914ced605 (diff) |
[WifiTrackerLib] Passpoint R2 expiration handling in network details
Allow Passpoint R2 remediation by tapping on "Connect" in the network
details page, and display "Expired" in the
display summary.
Bug: 150384136
Test: manually install expired profile and verify behavior in network
details page.
Change-Id: I8058c02a7795de3f346e205e2d9d4da4ec9192bb
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)); } |