summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkDetailsTracker.java3
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkRequestEntry.java160
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java4
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java47
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java28
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java76
6 files changed, 278 insertions, 40 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkDetailsTracker.java
index 366ffbf6c..91805f776 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkDetailsTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkDetailsTracker.java
@@ -61,7 +61,8 @@ public abstract class NetworkDetailsTracker extends BaseWifiTracker {
long maxScanAgeMillis,
long scanIntervalMillis,
String key) {
- if (key.startsWith(StandardWifiEntry.KEY_PREFIX)) {
+ if (key.startsWith(StandardWifiEntry.KEY_PREFIX)
+ || key.startsWith(NetworkRequestEntry.KEY_PREFIX)) {
return new StandardNetworkDetailsTracker(lifecycle, context, wifiManager,
connectivityManager, networkScoreManager, mainHandler, workerHandler, clock,
maxScanAgeMillis, scanIntervalMillis, key);
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkRequestEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkRequestEntry.java
new file mode 100644
index 000000000..ccda30d1e
--- /dev/null
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/NetworkRequestEntry.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wifitrackerlib;
+
+import static android.net.wifi.WifiInfo.sanitizeSsid;
+
+import static androidx.core.util.Preconditions.checkNotNull;
+
+import static com.android.wifitrackerlib.Utils.getSecurityTypeFromWifiConfiguration;
+
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
+import android.net.wifi.WifiNetworkScoreCache;
+import android.os.Handler;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+/**
+ * WifiEntry representation of network requested through the NetworkRequest API,
+ * uniquely identified by SSID and security.
+ */
+@VisibleForTesting
+public class NetworkRequestEntry extends StandardWifiEntry {
+ static final String KEY_PREFIX = "NetworkRequestEntry:";
+
+ NetworkRequestEntry(@NonNull Context context, @NonNull Handler callbackHandler,
+ @NonNull String key, @NonNull WifiManager wifiManager,
+ @NonNull WifiNetworkScoreCache scoreCache,
+ boolean forSavedNetworksPage) throws IllegalArgumentException {
+ super(context, callbackHandler, key, wifiManager, scoreCache, forSavedNetworksPage);
+ }
+
+ @Override
+ public boolean isMetered() {
+ return false;
+ }
+
+ @Override
+ public boolean isSaved() {
+ return false;
+ }
+
+ @Override
+ public boolean isSuggestion() {
+ return false;
+ }
+
+ @Override
+ public boolean isSubscription() {
+ return false;
+ }
+
+ @Override
+ public WifiConfiguration getWifiConfiguration() {
+ return null;
+ }
+
+ @Override
+ public boolean canConnect() {
+ return false;
+ }
+
+ @Override
+ public void connect(@Nullable ConnectCallback callback) {
+ return;
+ }
+
+ @Override
+ public boolean canForget() {
+ return false;
+ }
+
+ @Override
+ public void forget(@Nullable ForgetCallback callback) {
+ return;
+ }
+
+ @Override
+ public boolean canShare() {
+ return false;
+ }
+
+ @Override
+ public boolean canEasyConnect() {
+ return false;
+ }
+
+ @Override
+ @MeteredChoice
+ public int getMeteredChoice() {
+ return METERED_CHOICE_AUTO;
+ }
+
+ @Override
+ public boolean canSetMeteredChoice() {
+ return false;
+ }
+
+ @Override
+ public void setMeteredChoice(int meteredChoice) {
+ return;
+ }
+
+ @Override
+ public boolean canSetPrivacy() {
+ return false;
+ }
+
+ @Override
+ @Privacy
+ public int getPrivacy() {
+ return PRIVACY_RANDOMIZED_MAC;
+ }
+
+ @Override
+ public void setPrivacy(int privacy) {
+ return;
+ }
+
+ @Override
+ public boolean isAutoJoinEnabled() {
+ return true;
+ }
+
+ @Override
+ public boolean canSetAutoJoinEnabled() {
+ return false;
+ }
+
+ @Override
+ public void setAutoJoinEnabled(boolean enabled) {
+ return;
+ }
+
+ @NonNull
+ static String wifiConfigToNetworkRequestEntryKey(@NonNull WifiConfiguration config) {
+ checkNotNull(config, "Cannot create key with null config!");
+ checkNotNull(config.SSID, "Cannot create key with null SSID in config!");
+ return KEY_PREFIX + sanitizeSsid(config.SSID) + ","
+ + getSecurityTypeFromWifiConfiguration(config);
+ }
+}
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
index ef17166b9..ebabadef3 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/PasspointWifiEntry.java
@@ -220,10 +220,10 @@ public class PasspointWifiEntry extends WifiEntry {
String carrierName = mWifiConfig != null
? getCarrierNameForSubId(mContext, getSubIdForConfig(mContext, mWifiConfig))
: null;
- String suggestorLabel = getAppLabel(mContext, mWifiConfig.creatorName);
+ String suggestorLabel = getAppLabel(mContext, suggestionOrSpecifierPackageName);
if (TextUtils.isEmpty(suggestorLabel)) {
// Fall-back to the package name in case the app label is missing
- suggestorLabel = mWifiConfig.creatorName;
+ suggestorLabel = suggestionOrSpecifierPackageName;
}
return mContext.getString(R.string.connected_via_app, carrierName != null
? carrierName
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java
index aee8ca37c..b89c8ab9b 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardNetworkDetailsTracker.java
@@ -18,6 +18,7 @@ package com.android.wifitrackerlib;
import static androidx.core.util.Preconditions.checkNotNull;
+import static com.android.wifitrackerlib.NetworkRequestEntry.wifiConfigToNetworkRequestEntryKey;
import static com.android.wifitrackerlib.StandardWifiEntry.wifiConfigToStandardWifiEntryKey;
import static com.android.wifitrackerlib.Utils.getSecurityTypesFromScanResult;
import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTED;
@@ -28,8 +29,8 @@ import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
+import android.net.Network;
import android.net.NetworkCapabilities;
-import android.net.NetworkInfo;
import android.net.NetworkScoreManager;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
@@ -53,6 +54,7 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
private static final String TAG = "StandardNetworkDetailsTracker";
private final StandardWifiEntry mChosenEntry;
+ private final boolean mIsNetworkRequest;
StandardNetworkDetailsTracker(@NonNull Lifecycle lifecycle,
@NonNull Context context,
@@ -67,16 +69,24 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
String key) {
super(lifecycle, context, wifiManager, connectivityManager, networkScoreManager,
mainHandler, workerHandler, clock, maxScanAgeMillis, scanIntervalMillis, TAG);
- mChosenEntry = new StandardWifiEntry(mContext, mMainHandler, key, mWifiManager,
- mWifiNetworkScoreCache, false /* forSavedNetworksPage */);
+
+ if (key.startsWith(NetworkRequestEntry.KEY_PREFIX)) {
+ mIsNetworkRequest = true;
+ mChosenEntry = new NetworkRequestEntry(mContext, mMainHandler, key, mWifiManager,
+ mWifiNetworkScoreCache, false /* forSavedNetworksPage */);
+ } else {
+ mIsNetworkRequest = false;
+ mChosenEntry = new StandardWifiEntry(mContext, mMainHandler, key, mWifiManager,
+ mWifiNetworkScoreCache, false /* forSavedNetworksPage */);
+ }
cacheNewScanResults();
conditionallyUpdateScanResults(true /* lastScanSucceeded */);
conditionallyUpdateConfig();
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
- mChosenEntry.updateConnectionInfo(wifiInfo, networkInfo);
- handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(
- mWifiManager.getCurrentNetwork()));
+ final Network currentNetwork = mWifiManager.getCurrentNetwork();
+ mChosenEntry.updateConnectionInfo(wifiInfo, mConnectivityManager
+ .getNetworkInfo(currentNetwork));
+ handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(currentNetwork));
}
@AnyThread
@@ -106,9 +116,7 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
checkNotNull(intent, "Intent cannot be null!");
final WifiConfiguration updatedConfig =
(WifiConfiguration) intent.getExtra(WifiManager.EXTRA_WIFI_CONFIGURATION);
- if (updatedConfig != null && !updatedConfig.isPasspoint()
- && !updatedConfig.fromWifiNetworkSuggestion && TextUtils.equals(
- wifiConfigToStandardWifiEntryKey(updatedConfig), mChosenEntry.getKey())) {
+ if (updatedConfig != null && configMatches(updatedConfig)) {
final int changeReason = intent.getIntExtra(WifiManager.EXTRA_CHANGE_REASON,
-1 /* defaultValue*/);
if (changeReason == WifiManager.CHANGE_REASON_ADDED
@@ -127,14 +135,14 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
protected void handleNetworkStateChangedAction(@NonNull Intent intent) {
checkNotNull(intent, "Intent cannot be null!");
mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(),
- (NetworkInfo) intent.getExtra(WifiManager.EXTRA_NETWORK_INFO));
+ mConnectivityManager.getNetworkInfo(mWifiManager.getCurrentNetwork()));
}
@WorkerThread
@Override
protected void handleRssiChangedAction() {
mChosenEntry.updateConnectionInfo(mWifiManager.getConnectionInfo(),
- mConnectivityManager.getActiveNetworkInfo());
+ mConnectivityManager.getNetworkInfo(mWifiManager.getCurrentNetwork()));
}
@WorkerThread
@@ -186,10 +194,7 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
*/
private void conditionallyUpdateConfig() {
WifiConfiguration updatedConfig = mWifiManager.getPrivilegedConfiguredNetworks().stream()
- .filter(cachedConfig -> !cachedConfig.isPasspoint()
- && TextUtils.equals(
- wifiConfigToStandardWifiEntryKey(cachedConfig),
- mChosenEntry.getKey()))
+ .filter(this::configMatches)
.findAny().orElse(null);
mChosenEntry.updateConfig(updatedConfig);
}
@@ -204,4 +209,14 @@ class StandardNetworkDetailsTracker extends NetworkDetailsTracker {
mChosenEntry.getSecurity()))
.collect(toList()));
}
+
+ private boolean configMatches(@NonNull WifiConfiguration config) {
+ if (config.isPasspoint()) {
+ return false;
+ }
+ String configKey = config.fromWifiNetworkSpecifier
+ ? wifiConfigToNetworkRequestEntryKey(config)
+ : wifiConfigToStandardWifiEntryKey(config);
+ return TextUtils.equals(configKey, mChosenEntry.getKey());
+ }
}
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
index 5a06c8f11..2a3a71cb3 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
@@ -164,14 +164,12 @@ public class StandardWifiEntry extends WifiEntry {
// TODO: second argument (isSaved = false) is bogus in this context
super(callbackHandler, wifiManager, scoreCache, forSavedNetworksPage);
- if (!key.startsWith(KEY_PREFIX)) {
- throw new IllegalArgumentException("Key does not start with correct prefix!");
- }
mContext = context;
mKey = key;
try {
+ final int prefixDelimiter = key.indexOf(":");
final int securityDelimiter = key.lastIndexOf(",");
- mSsid = key.substring(KEY_PREFIX.length(), securityDelimiter);
+ mSsid = key.substring(prefixDelimiter + 1, securityDelimiter);
mSecurity = Integer.valueOf(key.substring(securityDelimiter + 1));
} catch (StringIndexOutOfBoundsException | NumberFormatException e) {
throw new IllegalArgumentException("Malformed key: " + key);
@@ -258,16 +256,7 @@ public class StandardWifiEntry extends WifiEntry {
private String getConnectStateDescription() {
if (getConnectedState() == CONNECTED_STATE_CONNECTED) {
- if (!isSaved() && !isSuggestion()) {
- // Special case for connected + ephemeral networks.
- if (!TextUtils.isEmpty(mRecommendationServiceLabel)) {
- return String.format(mContext.getString(R.string.connected_via_network_scorer),
- mRecommendationServiceLabel);
- }
- return mContext.getString(R.string.connected_via_network_scorer_default);
- }
-
- // For network suggestions
+ // For suggestion or specifier networks
final String suggestionOrSpecifierPackageName = mWifiInfo != null
? mWifiInfo.getRequestingPackageName() : null;
if (!TextUtils.isEmpty(suggestionOrSpecifierPackageName)) {
@@ -277,12 +266,21 @@ public class StandardWifiEntry extends WifiEntry {
String suggestorName = getAppLabel(mContext, suggestionOrSpecifierPackageName);
if (TextUtils.isEmpty(suggestorName)) {
// Fall-back to the package name in case the app label is missing
- suggestorName = mWifiConfig.creatorName;
+ suggestorName = suggestionOrSpecifierPackageName;
}
return mContext.getString(R.string.connected_via_app, carrierName != null
? carrierName : suggestorName);
}
+ if (!isSaved() && !isSuggestion()) {
+ // Special case for connected + ephemeral networks.
+ if (!TextUtils.isEmpty(mRecommendationServiceLabel)) {
+ return String.format(mContext.getString(R.string.connected_via_network_scorer),
+ mRecommendationServiceLabel);
+ }
+ return mContext.getString(R.string.connected_via_network_scorer_default);
+ }
+
String networkCapabilitiesinformation =
getCurrentNetworkCapabilitiesInformation(mContext, mNetworkCapabilities);
if (!TextUtils.isEmpty(networkCapabilitiesinformation)) {
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
index 10c3f65c5..734779a2d 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiPickerTracker.java
@@ -18,9 +18,11 @@ package com.android.wifitrackerlib;
import static androidx.core.util.Preconditions.checkNotNull;
+import static com.android.wifitrackerlib.NetworkRequestEntry.wifiConfigToNetworkRequestEntryKey;
import static com.android.wifitrackerlib.OsuWifiEntry.osuProviderToOsuWifiEntryKey;
import static com.android.wifitrackerlib.PasspointWifiEntry.uniqueIdToPasspointWifiEntryKey;
import static com.android.wifitrackerlib.StandardWifiEntry.wifiConfigToStandardWifiEntryKey;
+import static com.android.wifitrackerlib.Utils.getSecurityTypesFromScanResult;
import static com.android.wifitrackerlib.Utils.mapScanResultsToKey;
import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTED;
import static com.android.wifitrackerlib.WifiEntry.CONNECTED_STATE_CONNECTING;
@@ -34,6 +36,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.LinkProperties;
+import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkScoreManager;
@@ -90,10 +93,12 @@ public class WifiPickerTracker extends BaseWifiTracker {
@GuardedBy("mLock") private final List<WifiEntry> mWifiEntries = new ArrayList<>();
// Reference to the WifiEntry representing the network that is currently connected to
private WifiEntry mConnectedWifiEntry;
+ // NetworkRequestEntry representing a network that was connected through the NetworkRequest API
+ private NetworkRequestEntry mNetworkRequestEntry;
// Cache containing saved WifiConfigurations mapped by StandardWifiEntry key
private final Map<String, WifiConfiguration> mWifiConfigCache = new HashMap<>();
-
+ // Cache containing suggested WifiConfigurations mapped by StandardWifiEntry key
private final Map<String, WifiConfiguration> mSuggestedConfigCache = new HashMap<>();
// Cache containing visible StandardWifiEntries. Must be accessed only by the worker thread.
private final Map<String, StandardWifiEntry> mStandardWifiEntryCache = new HashMap<>();
@@ -186,10 +191,9 @@ public class WifiPickerTracker extends BaseWifiTracker {
mScanResultUpdater.update(mWifiManager.getScanResults());
conditionallyUpdateScanResults(true /* lastScanSucceeded */);
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
- updateConnectionInfo(wifiInfo, networkInfo);
- handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(
- mWifiManager.getCurrentNetwork()));
+ final Network currentNetwork = mWifiManager.getCurrentNetwork();
+ updateConnectionInfo(wifiInfo, mConnectivityManager.getNetworkInfo(currentNetwork));
+ handleLinkPropertiesChanged(mConnectivityManager.getLinkProperties(currentNetwork));
notifyOnNumSavedNetworksChanged();
notifyOnNumSavedSubscriptionsChanged();
updateWifiEntries();
@@ -229,6 +233,7 @@ public class WifiPickerTracker extends BaseWifiTracker {
// Update scans since config changes may result in different entries being shown.
final List<ScanResult> scanResults = mScanResultUpdater.getScanResults();
updateStandardWifiEntryScans(scanResults);
+ updateNetworkRequestEntryScans(scanResults);
updatePasspointWifiEntryScans(scanResults);
updateOsuWifiEntryScans(scanResults);
notifyOnNumSavedNetworksChanged();
@@ -252,7 +257,8 @@ public class WifiPickerTracker extends BaseWifiTracker {
protected void handleRssiChangedAction() {
if (mConnectedWifiEntry != null) {
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- final NetworkInfo networkInfo = mConnectivityManager.getActiveNetworkInfo();
+ final NetworkInfo networkInfo = mConnectivityManager.getNetworkInfo(
+ mWifiManager.getCurrentNetwork());
mConnectedWifiEntry.updateConnectionInfo(wifiInfo, networkInfo);
}
}
@@ -321,6 +327,10 @@ public class WifiPickerTracker extends BaseWifiTracker {
|| connectedState == CONNECTED_STATE_CONNECTING;
}).findAny().orElse(null /* other */);
}
+ if (mConnectedWifiEntry == null && mNetworkRequestEntry != null
+ && mNetworkRequestEntry.getConnectedState() != CONNECTED_STATE_DISCONNECTED) {
+ mConnectedWifiEntry = mNetworkRequestEntry;
+ }
mWifiEntries.clear();
for (String key : mStandardWifiEntryCache.keySet()) {
// Continue if we're connected to this network with a non-user-shareable config.
@@ -520,6 +530,23 @@ public class WifiPickerTracker extends BaseWifiTracker {
|| alreadyProvisioned.contains(entry.getValue().getOsuProvider()));
}
+ @WorkerThread
+ private void updateNetworkRequestEntryScans(@NonNull List<ScanResult> scanResults) {
+ checkNotNull(scanResults, "Scan Result list should not be null!");
+ if (mNetworkRequestEntry == null) {
+ return;
+ }
+
+ String ssid = mNetworkRequestEntry.getSsid();
+ @WifiEntry.Security int security = mNetworkRequestEntry.getSecurity();
+
+ List<ScanResult> matchedScans = scanResults.stream().filter(scan ->
+ TextUtils.equals(scan.SSID, ssid)
+ && getSecurityTypesFromScanResult(scan).contains(security))
+ .collect(toList());
+ mNetworkRequestEntry.updateScanResultInfo(matchedScans);
+ }
+
/**
* Conditionally updates the WifiEntry scan results based on the current wifi state and
* whether the last scan succeeded or not.
@@ -531,6 +558,7 @@ public class WifiPickerTracker extends BaseWifiTracker {
updateSuggestedWifiEntryScans(Collections.emptyList());
updatePasspointWifiEntryScans(Collections.emptyList());
updateOsuWifiEntryScans(Collections.emptyList());
+ updateNetworkRequestEntryScans(Collections.emptyList());
return;
}
@@ -549,6 +577,7 @@ public class WifiPickerTracker extends BaseWifiTracker {
updateSuggestedWifiEntryScans(scanResults);
updatePasspointWifiEntryScans(scanResults);
updateOsuWifiEntryScans(scanResults);
+ updateNetworkRequestEntryScans(scanResults);
}
/**
@@ -564,6 +593,15 @@ public class WifiPickerTracker extends BaseWifiTracker {
int changeReason) {
checkNotNull(config, "Config should not be null!");
+ if (config.fromWifiNetworkSpecifier) {
+ if (changeReason == WifiManager.CHANGE_REASON_REMOVED) {
+ updateNetworkRequestConfig(null);
+ } else { // CHANGE_REASON_ADDED || CHANGE_REASON_CONFIG_CHANGE
+ updateNetworkRequestConfig(config);
+ }
+ return;
+ }
+
final String key = wifiConfigToStandardWifiEntryKey(config);
StandardWifiEntry updatedEntry;
WifiConfiguration updatedConfig;
@@ -604,13 +642,20 @@ public class WifiPickerTracker extends BaseWifiTracker {
checkNotNull(configs, "Config list should not be null!");
mWifiConfigCache.clear();
mSuggestedConfigCache.clear();
+ boolean networkRequestConfigAvailable = false;
for (WifiConfiguration config : configs) {
if (config.fromWifiNetworkSuggestion) {
mSuggestedConfigCache.put(wifiConfigToStandardWifiEntryKey(config), config);
+ } else if (config.fromWifiNetworkSpecifier) {
+ networkRequestConfigAvailable = true;
+ updateNetworkRequestConfig(config);
} else {
mWifiConfigCache.put(wifiConfigToStandardWifiEntryKey(config), config);
}
}
+ if (!networkRequestConfigAvailable) {
+ updateNetworkRequestConfig(null);
+ }
mNumSavedNetworks = (int) mWifiConfigCache.values().stream()
.filter(cachedConfig ->
!cachedConfig.isEphemeral() && !cachedConfig.isPasspoint()).count();
@@ -641,6 +686,22 @@ public class WifiPickerTracker extends BaseWifiTracker {
}
@WorkerThread
+ private void updateNetworkRequestConfig(@Nullable WifiConfiguration config) {
+ if (config == null) {
+ mNetworkRequestEntry = null;
+ return;
+ }
+
+ String configKey = wifiConfigToNetworkRequestEntryKey(config);
+ if (mNetworkRequestEntry == null
+ || !TextUtils.equals(configKey, mNetworkRequestEntry.getKey())) {
+ mNetworkRequestEntry = new NetworkRequestEntry(mContext, mMainHandler, configKey,
+ mWifiManager, mWifiNetworkScoreCache, false /* forSavedNetworksPPage */);
+ }
+ mNetworkRequestEntry.updateConfig(config);
+ }
+
+ @WorkerThread
private void updatePasspointConfigurations(@NonNull List<PasspointConfiguration> configs) {
checkNotNull(configs, "Config list should not be null!");
mPasspointConfigCache.clear();
@@ -678,6 +739,9 @@ public class WifiPickerTracker extends BaseWifiTracker {
for (WifiEntry entry : mOsuWifiEntryCache.values()) {
entry.updateConnectionInfo(wifiInfo, networkInfo);
}
+ if (mNetworkRequestEntry != null) {
+ mNetworkRequestEntry.updateConnectionInfo(wifiInfo, networkInfo);
+ }
// Create a StandardWifiEntry for the current connection if there are no scan results yet.
conditionallyCreateConnectedStandardWifiEntry(wifiInfo, networkInfo);
conditionallyCreateConnectedSuggestedWifiEntry(wifiInfo, networkInfo);