Merge "Wrap subManager creation with createForAllProfiles" into main

This commit is contained in:
Ling Ma
2024-01-23 18:03:11 +00:00
committed by Android (Google) Code Review
15 changed files with 34 additions and 38 deletions

View File

@@ -49,7 +49,8 @@ class OpenNetworkSelectPagePreferenceControllerTest {
}
private val mockSubscriptionManager = mock<SubscriptionManager> {
on { activeSubscriptionInfoList } doAnswer { listOf(subscriptionInfo) }
on { createForAllUserProfiles() } doReturn mock
on { getActiveSubscriptionInfo(SUB_ID) } doReturn subscriptionInfo
}
private val context: Context = spy(ApplicationProvider.getApplicationContext()) {

View File

@@ -77,6 +77,7 @@ public class ActiveSubscriptionsListenerTest {
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
doReturn(mSubscriptionManager).when(mSubscriptionManager).createForAllUserProfiles();
mActiveSubscriptions = new ArrayList<SubscriptionInfo>();
addMockSubscription(SUB_ID1);

View File

@@ -77,6 +77,7 @@ public class UiccSlotUtilTest {
when(mTelephonyManager.getUiccCardsInfo()).thenReturn(mUiccCardInfo);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
when(mSubscriptionManager.getAllSubscriptionInfoList()).thenReturn(mSubscriptionInfoList);
}

View File

@@ -113,6 +113,7 @@ public class MobileNetworkUtilsTest {
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID_1)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID_2)).thenReturn(mTelephonyManager2);

View File

@@ -37,7 +37,6 @@ import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.FeatureFlagUtils;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceManager;
@@ -100,6 +99,7 @@ public class NetworkProviderWifiCallingGroupTest {
when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(
mCarrierConfigManager);
when(mContext.getSystemService(SubscriptionManager.class)).thenReturn(mSubscriptionManager);
when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
when(mContext.getSystemService(TelecomManager.class)).thenReturn(mTelecomManager);
when(mContext.getSystemService(TelephonyManager.class)).thenReturn(mTelephonyManager);
when(mTelephonyManager.createForSubscriptionId(SUB_ID)).thenReturn(mTelephonyManager);

View File

@@ -55,6 +55,7 @@ public class TelephonyBasePreferenceControllerTest {
mContext = spy(ApplicationProvider.getApplicationContext());
when(mContext.getSystemService(SubscriptionManager.class))
.thenReturn(mSubscriptionManager);
when(mSubscriptionManager.createForAllUserProfiles()).thenReturn(mSubscriptionManager);
when(mSubscriptionInfo.getSubscriptionId()).thenReturn(VALID_SUB_ID);
mPreferenceController = new TestPreferenceController(mContext, "prefKey");
}