summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java18
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java52
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java32
3 files changed, 85 insertions, 17 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java
index 16e55fb96..c6cd574d0 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/OsuWifiEntry.java
@@ -61,6 +61,7 @@ class OsuWifiEntry extends WifiEntry {
@NonNull private final Context mContext;
@NonNull private OsuProvider mOsuProvider;
private String mOsuStatusString;
+ private boolean mIsAlreadyProvisioned = false;
/**
* Create n OsuWifiEntry with the associated OsuProvider
@@ -92,8 +93,13 @@ class OsuWifiEntry extends WifiEntry {
@Override
public String getSummary(boolean concise) {
// TODO(b/70983952): Add verbose summary
- return mOsuStatusString != null
- ? mOsuStatusString : mContext.getString(R.string.tap_to_sign_up);
+ if (mOsuStatusString != null) {
+ return mOsuStatusString;
+ } else if (isAlreadyProvisioned()) {
+ return mContext.getString(R.string.tap_to_renew_subscription_and_connect);
+ } else {
+ return mContext.getString(R.string.tap_to_sign_up);
+ }
}
@Override
@@ -308,6 +314,14 @@ class OsuWifiEntry extends WifiEntry {
return mOsuProvider;
}
+ boolean isAlreadyProvisioned() {
+ return mIsAlreadyProvisioned;
+ }
+
+ void setAlreadyProvisioned(boolean isAlreadyProvisioned) {
+ mIsAlreadyProvisioned = isAlreadyProvisioned;
+ }
+
class OsuWifiEntryProvisioningCallback extends ProvisioningCallback {
@Override
@MainThread public void onProvisioningFailure(int status) {
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index ebabadef3..2c0134d5a 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -62,7 +62,7 @@ import java.util.StringJoiner;
* WifiEntry representation of a subscribed Passpoint network, uniquely identified by FQDN.
*/
@VisibleForTesting
-public class PasspointWifiEntry extends WifiEntry {
+public class PasspointWifiEntry extends WifiEntry implements WifiEntry.WifiEntryCallback {
static final String KEY_PREFIX = "PasspointWifiEntry:";
private final Object mLock = new Object();
@@ -81,6 +81,7 @@ public class PasspointWifiEntry extends WifiEntry {
@Nullable private WifiConfiguration mWifiConfig;
private @Security int mSecurity = SECURITY_EAP;
private boolean mIsRoaming = false;
+ private OsuWifiEntry mOsuWifiEntry;
protected long mSubscriptionExpirationTimeInMillis;
@@ -143,19 +144,33 @@ public class PasspointWifiEntry extends WifiEntry {
}
@Override
+ @ConnectedState
+ public int getConnectedState() {
+ if (isExpired()) {
+ if (super.getConnectedState() == CONNECTED_STATE_DISCONNECTED
+ && mOsuWifiEntry != null) {
+ return mOsuWifiEntry.getConnectedState();
+ }
+ }
+ return super.getConnectedState();
+ }
+
+ @Override
public String getTitle() {
return mFriendlyName;
}
@Override
public String getSummary(boolean concise) {
- if (isExpired()) {
- return mContext.getString(R.string.wifi_passpoint_expired);
- }
-
StringJoiner sj = new StringJoiner(mContext.getString(R.string.summary_separator));
- if (getConnectedState() == CONNECTED_STATE_DISCONNECTED) {
+ if (isExpired()) {
+ if (mOsuWifiEntry != null) {
+ sj.add(mOsuWifiEntry.getSummary());
+ } else {
+ sj.add(mContext.getString(R.string.wifi_passpoint_expired));
+ }
+ } else if (getConnectedState() == CONNECTED_STATE_DISCONNECTED) {
String disconnectDescription = getDisconnectedStateDescription(mContext, this);
if (TextUtils.isEmpty(disconnectDescription)) {
if (concise) {
@@ -257,7 +272,6 @@ public class PasspointWifiEntry extends WifiEntry {
@Override
@Security
public int getSecurity() {
- // TODO(b/70983952): Fill this method in
return mSecurity;
}
@@ -280,7 +294,6 @@ public class PasspointWifiEntry extends WifiEntry {
@Override
public boolean isSuggestion() {
- // TODO(b/70983952): Fill this method in when passpoint suggestions are in
return mWifiConfig != null && mWifiConfig.fromWifiNetworkSuggestion;
}
@@ -296,12 +309,23 @@ public class PasspointWifiEntry extends WifiEntry {
@Override
public boolean canConnect() {
+ if (isExpired()) {
+ return mOsuWifiEntry != null && mOsuWifiEntry.canConnect();
+ }
+
return mLevel != WIFI_LEVEL_UNREACHABLE
&& getConnectedState() == CONNECTED_STATE_DISCONNECTED && mWifiConfig != null;
}
@Override
public void connect(@Nullable ConnectCallback callback) {
+ if (isExpired()) {
+ if (mOsuWifiEntry != null) {
+ mOsuWifiEntry.connect(callback);
+ return;
+ }
+ }
+
mConnectCallback = callback;
if (mWifiConfig == null) {
@@ -593,4 +617,16 @@ public class PasspointWifiEntry extends WifiEntry {
String getNetworkSelectionDescription() {
return Utils.getNetworkSelectionDescription(mWifiConfig);
}
+
+ /** Pass a reference to a matching OsuWifiEntry for expiration handling */
+ void setOsuWifiEntry(OsuWifiEntry osuWifiEntry) {
+ mOsuWifiEntry = osuWifiEntry;
+ mOsuWifiEntry.setListener(this);
+ }
+
+ /** Callback for updates to the linked OsuWifiEntry */
+ @Override
+ public void onUpdated() {
+ notifyOnUpdated();
+ }
}
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
index 751e8b9b7..2b433bb76 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
@@ -348,7 +348,8 @@ public class WifiPickerTracker extends BaseWifiTracker {
mWifiEntries.addAll(mPasspointWifiEntryCache.values().stream().filter(entry ->
entry.getConnectedState() == CONNECTED_STATE_DISCONNECTED).collect(toList()));
mWifiEntries.addAll(mOsuWifiEntryCache.values().stream().filter(entry ->
- entry.getConnectedState() == CONNECTED_STATE_DISCONNECTED).collect(toList()));
+ entry.getConnectedState() == CONNECTED_STATE_DISCONNECTED
+ && !entry.isAlreadyProvisioned()).collect(toList()));
Collections.sort(mWifiEntries);
if (isVerboseLoggingEnabled()) {
Log.v(TAG, "Connected WifiEntry: " + mConnectedWifiEntry);
@@ -500,9 +501,9 @@ public class WifiPickerTracker extends BaseWifiTracker {
Map<OsuProvider, List<ScanResult>> osuProviderToScans =
mWifiManager.getMatchingOsuProviders(scanResults);
- Set<OsuProvider> alreadyProvisioned =
- mWifiManager.getMatchingPasspointConfigsForOsuProviders(osuProviderToScans.keySet())
- .keySet();
+ Map<OsuProvider, PasspointConfiguration> osuProviderToPasspointConfig =
+ mWifiManager.getMatchingPasspointConfigsForOsuProviders(
+ osuProviderToScans.keySet());
// Update each OsuWifiEntry with new scans (or empty scans).
for (OsuWifiEntry entry : mOsuWifiEntryCache.values()) {
entry.updateScanResultInfo(osuProviderToScans.remove(entry.getOsuProvider()));
@@ -516,10 +517,27 @@ public class WifiPickerTracker extends BaseWifiTracker {
mOsuWifiEntryCache.put(osuProviderToOsuWifiEntryKey(provider), newEntry);
}
- // Remove entries that are now unreachable or already provisioned
+ // Pass a reference of each OsuWifiEntry to any matching provisioned PasspointWifiEntries
+ // for expiration handling.
+ mOsuWifiEntryCache.values().forEach(osuEntry -> {
+ PasspointConfiguration provisionedConfig =
+ osuProviderToPasspointConfig.get(osuEntry.getOsuProvider());
+ if (provisionedConfig == null) {
+ osuEntry.setAlreadyProvisioned(false);
+ return;
+ }
+ osuEntry.setAlreadyProvisioned(true);
+ PasspointWifiEntry provisionedEntry = mPasspointWifiEntryCache.get(
+ uniqueIdToPasspointWifiEntryKey(provisionedConfig.getUniqueId()));
+ if (provisionedEntry == null) {
+ return;
+ }
+ provisionedEntry.setOsuWifiEntry(osuEntry);
+ });
+
+ // Remove entries that are now unreachable
mOsuWifiEntryCache.entrySet()
- .removeIf(entry -> entry.getValue().getLevel() == WIFI_LEVEL_UNREACHABLE
- || alreadyProvisioned.contains(entry.getValue().getOsuProvider()));
+ .removeIf(entry -> entry.getValue().getLevel() == WIFI_LEVEL_UNREACHABLE);
}
@WorkerThread