summaryrefslogtreecommitdiffstats
path: root/libs/WifiTrackerLib/src
diff options
context:
space:
mode:
authorArc Wang <arcwang@google.com>2020-07-13 19:13:37 +0800
committerArc Wang <arcwang@google.com>2020-07-22 11:07:13 +0800
commitb060c09e721281e33c25cb73d676da646c126a95 (patch)
tree815c192d0f5e516ddb7cf2ededc7049a2ba77799 /libs/WifiTrackerLib/src
parent3a524f8d1a4fcd7164652bab45a4d1935a40253e (diff)
downloadframeworks_opt_net_wifi-b060c09e721281e33c25cb73d676da646c126a95.tar.gz
frameworks_opt_net_wifi-b060c09e721281e33c25cb73d676da646c126a95.tar.bz2
frameworks_opt_net_wifi-b060c09e721281e33c25cb73d676da646c126a95.zip
[WifiTrackerLib] Hide Connect button if there is no active SIM of the carrier ID
If users set a carrier ID for SIM dependent EAP method, when the SIM subscription of the carrier ID is not active, Connect button should be hide. Bug: 142792009 Test: atest com.android.wifitrackerlib.StandardWifiEntryTest Change-Id: Idb225a34b7bcd3a9c7d3e415fd0d8f69ba52bc8e
Diffstat (limited to 'libs/WifiTrackerLib/src')
-rw-r--r--libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
index 19c2619bc..6fef5e961 100644
--- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
+++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java
@@ -54,6 +54,9 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkScoreCache;
import android.os.Handler;
import android.os.SystemClock;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import androidx.annotation.GuardedBy;
@@ -357,8 +360,35 @@ public class StandardWifiEntry extends WifiEntry {
@Override
public boolean canConnect() {
- return mLevel != WIFI_LEVEL_UNREACHABLE
- && getConnectedState() == CONNECTED_STATE_DISCONNECTED;
+ if (mLevel == WIFI_LEVEL_UNREACHABLE
+ || getConnectedState() != CONNECTED_STATE_DISCONNECTED) {
+ return false;
+ }
+ // Allow connection for EAP SIM dependent methods if the SIM of specified carrier ID is
+ // active in the device.
+ if (getSecurity() == SECURITY_EAP && mWifiConfig != null
+ && mWifiConfig.enterpriseConfig != null) {
+ if (!mWifiConfig.enterpriseConfig.isAuthenticationSimBased()) {
+ return true;
+ }
+ List<SubscriptionInfo> activeSubscriptionInfos = ((SubscriptionManager) mContext
+ .getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE))
+ .getActiveSubscriptionInfoList();
+ if (activeSubscriptionInfos == null || activeSubscriptionInfos.size() == 0) {
+ return false;
+ }
+ if (mWifiConfig.carrierId == TelephonyManager.UNKNOWN_CARRIER_ID) {
+ // To connect via default subscription.
+ return true;
+ }
+ for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfos) {
+ if (subscriptionInfo.getCarrierId() == mWifiConfig.carrierId) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
}
@Override