summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-04-09 18:34:09 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-04-09 18:34:09 +0000
commite75e4299ad619f0150fc52fa4ea56cd88e0a91b9 (patch)
treecd64f87a21abbbed8a63e00f25c69b4c43296833
parent1a1b2b8f0fa7231f76136632e4bdc8b674fbdb02 (diff)
parentbe30bfa05fcc465cf2f37a75ef0b5fbbd058d1b1 (diff)
Merge changes from topic "IMSINotification" into rvc-dev
* changes: Move IMSI notification to WifiCarrierInfoManager Rename TelephonyUtils to WifiCarrierInfoManager
-rw-r--r--service/java/com/android/server/wifi/ClientModeImpl.java40
-rw-r--r--service/java/com/android/server/wifi/EapFailureNotifier.java9
-rw-r--r--service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java5
-rw-r--r--service/java/com/android/server/wifi/NetworkSuggestionNominator.java19
-rw-r--r--service/java/com/android/server/wifi/SavedNetworkNominator.java15
-rw-r--r--service/java/com/android/server/wifi/WifiCarrierInfoManager.java (renamed from service/java/com/android/server/wifi/util/TelephonyUtil.java)341
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java13
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java28
-rw-r--r--service/java/com/android/server/wifi/WifiMonitor.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java266
-rw-r--r--service/java/com/android/server/wifi/WifiShellCommand.java8
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java13
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointManager.java18
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointObjectFactory.java17
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointProvider.java29
-rw-r--r--tests/wifitests/Android.bp6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java28
-rw-r--r--tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/NetworkSuggestionNominatorTest.java22
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java17
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java)580
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java12
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java9
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java215
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java63
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java23
28 files changed, 1060 insertions, 762 deletions
diff --git a/service/java/com/android/server/wifi/ClientModeImpl.java b/service/java/com/android/server/wifi/ClientModeImpl.java
index 96a2bf971..4ca7716c9 100644
--- a/service/java/com/android/server/wifi/ClientModeImpl.java
+++ b/service/java/com/android/server/wifi/ClientModeImpl.java
@@ -115,6 +115,8 @@ import com.android.internal.util.Protocol;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.wifi.MboOceController.BtmFrameData;
+import com.android.server.wifi.WifiCarrierInfoManager.SimAuthRequestData;
+import com.android.server.wifi.WifiCarrierInfoManager.SimAuthResponseData;
import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
import com.android.server.wifi.hotspot2.NetworkDetail;
@@ -130,9 +132,6 @@ import com.android.server.wifi.util.ExternalCallbackTracker;
import com.android.server.wifi.util.NativeUtil;
import com.android.server.wifi.util.RssiUtil;
import com.android.server.wifi.util.ScanResultUtil;
-import com.android.server.wifi.util.TelephonyUtil;
-import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData;
-import com.android.server.wifi.util.TelephonyUtil.SimAuthResponseData;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.wifi.resources.R;
@@ -722,7 +721,7 @@ public class ClientModeImpl extends StateMachine {
private final BatteryStatsManager mBatteryStatsManager;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
// Used for debug and stats gathering
@@ -751,7 +750,8 @@ public class ClientModeImpl extends StateMachine {
BatteryStatsManager batteryStatsManager,
SupplicantStateTracker supplicantStateTracker,
MboOceController mboOceController,
- TelephonyUtil telephonyUtil, EapFailureNotifier eapFailureNotifier,
+ WifiCarrierInfoManager wifiCarrierInfoManager,
+ EapFailureNotifier eapFailureNotifier,
SimRequiredNotifier simRequiredNotifier) {
super(TAG, looper);
mWifiInjector = wifiInjector;
@@ -771,7 +771,7 @@ public class ClientModeImpl extends StateMachine {
mWifiTrafficPoller = wifiTrafficPoller;
mLinkProbeManager = linkProbeManager;
mMboOceController = mboOceController;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mNetworkAgentState = DetailedState.DISCONNECTED;
mBatteryStatsManager = batteryStatsManager;
@@ -3930,7 +3930,7 @@ public class ClientModeImpl extends StateMachine {
&& mTargetWifiConfiguration.enterpriseConfig
.isAuthenticationSimBased()) {
// Pair<identity, encrypted identity>
- Pair<String, String> identityPair = mTelephonyUtil
+ Pair<String, String> identityPair = mWifiCarrierInfoManager
.getSimIdentity(mTargetWifiConfiguration);
Log.i(TAG, "SUP_REQUEST_IDENTITY: identityPair=["
+ ((identityPair.first.length() >= 7)
@@ -4164,15 +4164,15 @@ public class ClientModeImpl extends StateMachine {
// We need to get the updated pseudonym from supplicant for EAP-SIM/AKA/AKA'
if (config.enterpriseConfig != null
&& config.enterpriseConfig.isAuthenticationSimBased()) {
- mLastSubId = mTelephonyUtil.getBestMatchSubscriptionId(config);
+ mLastSubId = mWifiCarrierInfoManager.getBestMatchSubscriptionId(config);
mLastSimBasedConnectionCarrierName =
- mTelephonyUtil.getCarrierNameforSubId(mLastSubId);
+ mWifiCarrierInfoManager.getCarrierNameforSubId(mLastSubId);
String anonymousIdentity =
mWifiNative.getEapAnonymousIdentity(mInterfaceName);
if (!TextUtils.isEmpty(anonymousIdentity)
- && !TelephonyUtil
+ && !WifiCarrierInfoManager
.isAnonymousAtRealmIdentity(anonymousIdentity)) {
- String decoratedPseudonym = mTelephonyUtil
+ String decoratedPseudonym = mWifiCarrierInfoManager
.decoratePseudonymWith3GppRealm(config,
anonymousIdentity);
if (decoratedPseudonym != null) {
@@ -4488,7 +4488,7 @@ public class ClientModeImpl extends StateMachine {
case WifiEnterpriseConfig.Eap.AKA:
case WifiEnterpriseConfig.Eap.AKA_PRIME:
if (errorCode == WifiNative.EAP_SIM_VENDOR_SPECIFIC_CERT_EXPIRED) {
- mTelephonyUtil.resetCarrierKeysForImsiEncryption(targetedNetwork);
+ mWifiCarrierInfoManager.resetCarrierKeysForImsiEncryption(targetedNetwork);
}
break;
@@ -4933,7 +4933,7 @@ public class ClientModeImpl extends StateMachine {
&& config.carrierId != TelephonyManager.UNKNOWN_CARRIER_ID)
|| (config.enterpriseConfig != null
&& config.enterpriseConfig.isAuthenticationSimBased()
- && !mTelephonyUtil.isSimPresent(mLastSubId))) {
+ && !mWifiCarrierInfoManager.isSimPresent(mLastSubId))) {
mWifiMetrics.logStaEvent(StaEvent.TYPE_FRAMEWORK_DISCONNECT,
StaEvent.DISCONNECT_RESET_SIM_NETWORKS);
// remove local PMKSA cache in framework
@@ -5741,15 +5741,15 @@ public class ClientModeImpl extends StateMachine {
* 3. 3GPP TS 11.11 2G_authentication [RAND]
* [SRES][Cipher Key Kc]
*/
- String response = mTelephonyUtil
+ String response = mWifiCarrierInfoManager
.getGsmSimAuthResponse(requestData.data, mTargetWifiConfiguration);
if (response == null) {
// In case of failure, issue may be due to sim type, retry as No.2 case
- response = mTelephonyUtil
+ response = mWifiCarrierInfoManager
.getGsmSimpleSimAuthResponse(requestData.data, mTargetWifiConfiguration);
if (response == null) {
// In case of failure, issue may be due to sim type, retry as No.3 case
- response = mTelephonyUtil.getGsmSimpleSimNoLengthAuthResponse(
+ response = mWifiCarrierInfoManager.getGsmSimpleSimNoLengthAuthResponse(
requestData.data, mTargetWifiConfiguration);
}
}
@@ -5772,7 +5772,7 @@ public class ClientModeImpl extends StateMachine {
return;
}
- SimAuthResponseData response = mTelephonyUtil
+ SimAuthResponseData response = mWifiCarrierInfoManager
.get3GAuthResponse(requestData, mTargetWifiConfiguration);
if (response != null) {
mWifiNative.simAuthResponse(
@@ -6338,10 +6338,10 @@ public class ClientModeImpl extends StateMachine {
if (config.enterpriseConfig != null
&& config.enterpriseConfig.isAuthenticationSimBased()
- && mTelephonyUtil.isImsiEncryptionInfoAvailable(
- mTelephonyUtil.getBestMatchSubscriptionId(config))
+ && mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(
+ mWifiCarrierInfoManager.getBestMatchSubscriptionId(config))
&& TextUtils.isEmpty(config.enterpriseConfig.getAnonymousIdentity())) {
- String anonAtRealm = mTelephonyUtil
+ String anonAtRealm = mWifiCarrierInfoManager
.getAnonymousIdentityWith3GppRealm(config);
// Use anonymous@<realm> when pseudonym is not available
config.enterpriseConfig.setAnonymousIdentity(anonAtRealm);
diff --git a/service/java/com/android/server/wifi/EapFailureNotifier.java b/service/java/com/android/server/wifi/EapFailureNotifier.java
index 3cc80b982..fe4cfbd66 100644
--- a/service/java/com/android/server/wifi/EapFailureNotifier.java
+++ b/service/java/com/android/server/wifi/EapFailureNotifier.java
@@ -32,7 +32,6 @@ import android.text.TextUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
-import com.android.server.wifi.util.TelephonyUtil;
/**
* This class may be used to launch notifications when EAP failure occurs.
@@ -45,17 +44,17 @@ public class EapFailureNotifier {
private final WifiContext mContext;
private final NotificationManager mNotificationManager;
private final FrameworkFacade mFrameworkFacade;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
// Unique ID associated with the notification.
public static final int NOTIFICATION_ID = SystemMessage.NOTE_WIFI_EAP_FAILURE;
private String mCurrentShownSsid;
public EapFailureNotifier(WifiContext context, FrameworkFacade frameworkFacade,
- TelephonyUtil telephonyUtil) {
+ WifiCarrierInfoManager wifiCarrierInfoManager) {
mContext = context;
mFrameworkFacade = frameworkFacade;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mNotificationManager =
mContext.getSystemService(NotificationManager.class);
}
@@ -74,7 +73,7 @@ public class EapFailureNotifier {
}
}
Resources res = getResourcesForSubId(mContext,
- mTelephonyUtil.getBestMatchSubscriptionId(config));
+ mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
if (res == null) return;
int resourceId = res.getIdentifier(ERROR_MESSAGE_OVERLAY_PREFIX + errorCode,
"string", mContext.getWifiOverlayApkPkgName());
diff --git a/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java b/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java
index acfba80c5..98664d0fc 100644
--- a/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java
+++ b/service/java/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreData.java
@@ -172,8 +172,7 @@ public class ImsiPrivacyProtectionExemptionStoreData implements WifiConfigStore.
@Override
public int getStoreFileId() {
- // Suggestion Store.
- return WifiConfigStore.STORE_FILE_USER_NETWORK_SUGGESTIONS;
+ // User general store.
+ return WifiConfigStore.STORE_FILE_USER_GENERAL;
}
-
}
diff --git a/service/java/com/android/server/wifi/NetworkSuggestionNominator.java b/service/java/com/android/server/wifi/NetworkSuggestionNominator.java
index c4fd6a908..fbc1f5fdb 100644
--- a/service/java/com/android/server/wifi/NetworkSuggestionNominator.java
+++ b/service/java/com/android/server/wifi/NetworkSuggestionNominator.java
@@ -24,7 +24,6 @@ import android.util.Pair;
import com.android.server.wifi.WifiNetworkSuggestionsManager.ExtendedWifiNetworkSuggestion;
import com.android.server.wifi.hotspot2.PasspointNetworkNominateHelper;
-import com.android.server.wifi.util.TelephonyUtil;
import java.util.ArrayList;
import java.util.Arrays;
@@ -54,16 +53,16 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo
private final WifiConfigManager mWifiConfigManager;
private final PasspointNetworkNominateHelper mPasspointNetworkNominateHelper;
private final LocalLog mLocalLog;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
NetworkSuggestionNominator(WifiNetworkSuggestionsManager networkSuggestionsManager,
WifiConfigManager wifiConfigManager, PasspointNetworkNominateHelper nominateHelper,
- LocalLog localLog, TelephonyUtil telephonyUtil) {
+ LocalLog localLog, WifiCarrierInfoManager wifiCarrierInfoManager) {
mWifiNetworkSuggestionsManager = networkSuggestionsManager;
mWifiConfigManager = wifiConfigManager;
mPasspointNetworkNominateHelper = nominateHelper;
mLocalLog = localLog;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
}
@Override
@@ -111,7 +110,7 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo
}
if (WifiConfiguration.isMetered(config, null)
- && mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config)) {
+ && mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config)) {
continue;
}
if (!isSimBasedNetworkAvailableToAutoConnect(config)) {
@@ -152,7 +151,7 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo
continue;
}
if (WifiConfiguration.isMetered(config, null)
- && mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config)) {
+ && mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config)) {
continue;
}
if (!ewns.isAutojoinEnabled
@@ -214,13 +213,13 @@ public class NetworkSuggestionNominator implements WifiNetworkSelector.NetworkNo
|| !config.enterpriseConfig.isAuthenticationSimBased()) {
return true;
}
- int subId = mTelephonyUtil.getBestMatchSubscriptionId(config);
- if (!mTelephonyUtil.isSimPresent(subId)) {
+ int subId = mWifiCarrierInfoManager.getBestMatchSubscriptionId(config);
+ if (!mWifiCarrierInfoManager.isSimPresent(subId)) {
mLocalLog.log("SIM is not present for subId: " + subId);
return false;
}
- if (mTelephonyUtil.requiresImsiEncryption(subId)) {
- return mTelephonyUtil.isImsiEncryptionInfoAvailable(subId);
+ if (mWifiCarrierInfoManager.requiresImsiEncryption(subId)) {
+ return mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(subId);
}
return true;
}
diff --git a/service/java/com/android/server/wifi/SavedNetworkNominator.java b/service/java/com/android/server/wifi/SavedNetworkNominator.java
index dd4d45f90..cbc2c323e 100644
--- a/service/java/com/android/server/wifi/SavedNetworkNominator.java
+++ b/service/java/com/android/server/wifi/SavedNetworkNominator.java
@@ -23,7 +23,6 @@ import android.util.LocalLog;
import android.util.Pair;
import com.android.server.wifi.hotspot2.PasspointNetworkNominateHelper;
-import com.android.server.wifi.util.TelephonyUtil;
import java.util.List;
@@ -35,16 +34,16 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
private static final String NAME = "SavedNetworkNominator";
private final WifiConfigManager mWifiConfigManager;
private final LocalLog mLocalLog;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private final PasspointNetworkNominateHelper mPasspointNetworkNominateHelper;
SavedNetworkNominator(WifiConfigManager configManager,
PasspointNetworkNominateHelper nominateHelper,
- LocalLog localLog, TelephonyUtil telephonyUtil) {
+ LocalLog localLog, WifiCarrierInfoManager wifiCarrierInfoManager) {
mWifiConfigManager = configManager;
mPasspointNetworkNominateHelper = nominateHelper;
mLocalLog = localLog;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
}
private void localLog(String log) {
@@ -138,8 +137,8 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
continue;
} else if (network.enterpriseConfig != null
&& network.enterpriseConfig.isAuthenticationSimBased()) {
- int subId = mTelephonyUtil.getBestMatchSubscriptionId(network);
- if (!mTelephonyUtil.isSimPresent(subId)) {
+ int subId = mWifiCarrierInfoManager.getBestMatchSubscriptionId(network);
+ if (!mWifiCarrierInfoManager.isSimPresent(subId)) {
// Don't select if security type is EAP SIM/AKA/AKA' when SIM is not present.
localLog("No SIM card is good for Network "
+ WifiNetworkSelector.toNetworkString(network));
@@ -147,7 +146,7 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
}
// Ignore metered network with non-data Sim, ignore.
if (WifiConfiguration.isMetered(network, null)
- && mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(network)) {
+ && mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(network)) {
continue;
}
}
@@ -173,7 +172,7 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
WifiConfiguration config = candidate.second;
// Ignore metered network with non-data Sim, ignore.
if (WifiConfiguration.isMetered(config, null)
- && mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config)) {
+ && mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config)) {
continue;
}
onConnectableListener.onConnectable(candidate.first, config);
diff --git a/service/java/com/android/server/wifi/util/TelephonyUtil.java b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java
index b7b2d9e13..63786f920 100644
--- a/service/java/com/android/server/wifi/util/TelephonyUtil.java
+++ b/service/java/com/android/server/wifi/WifiCarrierInfoManager.java
@@ -14,14 +14,20 @@
* limitations under the License.
*/
-package com.android.server.wifi.util;
+package com.android.server.wifi;
import android.annotation.NonNull;
+import android.app.AlertDialog;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.database.ContentObserver;
+import android.graphics.drawable.Icon;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEnterpriseConfig;
@@ -39,19 +45,21 @@ import android.util.Base64;
import android.util.Log;
import android.util.Pair;
import android.util.SparseBooleanArray;
+import android.view.WindowManager;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.server.wifi.FrameworkFacade;
-import com.android.server.wifi.IMSIParameter;
-import com.android.server.wifi.WifiNative;
+import com.android.internal.messages.nano.SystemMessageProto;
+import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.annotation.Nullable;
import javax.crypto.BadPaddingException;
@@ -60,12 +68,12 @@ import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
/**
- * Utilities for the Wifi Service to interact with telephony.
+ * This class provide APIs to get carrier info from telephony service.
* TODO(b/132188983): Refactor into TelephonyFacade which owns all instances of
* TelephonyManager/SubscriptionManager in Wifi
*/
-public class TelephonyUtil {
- public static final String TAG = "TelephonyUtil";
+public class WifiCarrierInfoManager {
+ public static final String TAG = "WifiCarrierInfoManager";
public static final String DEFAULT_EAP_PREFIX = "\0";
public static final int CARRIER_INVALID_TYPE = -1;
@@ -73,6 +81,24 @@ public class TelephonyUtil {
public static final int CARRIER_MVNO_TYPE = 1; // Mobile Virtual Network Operator
public static final String ANONYMOUS_IDENTITY = "anonymous";
public static final String THREE_GPP_NAI_REALM_FORMAT = "wlan.mnc%s.mcc%s.3gppnetwork.org";
+ /** Intent when user tapped action button to allow the app. */
+ @VisibleForTesting
+ public static final String NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION =
+ "com.android.server.wifi.action.CarrierNetwork.USER_ALLOWED_CARRIER";
+ /** Intent when user tapped action button to disallow the app. */
+ @VisibleForTesting
+ public static final String NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION =
+ "com.android.server.wifi.action.CarrierNetwork.USER_DISALLOWED_CARRIER";
+ /** Intent when user dismissed the notification. */
+ @VisibleForTesting
+ public static final String NOTIFICATION_USER_DISMISSED_INTENT_ACTION =
+ "com.android.server.wifi.action.CarrierNetwork.USER_DISMISSED";
+ @VisibleForTesting
+ public static final String EXTRA_CARRIER_NAME =
+ "com.android.server.wifi.extra.CarrierNetwork.CARRIER_NAME";
+ @VisibleForTesting
+ public static final String EXTRA_CARRIER_ID =
+ "com.android.server.wifi.extra.CarrierNetwork.CARRIER_ID";
// IMSI encryption method: RSA-OAEP with SHA-256 hash function
private static final String IMSI_CIPHER_TRANSFORMATION =
@@ -97,27 +123,156 @@ public class TelephonyUtil {
private static final Uri CONTENT_URI = Uri.parse("content://carrier_information/carrier");
+ private final WifiContext mContext;
+ private final Handler mHandler;
+ private final WifiInjector mWifiInjector;
+ private final Resources mResources;
private final TelephonyManager mTelephonyManager;
private final SubscriptionManager mSubscriptionManager;
+ private final NotificationManager mNotificationManager;
+
+ /**
+ * Intent filter for processing notification actions.
+ */
+ private final IntentFilter mIntentFilter;
+ private final FrameworkFacade mFrameworkFacade;
private boolean mVerboseLogEnabled = false;
private SparseBooleanArray mImsiEncryptionRequired = new SparseBooleanArray();
private SparseBooleanArray mImsiEncryptionInfoAvailable = new SparseBooleanArray();
private SparseBooleanArray mEapMethodPrefixEnable = new SparseBooleanArray();
+ private final Map<Integer, Boolean> mImsiPrivacyProtectionExemptionMap = new HashMap<>();
+ private final List<OnUserApproveCarrierListener>
+ mOnUserApproveCarrierListeners =
+ new ArrayList<>();
+
+ private boolean mUserApprovalUiActive;
+ private boolean mHasNewDataToSerialize;
+
+ /**
+ * Interface for other modules to listen to the user approve IMSI protection exemption.
+ */
+ public interface OnUserApproveCarrierListener {
+
+ /**
+ * Invoke when user approve the IMSI protection exemption.
+ */
+ void onUserAllowed(int carrierId);
+ }
+
+ /**
+ * Module to interact with the wifi config store.
+ */
+ private class ImsiProtectionExemptionDataSource implements
+ ImsiPrivacyProtectionExemptionStoreData.DataSource {
+ @Override
+ public Map<Integer, Boolean> toSerialize() {
+ // Clear the flag after writing to disk.
+ // TODO(b/115504887): Don't reset the flag on write failure.
+ mHasNewDataToSerialize = false;
+ return mImsiPrivacyProtectionExemptionMap;
+ }
+
+ @Override
+ public void fromDeserialized(Map<Integer, Boolean> imsiProtectionExemptionMap) {
+ mImsiPrivacyProtectionExemptionMap.putAll(imsiProtectionExemptionMap);
+ }
+
+ @Override
+ public void reset() {
+ mImsiPrivacyProtectionExemptionMap.clear();
+ }
+
+ @Override
+ public boolean hasNewDataToSerialize() {
+ return mHasNewDataToSerialize;
+ }
+ }
+
+ private final BroadcastReceiver mBroadcastReceiver =
+ new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String carrierName = intent.getStringExtra(EXTRA_CARRIER_NAME);
+ int carrierId = intent.getIntExtra(EXTRA_CARRIER_ID, -1);
+ if (carrierName == null || carrierId == -1) {
+ Log.e(TAG, "No carrier name or carrier id found in intent");
+ return;
+ }
+
+ switch (intent.getAction()) {
+ case NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION:
+ Log.i(TAG, "User clicked to allow carrier");
+ sendImsiPrivacyConfirmationDialog(carrierName, carrierId);
+ // Collapse the notification bar
+ mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
+ break;
+ case NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION:
+ handleUserDisallowCarrierExemptionAction(carrierName, carrierId);
+ break;
+ case NOTIFICATION_USER_DISMISSED_INTENT_ACTION:
+ handleUserDismissAction();
+ return; // no need to cancel a dismissed notification, return.
+ default:
+ Log.e(TAG, "Unknown action " + intent.getAction());
+ return;
+ }
+ // Clear notification once the user interacts with it.
+ mNotificationManager.cancel(SystemMessageProto
+ .SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ }
+ };
+ private void handleUserDismissAction() {
+ Log.i(TAG, "User dismissed the notification");
+ mUserApprovalUiActive = false;
+ }
+
+ private void handleUserAllowCarrierExemptionAction(String carrierName, int carrierId) {
+ Log.i(TAG, "User clicked to allow carrier:" + carrierName);
+ setHasUserApprovedImsiPrivacyExemptionForCarrier(true, carrierId);
+ mUserApprovalUiActive = false;
+ }
+
+ private void handleUserDisallowCarrierExemptionAction(String carrierName, int carrierId) {
+ Log.i(TAG, "User clicked to disallow carrier:" + carrierName);
+ setHasUserApprovedImsiPrivacyExemptionForCarrier(false, carrierId);
+ mUserApprovalUiActive = false;
+ }
/**
- * Gets the instance of TelephonyUtil.
+ * Gets the instance of WifiCarrierInfoManager.
* @param telephonyManager Instance of {@link TelephonyManager}
* @param subscriptionManager Instance of {@link SubscriptionManager}
- * @return The instance of TelephonyUtil
+ * @param WifiInjector Instance of {@link WifiInjector}
+ * @return The instance of WifiCarrierInfoManager
*/
- public TelephonyUtil(@NonNull TelephonyManager telephonyManager,
+ public WifiCarrierInfoManager(@NonNull TelephonyManager telephonyManager,
@NonNull SubscriptionManager subscriptionManager,
+ @NonNull WifiInjector wifiInjector,
@NonNull FrameworkFacade frameworkFacade,
- @NonNull Context context,
+ @NonNull WifiContext context,
+ @NonNull WifiConfigStore configStore,
@NonNull Handler handler) {
mTelephonyManager = telephonyManager;
+ mContext = context;
+ mResources = mContext.getResources();
+ mWifiInjector = wifiInjector;
+ mHandler = handler;
mSubscriptionManager = subscriptionManager;
+ mFrameworkFacade = frameworkFacade;
+
+ mNotificationManager =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
+ // Register broadcast receiver for UI interactions.
+ mIntentFilter = new IntentFilter();
+ mIntentFilter.addAction(NOTIFICATION_USER_DISMISSED_INTENT_ACTION);
+ mIntentFilter.addAction(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION);
+ mIntentFilter.addAction(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION);
+ mUserApprovalUiActive = false;
+
+ mContext.registerReceiver(mBroadcastReceiver, mIntentFilter, null, handler);
+ configStore.registerStoreData(wifiInjector.makeImsiProtectionExemptionStoreData(
+ new ImsiProtectionExemptionDataSource()));
updateImsiEncryptionInfo(context);
@@ -552,7 +707,7 @@ public class TelephonyUtil {
*/
public static boolean isAnonymousAtRealmIdentity(String identity) {
if (TextUtils.isEmpty(identity)) return false;
- final String anonymousId = TelephonyUtil.ANONYMOUS_IDENTITY + "@";
+ final String anonymousId = WifiCarrierInfoManager.ANONYMOUS_IDENTITY + "@";
return identity.startsWith(anonymousId)
|| identity.substring(1).startsWith(anonymousId);
}
@@ -1184,4 +1339,166 @@ public class TelephonyUtil {
int subId = getMatchingSubId(config.carrierId);
return subId != SubscriptionManager.getDefaultDataSubscriptionId();
}
+
+ /**
+ * Add a listener to monitor user approval IMSI protection exemption.
+ */
+ public void addImsiExemptionUserApprovalListener(
+ OnUserApproveCarrierListener listener) {
+ mOnUserApproveCarrierListeners.add(listener);
+ }
+
+ /**
+ * Clear the Imsi Privacy Exemption user approval info the target carrier.
+ */
+ public void clearImsiPrivacyExemptionForCarrier(int carrierId) {
+ mImsiPrivacyProtectionExemptionMap.remove(carrierId);
+ saveToStore();
+ }
+
+ /**
+ * Check if carrier have user approved exemption for IMSI protection
+ */
+ public boolean hasUserApprovedImsiPrivacyExemptionForCarrier(int carrierId) {
+ return mImsiPrivacyProtectionExemptionMap.getOrDefault(carrierId, false);
+ }
+
+ /**
+ * Enable or disable exemption on IMSI protection.
+ */
+ public void setHasUserApprovedImsiPrivacyExemptionForCarrier(boolean approved, int carrierId) {
+ if (mVerboseLogEnabled) {
+ Log.v(TAG, "Setting Imsi privacy exemption for carrier " + carrierId
+ + (approved ? " approved" : " not approved"));
+ }
+ mImsiPrivacyProtectionExemptionMap.put(carrierId, approved);
+ // If user approved the exemption restore to initial auto join configure.
+ if (approved) {
+ for (OnUserApproveCarrierListener listener : mOnUserApproveCarrierListeners) {
+ listener.onUserAllowed(carrierId);
+ }
+ }
+ saveToStore();
+ }
+
+ private void sendImsiPrivacyNotification(int carrierId) {
+ String carrierName = getCarrierNameforSubId(getMatchingSubId(carrierId));
+ Notification.Action userAllowAppNotificationAction =
+ new Notification.Action.Builder(null,
+ mResources.getText(R.string
+ .wifi_suggestion_action_allow_imsi_privacy_exemption_carrier),
+ getPrivateBroadcast(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
+ Pair.create(EXTRA_CARRIER_NAME, carrierName),
+ Pair.create(EXTRA_CARRIER_ID, carrierId)))
+ .build();
+ Notification.Action userDisallowAppNotificationAction =
+ new Notification.Action.Builder(null,
+ mResources.getText(R.string
+ .wifi_suggestion_action_disallow_imsi_privacy_exemption_carrier),
+ getPrivateBroadcast(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION,
+ Pair.create(EXTRA_CARRIER_NAME, carrierName),
+ Pair.create(EXTRA_CARRIER_ID, carrierId)))
+ .build();
+
+ Notification notification = mFrameworkFacade.makeNotificationBuilder(
+ mContext, WifiService.NOTIFICATION_NETWORK_STATUS)
+ .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
+ com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
+ .setTicker(mResources.getString(
+ R.string.wifi_suggestion_imsi_privacy_title, carrierName))
+ .setContentTitle(mResources.getString(
+ R.string.wifi_suggestion_imsi_privacy_title, carrierName))
+ .setStyle(new Notification.BigTextStyle()
+ .bigText(mResources.getString(
+ R.string.wifi_suggestion_imsi_privacy_content)))
+ .setDeleteIntent(getPrivateBroadcast(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
+ Pair.create(EXTRA_CARRIER_NAME, carrierName),
+ Pair.create(EXTRA_CARRIER_ID, carrierId)))
+ .setShowWhen(false)
+ .setLocalOnly(true)
+ .setColor(mResources.getColor(android.R.color.system_notification_accent_color,
+ mContext.getTheme()))
+ .addAction(userDisallowAppNotificationAction)
+ .addAction(userAllowAppNotificationAction)
+ .build();
+
+ // Post the notification.
+ mNotificationManager.notify(
+ SystemMessageProto.SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE, notification);
+ mUserApprovalUiActive = true;
+ }
+
+ private void sendImsiPrivacyConfirmationDialog(@NonNull String carrierName, int carrierId) {
+ AlertDialog dialog = mFrameworkFacade.makeAlertDialogBuilder(mContext)
+ .setTitle(mResources.getString(
+ R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title))
+ .setMessage(mResources.getString(
+ R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_content,
+ carrierName))
+ .setPositiveButton(mResources.getText(
+ R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_confirmation),
+ (d, which) -> mHandler.post(
+ () -> handleUserAllowCarrierExemptionAction(
+ carrierName, carrierId)))
+ .setNegativeButton(mResources.getText(
+ R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_confirmation),
+ (d, which) -> mHandler.post(
+ () -> handleUserDisallowCarrierExemptionAction(
+ carrierName, carrierId)))
+ .setOnDismissListener(
+ (d) -> mHandler.post(this::handleUserDismissAction))
+ .setOnCancelListener(
+ (d) -> mHandler.post(this::handleUserDismissAction))
+ .create();
+ dialog.setCanceledOnTouchOutside(false);
+ dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
+ dialog.getWindow().addSystemFlags(
+ WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
+ dialog.show();
+ mUserApprovalUiActive = true;
+ }
+
+ /**
+ * Send notification for exemption of IMSI protection if user never made choice before.
+ */
+ public void sendImsiProtectionExemptionNotificationIfRequired(int carrierId) {
+ int subId = getMatchingSubId(carrierId);
+ if (requiresImsiEncryption(subId)) {
+ return;
+ }
+ if (mImsiPrivacyProtectionExemptionMap.containsKey(carrierId)) {
+ return;
+ }
+ if (mUserApprovalUiActive) {
+ return;
+ }
+ Log.i(TAG, "Sending IMSI protection notification for " + carrierId);
+ sendImsiPrivacyNotification(carrierId);
+ }
+
+ private PendingIntent getPrivateBroadcast(@NonNull String action,
+ @NonNull Pair<String, String> extra1, @NonNull Pair<String, Integer> extra2) {
+ Intent intent = new Intent(action)
+ .setPackage(mWifiInjector.getWifiStackPackageName())
+ .putExtra(extra1.first, extra1.second)
+ .putExtra(extra2.first, extra2.second);
+ return mFrameworkFacade.getBroadcast(mContext, 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ private void saveToStore() {
+ // Set the flag to let WifiConfigStore that we have new data to write.
+ mHasNewDataToSerialize = true;
+ if (!mWifiInjector.getWifiConfigManager().saveToStore(true)) {
+ Log.w(TAG, "Failed to save to store");
+ }
+ }
+
+ /**
+ * Helper method for user factory reset network setting.
+ */
+ public void clear() {
+ mImsiPrivacyProtectionExemptionMap.clear();
+ saveToStore();
+ }
}
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 476b21b68..309f54f60 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -54,7 +54,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.util.LruConnectionTracker;
import com.android.server.wifi.util.MissingCounterTimerLockList;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.wifi.resources.R;
@@ -240,7 +239,7 @@ public class WifiConfigManager {
private final WifiPermissionsWrapper mWifiPermissionsWrapper;
private final WifiInjector mWifiInjector;
private final MacAddressUtil mMacAddressUtil;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private final WifiScoreCard mWifiScoreCard;
// Keep order of network connection.
private final LruConnectionTracker mLruConnectionTracker;
@@ -331,7 +330,7 @@ public class WifiConfigManager {
*/
WifiConfigManager(
Context context, Clock clock, UserManager userManager,
- TelephonyUtil telephonyUtil, WifiKeyStore wifiKeyStore,
+ WifiCarrierInfoManager wifiCarrierInfoManager, WifiKeyStore wifiKeyStore,
WifiConfigStore wifiConfigStore,
WifiPermissionsUtil wifiPermissionsUtil,
WifiPermissionsWrapper wifiPermissionsWrapper,
@@ -346,7 +345,7 @@ public class WifiConfigManager {
mClock = clock;
mUserManager = userManager;
mBackupManagerProxy = new BackupManagerProxy();
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mWifiKeyStore = wifiKeyStore;
mWifiConfigStore = wifiConfigStore;
mWifiPermissionsUtil = wifiPermissionsUtil;
@@ -2726,7 +2725,7 @@ public class WifiConfigManager {
}
if (config.enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.PEAP) {
Pair<String, String> currentIdentity =
- mTelephonyUtil.getSimIdentity(config);
+ mWifiCarrierInfoManager.getSimIdentity(config);
if (mVerboseLoggingEnabled) {
Log.d(TAG, "New identity for config " + config + ": " + currentIdentity);
}
@@ -2741,7 +2740,7 @@ public class WifiConfigManager {
} else {
// reset identity as well: supplicant will ask us for it
config.enterpriseConfig.setIdentity("");
- if (!TelephonyUtil.isAnonymousAtRealmIdentity(
+ if (!WifiCarrierInfoManager.isAnonymousAtRealmIdentity(
config.enterpriseConfig.getAnonymousIdentity())) {
config.enterpriseConfig.setAnonymousIdentity("");
}
@@ -3194,7 +3193,7 @@ public class WifiConfigManager {
pw.println("WifiConfigManager - PNO scan recency sorting enabled = "
+ mContext.getResources().getBoolean(R.bool.config_wifiPnoRecencySortingEnabled));
mWifiConfigStore.dump(fd, pw, args);
- mTelephonyUtil.dump(fd, pw, args);
+ mWifiCarrierInfoManager.dump(fd, pw, args);
}
/**
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 3f3e027b2..68311303b 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -56,7 +56,6 @@ import com.android.server.wifi.rtt.RttMetrics;
import com.android.server.wifi.util.LruConnectionTracker;
import com.android.server.wifi.util.NetdWrapper;
import com.android.server.wifi.util.SettingsMigrationDataHolder;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
@@ -155,7 +154,7 @@ public class WifiInjector {
private BssidBlocklistMonitor mBssidBlocklistMonitor;
private final MacAddressUtil mMacAddressUtil;
private final MboOceController mMboOceController;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private WifiChannelUtilization mWifiChannelUtilizationScan;
private WifiChannelUtilization mWifiChannelUtilizationConnected;
private final KeyStore mKeyStore;
@@ -260,8 +259,9 @@ public class WifiInjector {
WifiConfigStore.createSharedFiles(mFrameworkFacade.isNiapModeOn(mContext)));
SubscriptionManager subscriptionManager =
mContext.getSystemService(SubscriptionManager.class);
- mTelephonyUtil = new TelephonyUtil(makeTelephonyManager(), subscriptionManager,
- mFrameworkFacade, mContext, wifiHandler);
+ mWifiCarrierInfoManager = new WifiCarrierInfoManager(makeTelephonyManager(),
+ subscriptionManager, this, mFrameworkFacade, mContext,
+ mWifiConfigStore, wifiHandler);
String l2KeySeed = Secure.getString(mContext.getContentResolver(), Secure.ANDROID_ID);
mWifiScoreCard = new WifiScoreCard(mClock, l2KeySeed, mDeviceConfigFacade);
mWifiMetrics.setWifiScoreCard(mWifiScoreCard);
@@ -269,7 +269,7 @@ public class WifiInjector {
mContext);
// Config Manager
mWifiConfigManager = new WifiConfigManager(mContext, mClock,
- mUserManager, mTelephonyUtil,
+ mUserManager, mWifiCarrierInfoManager,
mWifiKeyStore, mWifiConfigStore, mWifiPermissionsUtil,
mWifiPermissionsWrapper, this,
new NetworkListSharedStoreData(mContext),
@@ -301,17 +301,17 @@ public class WifiInjector {
mWifiMetrics.setWifiNetworkSelector(mWifiNetworkSelector);
mWifiNetworkSuggestionsManager = new WifiNetworkSuggestionsManager(mContext, wifiHandler,
this, mWifiPermissionsUtil, mWifiConfigManager, mWifiConfigStore, mWifiMetrics,
- mTelephonyUtil, mWifiKeyStore, mLruConnectionTracker);
+ mWifiCarrierInfoManager, mWifiKeyStore, mLruConnectionTracker);
mPasspointManager = new PasspointManager(mContext, this,
wifiHandler, mWifiNative, mWifiKeyStore, mClock, new PasspointObjectFactory(),
- mWifiConfigManager, mWifiConfigStore, mWifiMetrics, mTelephonyUtil);
+ mWifiConfigManager, mWifiConfigStore, mWifiMetrics, mWifiCarrierInfoManager);
PasspointNetworkNominateHelper nominateHelper =
new PasspointNetworkNominateHelper(mPasspointManager, mWifiConfigManager,
mConnectivityLocalLog);
mSavedNetworkNominator = new SavedNetworkNominator(
- mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mTelephonyUtil);
+ mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mWifiCarrierInfoManager);
mNetworkSuggestionNominator = new NetworkSuggestionNominator(mWifiNetworkSuggestionsManager,
- mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mTelephonyUtil);
+ mWifiConfigManager, nominateHelper, mConnectivityLocalLog, mWifiCarrierInfoManager);
mScoredNetworkNominator = new ScoredNetworkNominator(mContext, wifiHandler,
mFrameworkFacade, mNetworkScoreManager, mContext.getPackageManager(),
mWifiConfigManager, mConnectivityLocalLog,
@@ -346,8 +346,8 @@ public class WifiInjector {
this, mBackupManagerProxy, mCountryCode, mWifiNative,
new WrongPasswordNotifier(mContext, mFrameworkFacade),
mSarManager, mWifiTrafficPoller, mLinkProbeManager, mBatteryStats,
- supplicantStateTracker, mMboOceController, mTelephonyUtil,
- new EapFailureNotifier(mContext, mFrameworkFacade, mTelephonyUtil),
+ supplicantStateTracker, mMboOceController, mWifiCarrierInfoManager,
+ new EapFailureNotifier(mContext, mFrameworkFacade, mWifiCarrierInfoManager),
new SimRequiredNotifier(mContext, mFrameworkFacade));
mActiveModeWarden = new ActiveModeWarden(this, wifiLooper,
mWifiNative, new DefaultModeManager(mContext), mBatteryStats, mWifiDiagnostics,
@@ -410,7 +410,7 @@ public class WifiInjector {
mWifiNetworkSuggestionsManager.enableVerboseLogging(verbose);
LogcatLog.enableVerboseLogging(verbose);
mDppManager.enableVerboseLogging(verbose);
- mTelephonyUtil.enableVerboseLogging(verbose);
+ mWifiCarrierInfoManager.enableVerboseLogging(verbose);
}
public UserManager getUserManager() {
@@ -537,8 +537,8 @@ public class WifiInjector {
return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
}
- public TelephonyUtil getTelephonyUtil() {
- return mTelephonyUtil;
+ public WifiCarrierInfoManager getWifiCarrierInfoManager() {
+ return mWifiCarrierInfoManager;
}
public WifiStateTracker getWifiStateTracker() {
diff --git a/service/java/com/android/server/wifi/WifiMonitor.java b/service/java/com/android/server/wifi/WifiMonitor.java
index 4e006a2fc..7f620851d 100644
--- a/service/java/com/android/server/wifi/WifiMonitor.java
+++ b/service/java/com/android/server/wifi/WifiMonitor.java
@@ -29,10 +29,10 @@ import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Protocol;
import com.android.server.wifi.MboOceController.BtmFrameData;
+import com.android.server.wifi.WifiCarrierInfoManager.SimAuthRequestData;
import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
import com.android.server.wifi.hotspot2.WnmData;
-import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData;
import java.util.HashMap;
import java.util.Map;
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 003275c50..894a8bc0f 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -59,7 +59,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.server.wifi.util.ExternalCallbackTracker;
import com.android.server.wifi.util.LruConnectionTracker;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.wifi.resources.R;
@@ -106,22 +105,6 @@ public class WifiNetworkSuggestionsManager {
public static final String EXTRA_UID =
"com.android.server.wifi.extra.NetworkSuggestion.UID";
- @VisibleForTesting
- public static final String EXTRA_CARRIER_NAME =
- "com.android.server.wifi.extra.NetworkSuggestion.CARRIER_NAME";
- @VisibleForTesting
- public static final String EXTRA_CARRIER_ID =
- "com.android.server.wifi.extra.NetworkSuggestion.CARRIER_ID";
-
- /** Intent when user tapped action button to allow the app. */
- @VisibleForTesting
- public static final String NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION =
- "com.android.server.wifi.action.NetworkSuggestion.USER_ALLOWED_CARRIER";
- /** Intent when user tapped action button to disallow the app. */
- @VisibleForTesting
- public static final String NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION =
- "com.android.server.wifi.action.NetworkSuggestion.USER_DISALLOWED_CARRIER";
-
/**
* Limit number of hidden networks attach to scan
*/
@@ -140,7 +123,7 @@ public class WifiNetworkSuggestionsManager {
private final WifiMetrics mWifiMetrics;
private final WifiInjector mWifiInjector;
private final FrameworkFacade mFrameworkFacade;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private final WifiKeyStore mWifiKeyStore;
// Keep order of network connection.
private final LruConnectionTracker mLruConnectionTracker;
@@ -362,8 +345,6 @@ public class WifiNetworkSuggestionsManager {
private final HashMap<String, ExternalCallbackTracker<ISuggestionConnectionStatusListener>>
mSuggestionStatusListenerPerApp = new HashMap<>();
- private final Map<Integer, Boolean> mImsiPrivacyProtectionExemptionMap = new HashMap<>();
-
/**
* Store the suggestion update listeners.
*/
@@ -488,35 +469,6 @@ public class WifiNetworkSuggestionsManager {
}
}
- /**
- * Module to interact with the wifi config store.
- */
- private class ImsiProtectionExemptionDataSource implements
- ImsiPrivacyProtectionExemptionStoreData.DataSource {
- @Override
- public Map<Integer, Boolean> toSerialize() {
- // Clear the flag after writing to disk.
- // TODO(b/115504887): Don't reset the flag on write failure.
- mHasNewDataToSerialize = false;
- return mImsiPrivacyProtectionExemptionMap;
- }
-
- @Override
- public void fromDeserialized(Map<Integer, Boolean> imsiProtectionExemptionMap) {
- mImsiPrivacyProtectionExemptionMap.putAll(imsiProtectionExemptionMap);
- }
-
- @Override
- public void reset() {
- mImsiPrivacyProtectionExemptionMap.clear();
- }
-
- @Override
- public boolean hasNewDataToSerialize() {
- return mHasNewDataToSerialize;
- }
- }
-
private void handleUserAllowAction(int uid, String packageName) {
Log.i(TAG, "User clicked to allow app");
// Set the user approved flag.
@@ -539,59 +491,23 @@ public class WifiNetworkSuggestionsManager {
mUserApprovalUiActive = false;
}
- private void handleUserAllowCarrierExemptionAction(String carrierName, int carrierId) {
- Log.i(TAG, "User clicked to allow carrier:" + carrierName);
- setHasUserApprovedImsiPrivacyExemptionForCarrier(true, carrierId);
- mUserApprovalUiActive = false;
- }
-
- private void handleUserDisallowCarrierExemptionAction(String carrierName, int carrierId) {
- Log.i(TAG, "User clicked to disallow carrier:" + carrierName);
- setHasUserApprovedImsiPrivacyExemptionForCarrier(false, carrierId);
- mUserApprovalUiActive = false;
- }
-
private final BroadcastReceiver mBroadcastReceiver =
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
- String carrierName = intent.getStringExtra(EXTRA_CARRIER_NAME);
int uid = intent.getIntExtra(EXTRA_UID, -1);
- int carrierId = intent.getIntExtra(EXTRA_CARRIER_ID, -1);
-
+ if (packageName == null || uid == -1) {
+ Log.e(TAG, "No package name or uid found in intent");
+ return;
+ }
switch (intent.getAction()) {
case NOTIFICATION_USER_ALLOWED_APP_INTENT_ACTION:
- if (packageName == null || uid == -1) {
- Log.e(TAG, "No package name or uid found in intent");
- return;
- }
handleUserAllowAction(uid, packageName);
break;
case NOTIFICATION_USER_DISALLOWED_APP_INTENT_ACTION:
- if (packageName == null || uid == -1) {
- Log.e(TAG, "No package name or uid found in intent");
- return;
- }
handleUserDisallowAction(uid, packageName);
break;
- case NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION:
- if (carrierName == null || carrierId == -1) {
- Log.e(TAG, "No carrier name or carrier id found in intent");
- return;
- }
- Log.i(TAG, "User clicked to allow carrier");
- sendImsiPrivacyConfirmationDialog(carrierName, carrierId);
- // Collapse the notification bar
- mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
- break;
- case NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION:
- if (carrierName == null || carrierId == -1) {
- Log.e(TAG, "No carrier name or carrier id found in intent");
- return;
- }
- handleUserDisallowCarrierExemptionAction(carrierName, carrierId);
- break;
case NOTIFICATION_USER_DISMISSED_INTENT_ACTION:
handleUserDismissAction();
return; // no need to cancel a dismissed notification, return.
@@ -604,7 +520,6 @@ public class WifiNetworkSuggestionsManager {
}
};
-
/**
* Interface for other modules to listen to the suggestion updated events.
*/
@@ -619,10 +534,19 @@ public class WifiNetworkSuggestionsManager {
void onSuggestionsRemoved(@NonNull List<WifiNetworkSuggestion> removedSuggestions);
}
+ private final class UserApproveCarrierListener implements
+ WifiCarrierInfoManager.OnUserApproveCarrierListener {
+
+ @Override
+ public void onUserAllowed(int carrierId) {
+ restoreInitialAutojoinForCarrierId(carrierId);
+ }
+ }
+
public WifiNetworkSuggestionsManager(WifiContext context, Handler handler,
WifiInjector wifiInjector, WifiPermissionsUtil wifiPermissionsUtil,
WifiConfigManager wifiConfigManager, WifiConfigStore wifiConfigStore,
- WifiMetrics wifiMetrics, TelephonyUtil telephonyUtil,
+ WifiMetrics wifiMetrics, WifiCarrierInfoManager wifiCarrierInfoManager,
WifiKeyStore keyStore, LruConnectionTracker lruConnectionTracker) {
mContext = context;
mResources = context.getResources();
@@ -638,22 +562,21 @@ public class WifiNetworkSuggestionsManager {
mWifiPermissionsUtil = wifiPermissionsUtil;
mWifiConfigManager = wifiConfigManager;
mWifiMetrics = wifiMetrics;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mWifiKeyStore = keyStore;
// register the data store for serializing/deserializing data.
wifiConfigStore.registerStoreData(
wifiInjector.makeNetworkSuggestionStoreData(new NetworkSuggestionDataSource()));
- wifiConfigStore.registerStoreData(wifiInjector.makeImsiProtectionExemptionStoreData(
- new ImsiProtectionExemptionDataSource()));
+
+ mWifiCarrierInfoManager.addImsiExemptionUserApprovalListener(
+ new UserApproveCarrierListener());
// Register broadcast receiver for UI interactions.
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(NOTIFICATION_USER_ALLOWED_APP_INTENT_ACTION);
mIntentFilter.addAction(NOTIFICATION_USER_DISALLOWED_APP_INTENT_ACTION);
mIntentFilter.addAction(NOTIFICATION_USER_DISMISSED_INTENT_ACTION);
- mIntentFilter.addAction(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION);
- mIntentFilter.addAction(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION);
mContext.registerReceiver(mBroadcastReceiver, mIntentFilter, null, handler);
mLruConnectionTracker = lruConnectionTracker;
@@ -891,7 +814,8 @@ public class WifiNetworkSuggestionsManager {
return WifiManager.STATUS_NETWORK_SUGGESTIONS_ERROR_ADD_NOT_ALLOWED;
}
- int carrierId = mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(packageName);
+ int carrierId = mWifiCarrierInfoManager
+ .getCarrierIdForPackageWithCarrierPrivileges(packageName);
final String activeScorerPackage = mNetworkScoreManager.getActiveScorerPackage();
PerAppInfo perAppInfo = mActiveNetworkSuggestionsPerApp.get(packageName);
if (perAppInfo == null) {
@@ -948,9 +872,10 @@ public class WifiNetworkSuggestionsManager {
// If network has no IMSI protection and user didn't approve exemption, make it initial
// auto join disabled
if (isSimBasedSuggestion(ewns)) {
- int subId = mTelephonyUtil.getMatchingSubId(getCarrierIdFromSuggestion(ewns));
- if (!(mTelephonyUtil.requiresImsiEncryption(subId)
- || hasUserApprovedImsiPrivacyExemptionForCarrier(
+ int subId = mWifiCarrierInfoManager
+ .getMatchingSubId(getCarrierIdFromSuggestion(ewns));
+ if (!(mWifiCarrierInfoManager.requiresImsiEncryption(subId)
+ || mWifiCarrierInfoManager.hasUserApprovedImsiPrivacyExemptionForCarrier(
getCarrierIdFromSuggestion(ewns)))) {
ewns.isAutojoinEnabled = false;
}
@@ -1033,7 +958,7 @@ public class WifiNetworkSuggestionsManager {
private boolean validateCarrierNetworkSuggestions(
List<WifiNetworkSuggestion> networkSuggestions, int uid, String packageName) {
if (mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(uid)
- || mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(packageName)
+ || mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(packageName)
!= TelephonyManager.UNKNOWN_CARRIER_ID) {
return true;
}
@@ -1207,7 +1132,6 @@ public class WifiNetworkSuggestionsManager {
iter.remove();
}
mSuggestionStatusListenerPerApp.clear();
- mImsiPrivacyProtectionExemptionMap.clear();
saveToStore();
Log.i(TAG, "Cleared all internal state");
}
@@ -1238,37 +1162,6 @@ public class WifiNetworkSuggestionsManager {
}
/**
- * Clear the Imsi Privacy Exemption user approval info the target carrier.
- */
- public void clearImsiPrivacyExemptionForCarrier(int carrierId) {
- mImsiPrivacyProtectionExemptionMap.remove(carrierId);
- saveToStore();
- }
-
- /**
- * Check if carrier have user approved exemption for IMSI protection
- */
- public boolean hasUserApprovedImsiPrivacyExemptionForCarrier(int carrierId) {
- return mImsiPrivacyProtectionExemptionMap.getOrDefault(carrierId, false);
- }
-
- /**
- * Enable or disable exemption on IMSI protection.
- */
- public void setHasUserApprovedImsiPrivacyExemptionForCarrier(boolean approved, int carrierId) {
- if (mVerboseLoggingEnabled) {
- Log.v(TAG, "Setting Imsi privacy exemption for carrier " + carrierId
- + (approved ? " approved" : " not approved"));
- }
- mImsiPrivacyProtectionExemptionMap.put(carrierId, approved);
- // If user approved the exemption restore to initial auto join configure.
- if (approved) {
- restoreInitialAutojoinForCarrierId(carrierId);
- }
- saveToStore();
- }
-
- /**
* When user approve the IMSI protection exemption for carrier, restore the initial auto join
* configure. If user already change it to enabled, keep that choice.
*/
@@ -1430,83 +1323,6 @@ public class WifiNetworkSuggestionsManager {
mUserApprovalUiActive = true;
}
- private void sendImsiPrivacyNotification(@NonNull String carrierName, int carrierId) {
- Notification.Action userAllowAppNotificationAction =
- new Notification.Action.Builder(null,
- mResources.getText(R.string
- .wifi_suggestion_action_allow_imsi_privacy_exemption_carrier),
- getPrivateBroadcast(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
- Pair.create(EXTRA_CARRIER_NAME, carrierName),
- Pair.create(EXTRA_CARRIER_ID, carrierId)))
- .build();
- Notification.Action userDisallowAppNotificationAction =
- new Notification.Action.Builder(null,
- mResources.getText(R.string
- .wifi_suggestion_action_disallow_imsi_privacy_exemption_carrier),
- getPrivateBroadcast(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION,
- Pair.create(EXTRA_CARRIER_NAME, carrierName),
- Pair.create(EXTRA_CARRIER_ID, carrierId)))
- .build();
-
- Notification notification = mFrameworkFacade.makeNotificationBuilder(
- mContext, WifiService.NOTIFICATION_NETWORK_STATUS)
- .setSmallIcon(Icon.createWithResource(mContext.getWifiOverlayApkPkgName(),
- com.android.wifi.resources.R.drawable.stat_notify_wifi_in_range))
- .setTicker(mResources.getString(
- R.string.wifi_suggestion_imsi_privacy_title, carrierName))
- .setContentTitle(mResources.getString(
- R.string.wifi_suggestion_imsi_privacy_title, carrierName))
- .setStyle(new Notification.BigTextStyle()
- .bigText(mResources.getString(
- R.string.wifi_suggestion_imsi_privacy_content)))
- .setDeleteIntent(getPrivateBroadcast(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
- Pair.create(EXTRA_CARRIER_NAME, carrierName),
- Pair.create(EXTRA_CARRIER_ID, carrierId)))
- .setShowWhen(false)
- .setLocalOnly(true)
- .setColor(mResources.getColor(android.R.color.system_notification_accent_color,
- mContext.getTheme()))
- .addAction(userDisallowAppNotificationAction)
- .addAction(userAllowAppNotificationAction)
- .build();
-
- // Post the notification.
- mNotificationManager.notify(
- SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE, notification);
- mUserApprovalUiActive = true;
- }
-
- private void sendImsiPrivacyConfirmationDialog(@NonNull String carrierName, int carrierId) {
- AlertDialog dialog = mFrameworkFacade.makeAlertDialogBuilder(mContext)
- .setTitle(mResources.getString(
- R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title))
- .setMessage(mResources.getString(
- R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_content,
- carrierName))
- .setPositiveButton(mResources.getText(
- R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_confirmation),
- (d, which) -> mHandler.post(
- () -> handleUserAllowCarrierExemptionAction(
- carrierName, carrierId)))
- .setNegativeButton(mResources.getText(
- R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_confirmation),
- (d, which) -> mHandler.post(
- () -> handleUserDisallowCarrierExemptionAction(
- carrierName, carrierId)))
- .setOnDismissListener(
- (d) -> mHandler.post(this::handleUserDismissAction))
- .setOnCancelListener(
- (d) -> mHandler.post(this::handleUserDismissAction))
- .create();
- dialog.setCanceledOnTouchOutside(false);
- dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
- dialog.getWindow().addSystemFlags(
- WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS);
- dialog.show();
- mUserApprovalUiActive = true;
- }
-
-
/**
* Send user approval notification if the app is not approved
* @param packageName app package name
@@ -1531,24 +1347,6 @@ public class WifiNetworkSuggestionsManager {
return true;
}
- /**
- * Send notification for exemption of IMSI protection if user never made choice before.
- */
- private void sendImsiProtectionExemptionNotificationIfRequired(int carrierId) {
- int subId = mTelephonyUtil.getMatchingSubId(carrierId);
- if (mTelephonyUtil.requiresImsiEncryption(subId)) {
- return;
- }
- if (mImsiPrivacyProtectionExemptionMap.containsKey(carrierId)) {
- return;
- }
- if (mUserApprovalUiActive) {
- return;
- }
- Log.i(TAG, "Sending IMSI protection notification for " + carrierId);
- sendImsiPrivacyNotification(mTelephonyUtil.getCarrierNameforSubId(subId), carrierId);
- }
-
private @Nullable Set<ExtendedWifiNetworkSuggestion>
getNetworkSuggestionsForScanResultMatchInfo(
@NonNull ScanResultMatchInfo scanResultMatchInfo, @Nullable MacAddress bssid) {
@@ -1598,8 +1396,8 @@ public class WifiNetworkSuggestionsManager {
continue;
}
if (isSimBasedSuggestion(ewns)) {
- int carrierId = getCarrierIdFromSuggestion(ewns);
- sendImsiProtectionExemptionNotificationIfRequired(carrierId);
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(
+ getCarrierIdFromSuggestion(ewns));
}
approvedExtNetworkSuggestions.add(ewns);
}
@@ -1645,8 +1443,8 @@ public class WifiNetworkSuggestionsManager {
continue;
}
if (isSimBasedSuggestion(ewns)) {
- int carrierId = getCarrierIdFromSuggestion(ewns);
- sendImsiProtectionExemptionNotificationIfRequired(carrierId);
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(
+ getCarrierIdFromSuggestion(ewns));
}
approvedExtNetworkSuggestions.add(ewns);
}
@@ -1753,7 +1551,7 @@ public class WifiNetworkSuggestionsManager {
*/
public boolean isPasspointSuggestionSharedWithUser(WifiConfiguration config) {
if (WifiConfiguration.isMetered(config, null)
- && mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config)) {
+ && mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config)) {
return false;
}
Set<ExtendedWifiNetworkSuggestion> extendedWifiNetworkSuggestions =
@@ -2080,7 +1878,7 @@ public class WifiNetworkSuggestionsManager {
public void resetCarrierPrivilegedApps() {
Log.w(TAG, "SIM state is changed!");
for (PerAppInfo appInfo : mActiveNetworkSuggestionsPerApp.values()) {
- int carrierId = mTelephonyUtil
+ int carrierId = mWifiCarrierInfoManager
.getCarrierIdForPackageWithCarrierPrivileges(appInfo.packageName);
if (carrierId == appInfo.carrierId) {
continue;
diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java
index 64b29f2ac..f3bd4ba01 100644
--- a/service/java/com/android/server/wifi/WifiShellCommand.java
+++ b/service/java/com/android/server/wifi/WifiShellCommand.java
@@ -111,6 +111,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
private final WifiServiceImpl mWifiService;
private final Context mContext;
private final ConnectivityManager mConnectivityManager;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
WifiShellCommand(WifiInjector wifiInjector, WifiServiceImpl wifiService, Context context) {
mClientModeImpl = wifiInjector.getClientModeImpl();
@@ -124,6 +125,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
mWifiService = wifiService;
mContext = context;
mConnectivityManager = context.getSystemService(ConnectivityManager.class);
+ mWifiCarrierInfoManager = wifiInjector.getWifiCarrierInfoManager();
}
@Override
@@ -216,7 +218,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
return -1;
}
boolean approved = getNextArgRequiredTrueOrFalse("yes", "no");
- mWifiNetworkSuggestionsManager
+ mWifiCarrierInfoManager
.setHasUserApprovedImsiPrivacyExemptionForCarrier(approved, carrierId);
return 0;
}
@@ -231,7 +233,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
+ "- 'carrierId' must be an Integer");
return -1;
}
- boolean hasUserApproved = mWifiNetworkSuggestionsManager
+ boolean hasUserApproved = mWifiCarrierInfoManager
.hasUserApprovedImsiPrivacyExemptionForCarrier(carrierId);
pw.println(hasUserApproved ? "yes" : "no");
return 0;
@@ -247,7 +249,7 @@ public class WifiShellCommand extends BasicShellCommandHandler {
+ "- 'carrierId' must be an Integer");
return -1;
}
- mWifiNetworkSuggestionsManager.clearImsiPrivacyExemptionForCarrier(carrierId);
+ mWifiCarrierInfoManager.clearImsiPrivacyExemptionForCarrier(carrierId);
return 0;
}
case "network-requests-remove-user-approved-access-points": {
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java b/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java
index e7de22f55..8400bb581 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointConfigUserStoreData.java
@@ -21,9 +21,9 @@ import android.net.wifi.hotspot2.PasspointConfiguration;
import android.text.TextUtils;
import android.util.Log;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiConfigStore;
import com.android.server.wifi.WifiKeyStore;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil;
import com.android.server.wifi.util.XmlUtil;
@@ -77,7 +77,7 @@ public class PasspointConfigUserStoreData implements WifiConfigStore.StoreData {
private static final String XML_TAG_IS_TRUSTED = "IsTrusted";
private final WifiKeyStore mKeyStore;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private final DataSource mDataSource;
/**
@@ -99,10 +99,10 @@ public class PasspointConfigUserStoreData implements WifiConfigStore.StoreData {
void setProviders(List<PasspointProvider> providers);
}
- PasspointConfigUserStoreData(WifiKeyStore keyStore, TelephonyUtil telephonyUtil,
- DataSource dataSource) {
+ PasspointConfigUserStoreData(WifiKeyStore keyStore,
+ WifiCarrierInfoManager wifiCarrierInfoManager, DataSource dataSource) {
mKeyStore = keyStore;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mDataSource = dataSource;
}
@@ -348,7 +348,8 @@ public class PasspointConfigUserStoreData implements WifiConfigStore.StoreData {
if (config == null) {
throw new XmlPullParserException("Missing Passpoint configuration");
}
- PasspointProvider provider = new PasspointProvider(config, mKeyStore, mTelephonyUtil,
+ PasspointProvider provider = new PasspointProvider(config, mKeyStore,
+ mWifiCarrierInfoManager,
providerId, creatorUid, packageName, isFromSuggestion, caCertificateAliases,
clientPrivateKeyAndCertificateAlias, remediationCaCertificateAlias,
hasEverConnected, shared);
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
index 14f326ef0..a702c7e98 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointManager.java
@@ -52,6 +52,7 @@ import android.util.Pair;
import com.android.server.wifi.Clock;
import com.android.server.wifi.NetworkUpdateResult;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiConfigManager;
import com.android.server.wifi.WifiConfigStore;
import com.android.server.wifi.WifiInjector;
@@ -63,7 +64,6 @@ import com.android.server.wifi.hotspot2.anqp.Constants;
import com.android.server.wifi.hotspot2.anqp.HSOsuProvidersElement;
import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
import com.android.server.wifi.util.InformationElementUtil;
-import com.android.server.wifi.util.TelephonyUtil;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -118,7 +118,7 @@ public class PasspointManager {
private final WifiMetrics mWifiMetrics;
private final PasspointProvisioner mPasspointProvisioner;
private final AppOpsManager mAppOps;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
/**
* Map of package name of an app to the app ops changed listener for the app.
@@ -331,7 +331,7 @@ public class PasspointManager {
PasspointObjectFactory objectFactory, WifiConfigManager wifiConfigManager,
WifiConfigStore wifiConfigStore,
WifiMetrics wifiMetrics,
- TelephonyUtil telephonyUtil) {
+ WifiCarrierInfoManager wifiCarrierInfoManager) {
mPasspointEventHandler = objectFactory.makePasspointEventHandler(wifiNative,
new CallbackHandler(context));
mWifiInjector = wifiInjector;
@@ -344,9 +344,9 @@ public class PasspointManager {
mWifiConfigManager = wifiConfigManager;
mWifiMetrics = wifiMetrics;
mProviderIndex = 0;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
wifiConfigStore.registerStoreData(objectFactory.makePasspointConfigUserStoreData(
- mKeyStore, mTelephonyUtil, new UserDataSourceHandler()));
+ mKeyStore, mWifiCarrierInfoManager, new UserDataSourceHandler()));
wifiConfigStore.registerStoreData(objectFactory.makePasspointConfigSharedStoreData(
new SharedDataSourceHandler()));
mPasspointProvisioner = objectFactory.makePasspointProvisioner(context, wifiNative,
@@ -433,10 +433,10 @@ public class PasspointManager {
return false;
}
- mTelephonyUtil.tryUpdateCarrierIdForPasspoint(config);
+ mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(config);
// Create a provider and install the necessary certificates and keys.
PasspointProvider newProvider = mObjectFactory.makePasspointProvider(config, mKeyStore,
- mTelephonyUtil, mProviderIndex++, uid, packageName, isFromSuggestion);
+ mWifiCarrierInfoManager, mProviderIndex++, uid, packageName, isFromSuggestion);
newProvider.setTrusted(isTrusted);
if (!newProvider.installCertsAndKeys()) {
@@ -1171,7 +1171,7 @@ public class PasspointManager {
// Note that for legacy configuration, the alias for client private key is the same as the
// alias for the client certificate.
PasspointProvider provider = new PasspointProvider(passpointConfig, mKeyStore,
- mTelephonyUtil,
+ mWifiCarrierInfoManager,
mProviderIndex++, wifiConfig.creatorUid, null, false,
Arrays.asList(enterpriseConfig.getCaCertificateAlias()),
enterpriseConfig.getClientCertificateAlias(), null, false, false);
@@ -1226,7 +1226,7 @@ public class PasspointManager {
@NonNull PasspointConfiguration passpointConfiguration,
@NonNull List<ScanResult> scanResults) {
PasspointProvider provider = mObjectFactory.makePasspointProvider(passpointConfiguration,
- null, mTelephonyUtil, 0, 0, null, false);
+ null, mWifiCarrierInfoManager, 0, 0, null, false);
List<ScanResult> filteredScanResults = new ArrayList<>();
for (ScanResult scanResult : scanResults) {
PasspointMatch matchInfo = provider.match(getANQPElements(scanResult),
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointObjectFactory.java b/service/java/com/android/server/wifi/hotspot2/PasspointObjectFactory.java
index 70095f0d4..2ce1b1a6d 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointObjectFactory.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointObjectFactory.java
@@ -20,10 +20,10 @@ import android.content.Context;
import android.net.wifi.hotspot2.PasspointConfiguration;
import com.android.server.wifi.Clock;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiKeyStore;
import com.android.server.wifi.WifiMetrics;
import com.android.server.wifi.WifiNative;
-import com.android.server.wifi.util.TelephonyUtil;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -59,23 +59,24 @@ public class PasspointObjectFactory{
* @return {@link PasspointProvider}
*/
public PasspointProvider makePasspointProvider(PasspointConfiguration config,
- WifiKeyStore keyStore, TelephonyUtil telephonyUtil, long providerId, int creatorUid,
- String packageName, boolean isFromSuggestion) {
- return new PasspointProvider(config, keyStore, telephonyUtil, providerId, creatorUid,
- packageName, isFromSuggestion);
+ WifiKeyStore keyStore, WifiCarrierInfoManager wifiCarrierInfoManager, long providerId,
+ int creatorUid, String packageName, boolean isFromSuggestion) {
+ return new PasspointProvider(config, keyStore, wifiCarrierInfoManager, providerId,
+ creatorUid, packageName, isFromSuggestion);
}
/**
* Create a {@link PasspointConfigUserStoreData} instance.
*
* @param keyStore Instance of {@link WifiKeyStore}
- * @param telephonyUtil Instance of {@link TelephonyUtil}
+ * @param wifiCarrierInfoManager Instance of {@link WifiCarrierInfoManager}
* @param dataSource Passpoint configuration data source
* @return {@link PasspointConfigUserStoreData}
*/
public PasspointConfigUserStoreData makePasspointConfigUserStoreData(WifiKeyStore keyStore,
- TelephonyUtil telephonyUtil, PasspointConfigUserStoreData.DataSource dataSource) {
- return new PasspointConfigUserStoreData(keyStore, telephonyUtil, dataSource);
+ WifiCarrierInfoManager wifiCarrierInfoManager,
+ PasspointConfigUserStoreData.DataSource dataSource) {
+ return new PasspointConfigUserStoreData(keyStore, wifiCarrierInfoManager, dataSource);
}
/**
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
index 43d6f0634..006b8eaef 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java
@@ -34,6 +34,7 @@ import android.util.Log;
import android.util.Pair;
import com.android.server.wifi.IMSIParameter;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiKeyStore;
import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.Constants.ANQPElementType;
@@ -45,7 +46,6 @@ import com.android.server.wifi.hotspot2.anqp.eap.AuthParam;
import com.android.server.wifi.hotspot2.anqp.eap.NonEAPInnerAuth;
import com.android.server.wifi.util.ArrayUtils;
import com.android.server.wifi.util.InformationElementUtil.RoamingConsortium;
-import com.android.server.wifi.util.TelephonyUtil;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@@ -98,7 +98,7 @@ public class PasspointProvider {
private final int mEAPMethodID;
private final AuthParam mAuthParam;
- private final TelephonyUtil mTelephonyUtil;
+ private final WifiCarrierInfoManager mWifiCarrierInfoManager;
private int mBestGuessCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
private boolean mHasEverConnected;
@@ -108,17 +108,16 @@ public class PasspointProvider {
private boolean mVerboseLoggingEnabled;
public PasspointProvider(PasspointConfiguration config, WifiKeyStore keyStore,
- TelephonyUtil telephonyUtil, long providerId, int creatorUid, String packageName,
- boolean isFromSuggestion) {
- this(config, keyStore, telephonyUtil, providerId, creatorUid, packageName, isFromSuggestion,
- null, null, null, false, false);
+ WifiCarrierInfoManager wifiCarrierInfoManager, long providerId, int creatorUid,
+ String packageName, boolean isFromSuggestion) {
+ this(config, keyStore, wifiCarrierInfoManager, providerId, creatorUid, packageName,
+ isFromSuggestion, null, null, null, false, false);
}
public PasspointProvider(PasspointConfiguration config, WifiKeyStore keyStore,
- TelephonyUtil telephonyUtil, long providerId, int creatorUid, String packageName,
- boolean isFromSuggestion, List<String> caCertificateAliases,
- String clientPrivateKeyAndCertificateAlias,
- String remediationCaCertificateAlias,
+ WifiCarrierInfoManager wifiCarrierInfoManager, long providerId, int creatorUid,
+ String packageName, boolean isFromSuggestion, List<String> caCertificateAliases,
+ String clientPrivateKeyAndCertificateAlias, String remediationCaCertificateAlias,
boolean hasEverConnected, boolean isShared) {
// Maintain a copy of the configuration to avoid it being updated by others.
mConfig = new PasspointConfiguration(config);
@@ -132,7 +131,7 @@ public class PasspointProvider {
mHasEverConnected = hasEverConnected;
mIsShared = isShared;
mIsFromSuggestion = isFromSuggestion;
- mTelephonyUtil = telephonyUtil;
+ mWifiCarrierInfoManager = wifiCarrierInfoManager;
mIsTrusted = true;
// Setup EAP method and authentication parameter based on the credential.
@@ -351,19 +350,19 @@ public class PasspointProvider {
* @return true if the carrier ID is updated, otherwise false.
*/
public boolean tryUpdateCarrierId() {
- return mTelephonyUtil.tryUpdateCarrierIdForPasspoint(mConfig);
+ return mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(mConfig);
}
private @Nullable String getMatchingSimImsi() {
String matchingSIMImsi = null;
if (mConfig.getCarrierId() != TelephonyManager.UNKNOWN_CARRIER_ID) {
- matchingSIMImsi = mTelephonyUtil
+ matchingSIMImsi = mWifiCarrierInfoManager
.getMatchingImsi(mConfig.getCarrierId());
} else {
// Get the IMSI and carrier ID of SIM card which match with the IMSI prefix from
// passpoint profile
- Pair<String, Integer> imsiCarrierIdPair = mTelephonyUtil.getMatchingImsiCarrierId(
- mConfig.getCredential().getSimCredential().getImsi());
+ Pair<String, Integer> imsiCarrierIdPair = mWifiCarrierInfoManager
+ .getMatchingImsiCarrierId(mConfig.getCredential().getSimCredential().getImsi());
if (imsiCarrierIdPair != null) {
matchingSIMImsi = imsiCarrierIdPair.first;
mBestGuessCarrierId = imsiCarrierIdPair.second;
diff --git a/tests/wifitests/Android.bp b/tests/wifitests/Android.bp
index 2f3cbad1b..02b4f7a9c 100644
--- a/tests/wifitests/Android.bp
+++ b/tests/wifitests/Android.bp
@@ -936,9 +936,9 @@ android_test {
"com.android.server.wifi.util.StringUtil",
"com.android.server.wifi.util.StringUtil$*",
"com.android.server.wifi.util.StringUtil.**",
- "com.android.server.wifi.util.TelephonyUtil",
- "com.android.server.wifi.util.TelephonyUtil$*",
- "com.android.server.wifi.util.TelephonyUtil.**",
+ "com.android.server.wifi.WifiCarrierInfoManager",
+ "com.android.server.wifi.WifiCarrierInfoManager$*",
+ "com.android.server.wifi.WifiCarrierInfoManager.**",
"com.android.server.wifi.util.TimedQuotaManager",
"com.android.server.wifi.util.TimedQuotaManager$*",
"com.android.server.wifi.util.TimedQuotaManager.**",
diff --git a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
index cd0b0f1c2..17fc1a7f8 100644
--- a/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ClientModeImplTest.java
@@ -133,7 +133,6 @@ import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiIsUnusableEvent;
import com.android.server.wifi.proto.nano.WifiMetricsProto.WifiUsabilityStats;
import com.android.server.wifi.util.RssiUtilTest;
import com.android.server.wifi.util.ScanResultUtil;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.wifi.resources.R;
@@ -367,7 +366,7 @@ public class ClientModeImplTest extends WifiBaseTest {
IpClientCallbacks mIpClientCallback;
OsuProvider mOsuProvider;
WifiConfiguration mConnectedNetwork;
- TelephonyUtil mTelephonyUtil;
+ WifiCarrierInfoManager mWifiCarrierInfoManager;
@Mock WifiScanner mWifiScanner;
@Mock SupplicantStateTracker mSupplicantStateTracker;
@@ -542,9 +541,10 @@ public class ClientModeImplTest extends WifiBaseTest {
when(mSubscriptionManager.getActiveSubscriptionIdList())
.thenReturn(new int[]{DATA_SUBID});
- TelephonyUtil tu = new TelephonyUtil(mTelephonyManager, mSubscriptionManager,
- mock(FrameworkFacade.class), mock(Context.class), mock(Handler.class));
- mTelephonyUtil = spy(tu);
+ WifiCarrierInfoManager tu = new WifiCarrierInfoManager(mTelephonyManager,
+ mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
+ mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class));
+ mWifiCarrierInfoManager = spy(tu);
// static mocking
mSession = ExtendedMockito.mockitoSession().strictness(Strictness.LENIENT)
.spyStatic(MacAddress.class)
@@ -605,9 +605,9 @@ public class ClientModeImplTest extends WifiBaseTest {
private void initializeCmi() throws Exception {
mCmi = new ClientModeImpl(mContext, mFrameworkFacade, mLooper.getLooper(),
mUserManager, mWifiInjector, mBackupManagerProxy, mCountryCode, mWifiNative,
- mWrongPasswordNotifier, mSarManager, mWifiTrafficPoller,
- mLinkProbeManager, mBatteryStatsManager, mSupplicantStateTracker,
- mMboOceController, mTelephonyUtil, mEapFailureNotifier, mSimRequiredNotifier);
+ mWrongPasswordNotifier, mSarManager, mWifiTrafficPoller, mLinkProbeManager,
+ mBatteryStatsManager, mSupplicantStateTracker, mMboOceController,
+ mWifiCarrierInfoManager, mEapFailureNotifier, mSimRequiredNotifier);
mCmi.start();
mWifiCoreThread = getCmiHandlerThread(mCmi);
@@ -1051,7 +1051,7 @@ public class ClientModeImplTest extends WifiBaseTest {
mConnectedNetwork = spy(WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE));
mConnectedNetwork.carrierId = CARRIER_ID_1;
- doReturn(DATA_SUBID).when(mTelephonyUtil)
+ doReturn(DATA_SUBID).when(mWifiCarrierInfoManager)
.getBestMatchSubscriptionId(any(WifiConfiguration.class));
when(mDataTelephonyManager.getSimOperator()).thenReturn("123456");
when(mDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
@@ -1078,7 +1078,7 @@ public class ClientModeImplTest extends WifiBaseTest {
@Test
public void testResetSimWhenNonConnectedSimRemoved() throws Exception {
setupEapSimConnection();
- doReturn(true).when(mTelephonyUtil).isSimPresent(eq(DATA_SUBID));
+ doReturn(true).when(mWifiCarrierInfoManager).isSimPresent(eq(DATA_SUBID));
mCmi.sendMessage(ClientModeImpl.CMD_RESET_SIM_NETWORKS,
ClientModeImpl.RESET_SIM_REASON_SIM_REMOVED);
mLooper.dispatchAll();
@@ -1095,7 +1095,7 @@ public class ClientModeImplTest extends WifiBaseTest {
@Test
public void testResetSimWhenConnectedSimRemoved() throws Exception {
setupEapSimConnection();
- doReturn(false).when(mTelephonyUtil).isSimPresent(eq(DATA_SUBID));
+ doReturn(false).when(mWifiCarrierInfoManager).isSimPresent(eq(DATA_SUBID));
mCmi.sendMessage(ClientModeImpl.CMD_RESET_SIM_NETWORKS,
ClientModeImpl.RESET_SIM_REASON_SIM_REMOVED);
mLooper.dispatchAll();
@@ -1135,7 +1135,7 @@ public class ClientModeImplTest extends WifiBaseTest {
.mockStatic(SubscriptionManager.class)
.startMocking();
when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(DATA_SUBID);
- doReturn(true).when(mTelephonyUtil).isImsiEncryptionInfoAvailable(anyInt());
+ doReturn(true).when(mWifiCarrierInfoManager).isImsiEncryptionInfoAvailable(anyInt());
// Initial value should be "not set"
assertEquals("", mConnectedNetwork.enterpriseConfig.getAnonymousIdentity());
@@ -1191,7 +1191,7 @@ public class ClientModeImplTest extends WifiBaseTest {
.mockStatic(SubscriptionManager.class)
.startMocking();
when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(DATA_SUBID);
- doReturn(true).when(mTelephonyUtil).isImsiEncryptionInfoAvailable(anyInt());
+ doReturn(true).when(mWifiCarrierInfoManager).isImsiEncryptionInfoAvailable(anyInt());
triggerConnect();
@@ -1245,7 +1245,7 @@ public class ClientModeImplTest extends WifiBaseTest {
.mockStatic(SubscriptionManager.class)
.startMocking();
when(SubscriptionManager.getDefaultDataSubscriptionId()).thenReturn(DATA_SUBID);
- doReturn(true).when(mTelephonyUtil).isImsiEncryptionInfoAvailable(anyInt());
+ doReturn(true).when(mWifiCarrierInfoManager).isImsiEncryptionInfoAvailable(anyInt());
triggerConnect();
diff --git a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
index 08076dd72..f2ec351ae 100644
--- a/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/EapFailureNotifierTest.java
@@ -33,8 +33,6 @@ import android.telephony.SubscriptionManager;
import androidx.test.filters.SmallTest;
-import com.android.server.wifi.util.TelephonyUtil;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -54,7 +52,8 @@ public class EapFailureNotifierTest extends WifiBaseTest {
@Mock NotificationManager mNotificationManager;
@Mock FrameworkFacade mFrameworkFacade;
@Mock Notification mNotification;
- @Mock TelephonyUtil mTelephonyUtil;
+ @Mock
+ WifiCarrierInfoManager mWifiCarrierInfoManager;
@Mock WifiConfiguration mWifiConfiguration;
@Mock(answer = Answers.RETURNS_DEEP_STUBS) private Notification.Builder mNotificationBuilder;
@@ -79,7 +78,7 @@ public class EapFailureNotifierTest extends WifiBaseTest {
.startMocking();
when(mContext.getSystemService(NotificationManager.class))
.thenReturn(mNotificationManager);
- when(mTelephonyUtil.getBestMatchSubscriptionId(mWifiConfiguration)).thenReturn(0);
+ when(mWifiCarrierInfoManager.getBestMatchSubscriptionId(mWifiConfiguration)).thenReturn(0);
lenient().when(SubscriptionManager.getResourcesForSubId(eq(mContext), anyInt()))
.thenReturn(mResources);
when(mContext.getResources()).thenReturn(mResources);
@@ -92,7 +91,7 @@ public class EapFailureNotifierTest extends WifiBaseTest {
when(mContext.createPackageContext(anyString(), eq(0))).thenReturn(mContext);
when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
mEapFailureNotifier =
- new EapFailureNotifier(mContext, mFrameworkFacade, mTelephonyUtil);
+ new EapFailureNotifier(mContext, mFrameworkFacade, mWifiCarrierInfoManager);
}
@After
diff --git a/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java
index f9e05cb32..ec2142dbf 100644
--- a/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/ImsiPrivacyProtectionExemptionStoreDataTest.java
@@ -79,7 +79,7 @@ public class ImsiPrivacyProtectionExemptionStoreDataTest {
*/
@Test
public void verifyStoreFileId() throws Exception {
- assertEquals(WifiConfigStore.STORE_FILE_USER_NETWORK_SUGGESTIONS,
+ assertEquals(WifiConfigStore.STORE_FILE_USER_GENERAL,
mImsiPrivacyProtectionExemptionStoreData.getStoreFileId());
}
diff --git a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionNominatorTest.java b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionNominatorTest.java
index f8084e374..94b14ecff 100644
--- a/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionNominatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/NetworkSuggestionNominatorTest.java
@@ -39,7 +39,6 @@ import androidx.test.filters.SmallTest;
import com.android.server.wifi.WifiNetworkSuggestionsManager.ExtendedWifiNetworkSuggestion;
import com.android.server.wifi.WifiNetworkSuggestionsManager.PerAppInfo;
import com.android.server.wifi.hotspot2.PasspointNetworkNominateHelper;
-import com.android.server.wifi.util.TelephonyUtil;
import org.junit.Before;
import org.junit.Test;
@@ -74,7 +73,8 @@ public class NetworkSuggestionNominatorTest extends WifiBaseTest {
private @Mock WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
private @Mock PasspointNetworkNominateHelper mPasspointNetworkNominateHelper;
private @Mock Clock mClock;
- private @Mock TelephonyUtil mTelephonyUtil;
+ private @Mock
+ WifiCarrierInfoManager mWifiCarrierInfoManager;
private NetworkSuggestionNominator mNetworkSuggestionNominator;
/** Sets up test. */
@@ -83,7 +83,7 @@ public class NetworkSuggestionNominatorTest extends WifiBaseTest {
MockitoAnnotations.initMocks(this);
mNetworkSuggestionNominator = new NetworkSuggestionNominator(
mWifiNetworkSuggestionsManager, mWifiConfigManager, mPasspointNetworkNominateHelper,
- new LocalLog(100), mTelephonyUtil);
+ new LocalLog(100), mWifiCarrierInfoManager);
}
/**
@@ -773,8 +773,9 @@ public class NetworkSuggestionNominatorTest extends WifiBaseTest {
eapSimConfig.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM);
eapSimConfig.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE);
eapSimConfig.carrierId = TEST_CARRIER_ID;
- when(mTelephonyUtil.getBestMatchSubscriptionId(eapSimConfig)).thenReturn(TEST_SUB_ID);
- when(mTelephonyUtil.isSimPresent(TEST_SUB_ID)).thenReturn(false);
+ when(mWifiCarrierInfoManager.getBestMatchSubscriptionId(eapSimConfig))
+ .thenReturn(TEST_SUB_ID);
+ when(mWifiCarrierInfoManager.isSimPresent(TEST_SUB_ID)).thenReturn(false);
// Link the scan result with suggestions.
linkScanDetailsWithNetworkSuggestions(scanDetails, suggestions);
// setup config manager interactions.
@@ -818,10 +819,11 @@ public class NetworkSuggestionNominatorTest extends WifiBaseTest {
eapSimConfig.enterpriseConfig.setEapMethod(WifiEnterpriseConfig.Eap.SIM);
eapSimConfig.enterpriseConfig.setPhase2Method(WifiEnterpriseConfig.Phase2.NONE);
eapSimConfig.carrierId = TEST_CARRIER_ID;
- when(mTelephonyUtil.getBestMatchSubscriptionId(eapSimConfig)).thenReturn(TEST_SUB_ID);
- when(mTelephonyUtil.isSimPresent(TEST_SUB_ID)).thenReturn(true);
- when(mTelephonyUtil.requiresImsiEncryption(TEST_SUB_ID)).thenReturn(true);
- when(mTelephonyUtil.isImsiEncryptionInfoAvailable(TEST_SUB_ID)).thenReturn(false);
+ when(mWifiCarrierInfoManager.getBestMatchSubscriptionId(eapSimConfig))
+ .thenReturn(TEST_SUB_ID);
+ when(mWifiCarrierInfoManager.isSimPresent(TEST_SUB_ID)).thenReturn(true);
+ when(mWifiCarrierInfoManager.requiresImsiEncryption(TEST_SUB_ID)).thenReturn(true);
+ when(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(TEST_SUB_ID)).thenReturn(false);
// Link the scan result with suggestions.
linkScanDetailsWithNetworkSuggestions(scanDetails, suggestions);
// setup config manager interactions.
@@ -954,7 +956,7 @@ public class NetworkSuggestionNominatorTest extends WifiBaseTest {
securities, appInteractions, meteredness, priorities, uids,
packageNames, autojoin, shareWithUser);
suggestions[0].wns.wifiConfiguration.meteredHint = true;
- when(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(any())).thenReturn(true);
+ when(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(any())).thenReturn(true);
// Link the scan result with suggestions.
linkScanDetailsWithNetworkSuggestions(scanDetails, suggestions);
diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
index 1a56fbbd9..cdc6762ba 100644
--- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
@@ -29,7 +29,6 @@ import android.util.Pair;
import com.android.server.wifi.WifiNetworkSelector.NetworkNominator.OnConnectableListener;
import com.android.server.wifi.WifiNetworkSelectorTestUtil.ScanDetailsAndWifiConfigs;
import com.android.server.wifi.hotspot2.PasspointNetworkNominateHelper;
-import com.android.server.wifi.util.TelephonyUtil;
import org.junit.After;
import org.junit.Before;
@@ -53,9 +52,9 @@ public class SavedNetworkNominatorTest extends WifiBaseTest {
MockitoAnnotations.initMocks(this);
mLocalLog = new LocalLog(512);
mSavedNetworkNominator = new SavedNetworkNominator(mWifiConfigManager,
- mPasspointNetworkNominateHelper, mLocalLog, mTelephonyUtil);
- when(mTelephonyUtil.isSimPresent(anyInt())).thenReturn(true);
- when(mTelephonyUtil.getBestMatchSubscriptionId(any())).thenReturn(1);
+ mPasspointNetworkNominateHelper, mLocalLog, mWifiCarrierInfoManager);
+ when(mWifiCarrierInfoManager.isSimPresent(anyInt())).thenReturn(true);
+ when(mWifiCarrierInfoManager.getBestMatchSubscriptionId(any())).thenReturn(1);
}
/** Cleans up test. */
@@ -74,7 +73,7 @@ public class SavedNetworkNominatorTest extends WifiBaseTest {
@Mock private WifiConfigManager mWifiConfigManager;
@Mock private Clock mClock;
@Mock private OnConnectableListener mOnConnectableListener;
- @Mock private TelephonyUtil mTelephonyUtil;
+ @Mock private WifiCarrierInfoManager mWifiCarrierInfoManager;
@Mock private PasspointNetworkNominateHelper mPasspointNetworkNominateHelper;
private LocalLog mLocalLog;
@@ -122,9 +121,9 @@ public class SavedNetworkNominatorTest extends WifiBaseTest {
WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs();
savedConfigs[0].carrierId = TEST_CARRIER_ID;
// SIM is absent
- when(mTelephonyUtil.getBestMatchSubscriptionId(any(WifiConfiguration.class)))
+ when(mWifiCarrierInfoManager.getBestMatchSubscriptionId(any(WifiConfiguration.class)))
.thenReturn(INVALID_SUBID);
- when(mTelephonyUtil.isSimPresent(eq(INVALID_SUBID))).thenReturn(false);
+ when(mWifiCarrierInfoManager.isSimPresent(eq(INVALID_SUBID))).thenReturn(false);
mSavedNetworkNominator.nominateNetworks(scanDetails,
null, null, true, false, mOnConnectableListener);
@@ -250,13 +249,13 @@ public class SavedNetworkNominatorTest extends WifiBaseTest {
freqs, levels, mWifiConfigManager, mClock);
List<ScanDetail> scanDetails = scanDetailsAndConfigs.getScanDetails();
WifiConfiguration[] savedConfigs = scanDetailsAndConfigs.getWifiConfigs();
- when(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(savedConfigs[0]))
+ when(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(savedConfigs[0]))
.thenReturn(false);
mSavedNetworkNominator.nominateNetworks(scanDetails,
null, null, true, false, mOnConnectableListener);
verify(mOnConnectableListener).onConnectable(any(), any());
reset(mOnConnectableListener);
- when(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(savedConfigs[0]))
+ when(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(savedConfigs[0]))
.thenReturn(true);
verify(mOnConnectableListener, never()).onConnectable(any(), any());
}
diff --git a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
index a07dafb6d..1053d733f 100644
--- a/tests/wifitests/src/com/android/server/wifi/util/TelephonyUtilTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiCarrierInfoManagerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016 The Android Open Source Project
+ * 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.
@@ -14,18 +14,27 @@
* limitations under the License.
*/
-package com.android.server.wifi.util;
+package com.android.server.wifi;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
+import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION;
+import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION;
+import static com.android.server.wifi.WifiCarrierInfoManager.NOTIFICATION_USER_DISMISSED_INTENT_ACTION;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
+import android.app.AlertDialog;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
@@ -42,20 +51,21 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Base64;
import android.util.Pair;
+import android.view.Window;
import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
-import com.android.server.wifi.FrameworkFacade;
-import com.android.server.wifi.WifiBaseTest;
-import com.android.server.wifi.WifiConfigurationTestUtil;
-import com.android.server.wifi.util.TelephonyUtil.SimAuthRequestData;
-import com.android.server.wifi.util.TelephonyUtil.SimAuthResponseData;
+import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
+import com.android.server.wifi.WifiCarrierInfoManager.SimAuthRequestData;
+import com.android.server.wifi.WifiCarrierInfoManager.SimAuthResponseData;
+import com.android.wifi.resources.R;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoSession;
@@ -71,11 +81,11 @@ import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
/**
- * Unit tests for {@link com.android.server.wifi.util.TelephonyUtil}.
+ * Unit tests for {@link WifiCarrierInfoManager}.
*/
@SmallTest
-public class TelephonyUtilTest extends WifiBaseTest {
- private TelephonyUtil mTelephonyUtil;
+public class WifiCarrierInfoManagerTest extends WifiBaseTest {
+ private WifiCarrierInfoManager mWifiCarrierInfoManager;
private static final int DATA_SUBID = 1;
private static final int NON_DATA_SUBID = 2;
@@ -97,29 +107,34 @@ public class TelephonyUtilTest extends WifiBaseTest {
private static final String ANONYMOUS_IDENTITY = "anonymous@wlan.mnc456.mcc123.3gppnetwork.org";
private static final String CARRIER_NAME = "Google";
- @Mock
- CarrierConfigManager mCarrierConfigManager;
- @Mock
- Context mContext;
- @Mock
- FrameworkFacade mFrameworkFacade;
- @Mock
- TelephonyManager mTelephonyManager;
- @Mock
- TelephonyManager mDataTelephonyManager;
- @Mock
- TelephonyManager mNonDataTelephonyManager;
- @Mock
- SubscriptionManager mSubscriptionManager;
- @Mock
- SubscriptionInfo mDataSubscriptionInfo;
- @Mock
- SubscriptionInfo mNonDataSubscriptionInfo;
+ @Mock CarrierConfigManager mCarrierConfigManager;
+ @Mock WifiContext mContext;
+ @Mock Resources mResources;
+ @Mock FrameworkFacade mFrameworkFacade;
+ @Mock TelephonyManager mTelephonyManager;
+ @Mock TelephonyManager mDataTelephonyManager;
+ @Mock TelephonyManager mNonDataTelephonyManager;
+ @Mock SubscriptionManager mSubscriptionManager;
+ @Mock SubscriptionInfo mDataSubscriptionInfo;
+ @Mock SubscriptionInfo mNonDataSubscriptionInfo;
+ @Mock WifiConfigStore mWifiConfigStore;
+ @Mock WifiInjector mWifiInjector;
+ @Mock WifiConfigManager mWifiConfigManager;
+ @Mock ImsiPrivacyProtectionExemptionStoreData mImsiPrivacyProtectionExemptionStoreData;
+ @Mock NotificationManager mNotificationManger;
+ @Mock Notification.Builder mNotificationBuilder;
+ @Mock Notification mNotification;
+ @Mock AlertDialog.Builder mAlertDialogBuilder;
+ @Mock AlertDialog mAlertDialog;
+ @Mock WifiCarrierInfoManager.OnUserApproveCarrierListener mListener;
private List<SubscriptionInfo> mSubInfoList;
MockitoSession mMockingSession = null;
TestLooper mLooper;
+ private ImsiPrivacyProtectionExemptionStoreData.DataSource mImsiDataSource;
+ private ArgumentCaptor<BroadcastReceiver> mBroadcastReceiverCaptor =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
@Before
public void setUp() throws Exception {
@@ -127,8 +142,48 @@ public class TelephonyUtilTest extends WifiBaseTest {
mLooper = new TestLooper();
when(mContext.getSystemService(Context.CARRIER_CONFIG_SERVICE))
.thenReturn(mCarrierConfigManager);
- mTelephonyUtil = new TelephonyUtil(mTelephonyManager, mSubscriptionManager,
- mFrameworkFacade, mContext, new Handler(mLooper.getLooper()));
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mContext.getSystemService(Context.NOTIFICATION_SERVICE))
+ .thenReturn(mNotificationManger);
+ when(mContext.getWifiOverlayApkPkgName()).thenReturn("test.com.android.wifi.resources");
+ when(mFrameworkFacade.makeAlertDialogBuilder(any()))
+ .thenReturn(mAlertDialogBuilder);
+ when(mFrameworkFacade.makeNotificationBuilder(any(), anyString()))
+ .thenReturn(mNotificationBuilder);
+ when(mFrameworkFacade.getBroadcast(any(), anyInt(), any(), anyInt()))
+ .thenReturn(mock(PendingIntent.class));
+ when(mAlertDialogBuilder.setTitle(any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setMessage(any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setPositiveButton(any(), any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setNegativeButton(any(), any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setOnDismissListener(any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.setOnCancelListener(any())).thenReturn(mAlertDialogBuilder);
+ when(mAlertDialogBuilder.create()).thenReturn(mAlertDialog);
+ when(mAlertDialog.getWindow()).thenReturn(mock(Window.class));
+ when(mNotificationBuilder.setSmallIcon(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setTicker(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setContentTitle(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setStyle(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setDeleteIntent(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setShowWhen(anyBoolean())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setLocalOnly(anyBoolean())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.setColor(anyInt())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.addAction(any())).thenReturn(mNotificationBuilder);
+ when(mNotificationBuilder.build()).thenReturn(mNotification);
+ when(mWifiInjector.makeImsiProtectionExemptionStoreData(any()))
+ .thenReturn(mImsiPrivacyProtectionExemptionStoreData);
+ when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager);
+ mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
+ mSubscriptionManager, mWifiInjector, mFrameworkFacade, mContext, mWifiConfigStore,
+ new Handler(mLooper.getLooper()));
+ ArgumentCaptor<ImsiPrivacyProtectionExemptionStoreData.DataSource>
+ imsiDataSourceArgumentCaptor =
+ ArgumentCaptor.forClass(ImsiPrivacyProtectionExemptionStoreData.DataSource.class);
+ verify(mContext).registerReceiver(mBroadcastReceiverCaptor.capture(), any(), any(), any());
+ verify(mWifiInjector).makeImsiProtectionExemptionStoreData(imsiDataSourceArgumentCaptor
+ .capture());
+ mImsiDataSource = imsiDataSourceArgumentCaptor.getValue();
+ assertNotNull(mImsiDataSource);
mSubInfoList = new ArrayList<>();
mSubInfoList.add(mDataSubscriptionInfo);
mSubInfoList.add(mNonDataSubscriptionInfo);
@@ -163,6 +218,31 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getSimState()).thenReturn(TelephonyManager.SIM_STATE_READY);
when(mSubscriptionManager.getActiveSubscriptionIdList())
.thenReturn(new int[]{DATA_SUBID, NON_DATA_SUBID});
+
+ // setup resource strings for IMSI protection notification.
+ when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_title), anyString()))
+ .thenAnswer(s -> "blah" + s.getArguments()[1]);
+ when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_content)))
+ .thenReturn("blah");
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_carrier)))
+ .thenReturn("blah");
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_carrier)))
+ .thenReturn("blah");
+ when(mResources.getString(
+ eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title)))
+ .thenReturn("blah");
+ when(mResources.getString(
+ eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_content),
+ anyString())).thenAnswer(s -> "blah" + s.getArguments()[1]);
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_confirmation)))
+ .thenReturn("blah");
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_confirmation)))
+ .thenReturn("blah");
+ mWifiCarrierInfoManager.addImsiExemptionUserApprovalListener(mListener);
}
@After
@@ -222,8 +302,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
receiver.getValue().onReceive(mContext,
new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
- assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
- assertFalse(mTelephonyUtil.requiresImsiEncryption(NON_DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(NON_DATA_SUBID));
}
/**
@@ -242,8 +322,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
receiver.getValue().onReceive(mContext,
new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
- assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
- assertTrue(mTelephonyUtil.requiresImsiEncryption(NON_DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(NON_DATA_SUBID));
when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
.thenReturn(generateTestCarrierConfig(false));
@@ -252,8 +332,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
receiver.getValue().onReceive(mContext,
new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
- assertFalse(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
- assertFalse(mTelephonyUtil.requiresImsiEncryption(NON_DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(NON_DATA_SUBID));
}
/**
@@ -278,16 +358,16 @@ public class TelephonyUtilTest extends WifiBaseTest {
observer.onChange(false);
- assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
- assertFalse(mTelephonyUtil.isImsiEncryptionInfoAvailable(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(DATA_SUBID));
when(mDataTelephonyManager.getCarrierInfoForImsiEncryption(TelephonyManager.KEY_TYPE_WLAN))
.thenReturn(mock(ImsiEncryptionInfo.class));
observer.onChange(false);
- assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
- assertTrue(mTelephonyUtil.isImsiEncryptionInfoAvailable(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(DATA_SUBID));
}
/**
@@ -313,8 +393,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
observer.onChange(false);
- assertTrue(mTelephonyUtil.isImsiEncryptionInfoAvailable(DATA_SUBID));
- assertTrue(mTelephonyUtil.isImsiEncryptionInfoAvailable(NON_DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(NON_DATA_SUBID));
when(mDataTelephonyManager.getCarrierInfoForImsiEncryption(TelephonyManager.KEY_TYPE_WLAN))
.thenReturn(null);
@@ -323,8 +403,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
observer.onChange(false);
- assertFalse(mTelephonyUtil.isImsiEncryptionInfoAvailable(DATA_SUBID));
- assertFalse(mTelephonyUtil.isImsiEncryptionInfoAvailable(NON_DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(NON_DATA_SUBID));
}
@Test
@@ -341,14 +421,14 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
simConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(simConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(simConfig));
WifiConfiguration peapSimConfig =
WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.PEAP,
WifiEnterpriseConfig.Phase2.SIM);
peapSimConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(peapSimConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(peapSimConfig));
}
@Test
@@ -365,14 +445,14 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
akaConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(akaConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(akaConfig));
WifiConfiguration peapAkaConfig =
WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.PEAP,
WifiEnterpriseConfig.Phase2.AKA);
peapAkaConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(peapAkaConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(peapAkaConfig));
}
@Test
@@ -389,14 +469,14 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
akaPConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(akaPConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(akaPConfig));
WifiConfiguration peapAkaPConfig =
WifiConfigurationTestUtil.createEapNetwork(WifiEnterpriseConfig.Eap.PEAP,
WifiEnterpriseConfig.Phase2.AKA_PRIME);
peapAkaPConfig.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(peapAkaPConfig));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(peapAkaPConfig));
}
/**
@@ -434,7 +514,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(config));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(config));
} finally {
session.finishMocking();
}
@@ -470,7 +550,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = DATA_CARRIER_ID;
- assertNull(mTelephonyUtil.getSimIdentity(config));
+ assertNull(mWifiCarrierInfoManager.getSimIdentity(config));
} finally {
session.finishMocking();
}
@@ -490,7 +570,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(config));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(config));
}
@Test
@@ -507,7 +587,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = DATA_CARRIER_ID;
- assertEquals(expectedIdentity, mTelephonyUtil.getSimIdentity(config));
+ assertEquals(expectedIdentity, mWifiCarrierInfoManager.getSimIdentity(config));
}
@Test
@@ -517,16 +597,16 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mDataTelephonyManager.getSimOperator()).thenReturn("32156");
assertEquals(null,
- mTelephonyUtil.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
+ mWifiCarrierInfoManager.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.TTLS, WifiEnterpriseConfig.Phase2.SIM)));
assertEquals(null,
- mTelephonyUtil.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
+ mWifiCarrierInfoManager.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.PEAP, WifiEnterpriseConfig.Phase2.MSCHAPV2)));
assertEquals(null,
- mTelephonyUtil.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
+ mWifiCarrierInfoManager.getSimIdentity(WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.TLS, WifiEnterpriseConfig.Phase2.NONE)));
assertEquals(null,
- mTelephonyUtil.getSimIdentity(new WifiConfiguration()));
+ mWifiCarrierInfoManager.getSimIdentity(new WifiConfiguration()));
}
/**
@@ -588,7 +668,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals("", mTelephonyUtil.getGsmSimAuthResponse(invalidRequests, config));
+ assertEquals("", mWifiCarrierInfoManager.getGsmSimAuthResponse(invalidRequests, config));
}
@Test
@@ -599,7 +679,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(null, mTelephonyUtil.getGsmSimAuthResponse(failedRequests, config));
+ assertEquals(null, mWifiCarrierInfoManager.getGsmSimAuthResponse(failedRequests, config));
}
@Test
@@ -617,7 +697,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(":3b4a:1d2c:1234:1111", mTelephonyUtil.getGsmSimAuthResponse(
+ assertEquals(":3b4a:1d2c:1234:1111", mWifiCarrierInfoManager.getGsmSimAuthResponse(
new String[] { "1B2B", "0122" }, config));
}
@@ -628,7 +708,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
assertEquals("",
- mTelephonyUtil.getGsmSimpleSimAuthResponse(invalidRequests, config));
+ mWifiCarrierInfoManager.getGsmSimpleSimAuthResponse(invalidRequests, config));
}
@Test
@@ -640,7 +720,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
assertEquals(null,
- mTelephonyUtil.getGsmSimpleSimAuthResponse(failedRequests, config));
+ mWifiCarrierInfoManager.getGsmSimpleSimAuthResponse(failedRequests, config));
}
@Test
@@ -658,7 +738,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(":3b4a:1d2c:1100:3322", mTelephonyUtil.getGsmSimpleSimAuthResponse(
+ assertEquals(":3b4a:1d2c:1100:3322", mWifiCarrierInfoManager.getGsmSimpleSimAuthResponse(
new String[] { "1A2B", "0123" }, config));
}
@@ -668,8 +748,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals("", mTelephonyUtil.getGsmSimpleSimNoLengthAuthResponse(invalidRequests,
- config));
+ assertEquals("", mWifiCarrierInfoManager.getGsmSimpleSimNoLengthAuthResponse(
+ invalidRequests, config));
}
@Test
@@ -680,8 +760,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(null, mTelephonyUtil.getGsmSimpleSimNoLengthAuthResponse(failedRequests,
- config));
+ assertEquals(null, mWifiCarrierInfoManager.getGsmSimpleSimNoLengthAuthResponse(
+ failedRequests, config));
}
@Test
@@ -700,7 +780,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
assertEquals(":1a2b3c4d5e6f7a1a:1a2b3c4d:1234567812345678:12345678",
- mTelephonyUtil.getGsmSimpleSimNoLengthAuthResponse(
+ mWifiCarrierInfoManager.getGsmSimpleSimNoLengthAuthResponse(
new String[] { "1A2B", "0123" }, config));
}
@@ -743,9 +823,9 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(null, mTelephonyUtil.get3GAuthResponse(
+ assertEquals(null, mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123"}), config));
- assertEquals(null, mTelephonyUtil.get3GAuthResponse(
+ assertEquals(null, mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"xyz2", "1234"}),
config));
verifyNoMoreInteractions(mDataTelephonyManager);
@@ -757,7 +837,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
TelephonyManager.AUTHTYPE_EAP_AKA, "AgEjAkVn")).thenReturn(null);
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- SimAuthResponseData response = mTelephonyUtil.get3GAuthResponse(
+ SimAuthResponseData response = mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123", "4567"}),
config);
@@ -771,7 +851,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(Base64.encodeToString(new byte[] {(byte) 0xdc}, Base64.NO_WRAP));
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- SimAuthResponseData response = mTelephonyUtil.get3GAuthResponse(
+ SimAuthResponseData response = mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123", "4567"}),
config);
@@ -786,7 +866,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
Base64.NO_WRAP));
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- SimAuthResponseData response = mTelephonyUtil.get3GAuthResponse(
+ SimAuthResponseData response = mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123", "4567"}),
config);
@@ -801,7 +881,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
new byte[] {0x21, 0x22, 0x23}, new byte[] {0x31}));
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- SimAuthResponseData response = mTelephonyUtil.get3GAuthResponse(
+ SimAuthResponseData response = mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123", "4567"}),
config);
@@ -817,7 +897,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(create3GSimAuthUmtsAutsResponse(new byte[] {0x22, 0x33}));
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- SimAuthResponseData response = mTelephonyUtil.get3GAuthResponse(
+ SimAuthResponseData response = mWifiCarrierInfoManager.get3GAuthResponse(
new SimAuthRequestData(0, 0, "SSID", new String[]{"0123", "4567"}),
config);
assertNotNull(response);
@@ -838,7 +918,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
assertEquals(expectedIdentity,
- mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config));
+ mWifiCarrierInfoManager.getAnonymousIdentityWith3GppRealm(config));
}
/**
@@ -850,7 +930,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- assertNull(mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config));
+ assertNull(mWifiCarrierInfoManager.getAnonymousIdentityWith3GppRealm(config));
}
/**
@@ -864,7 +944,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(subInfo2.getSubscriptionId()).thenReturn(NON_DATA_SUBID);
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Arrays.asList(subInfo1, subInfo2));
- assertTrue(mTelephonyUtil.isSimPresent(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.isSimPresent(DATA_SUBID));
}
/**
@@ -875,13 +955,13 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
- assertFalse(mTelephonyUtil.isSimPresent(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isSimPresent(DATA_SUBID));
SubscriptionInfo subInfo = mock(SubscriptionInfo.class);
when(subInfo.getSubscriptionId()).thenReturn(NON_DATA_SUBID);
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Arrays.asList(subInfo));
- assertFalse(mTelephonyUtil.isSimPresent(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isSimPresent(DATA_SUBID));
}
/**
@@ -897,7 +977,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(Arrays.asList(subInfo1, subInfo2));
when(mTelephonyManager.getSimState(anyInt()))
.thenReturn(TelephonyManager.SIM_STATE_NETWORK_LOCKED);
- assertFalse(mTelephonyUtil.isSimPresent(DATA_SUBID));
+ assertFalse(mWifiCarrierInfoManager.isSimPresent(DATA_SUBID));
}
/**
@@ -910,12 +990,12 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
when(mSubscriptionManager.getActiveSubscriptionIdList()).thenReturn(new int[0]);
- assertEquals(INVALID_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(INVALID_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
- assertEquals(INVALID_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(INVALID_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
}
/**
@@ -926,7 +1006,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration config = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
- assertEquals(DATA_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(DATA_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
}
/**
@@ -937,7 +1017,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
public void getBestMatchSubscriptionIdForEnterpriseWithoutCarrierIdFieldForNonSimConfig() {
WifiConfiguration config = new WifiConfiguration();
- assertEquals(INVALID_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(INVALID_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
}
/**
@@ -950,10 +1030,10 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = NON_DATA_CARRIER_ID;
- assertEquals(NON_DATA_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(NON_DATA_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
config.carrierId = DATA_CARRIER_ID;
- assertEquals(DATA_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(DATA_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
}
/**
@@ -967,7 +1047,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration spyConfig = spy(config);
doReturn(true).when(spyConfig).isPasspoint();
- assertEquals(DATA_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(spyConfig));
+ assertEquals(DATA_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(spyConfig));
}
/**
@@ -980,7 +1060,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiConfiguration spyConfig = spy(config);
doReturn(true).when(spyConfig).isPasspoint();
- assertEquals(INVALID_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(spyConfig));
+ assertEquals(INVALID_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(spyConfig));
}
/**
@@ -993,7 +1073,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE);
config.carrierId = DEACTIVE_CARRIER_ID;
- assertEquals(INVALID_SUBID, mTelephonyUtil.getBestMatchSubscriptionId(config));
+ assertEquals(INVALID_SUBID, mWifiCarrierInfoManager.getBestMatchSubscriptionId(config));
}
/**
@@ -1004,7 +1084,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
- assertNull(mTelephonyUtil.getMatchingImsi(DEACTIVE_CARRIER_ID));
+ assertNull(mWifiCarrierInfoManager.getMatchingImsi(DEACTIVE_CARRIER_ID));
}
/**
@@ -1013,7 +1093,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
*/
@Test
public void getMatchingImsiCarrierIdWithValidCarrierIdForImsiEncryptionCheck() {
- TelephonyUtil spyTu = spy(mTelephonyUtil);
+ WifiCarrierInfoManager spyTu = spy(mWifiCarrierInfoManager);
doReturn(true).when(spyTu).requiresImsiEncryption(DATA_SUBID);
doReturn(false).when(spyTu).isImsiEncryptionInfoAvailable(DATA_SUBID);
@@ -1027,7 +1107,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
@Test
public void getMatchingImsiCarrierIdWithValidCarrierId() {
assertEquals(DATA_FULL_IMSI,
- mTelephonyUtil.getMatchingImsi(DATA_CARRIER_ID));
+ mWifiCarrierInfoManager.getMatchingImsi(DATA_CARRIER_ID));
}
/**
@@ -1037,12 +1117,12 @@ public class TelephonyUtilTest extends WifiBaseTest {
public void getMatchingImsiCarrierIdWithEmptyActiveSubscriptionInfoList() {
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
- assertNull(mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ assertNull(mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
- assertNull(mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ assertNull(mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
}
/**
@@ -1057,7 +1137,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getCarrierIdFromSimMccMnc()).thenReturn(NON_DATA_CARRIER_ID);
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
- assertNull(mTelephonyUtil.getMatchingImsiCarrierId(NO_MATCH_PREFIX_IMSI));
+ assertNull(mWifiCarrierInfoManager.getMatchingImsiCarrierId(NO_MATCH_PREFIX_IMSI));
}
/**
@@ -1073,7 +1153,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getCarrierIdFromSimMccMnc()).thenReturn(NON_DATA_CARRIER_ID);
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
- Pair<String, Integer> ic = mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
+ Pair<String, Integer> ic = mWifiCarrierInfoManager
+ .getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
assertEquals(new Pair<>(DATA_FULL_IMSI, DATA_CARRIER_ID), ic);
@@ -1083,7 +1164,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
assertEquals(new Pair<>(DATA_FULL_IMSI, DATA_CARRIER_ID),
- mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
// non data SIM doesn't match.
when(mNonDataTelephonyManager.getCarrierIdFromSimMccMnc()).thenReturn(NON_DATA_CARRIER_ID);
@@ -1093,7 +1174,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(NO_MATCH_OPERATOR_NUMERIC);
assertEquals(new Pair<>(DATA_FULL_IMSI, DATA_CARRIER_ID),
- mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
}
/**
@@ -1110,7 +1191,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(PARENT_NON_DATA_CARRIER_ID);
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
- Pair<String, Integer> ic = mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
+ Pair<String, Integer> ic = mWifiCarrierInfoManager
+ .getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
assertEquals(new Pair<>(DATA_FULL_IMSI, DATA_CARRIER_ID), ic);
@@ -1122,7 +1204,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
.thenReturn(NO_MATCH_OPERATOR_NUMERIC);
assertEquals(new Pair<>(DATA_FULL_IMSI, DATA_CARRIER_ID),
- mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
}
/**
@@ -1139,7 +1221,8 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
- Pair<String, Integer> ic = mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
+ Pair<String, Integer> ic = mWifiCarrierInfoManager
+ .getMatchingImsiCarrierId(MATCH_PREFIX_IMSI);
assertEquals(new Pair<>(NON_DATA_FULL_IMSI, NON_DATA_CARRIER_ID), ic);
@@ -1150,7 +1233,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mDataTelephonyManager.getSimOperator()).thenReturn(NO_MATCH_OPERATOR_NUMERIC);
assertEquals(new Pair<>(NON_DATA_FULL_IMSI, NON_DATA_CARRIER_ID),
- mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
}
/**
@@ -1169,7 +1252,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getSimCarrierId()).thenReturn(NON_DATA_CARRIER_ID);
assertEquals(new Pair<>(NON_DATA_FULL_IMSI, NON_DATA_CARRIER_ID),
- mTelephonyUtil.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
+ mWifiCarrierInfoManager.getMatchingImsiCarrierId(MATCH_PREFIX_IMSI));
}
/**
@@ -1187,7 +1270,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mNonDataTelephonyManager.getSubscriberId()).thenReturn(NO_MATCH_FULL_IMSI);
when(mNonDataTelephonyManager.getSimOperator())
.thenReturn(NO_MATCH_OPERATOR_NUMERIC);
- TelephonyUtil spyTu = spy(mTelephonyUtil);
+ WifiCarrierInfoManager spyTu = spy(mWifiCarrierInfoManager);
doReturn(true).when(spyTu).requiresImsiEncryption(eq(DATA_SUBID));
doReturn(false).when(spyTu).isImsiEncryptionInfoAvailable(eq(DATA_SUBID));
@@ -1203,12 +1286,12 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(config.getCarrierId()).thenReturn(DATA_CARRIER_ID);
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(config));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(config));
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(config));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(config));
}
/**
@@ -1219,7 +1302,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
PasspointConfiguration config = mock(PasspointConfiguration.class);
when(config.getCarrierId()).thenReturn(DATA_CARRIER_ID);
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(config));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(config));
}
/**
@@ -1232,7 +1315,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
doReturn(credential).when(spyConfig).getCredential();
when(credential.getSimCredential()).thenReturn(null);
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(spyConfig));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(spyConfig));
}
/**
@@ -1248,7 +1331,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(credential.getSimCredential()).thenReturn(simCredential);
when(simCredential.getImsi()).thenReturn(MATCH_PREFIX_IMSI);
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(spyConfig));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(spyConfig));
}
/**
@@ -1264,7 +1347,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(credential.getSimCredential()).thenReturn(simCredential);
when(simCredential.getImsi()).thenReturn(DATA_FULL_IMSI);
- assertTrue(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(spyConfig));
+ assertTrue(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(spyConfig));
assertEquals(DATA_CARRIER_ID, spyConfig.getCarrierId());
}
@@ -1280,7 +1363,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(credential.getSimCredential()).thenReturn(simCredential);
when(simCredential.getImsi()).thenReturn(NO_MATCH_PREFIX_IMSI);
- assertFalse(mTelephonyUtil.tryUpdateCarrierIdForPasspoint(spyConfig));
+ assertFalse(mWifiCarrierInfoManager.tryUpdateCarrierIdForPasspoint(spyConfig));
}
private void testIdentityWithSimAndEapAkaMethodPrefix(int method, String methodStr)
@@ -1296,7 +1379,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
receiver.getValue().onReceive(mContext,
new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
- assertTrue(mTelephonyUtil.requiresImsiEncryption(DATA_SUBID));
+ assertTrue(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
String mccmnc = "123456";
String expectedIdentity = methodStr + ANONYMOUS_IDENTITY;
@@ -1306,7 +1389,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
method, WifiEnterpriseConfig.Phase2.NONE);
assertEquals(expectedIdentity,
- mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config));
+ mWifiCarrierInfoManager.getAnonymousIdentityWith3GppRealm(config));
}
/**
@@ -1339,11 +1422,11 @@ public class TelephonyUtilTest extends WifiBaseTest {
*/
@Test
public void testIsAnonymousAtRealmIdentity() throws Exception {
- assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity(ANONYMOUS_IDENTITY));
- assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("0" + ANONYMOUS_IDENTITY));
- assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("1" + ANONYMOUS_IDENTITY));
- assertTrue(mTelephonyUtil.isAnonymousAtRealmIdentity("6" + ANONYMOUS_IDENTITY));
- assertFalse(mTelephonyUtil.isAnonymousAtRealmIdentity("AKA" + ANONYMOUS_IDENTITY));
+ assertTrue(mWifiCarrierInfoManager.isAnonymousAtRealmIdentity(ANONYMOUS_IDENTITY));
+ assertTrue(mWifiCarrierInfoManager.isAnonymousAtRealmIdentity("0" + ANONYMOUS_IDENTITY));
+ assertTrue(mWifiCarrierInfoManager.isAnonymousAtRealmIdentity("1" + ANONYMOUS_IDENTITY));
+ assertTrue(mWifiCarrierInfoManager.isAnonymousAtRealmIdentity("6" + ANONYMOUS_IDENTITY));
+ assertFalse(mWifiCarrierInfoManager.isAnonymousAtRealmIdentity("AKA" + ANONYMOUS_IDENTITY));
}
/**
@@ -1354,12 +1437,12 @@ public class TelephonyUtilTest extends WifiBaseTest {
public void getCarrierPrivilegeWithNoActiveSubscription() {
when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(null);
assertEquals(TelephonyManager.UNKNOWN_CARRIER_ID,
- mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
+ mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
when(mSubscriptionManager.getActiveSubscriptionInfoList())
.thenReturn(Collections.emptyList());
assertEquals(TelephonyManager.UNKNOWN_CARRIER_ID,
- mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
+ mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
}
/**
@@ -1375,7 +1458,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mDataTelephonyManager.checkCarrierPrivilegesForPackage(TEST_PACKAGE))
.thenReturn(TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS);
assertEquals(TelephonyManager.UNKNOWN_CARRIER_ID,
- mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
+ mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
}
/**
@@ -1392,7 +1475,7 @@ public class TelephonyUtilTest extends WifiBaseTest {
when(mDataTelephonyManager.checkCarrierPrivilegesForPackage(TEST_PACKAGE))
.thenReturn(TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS);
assertEquals(DATA_CARRIER_ID,
- mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
+ mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE));
}
/**
@@ -1400,17 +1483,256 @@ public class TelephonyUtilTest extends WifiBaseTest {
*/
@Test
public void getCarrierNameFromSubId() {
- assertEquals(CARRIER_NAME, mTelephonyUtil.getCarrierNameforSubId(DATA_SUBID));
- assertNull(mTelephonyUtil.getCarrierNameforSubId(NON_DATA_SUBID));
+ assertEquals(CARRIER_NAME, mWifiCarrierInfoManager.getCarrierNameforSubId(DATA_SUBID));
+ assertNull(mWifiCarrierInfoManager.getCarrierNameforSubId(NON_DATA_SUBID));
}
@Test
public void testIsCarrierNetworkFromNonDataSim() {
WifiConfiguration config = new WifiConfiguration();
- assertFalse(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config));
+ assertFalse(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config));
config.carrierId = DATA_CARRIER_ID;
- assertFalse(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config));
+ assertFalse(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config));
config.carrierId = NON_DATA_CARRIER_ID;
- assertTrue(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(config));
+ assertTrue(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(config));
+ }
+
+ @Test
+ public void testCheckSetClearImsiProtectionExemption() {
+ InOrder inOrder = inOrder(mWifiConfigManager);
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ mWifiCarrierInfoManager.setHasUserApprovedImsiPrivacyExemptionForCarrier(true,
+ DATA_CARRIER_ID);
+ verify(mListener).onUserAllowed(DATA_CARRIER_ID);
+ inOrder.verify(mWifiConfigManager).saveToStore(true);
+ assertTrue(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ mWifiCarrierInfoManager.clearImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID);
+ inOrder.verify(mWifiConfigManager).saveToStore(true);
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ }
+
+ @Test
+ public void testSendImsiProtectionExemptionNotificationWithUserAllowed() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ // Simulate user clicking on allow in the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
+ CARRIER_NAME, DATA_CARRIER_ID);
+ verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ validateUserApprovalDialog(CARRIER_NAME);
+
+ // Simulate user clicking on allow in the dialog.
+ ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
+ ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setPositiveButton(
+ any(), clickListenerCaptor.capture());
+ assertNotNull(clickListenerCaptor.getValue());
+ clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
+ mLooper.dispatchAll();
+ ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcast(intentCaptor.capture());
+ assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
+ verify(mWifiConfigManager).saveToStore(true);
+ assertTrue(mImsiDataSource.hasNewDataToSerialize());
+ assertTrue(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ verify(mListener).onUserAllowed(DATA_CARRIER_ID);
+ }
+
+ @Test
+ public void testSendImsiProtectionExemptionNotificationWithUserDisallowed() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ // Simulate user clicking on disallow in the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION,
+ CARRIER_NAME, DATA_CARRIER_ID);
+ verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ verify(mAlertDialog, never()).show();
+
+ verify(mWifiConfigManager).saveToStore(true);
+ assertTrue(mImsiDataSource.hasNewDataToSerialize());
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ }
+
+ @Test
+ public void testSendImsiProtectionExemptionNotificationWithUserDismissal() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ //Simulate user dismissal the notification
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
+ CARRIER_NAME, DATA_SUBID);
+ reset(mNotificationManger);
+ // No Notification is active, should send notification again.
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ reset(mNotificationManger);
+
+ // As there is notification is active, should not send notification again.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISMISSED_INTENT_ACTION,
+ CARRIER_NAME, DATA_SUBID);
+ verifyNoMoreInteractions(mNotificationManger);
+ verify(mWifiConfigManager, never()).saveToStore(true);
+ assertFalse(mImsiDataSource.hasNewDataToSerialize());
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ }
+
+ @Test
+ public void testSendImsiProtectionExemptionConfirmationDialogWithUserDisallowed() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ // Simulate user clicking on allow in the notification.
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
+ CARRIER_NAME, DATA_SUBID);
+ verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ validateUserApprovalDialog(CARRIER_NAME);
+
+ // Simulate user clicking on disallow in the dialog.
+ ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
+ ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setNegativeButton(
+ any(), clickListenerCaptor.capture());
+ assertNotNull(clickListenerCaptor.getValue());
+ clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
+ mLooper.dispatchAll();
+ ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcast(intentCaptor.capture());
+ assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
+ verify(mWifiConfigManager).saveToStore(true);
+ assertTrue(mImsiDataSource.hasNewDataToSerialize());
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ }
+
+ @Test
+ public void testSendImsiProtectionExemptionConfirmationDialogWithUserDismissal() {
+ // Setup carrier without IMSI privacy protection
+ when(mCarrierConfigManager.getConfigForSubId(DATA_SUBID))
+ .thenReturn(generateTestCarrierConfig(false));
+ ArgumentCaptor<BroadcastReceiver> receiver =
+ ArgumentCaptor.forClass(BroadcastReceiver.class);
+ verify(mContext).registerReceiver(receiver.capture(), any(IntentFilter.class));
+
+ receiver.getValue().onReceive(mContext,
+ new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED));
+ assertFalse(mWifiCarrierInfoManager.requiresImsiEncryption(DATA_SUBID));
+
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+ sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
+ CARRIER_NAME, DATA_SUBID);
+ verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ validateUserApprovalDialog(CARRIER_NAME);
+
+ // Simulate user clicking on dismissal in the dialog.
+ ArgumentCaptor<DialogInterface.OnDismissListener> dismissListenerCaptor =
+ ArgumentCaptor.forClass(DialogInterface.OnDismissListener.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setOnDismissListener(
+ dismissListenerCaptor.capture());
+ assertNotNull(dismissListenerCaptor.getValue());
+ dismissListenerCaptor.getValue().onDismiss(mAlertDialog);
+ mLooper.dispatchAll();
+ ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcast(intentCaptor.capture());
+ assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
+
+ // As no notification is active, new notification should be sent
+ mWifiCarrierInfoManager.sendImsiProtectionExemptionNotificationIfRequired(DATA_CARRIER_ID);
+ validateImsiProtectionNotification(CARRIER_NAME);
+
+ verify(mWifiConfigManager, never()).saveToStore(true);
+ assertFalse(mImsiDataSource.hasNewDataToSerialize());
+ assertFalse(mWifiCarrierInfoManager
+ .hasUserApprovedImsiPrivacyExemptionForCarrier(DATA_CARRIER_ID));
+ verify(mListener, never()).onUserAllowed(DATA_CARRIER_ID);
+ }
+
+ private void validateImsiProtectionNotification(String carrierName) {
+ verify(mNotificationManger, atLeastOnce()).notify(
+ eq(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE),
+ eq(mNotification));
+ ArgumentCaptor<CharSequence> contentCaptor =
+ ArgumentCaptor.forClass(CharSequence.class);
+ verify(mNotificationBuilder, atLeastOnce()).setContentTitle(contentCaptor.capture());
+ CharSequence content = contentCaptor.getValue();
+ assertNotNull(content);
+ assertTrue(content.toString().contains(carrierName));
+ }
+
+ private void validateUserApprovalDialog(String... anyOfExpectedAppNames) {
+ verify(mAlertDialog, atLeastOnce()).show();
+ ArgumentCaptor<CharSequence> contentCaptor =
+ ArgumentCaptor.forClass(CharSequence.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setMessage(contentCaptor.capture());
+ CharSequence content = contentCaptor.getValue();
+ assertNotNull(content);
+
+ boolean foundMatch = false;
+ for (int i = 0; i < anyOfExpectedAppNames.length; i++) {
+ foundMatch = content.toString().contains(anyOfExpectedAppNames[i]);
+ if (foundMatch) break;
+ }
+ assertTrue(foundMatch);
+ }
+
+ private void sendBroadcastForUserActionOnImsi(String action, String carrierName,
+ int carrierId) {
+ Intent intent = new Intent()
+ .setAction(action)
+ .putExtra(WifiCarrierInfoManager.EXTRA_CARRIER_NAME, carrierName)
+ .putExtra(WifiCarrierInfoManager.EXTRA_CARRIER_ID, carrierId);
+ assertNotNull(mBroadcastReceiverCaptor.getValue());
+ mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 94586073e..b1e6f2189 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -52,7 +52,6 @@ import androidx.test.filters.SmallTest;
import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.server.wifi.WifiScoreCard.PerNetwork;
import com.android.server.wifi.util.LruConnectionTracker;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.wifi.resources.R;
@@ -152,7 +151,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
private boolean mStoreReadTriggered = false;
private TestLooper mLooper = new TestLooper();
private MockitoSession mSession;
- private TelephonyUtil mTelephonyUtil;
+ private WifiCarrierInfoManager mWifiCarrierInfoManager;
/**
@@ -226,8 +225,9 @@ public class WifiConfigManagerTest extends WifiBaseTest {
when(mMacAddressUtil.calculatePersistentMac(any(), any())).thenReturn(TEST_RANDOMIZED_MAC);
when(mWifiScoreCard.lookupNetwork(any())).thenReturn(mPerNetwork);
- mTelephonyUtil = new TelephonyUtil(mTelephonyManager, mSubscriptionManager,
- mock(FrameworkFacade.class), mock(Context.class), mock(Handler.class));
+ mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
+ mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
+ mock(WifiContext.class), mock(WifiConfigStore.class), mock(Handler.class));
mLruConnectionTracker = new LruConnectionTracker(100, mContext);
createWifiConfigManager();
mWifiConfigManager.addOnNetworkUpdateListener(mWcmListener);
@@ -4276,7 +4276,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
/**
* {@link WifiConfigManager#resetSimNetworks()} should reset all non-PEAP SIM networks, no
- * matter if {@link TelephonyUtil#getSimIdentity()} returns null or not.
+ * matter if {@link WifiCarrierInfoManager#getSimIdentity()} returns null or not.
*/
@Test
public void testResetSimNetworks_getSimIdentityNull_shouldResetAllNonPeapSimIdentities() {
@@ -4583,7 +4583,7 @@ public class WifiConfigManagerTest extends WifiBaseTest {
private void createWifiConfigManager() {
mWifiConfigManager =
new WifiConfigManager(
- mContext, mClock, mUserManager, mTelephonyUtil,
+ mContext, mClock, mUserManager, mWifiCarrierInfoManager,
mWifiKeyStore, mWifiConfigStore,
mWifiPermissionsUtil, mWifiPermissionsWrapper, mWifiInjector,
mNetworkListSharedStoreData, mNetworkListUserStoreData,
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
index 6652e9b0c..24bb968a5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMonitorTest.java
@@ -39,7 +39,6 @@ import androidx.test.filters.SmallTest;
import com.android.server.wifi.MboOceController.BtmFrameData;
import com.android.server.wifi.hotspot2.AnqpEvent;
import com.android.server.wifi.hotspot2.IconEvent;
-import com.android.server.wifi.util.TelephonyUtil;
import org.junit.Before;
import org.junit.Test;
@@ -264,8 +263,8 @@ public class WifiMonitorTest extends WifiBaseTest {
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
verify(mHandlerSpy).handleMessage(messageCaptor.capture());
assertEquals(WifiMonitor.SUP_REQUEST_SIM_AUTH, messageCaptor.getValue().what);
- TelephonyUtil.SimAuthRequestData authData =
- (TelephonyUtil.SimAuthRequestData) messageCaptor.getValue().obj;
+ WifiCarrierInfoManager.SimAuthRequestData authData =
+ (WifiCarrierInfoManager.SimAuthRequestData) messageCaptor.getValue().obj;
assertEquals(networkId, authData.networkId);
assertEquals(ssid, authData.ssid);
assertEquals(WifiEnterpriseConfig.Eap.SIM, authData.protocol);
@@ -288,8 +287,8 @@ public class WifiMonitorTest extends WifiBaseTest {
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
verify(mHandlerSpy).handleMessage(messageCaptor.capture());
assertEquals(WifiMonitor.SUP_REQUEST_SIM_AUTH, messageCaptor.getValue().what);
- TelephonyUtil.SimAuthRequestData authData =
- (TelephonyUtil.SimAuthRequestData) messageCaptor.getValue().obj;
+ WifiCarrierInfoManager.SimAuthRequestData authData =
+ (WifiCarrierInfoManager.SimAuthRequestData) messageCaptor.getValue().obj;
assertEquals(networkId, authData.networkId);
assertEquals(ssid, authData.ssid);
assertEquals(WifiEnterpriseConfig.Eap.AKA, authData.protocol);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index a1c5b2741..3899453d5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -26,9 +26,7 @@ import static android.app.AppOpsManager.OPSTR_CHANGE_WIFI_STATE;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.when;
import static com.android.server.wifi.WifiNetworkSuggestionsManager.NOTIFICATION_USER_ALLOWED_APP_INTENT_ACTION;
-import static com.android.server.wifi.WifiNetworkSuggestionsManager.NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION;
import static com.android.server.wifi.WifiNetworkSuggestionsManager.NOTIFICATION_USER_DISALLOWED_APP_INTENT_ACTION;
-import static com.android.server.wifi.WifiNetworkSuggestionsManager.NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION;
import static com.android.server.wifi.WifiNetworkSuggestionsManager.NOTIFICATION_USER_DISMISSED_INTENT_ACTION;
import static org.junit.Assert.assertEquals;
@@ -80,7 +78,6 @@ import com.android.server.wifi.WifiNetworkSuggestionsManager.ExtendedWifiNetwork
import com.android.server.wifi.WifiNetworkSuggestionsManager.PerAppInfo;
import com.android.server.wifi.hotspot2.PasspointManager;
import com.android.server.wifi.util.LruConnectionTracker;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.wifi.resources.R;
@@ -139,9 +136,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
private @Mock WifiConfigStore mWifiConfigStore;
private @Mock WifiConfigManager mWifiConfigManager;
private @Mock NetworkSuggestionStoreData mNetworkSuggestionStoreData;
- private @Mock ImsiPrivacyProtectionExemptionStoreData mImsiPrivacyProtectionExemptionStoreData;
private @Mock WifiMetrics mWifiMetrics;
- private @Mock TelephonyUtil mTelephonyUtil;
+ private @Mock WifiCarrierInfoManager mWifiCarrierInfoManager;
private @Mock PasspointManager mPasspointManager;
private @Mock ISuggestionConnectionStatusListener mListener;
private @Mock IBinder mBinder;
@@ -158,12 +154,14 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
ArgumentCaptor.forClass(AppOpsManager.OnOpChangedListener.class);
private ArgumentCaptor<BroadcastReceiver> mBroadcastReceiverCaptor =
ArgumentCaptor.forClass(BroadcastReceiver.class);
+ private ArgumentCaptor<WifiCarrierInfoManager.OnUserApproveCarrierListener>
+ mUserApproveCarrierListenerArgumentCaptor = ArgumentCaptor.forClass(
+ WifiCarrierInfoManager.OnUserApproveCarrierListener.class);
private InOrder mInorder;
private WifiNetworkSuggestionsManager mWifiNetworkSuggestionsManager;
private NetworkSuggestionStoreData.DataSource mDataSource;
- private ImsiPrivacyProtectionExemptionStoreData.DataSource mImsiDataSource;
/**
* Setup the mocks.
@@ -177,8 +175,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
when(mWifiInjector.makeNetworkSuggestionStoreData(any()))
.thenReturn(mNetworkSuggestionStoreData);
- when(mWifiInjector.makeImsiProtectionExemptionStoreData(any()))
- .thenReturn(mImsiPrivacyProtectionExemptionStoreData);
when(mWifiInjector.getFrameworkFacade()).thenReturn(mFrameworkFacade);
when(mWifiInjector.getPasspointManager()).thenReturn(mPasspointManager);
when(mWifiInjector.getWifiScoreCard()).thenReturn(mWifiScoreCard);
@@ -230,30 +226,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
when(mResources.getText(eq(R.string.wifi_suggestion_action_disallow_app)))
.thenReturn("blah");
- // setup resource strings for IMSI protection notification.
- when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_title), anyString()))
- .thenAnswer(s -> "blah" + s.getArguments()[1]);
- when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_content)))
- .thenReturn("blah");
- when(mResources.getText(
- eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_carrier)))
- .thenReturn("blah");
- when(mResources.getText(
- eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_carrier)))
- .thenReturn("blah");
- when(mResources.getString(
- eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title)))
- .thenReturn("blah");
- when(mResources.getString(
- eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_content),
- anyString())).thenAnswer(s -> "blah" + s.getArguments()[1]);
- when(mResources.getText(
- eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_confirmation)))
- .thenReturn("blah");
- when(mResources.getText(
- eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_confirmation)))
- .thenReturn("blah");
-
// Our app Info. Needed for notification builder.
ApplicationInfo ourAppInfo = new ApplicationInfo();
@@ -267,7 +239,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
when(mPackageManager.getApplicationInfoAsUser(eq(TEST_PACKAGE_2), eq(0), any()))
.thenReturn(appInfO2);
when(mPackageManager.getApplicationLabel(appInfO2)).thenReturn(TEST_APP_NAME_2);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(any())).thenReturn(
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(any())).thenReturn(
TelephonyManager.UNKNOWN_CARRIER_ID);
when(mWifiKeyStore.updateNetworkKeys(any(), any())).thenReturn(true);
@@ -275,7 +247,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
mWifiNetworkSuggestionsManager =
new WifiNetworkSuggestionsManager(mContext, new Handler(mLooper.getLooper()),
mWifiInjector, mWifiPermissionsUtil, mWifiConfigManager, mWifiConfigStore,
- mWifiMetrics, mTelephonyUtil, mWifiKeyStore, mLruConnectionTracker);
+ mWifiMetrics, mWifiCarrierInfoManager, mWifiKeyStore,
+ mLruConnectionTracker);
verify(mContext).getResources();
verify(mContext).getSystemService(Context.APP_OPS_SERVICE);
verify(mContext).getSystemService(Context.NOTIFICATION_SERVICE);
@@ -289,13 +262,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
mDataSource = dataSourceArgumentCaptor.getValue();
assertNotNull(mDataSource);
- ArgumentCaptor<ImsiPrivacyProtectionExemptionStoreData.DataSource>
- imsiDataSourceArgumentCaptor =
- ArgumentCaptor.forClass(ImsiPrivacyProtectionExemptionStoreData.DataSource.class);
- verify(mWifiInjector).makeImsiProtectionExemptionStoreData(imsiDataSourceArgumentCaptor
- .capture());
- mImsiDataSource = imsiDataSourceArgumentCaptor.getValue();
- assertNotNull(mImsiDataSource);
+ verify(mWifiCarrierInfoManager).addImsiExemptionUserApprovalListener(
+ mUserApproveCarrierListenerArgumentCaptor.capture());
mWifiNetworkSuggestionsManager.enableVerboseLogging(1);
}
@@ -1093,7 +1061,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertTrue(mWifiNetworkSuggestionsManager
.registerSuggestionConnectionStatusListener(mBinder, mListener,
NETWORK_CALLBACK_ID, TEST_PACKAGE_1));
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(TEST_CARRIER_ID);
WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
WifiConfigurationTestUtil.createPskNetwork(), null, true, false, true, true);
@@ -2885,18 +2853,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertEquals(expectedNetworkSuggestion, networkSuggestion);
}
- private void validateImsiProtectionNotification(String carrierName) {
- verify(mNotificationManger, atLeastOnce()).notify(
- eq(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE),
- eq(mNotification));
- ArgumentCaptor<CharSequence> contentCaptor =
- ArgumentCaptor.forClass(CharSequence.class);
- verify(mNotificationBuilder, atLeastOnce()).setContentTitle(contentCaptor.capture());
- CharSequence content = contentCaptor.getValue();
- assertNotNull(content);
- assertTrue(content.toString().contains(carrierName));
- }
-
private void validateUserApprovalDialog(String... anyOfExpectedAppNames) {
verify(mAlertDialog, atLeastOnce()).show();
ArgumentCaptor<CharSequence> contentCaptor =
@@ -2940,16 +2896,6 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent);
}
- private void sendBroadcastForUserActionOnImsi(String action, String carrierName,
- int carrierId) {
- Intent intent = new Intent()
- .setAction(action)
- .putExtra(WifiNetworkSuggestionsManager.EXTRA_CARRIER_NAME, carrierName)
- .putExtra(WifiNetworkSuggestionsManager.EXTRA_CARRIER_ID, carrierId);
- assertNotNull(mBroadcastReceiverCaptor.getValue());
- mBroadcastReceiverCaptor.getValue().onReceive(mContext, intent);
- }
-
@Test
public void testAddSuggestionWithValidCarrierIdWithCarrierProvisionPermission() {
WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork();
@@ -3100,7 +3046,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
assertTrue(mWifiNetworkSuggestionsManager
.isPasspointSuggestionSharedWithUser(dummyConfiguration));
dummyConfiguration.meteredHint = true;
- when(mTelephonyUtil.isCarrierNetworkFromNonDefaultDataSim(dummyConfiguration))
+ when(mWifiCarrierInfoManager.isCarrierNetworkFromNonDefaultDataSim(dummyConfiguration))
.thenReturn(true);
assertFalse(mWifiNetworkSuggestionsManager
.isPasspointSuggestionSharedWithUser(dummyConfiguration));
@@ -3214,7 +3160,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
.thenReturn(false);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(TelephonyManager.UNKNOWN_CARRIER_ID);
int status = mWifiNetworkSuggestionsManager
.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE);
@@ -3237,7 +3183,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
.thenReturn(false);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(VALID_CARRIER_ID);
int status = mWifiNetworkSuggestionsManager
.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE);
@@ -3260,7 +3206,7 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
.thenReturn(true);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(TelephonyManager.UNKNOWN_CARRIER_ID);
int status = mWifiNetworkSuggestionsManager
.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE);
@@ -3283,12 +3229,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
.thenReturn(false);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(VALID_CARRIER_ID);
- when(mTelephonyUtil.getMatchingSubId(VALID_CARRIER_ID)).thenReturn(TEST_SUBID);
- when(mTelephonyUtil.isSimPresent(TEST_SUBID)).thenReturn(true);
- when(mTelephonyUtil.requiresImsiEncryption(TEST_SUBID)).thenReturn(true);
- when(mTelephonyUtil.isImsiEncryptionInfoAvailable(TEST_SUBID)).thenReturn(true);
+ when(mWifiCarrierInfoManager.getMatchingSubId(VALID_CARRIER_ID)).thenReturn(TEST_SUBID);
+ when(mWifiCarrierInfoManager.isSimPresent(TEST_SUBID)).thenReturn(true);
+ when(mWifiCarrierInfoManager.requiresImsiEncryption(TEST_SUBID)).thenReturn(true);
+ when(mWifiCarrierInfoManager.isImsiEncryptionInfoAvailable(TEST_SUBID)).thenReturn(true);
ScanDetail scanDetail = createScanDetailForNetwork(config);
int status = mWifiNetworkSuggestionsManager
.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE);
@@ -3319,13 +3265,13 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
networkSuggestionList.add(networkSuggestion);
when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
.thenReturn(false);
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(VALID_CARRIER_ID);
int status = mWifiNetworkSuggestionsManager
.add(networkSuggestionList, TEST_UID_1, TEST_PACKAGE_1, TEST_FEATURE);
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS, status);
verify(mNotificationManger, never()).notify(anyInt(), any());
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(TelephonyManager.UNKNOWN_CARRIER_ID);
mWifiNetworkSuggestionsManager.resetCarrierPrivilegedApps();
assertEquals(0, mWifiNetworkSuggestionsManager.get(TEST_PACKAGE_1).size());
@@ -3560,15 +3506,20 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}
/**
- * Test the IMSI protection notification and user click on the allow.
+ * Verify when matching a SIM-Based network without IMSI protection, framework will mark it
+ * auto-join disable and send notification. If user click on allow, will restore the auto-join
+ * config.
*/
@Test
public void testSendImsiProtectionNotificationOnUserAllowed() {
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
+ when(mWifiCarrierInfoManager.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
.thenReturn(TEST_CARRIER_ID);
- when(mTelephonyUtil.getMatchingSubId(TEST_CARRIER_ID)).thenReturn(TEST_SUBID);
- when(mTelephonyUtil.getCarrierNameforSubId(TEST_SUBID)).thenReturn(TEST_CARRIER_NAME);
- when(mTelephonyUtil.requiresImsiEncryption(TEST_SUBID)).thenReturn(false);
+ when(mWifiCarrierInfoManager.getMatchingSubId(TEST_CARRIER_ID)).thenReturn(TEST_SUBID);
+ when(mWifiCarrierInfoManager.getCarrierNameforSubId(TEST_SUBID))
+ .thenReturn(TEST_CARRIER_NAME);
+ when(mWifiCarrierInfoManager.requiresImsiEncryption(TEST_SUBID)).thenReturn(false);
+ when(mWifiCarrierInfoManager.hasUserApprovedImsiPrivacyExemptionForCarrier(TEST_CARRIER_ID))
+ .thenReturn(false);
WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork(
WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
@@ -3583,113 +3534,21 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
verifyNoMoreInteractions(mNotificationManger);
Set<ExtendedWifiNetworkSuggestion> matchedSuggestion = mWifiNetworkSuggestionsManager
.getNetworkSuggestionsForScanDetail(createScanDetailForNetwork(eapSimConfig));
- validateImsiProtectionNotification(TEST_CARRIER_NAME);
+ verify(mWifiCarrierInfoManager)
+ .sendImsiProtectionExemptionNotificationIfRequired(TEST_CARRIER_ID);
for (ExtendedWifiNetworkSuggestion ewns : matchedSuggestion) {
assertFalse(ewns.isAutojoinEnabled);
}
- sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
- TEST_CARRIER_NAME, TEST_CARRIER_ID);
- verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
- validateUserApprovalDialog(TEST_CARRIER_NAME);
- // Simulate user clicking on allow in the dialog.
- ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
- ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
- verify(mAlertDialogBuilder, atLeastOnce()).setPositiveButton(
- any(), clickListenerCaptor.capture());
- assertNotNull(clickListenerCaptor.getValue());
- clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
- mLooper.dispatchAll();
- ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mContext).sendBroadcast(intentCaptor.capture());
- assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
- verify(mWifiConfigManager, times(2)).saveToStore(true);
- assertTrue(mImsiDataSource.hasNewDataToSerialize());
- matchedSuggestion = mWifiNetworkSuggestionsManager
- .getNetworkSuggestionsForScanDetail(createScanDetailForNetwork(eapSimConfig));
- verifyNoMoreInteractions(mNotificationManger);
- assertTrue(mWifiNetworkSuggestionsManager
- .hasUserApprovedImsiPrivacyExemptionForCarrier(TEST_CARRIER_ID));
-
- for (ExtendedWifiNetworkSuggestion ewns : matchedSuggestion) {
- assertTrue(ewns.isAutojoinEnabled);
- }
- }
-
- /**
- * Test the IMSI protection notification and user click on the disallow.
- */
- @Test
- public void testSendImsiProtectionNotificationOnUserDisallowed() {
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
- .thenReturn(TEST_CARRIER_ID);
- when(mTelephonyUtil.getMatchingSubId(TEST_CARRIER_ID)).thenReturn(TEST_SUBID);
- when(mTelephonyUtil.getCarrierNameforSubId(TEST_SUBID)).thenReturn(TEST_CARRIER_NAME);
- when(mTelephonyUtil.requiresImsiEncryption(TEST_SUBID)).thenReturn(false);
- WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork(
- WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
- eapSimConfig, null, true, false, true, true);
- List<WifiNetworkSuggestion> networkSuggestionList =
- new ArrayList<WifiNetworkSuggestion>() {{
- add(networkSuggestion);
- }};
- assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
- mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1, TEST_FEATURE));
- Set<ExtendedWifiNetworkSuggestion> matchedSuggestion = mWifiNetworkSuggestionsManager
- .getNetworkSuggestionsForScanDetail(createScanDetailForNetwork(eapSimConfig));
- validateImsiProtectionNotification(TEST_CARRIER_NAME);
- for (ExtendedWifiNetworkSuggestion ewns : matchedSuggestion) {
- assertFalse(ewns.isAutojoinEnabled);
- }
- sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_DISALLOWED_CARRIER_INTENT_ACTION,
- TEST_CARRIER_NAME, TEST_CARRIER_ID);
- verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ // Simulate user approved carrier
+ mUserApproveCarrierListenerArgumentCaptor.getValue().onUserAllowed(TEST_CARRIER_ID);
+ when(mWifiCarrierInfoManager.hasUserApprovedImsiPrivacyExemptionForCarrier(TEST_CARRIER_ID))
+ .thenReturn(true);
- verify(mWifiConfigManager, times(2)).saveToStore(true);
- assertTrue(mImsiDataSource.hasNewDataToSerialize());
matchedSuggestion = mWifiNetworkSuggestionsManager
.getNetworkSuggestionsForScanDetail(createScanDetailForNetwork(eapSimConfig));
- verifyNoMoreInteractions(mNotificationManger);
- assertFalse(mWifiNetworkSuggestionsManager
- .hasUserApprovedImsiPrivacyExemptionForCarrier(TEST_CARRIER_ID));
for (ExtendedWifiNetworkSuggestion ewns : matchedSuggestion) {
- assertFalse(ewns.isAutojoinEnabled);
- }
- }
-
- /**
- * Test when carrier start to support IMSI protection, imsiExemptionMap will update too.
- */
- @Test
- public void testUpdateImsiExemptionMapWhenCarrierFromWithoutProtectionToWithProtection() {
- // Simulate user click on disallow before.
- mWifiNetworkSuggestionsManager
- .setHasUserApprovedImsiPrivacyExemptionForCarrier(false, TEST_CARRIER_ID);
- verifyNoMoreInteractions(mNotificationManger);
- // Now carrier upgrade to support Imsi protection
- when(mTelephonyUtil.getCarrierIdForPackageWithCarrierPrivileges(TEST_PACKAGE_1))
- .thenReturn(TEST_CARRIER_ID);
- when(mTelephonyUtil.getMatchingSubId(TEST_CARRIER_ID)).thenReturn(TEST_SUBID);
- when(mTelephonyUtil.requiresImsiEncryption(TEST_SUBID)).thenReturn(true);
- WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork(
- WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE);
- WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
- eapSimConfig, null, true, false, true, true);
- List<WifiNetworkSuggestion> networkSuggestionList =
- new ArrayList<WifiNetworkSuggestion>() {{
- add(networkSuggestion);
- }};
- assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
- mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
- TEST_PACKAGE_1, TEST_FEATURE));
- Set<ExtendedWifiNetworkSuggestion> matchedSuggestion = mWifiNetworkSuggestionsManager
- .getNetworkSuggestionsForScanDetail(createScanDetailForNetwork(eapSimConfig));
- // Should be no more notification and suggestion restore to the initial auto join configure.
- verifyNoMoreInteractions(mNotificationManger);
- for (ExtendedWifiNetworkSuggestion ewns : matchedSuggestion) {
assertTrue(ewns.isAutojoinEnabled);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java
index cfa6044f6..697f83125 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointConfigUserStoreDataTest.java
@@ -36,9 +36,9 @@ import androidx.test.filters.SmallTest;
import com.android.internal.util.FastXmlSerializer;
import com.android.server.wifi.WifiBaseTest;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiConfigStore;
import com.android.server.wifi.WifiKeyStore;
-import com.android.server.wifi.util.TelephonyUtil;
import com.android.server.wifi.util.WifiConfigStoreEncryptionUtil;
import org.junit.Before;
@@ -77,7 +77,7 @@ public class PasspointConfigUserStoreDataTest extends WifiBaseTest {
private static final boolean TEST_SHARED = false;
@Mock WifiKeyStore mKeyStore;
- @Mock TelephonyUtil mTelephonyUtil;
+ @Mock WifiCarrierInfoManager mWifiCarrierInfoManager;
@Mock PasspointConfigUserStoreData.DataSource mDataSource;
PasspointConfigUserStoreData mConfigStoreData;
@@ -85,7 +85,8 @@ public class PasspointConfigUserStoreDataTest extends WifiBaseTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- mConfigStoreData = new PasspointConfigUserStoreData(mKeyStore, mTelephonyUtil, mDataSource);
+ mConfigStoreData = new PasspointConfigUserStoreData(mKeyStore, mWifiCarrierInfoManager,
+ mDataSource);
}
/**
@@ -251,12 +252,12 @@ public class PasspointConfigUserStoreDataTest extends WifiBaseTest {
// Setup expected data.
List<PasspointProvider> providerList = new ArrayList<>();
PasspointProvider provider1 = new PasspointProvider(createFullPasspointConfiguration(),
- mKeyStore, mTelephonyUtil, TEST_PROVIDER_ID, TEST_CREATOR_UID, TEST_CREATOR_PACKAGE,
- false, Arrays.asList(TEST_CA_CERTIFICATE_ALIAS),
+ mKeyStore, mWifiCarrierInfoManager, TEST_PROVIDER_ID, TEST_CREATOR_UID,
+ TEST_CREATOR_PACKAGE, false, Arrays.asList(TEST_CA_CERTIFICATE_ALIAS),
TEST_CLIENT_PRIVATE_KEY_AND_CERT_ALIAS, null,
TEST_HAS_EVER_CONNECTED, TEST_SHARED);
PasspointProvider provider2 = new PasspointProvider(createFullPasspointConfiguration(),
- mKeyStore, mTelephonyUtil, TEST_PROVIDER_ID_2, TEST_CREATOR_UID,
+ mKeyStore, mWifiCarrierInfoManager, TEST_PROVIDER_ID_2, TEST_CREATOR_UID,
TEST_CREATOR_PACKAGE, true,
Arrays.asList(TEST_CA_CERTIFICATE_ALIAS, TEST_CA_CERTIFICATE_ALIAS_2),
TEST_CLIENT_PRIVATE_KEY_AND_CERT_ALIAS, TEST_REMEDIATION_CA_CERTIFICATE_ALIAS,
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
index 3f92809dd..73c5713ac 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java
@@ -92,9 +92,11 @@ import com.android.server.wifi.FakeKeys;
import com.android.server.wifi.FrameworkFacade;
import com.android.server.wifi.NetworkUpdateResult;
import com.android.server.wifi.WifiBaseTest;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiConfigManager;
import com.android.server.wifi.WifiConfigStore;
import com.android.server.wifi.WifiConfigurationTestUtil;
+import com.android.server.wifi.WifiContext;
import com.android.server.wifi.WifiInjector;
import com.android.server.wifi.WifiKeyStore;
import com.android.server.wifi.WifiMetrics;
@@ -108,7 +110,6 @@ import com.android.server.wifi.hotspot2.anqp.I18Name;
import com.android.server.wifi.hotspot2.anqp.OsuProviderInfo;
import com.android.server.wifi.util.InformationElementUtil;
import com.android.server.wifi.util.InformationElementUtil.RoamingConsortium;
-import com.android.server.wifi.util.TelephonyUtil;
import org.junit.Before;
import org.junit.Test;
@@ -204,7 +205,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointManager mManager;
ArgumentCaptor<AppOpsManager.OnOpChangedListener> mAppOpChangedListenerCaptor =
ArgumentCaptor.forClass(AppOpsManager.OnOpChangedListener.class);
- TelephonyUtil mTelephonyUtil;
+ WifiCarrierInfoManager mWifiCarrierInfoManager;
/** Sets up test. */
@Before
@@ -226,13 +227,14 @@ public class PasspointManagerTest extends WifiBaseTest {
when(mWifiInjector.getClientModeImpl()).thenReturn(mClientModeImpl);
when(mWifiInjector.getWifiNetworkSuggestionsManager())
.thenReturn(mWifiNetworkSuggestionsManager);
- mTelephonyUtil = new TelephonyUtil(mTelephonyManager, mSubscriptionManager,
- mock(FrameworkFacade.class), mock(Context.class), mock(Handler.class));
+ mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager,
+ mSubscriptionManager, mWifiInjector, mock(FrameworkFacade.class),
+ mock(WifiContext.class), mWifiConfigStore, mock(Handler.class));
mLooper = new TestLooper();
mHandler = new Handler(mLooper.getLooper());
mManager = new PasspointManager(mContext, mWifiInjector, mHandler, mWifiNative,
mWifiKeyStore, mClock, mObjectFactory, mWifiConfigManager,
- mWifiConfigStore, mWifiMetrics, mTelephonyUtil);
+ mWifiConfigStore, mWifiMetrics, mWifiCarrierInfoManager);
ArgumentCaptor<PasspointEventHandler.Callbacks> callbacks =
ArgumentCaptor.forClass(PasspointEventHandler.Callbacks.class);
verify(mObjectFactory).makePasspointEventHandler(any(WifiNative.class),
@@ -242,8 +244,8 @@ public class PasspointManagerTest extends WifiBaseTest {
verify(mObjectFactory).makePasspointConfigSharedStoreData(sharedDataSource.capture());
ArgumentCaptor<PasspointConfigUserStoreData.DataSource> userDataSource =
ArgumentCaptor.forClass(PasspointConfigUserStoreData.DataSource.class);
- verify(mObjectFactory).makePasspointConfigUserStoreData(
- any(WifiKeyStore.class), any(TelephonyUtil.class), userDataSource.capture());
+ verify(mObjectFactory).makePasspointConfigUserStoreData(any(WifiKeyStore.class),
+ any(WifiCarrierInfoManager.class), userDataSource.capture());
mCallbacks = callbacks.getValue();
mSharedDataSource = sharedDataSource.getValue();
mUserDataSource = userDataSource.getValue();
@@ -399,7 +401,7 @@ public class PasspointManagerTest extends WifiBaseTest {
wifiConfig.setPasspointUniqueId(config.getUniqueId());
PasspointProvider provider = createMockProvider(config, wifiConfig, isSuggestion);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(isSuggestion))).thenReturn(provider);
when(provider.getPackageName()).thenReturn(packageName);
assertTrue(mManager.addOrUpdateProvider(
@@ -642,7 +644,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider provider = createMockProvider(config);
when(provider.getPackageName()).thenReturn(TEST_PACKAGE);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -784,7 +786,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_REALM);
PasspointProvider provider = createMockProvider(config);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -846,7 +848,7 @@ public class PasspointManagerTest extends WifiBaseTest {
.thenReturn(true);
PasspointManager ut = new PasspointManager(mContext, mWifiInjector, mHandler, mWifiNative,
mWifiKeyStore, mClock, spyFactory, mWifiConfigManager,
- mWifiConfigStore, mWifiMetrics, mTelephonyUtil);
+ mWifiConfigStore, mWifiMetrics, mWifiCarrierInfoManager);
assertTrue(ut.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
true, true));
@@ -873,7 +875,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_REALM);
PasspointProvider origProvider = createMockProvider(origConfig);
when(mObjectFactory.makePasspointProvider(eq(origConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(origProvider);
assertTrue(mManager.addOrUpdateProvider(origConfig, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -917,7 +919,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_FRIENDLY_NAME);
PasspointProvider newProvider = createMockProvider(newConfig);
when(mObjectFactory.makePasspointProvider(eq(newConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(newProvider);
when(mWifiConfigManager.getConfiguredNetwork(origProvider.getWifiConfig().getKey()))
.thenReturn(origWifiConfig);
@@ -954,7 +956,8 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_FRIENDLY_NAME);
PasspointProvider provider = mock(PasspointProvider.class);
when(provider.installCertsAndKeys()).thenReturn(false);
- when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore), eq(mTelephonyUtil),
+ when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore), eq(
+ mWifiCarrierInfoManager),
anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE), eq(false))).thenReturn(provider);
assertFalse(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -974,7 +977,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_FRIENDLY_NAME);
PasspointProvider provider = createMockProvider(config);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -996,7 +999,7 @@ public class PasspointManagerTest extends WifiBaseTest {
config.setUpdateIdentifier(1);
PasspointProvider provider = createMockProvider(config);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -1603,7 +1606,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider provider = createMockProvider(config);
// Verify the provider ID used to create the new provider.
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), eq(providerIndex), eq(TEST_CREATOR_UID),
+ eq(mWifiCarrierInfoManager), eq(providerIndex), eq(TEST_CREATOR_UID),
eq(TEST_PACKAGE), eq(false))).thenReturn(provider);
assertTrue(
@@ -1960,7 +1963,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_REALM);
PasspointProvider provider = createMockProvider(config);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -2003,7 +2006,7 @@ public class PasspointManagerTest extends WifiBaseTest {
when(provider.getPackageName()).thenReturn(TEST_PACKAGE);
when(provider.isFromSuggestion()).thenReturn(true);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(provider);
assertTrue(mManager.addOrUpdateProvider(config, TEST_CREATOR_UID, TEST_PACKAGE,
true, true));
@@ -2073,7 +2076,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider origProvider = createMockProvider(origConfig);
when(origProvider.getPackageName()).thenReturn(TEST_PACKAGE);
when(mObjectFactory.makePasspointProvider(eq(origConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(origProvider);
assertTrue(mManager.addOrUpdateProvider(origConfig, TEST_CREATOR_UID, TEST_PACKAGE,
true, true));
@@ -2120,7 +2123,7 @@ public class PasspointManagerTest extends WifiBaseTest {
when(newProvider.isFromSuggestion()).thenReturn(true);
when(newProvider.getPackageName()).thenReturn(TEST_PACKAGE);
when(mObjectFactory.makePasspointProvider(eq(newConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(newProvider);
assertTrue(mManager.addOrUpdateProvider(newConfig, TEST_CREATOR_UID, TEST_PACKAGE,
true, true));
@@ -2153,7 +2156,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider origProvider = createMockProvider(origConfig);
when(origProvider.getPackageName()).thenReturn(TEST_PACKAGE);
when(mObjectFactory.makePasspointProvider(eq(origConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(origProvider);
assertTrue(mManager.addOrUpdateProvider(origConfig, TEST_CREATOR_UID, TEST_PACKAGE,
true, true));
@@ -2174,7 +2177,7 @@ public class PasspointManagerTest extends WifiBaseTest {
TEST_FRIENDLY_NAME);
PasspointProvider newProvider = createMockProvider(newConfig);
when(mObjectFactory.makePasspointProvider(eq(newConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(newProvider);
assertTrue(mManager.addOrUpdateProvider(newConfig, TEST_CREATOR_UID, TEST_PACKAGE,
false, true));
@@ -2206,7 +2209,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider origProvider = createMockProvider(origConfig);
when(origProvider.getPackageName()).thenReturn(TEST_PACKAGE);
when(mObjectFactory.makePasspointProvider(eq(origConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(false))).thenReturn(origProvider);
assertTrue(mManager.addOrUpdateProvider(origConfig, TEST_CREATOR_UID, TEST_PACKAGE, false,
true));
@@ -2231,7 +2234,7 @@ public class PasspointManagerTest extends WifiBaseTest {
when(newProvider.isFromSuggestion()).thenReturn(true);
when(newProvider.getPackageName()).thenReturn(TEST_PACKAGE1);
when(mObjectFactory.makePasspointProvider(eq(newConfig), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE1),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE1),
eq(true))).thenReturn(newProvider);
assertTrue(mManager.addOrUpdateProvider(newConfig, TEST_CREATOR_UID, TEST_PACKAGE1, true,
true));
@@ -2411,7 +2414,7 @@ public class PasspointManagerTest extends WifiBaseTest {
createTestConfigWithUserCredential(TEST_FQDN, TEST_FRIENDLY_NAME);
PasspointProvider provider = createMockProvider(config, wifiConfig, true);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(provider);
when(provider.getPackageName()).thenReturn(TEST_PACKAGE);
assertTrue(mManager.addOrUpdateProvider(
@@ -2430,7 +2433,7 @@ public class PasspointManagerTest extends WifiBaseTest {
createTestConfigWithUserCredential(TEST_FQDN, TEST_FRIENDLY_NAME);
PasspointProvider provider = createMockProvider(config, wifiConfig, false);
when(mObjectFactory.makePasspointProvider(eq(config), eq(mWifiKeyStore),
- eq(mTelephonyUtil), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
+ eq(mWifiCarrierInfoManager), anyLong(), eq(TEST_CREATOR_UID), eq(TEST_PACKAGE),
eq(true))).thenReturn(provider);
when(provider.getPackageName()).thenReturn(TEST_PACKAGE);
assertFalse(mManager.addOrUpdateProvider(
@@ -2447,7 +2450,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointConfiguration config = mock(PasspointConfiguration.class);
PasspointProvider mockProvider = mock(PasspointProvider.class);
when(mObjectFactory.makePasspointProvider(config, null,
- mTelephonyUtil, 0, 0, null, false))
+ mWifiCarrierInfoManager, 0, 0, null, false))
.thenReturn(mockProvider);
List<ScanResult> scanResults = new ArrayList<>() {{
add(mock(ScanResult.class));
@@ -2469,7 +2472,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointConfiguration config = mock(PasspointConfiguration.class);
PasspointProvider mockProvider = mock(PasspointProvider.class);
when(mObjectFactory.makePasspointProvider(config, null,
- mTelephonyUtil, 0, 0, null, false))
+ mWifiCarrierInfoManager, 0, 0, null, false))
.thenReturn(mockProvider);
List<ScanResult> scanResults = new ArrayList<>() {{
add(mock(ScanResult.class));
@@ -2493,7 +2496,7 @@ public class PasspointManagerTest extends WifiBaseTest {
PasspointProvider mockProvider = mock(PasspointProvider.class);
when(mObjectFactory.makePasspointProvider(config, null,
- mTelephonyUtil, 0, 0, null, false))
+ mWifiCarrierInfoManager, 0, 0, null, false))
.thenReturn(mockProvider);
List<ScanResult> scanResults = new ArrayList<>() {{
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
index 5a20ef5a6..19ced12fc 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointProviderTest.java
@@ -39,6 +39,7 @@ import androidx.test.filters.SmallTest;
import com.android.server.wifi.FakeKeys;
import com.android.server.wifi.WifiBaseTest;
+import com.android.server.wifi.WifiCarrierInfoManager;
import com.android.server.wifi.WifiKeyStore;
import com.android.server.wifi.hotspot2.anqp.ANQPElement;
import com.android.server.wifi.hotspot2.anqp.CellularNetwork;
@@ -53,7 +54,6 @@ import com.android.server.wifi.hotspot2.anqp.eap.EAPMethod;
import com.android.server.wifi.hotspot2.anqp.eap.NonEAPInnerAuth;
import com.android.server.wifi.util.ArrayUtils;
import com.android.server.wifi.util.InformationElementUtil.RoamingConsortium;
-import com.android.server.wifi.util.TelephonyUtil;
import org.junit.Before;
import org.junit.Test;
@@ -118,7 +118,8 @@ public class PasspointProviderTest extends WifiBaseTest {
}
@Mock WifiKeyStore mKeyStore;
- @Mock TelephonyUtil mTelephonyUtil;
+ @Mock
+ WifiCarrierInfoManager mWifiCarrierInfoManager;
@Mock RoamingConsortium mRoamingConsortium;
PasspointProvider mProvider;
X509Certificate mRemediationCaCertificate;
@@ -152,8 +153,8 @@ public class PasspointProviderTest extends WifiBaseTest {
* @return {@link com.android.server.wifi.hotspot2.PasspointProvider}
*/
private PasspointProvider createProvider(PasspointConfiguration config) {
- return new PasspointProvider(config, mKeyStore, mTelephonyUtil, PROVIDER_ID, CREATOR_UID,
- CREATOR_PACKAGE, false);
+ return new PasspointProvider(config, mKeyStore, mWifiCarrierInfoManager, PROVIDER_ID,
+ CREATOR_UID, CREATOR_PACKAGE, false);
}
/**
@@ -704,7 +705,7 @@ public class PasspointProviderTest extends WifiBaseTest {
// Setup test provider.
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
- when(mTelephonyUtil.getMatchingImsiCarrierId(TEST_IMSI))
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(TEST_IMSI))
.thenReturn(new Pair<String, Integer>(TEST_IMSI, VALID_CARRIER_ID));
mProvider = createProvider(config);
@@ -729,7 +730,7 @@ public class PasspointProviderTest extends WifiBaseTest {
// Setup test provider.
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
- when(mTelephonyUtil.getMatchingImsiCarrierId(TEST_IMSI))
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(TEST_IMSI))
.thenReturn(new Pair<String, Integer>(TEST_IMSI, VALID_CARRIER_ID));
mProvider = createProvider(config);
@@ -758,7 +759,7 @@ public class PasspointProviderTest extends WifiBaseTest {
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
mProvider = createProvider(config);
- when(mTelephonyUtil.getMatchingImsiCarrierId(
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(
eq(config.getCredential().getSimCredential().getImsi())))
.thenReturn(new Pair<String, Integer>(TEST_IMSI, VALID_CARRIER_ID));
@@ -941,7 +942,7 @@ public class PasspointProviderTest extends WifiBaseTest {
// Setup test provider.
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
- when(mTelephonyUtil.getMatchingImsiCarrierId(TEST_IMSI))
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(TEST_IMSI))
.thenReturn(new Pair<String, Integer>(TEST_IMSI, VALID_CARRIER_ID));
mProvider = createProvider(config);
@@ -971,7 +972,7 @@ public class PasspointProviderTest extends WifiBaseTest {
// Setup test provider.
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
- when(mTelephonyUtil.getMatchingImsiCarrierId(TEST_IMSI))
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(TEST_IMSI))
.thenReturn(new Pair<String, Integer>(TEST_IMSI, VALID_CARRIER_ID));
mProvider = createProvider(config);
@@ -1001,7 +1002,7 @@ public class PasspointProviderTest extends WifiBaseTest {
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
config.setCarrierId(VALID_CARRIER_ID);
- when(mTelephonyUtil.getMatchingImsi(eq(VALID_CARRIER_ID)))
+ when(mWifiCarrierInfoManager.getMatchingImsi(eq(VALID_CARRIER_ID)))
.thenReturn(null);
mProvider = createProvider(config);
@@ -1029,7 +1030,7 @@ public class PasspointProviderTest extends WifiBaseTest {
// Setup test provider.
PasspointConfiguration config = generateTestPasspointConfiguration(
CredentialType.SIM, false);
- when(mTelephonyUtil.getMatchingImsiCarrierId(eq(TEST_IMSI)))
+ when(mWifiCarrierInfoManager.getMatchingImsiCarrierId(eq(TEST_IMSI)))
.thenReturn(null);
mProvider = createProvider(config);