diff options
author | Arc Wang <arcwang@google.com> | 2020-04-27 19:39:04 +0800 |
---|---|---|
committer | Arc Wang <arcwang@google.com> | 2020-04-28 11:11:41 +0800 |
commit | 893e6a15cb6a891d915d531f89fcf67cb2126223 (patch) | |
tree | e44fc03a89725807e5537a992dbd509d1eaf4593 /libs/WifiTrackerLib/src | |
parent | fc9e8316cd8b3f97e994815f5fe692c894f38e59 (diff) | |
download | frameworks_opt_net_wifi-893e6a15cb6a891d915d531f89fcf67cb2126223.tar.gz frameworks_opt_net_wifi-893e6a15cb6a891d915d531f89fcf67cb2126223.tar.bz2 frameworks_opt_net_wifi-893e6a15cb6a891d915d531f89fcf67cb2126223.zip |
Show Wi-Fi editor for authentication failures
When the Wi-Fi network is disabled because of authentication failures,
Wi-Fi picker should show editor before connecting or the network will
always fail to connect.
Bug: 112137755
Test: atest com.android.wifitrackerlib.StandardWifiEntryTest
Change-Id: I6b9f737f8aea6ef60e92e043afd343e7b8a93ba7
Diffstat (limited to 'libs/WifiTrackerLib/src')
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java | 33 | ||||
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java | 9 |
2 files changed, 42 insertions, 0 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index b6afa984a..b65f65630 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -16,6 +16,10 @@ package com.android.wifitrackerlib; +import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_FAILURE; +import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_AUTHENTICATION_NO_CREDENTIALS; +import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.DISABLED_BY_WRONG_PASSWORD; +import static android.net.wifi.WifiConfiguration.NetworkSelectionStatus.NETWORK_SELECTION_ENABLED; import static android.net.wifi.WifiInfo.sanitizeSsid; import static androidx.core.util.Preconditions.checkNotNull; @@ -44,6 +48,7 @@ import android.net.NetworkScoreManager; import android.net.NetworkScorerAppData; import android.net.wifi.ScanResult; import android.net.wifi.WifiConfiguration; +import android.net.wifi.WifiConfiguration.NetworkSelectionStatus; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; @@ -641,6 +646,34 @@ public class StandardWifiEntry extends WifiEntry { return false; } + @Override + public boolean shouldEditBeforeConnect() { + WifiConfiguration wifiConfig = getWifiConfiguration(); + if (wifiConfig == null) { + return false; + } + + // The secured Wi-Fi entry is never connected. + if (getSecurity() != SECURITY_NONE && getSecurity() != SECURITY_OWE + && !wifiConfig.getNetworkSelectionStatus().hasEverConnected()) { + return true; + } + + // The network is disabled because of one of the authentication problems. + NetworkSelectionStatus networkSelectionStatus = wifiConfig.getNetworkSelectionStatus(); + if (networkSelectionStatus.getNetworkSelectionStatus() != NETWORK_SELECTION_ENABLED) { + if (networkSelectionStatus.getDisableReasonCounter(DISABLED_AUTHENTICATION_FAILURE) > 0 + || networkSelectionStatus.getDisableReasonCounter( + DISABLED_BY_WRONG_PASSWORD) > 0 + || networkSelectionStatus.getDisableReasonCounter( + DISABLED_AUTHENTICATION_NO_CREDENTIALS) > 0) { + return true; + } + } + + return false; + } + @WorkerThread void updateScanResultInfo(@Nullable List<ScanResult> scanResults) throws IllegalArgumentException { diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java index 989c764aa..29b638e59 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java @@ -429,6 +429,15 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { abstract String getScanResultDescription(); /** + * In Wi-Fi picker, when users click a saved network, it will connect to the Wi-Fi network. + * However, for some special cases, Wi-Fi picker should show Wi-Fi editor UI for users to edit + * security or password before connecting. Or users will always get connection fail results. + */ + public boolean shouldEditBeforeConnect() { + return false; + } + + /** * Sets the callback listener for WifiEntryCallback methods. * Subsequent calls will overwrite the previous listener. */ |