diff options
author | Nate Jiang <qiangjiang@google.com> | 2020-04-03 16:10:31 -0700 |
---|---|---|
committer | Nate Jiang <qiangjiang@google.com> | 2020-04-09 09:16:01 -0700 |
commit | 7faeb01bd0764cda06d8d915f43a5d968211e842 (patch) | |
tree | 860b7e1237f6130b522dbbd3814a76b6d037ccbd /tests | |
parent | e452e6a22830d3ff9e1b86cd6437afcb8df3e4d7 (diff) |
Rename TelephonyUtils to WifiCarrierInfoManager
As we add many function to it and it is already an always run
service, rename it to manager.
Bug: 153109682
Test: atest com.android.server.wifi
Change-Id: Ib1cb8363fc019e6f4edea16a7e497b2873bd6480
Diffstat (limited to 'tests')
12 files changed, 242 insertions, 236 deletions
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..2b87a2820 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, + WifiCarrierInfoManager tu = new WifiCarrierInfoManager(mTelephonyManager, + mSubscriptionManager, mock(FrameworkFacade.class), mock(Context.class), mock(Handler.class)); - mTelephonyUtil = spy(tu); + 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/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..bbc3a1c3b 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,7 +14,7 @@ * 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; @@ -46,11 +46,8 @@ import android.util.Pair; 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.server.wifi.WifiCarrierInfoManager.SimAuthRequestData; +import com.android.server.wifi.WifiCarrierInfoManager.SimAuthResponseData; import org.junit.After; import org.junit.Before; @@ -71,11 +68,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; @@ -127,8 +124,8 @@ 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())); + mWifiCarrierInfoManager = new WifiCarrierInfoManager(mTelephonyManager, + mSubscriptionManager, mFrameworkFacade, mContext, new Handler(mLooper.getLooper())); mSubInfoList = new ArrayList<>(); mSubInfoList.add(mDataSubscriptionInfo); mSubInfoList.add(mNonDataSubscriptionInfo); @@ -222,8 +219,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 +239,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 +249,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 +275,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 +310,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 +320,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 +338,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 +362,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 +386,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 +431,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 +467,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 +487,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 +504,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 +514,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 +585,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 +596,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 +614,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 +625,7 @@ public class TelephonyUtilTest extends WifiBaseTest { WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE); assertEquals("", - mTelephonyUtil.getGsmSimpleSimAuthResponse(invalidRequests, config)); + mWifiCarrierInfoManager.getGsmSimpleSimAuthResponse(invalidRequests, config)); } @Test @@ -640,7 +637,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 +655,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 +665,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 +677,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 +697,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 +740,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 +754,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 +768,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 +783,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 +798,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 +814,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 +835,7 @@ public class TelephonyUtilTest extends WifiBaseTest { WifiEnterpriseConfig.Eap.AKA, WifiEnterpriseConfig.Phase2.NONE); assertEquals(expectedIdentity, - mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config)); + mWifiCarrierInfoManager.getAnonymousIdentityWith3GppRealm(config)); } /** @@ -850,7 +847,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 +861,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 +872,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 +894,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 +907,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 +923,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 +934,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 +947,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 +964,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 +977,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 +990,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 +1001,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 +1010,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 +1024,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 +1034,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 +1054,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 +1070,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 +1081,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 +1091,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 +1108,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 +1121,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 +1138,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 +1150,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 +1169,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 +1187,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 +1203,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 +1219,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 +1232,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 +1248,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 +1264,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 +1280,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 +1296,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 +1306,7 @@ public class TelephonyUtilTest extends WifiBaseTest { method, WifiEnterpriseConfig.Phase2.NONE); assertEquals(expectedIdentity, - mTelephonyUtil.getAnonymousIdentityWith3GppRealm(config)); + mWifiCarrierInfoManager.getAnonymousIdentityWith3GppRealm(config)); } /** @@ -1339,11 +1339,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 +1354,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 +1375,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 +1392,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 +1400,17 @@ 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)); } } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java index 94586073e..25326e5e8 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, mock(FrameworkFacade.class), mock(Context.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..66e0da855 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java @@ -80,7 +80,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; @@ -141,7 +140,8 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { 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; @@ -267,7 +267,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 +275,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); @@ -1093,7 +1094,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); @@ -3100,7 +3101,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 +3215,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 +3238,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 +3261,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 +3284,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 +3320,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()); @@ -3564,11 +3565,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { */ @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); WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork( WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE); WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( @@ -3621,11 +3623,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { */ @Test public void testSendImsiProtectionNotificationOnUserDisallowed() { - 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); WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork( WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE); WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( @@ -3670,10 +3673,10 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest { .setHasUserApprovedImsiPrivacyExemptionForCarrier(false, TEST_CARRIER_ID); verifyNoMoreInteractions(mNotificationManger); // Now carrier upgrade to support Imsi protection - 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.requiresImsiEncryption(TEST_SUBID)).thenReturn(true); + when(mWifiCarrierInfoManager.getMatchingSubId(TEST_CARRIER_ID)).thenReturn(TEST_SUBID); + when(mWifiCarrierInfoManager.requiresImsiEncryption(TEST_SUBID)).thenReturn(true); WifiConfiguration eapSimConfig = WifiConfigurationTestUtil.createEapNetwork( WifiEnterpriseConfig.Eap.SIM, WifiEnterpriseConfig.Phase2.NONE); WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion( 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..aba3176a3 100644 --- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointManagerTest.java @@ -92,6 +92,7 @@ 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; @@ -108,7 +109,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 +204,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 +226,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, mock(FrameworkFacade.class), mock(Context.class), + 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 +243,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 +400,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 +643,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 +785,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 +847,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 +874,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 +918,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 +955,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 +976,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 +998,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 +1605,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 +1962,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 +2005,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 +2075,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 +2122,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 +2155,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 +2176,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 +2208,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 +2233,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 +2413,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 +2432,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 +2449,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 +2471,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 +2495,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); |