Merge "[Settings] Replace #getSubscriberId(I) with #getSubscriberId()"
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 753e924..68ad98c 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -457,10 +457,6 @@
         <item>1xRTT</item>
         <item>IS95B</item>
         <item>IS95A</item>
-        <item>GSM</item>
-        <item>TD_SCDMA</item>
-        <item>IWLAN</item>
-        <item>LTE_CA</item>
         <item>NR</item>
     </string-array>
 
@@ -498,14 +494,6 @@
         <!-- Do not translate. -->
         <item>4</item>
         <!-- Do not translate. -->
-        <item>16</item>
-        <!-- Do not translate. -->
-        <item>17</item>
-        <!-- Do not translate. -->
-        <item>18</item>
-        <!-- Do not translate. -->
-        <item>19</item>
-        <!-- Do not translate. -->
         <item>20</item>
     </string-array>
 
diff --git a/src/com/android/settings/network/MobileDataContentObserver.java b/src/com/android/settings/network/MobileDataContentObserver.java
index 15e726f..0aab75f 100644
--- a/src/com/android/settings/network/MobileDataContentObserver.java
+++ b/src/com/android/settings/network/MobileDataContentObserver.java
@@ -39,7 +39,7 @@
     public static Uri getObservableUri(Context context, int subId) {
         Uri uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA);
         TelephonyManager telephonyManager = context.getSystemService(TelephonyManager.class);
-        if (telephonyManager.getSimCount() != 1) {
+        if (telephonyManager.getActiveModemCount() != 1) {
             uri = Settings.Global.getUriFor(Settings.Global.MOBILE_DATA + subId);
         }
         return uri;
diff --git a/src/com/android/settings/network/telephony/EuiccPreferenceController.java b/src/com/android/settings/network/telephony/EuiccPreferenceController.java
index ecd20ed..68f4370 100644
--- a/src/com/android/settings/network/telephony/EuiccPreferenceController.java
+++ b/src/com/android/settings/network/telephony/EuiccPreferenceController.java
@@ -50,7 +50,8 @@
 
     public void init(int subId) {
         mSubId = subId;
-        mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
+        mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
+                .createForSubscriptionId(mSubId);
     }
 
     @Override
diff --git a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
index f18340a..daee6ab 100644
--- a/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
+++ b/src/com/android/settings/network/telephony/MobileDataPreferenceController.java
@@ -145,7 +145,7 @@
     @VisibleForTesting
     boolean isDialogNeeded() {
         final boolean enableData = !isChecked();
-        final boolean isMultiSim = (mTelephonyManager.getSimCount() > 1);
+        final boolean isMultiSim = (mTelephonyManager.getActiveModemCount() > 1);
         final int defaultSubId = mSubscriptionManager.getDefaultDataSubscriptionId();
         final boolean needToDisableOthers = mSubscriptionManager
                 .isActiveSubscriptionId(defaultSubId) && defaultSubId != mSubId;
diff --git a/src/com/android/settings/sim/CallsSimListDialogFragment.java b/src/com/android/settings/sim/CallsSimListDialogFragment.java
index 7d3de44..6dd262b 100644
--- a/src/com/android/settings/sim/CallsSimListDialogFragment.java
+++ b/src/com/android/settings/sim/CallsSimListDialogFragment.java
@@ -47,8 +47,7 @@
             return result;
         }
         for (PhoneAccountHandle handle : phoneAccounts) {
-            final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
-            final int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount);
+            final int subId = telephonyManager.getSubscriptionId(handle);
 
             if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
                 continue;
diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java
index d24dbf5..0ae294e 100644
--- a/src/com/android/settings/sim/SimDialogActivity.java
+++ b/src/com/android/settings/sim/SimDialogActivity.java
@@ -176,8 +176,7 @@
         final TelephonyManager telephonyManager = getSystemService(TelephonyManager.class);
 
         for (PhoneAccountHandle handle : telecomManager.getCallCapablePhoneAccounts()) {
-            final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(handle);
-            if (subId == telephonyManager.getSubIdForPhoneAccount(phoneAccount)) {
+            if (subId == telephonyManager.getSubscriptionId(handle)) {
                 return handle;
             }
         }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
index e4cf303..bb60fd6 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/EuiccPreferenceControllerTest.java
@@ -18,37 +18,32 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
+import static org.robolectric.Shadows.shadowOf;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.telephony.TelephonyManager;
 import android.telephony.euicc.EuiccManager;
 
 import androidx.preference.Preference;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.Robolectric;
-import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.shadows.ShadowTelephonyManager;
 
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
 public class EuiccPreferenceControllerTest {
     private static final int SUB_ID = 2;
 
-    @Mock
     private TelephonyManager mTelephonyManager;
-
-    @Mock
-    private Activity mActivity;
+    private ShadowTelephonyManager mShadowTelephonyManager;
 
     private EuiccPreferenceController mController;
     private Preference mPreference;
@@ -58,12 +53,14 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = spy(RuntimeEnvironment.application);
-        doReturn(mTelephonyManager).when(mActivity).getSystemService(Context.TELEPHONY_SERVICE);
-        doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
+        mContext = spy(RuntimeEnvironment.application.getBaseContext());
+
+        mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+        mShadowTelephonyManager = shadowOf(mTelephonyManager);
+        mShadowTelephonyManager.setTelephonyManagerForSubscriptionId(SUB_ID, mTelephonyManager);
 
         mPreference = new Preference(mContext);
-        mController = new EuiccPreferenceController(mActivity, "euicc");
+        mController = new EuiccPreferenceController(mContext, "euicc");
         mController.init(SUB_ID);
         mPreference.setKey(mController.getPreferenceKey());
     }
@@ -71,10 +68,10 @@
     @Test
     public void handlePreferenceTreeClick_startActivity() {
         ArgumentCaptor<Intent> captor = ArgumentCaptor.forClass(Intent.class);
+        doNothing().when(mContext).startActivity(captor.capture());
 
         mController.handlePreferenceTreeClick(mPreference);
 
-        verify(mActivity).startActivity(captor.capture());
         assertThat(captor.getValue().getAction()).isEqualTo(
                 EuiccManager.ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS);
     }
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
index 86f2355..1a11c49 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileDataPreferenceControllerTest.java
@@ -99,7 +99,7 @@
         doReturn(true).when(mTelephonyManager).isDataEnabled();
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
-        doReturn(1).when(mTelephonyManager).getSimCount();
+        doReturn(1).when(mTelephonyManager).getActiveModemCount();
 
         assertThat(mController.isDialogNeeded()).isFalse();
     }
@@ -110,7 +110,7 @@
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
         doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(SUB_ID_OTHER);
         ShadowSubscriptionManager.setDefaultDataSubscriptionId(SUB_ID_OTHER);
-        doReturn(2).when(mTelephonyManager).getSimCount();
+        doReturn(2).when(mTelephonyManager).getActiveModemCount();
 
         assertThat(mController.isDialogNeeded()).isTrue();
         assertThat(mController.mDialogType).isEqualTo(
@@ -131,7 +131,7 @@
         doReturn(true).when(mTelephonyManager).isDataEnabled();
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
-        doReturn(1).when(mTelephonyManager).getSimCount();
+        doReturn(1).when(mTelephonyManager).getActiveModemCount();
 
         mController.onPreferenceChange(mPreference, true);
 
@@ -143,7 +143,7 @@
         doReturn(true).when(mTelephonyManager).isDataEnabled();
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getActiveSubscriptionInfo(SUB_ID);
         doReturn(mSubscriptionInfo).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
-        doReturn(2).when(mTelephonyManager).getSimCount();
+        doReturn(2).when(mTelephonyManager).getActiveModemCount();
 
         mController.onPreferenceChange(mPreference, true);