Merge "Implementation for getPhoneAccountHandleForSubscriptionId method."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0028e63..69f9cf0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -89,6 +89,7 @@
     <protected-broadcast android:name= "android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED" />
     <protected-broadcast android:name= "android.telephony.action.SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED" />
     <protected-broadcast android:name= "android.telephony.action.NETWORK_COUNTRY_CHANGED" />
+    <protected-broadcast android:name= "android.telephony.action.PRIMARY_SUBSCRIPTION_LIST_CHANGED" />
 
     <!-- For Vendor Debugging in Telephony -->
     <protected-broadcast android:name="android.telephony.action.ANOMALY_REPORTED" />
@@ -119,6 +120,7 @@
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
     <uses-permission android:name="android.permission.STATUS_BAR" />
+    <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
     <uses-permission android:name="android.permission.RECEIVE_SMS" />
     <uses-permission android:name="android.permission.READ_SMS" />
     <uses-permission android:name="android.permission.WRITE_SMS" />
diff --git a/res/layout/emergency_dialer.xml b/res/layout/emergency_dialer.xml
index 491b661..6247379 100644
--- a/res/layout/emergency_dialer.xml
+++ b/res/layout/emergency_dialer.xml
@@ -66,25 +66,6 @@
             android:layout_gravity="bottom"
             android:orientation="vertical">
 
-            <!--Emergency dialer shortcuts implement EmergencyInfoGroup to replace
-            EmergencyActionGroup. Using a title to indicate the dialpad is emergency calls only.-->
-            <FrameLayout
-                android:id="@+id/emergency_dialpad_title_container"
-                android:layout_height="64dp"
-                android:layout_width="match_parent"
-                android:layout_marginTop="16dp"
-                android:layout_marginBottom="24dp"
-                android:visibility="gone">
-                <TextView
-                    android:id="@+id/emergency_dialpad_title"
-                    android:layout_height="wrap_content"
-                    android:layout_width="wrap_content"
-                    android:layout_gravity="center"
-                    android:textStyle="bold"
-                    android:maxLines="1"
-                    android:text="@string/emergency_dialpad_title"/>
-            </FrameLayout>
-
             <!-- FrameLayout -->
             <com.android.phone.EmergencyActionGroup
                 android:id="@+id/emergency_action_group"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e4588c2..011f7cf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1152,8 +1152,6 @@
     <string name="emergency_information_confirm_hint">Tap again to view info</string>
     <!-- Dialog title for the "radio enable" UI for emergency calls -->
     <string name="emergency_enable_radio_dialog_title">Emergency call</string>
-    <!-- Title for the emergency dialpad UI -->
-    <string name="emergency_dialpad_title">Emergency calls only</string>
     <!-- Emergency dialer: Title of single emergency shortcut button -->
     <string name="single_emergency_number_title">Emergency number</string>
     <!-- Emergency dialer: Title of numerous emergency shortcut buttons -->
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 6a3e928..061efef 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -48,6 +48,7 @@
 import android.telephony.CarrierConfigManager;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.util.LocalLog;
 import android.util.Log;
 
 import com.android.internal.telephony.ICarrierConfigLoader;
@@ -104,6 +105,8 @@
     private final BroadcastReceiver mBootReceiver = new ConfigLoaderBroadcastReceiver();
     // Broadcast receiver for SIM and pkg intents, register intent filter in constructor.
     private final BroadcastReceiver mPackageReceiver = new ConfigLoaderBroadcastReceiver();
+    private final LocalLog mCarrierConfigLoadingLog = new LocalLog(50);
+
 
     // Message codes; see mHandler below.
     // Request from SubscriptionInfoUpdater when SIM becomes absent or error.
@@ -243,6 +246,8 @@
                             broadcastConfigChangedIntent(phoneId);
                             // TODO: We *must* call unbindService even if bindService returns false.
                             // (And possibly if SecurityException was thrown.)
+                            loge("binding to default app: "
+                                    + mPlatformCarrierConfigPackage + " fails");
                         }
                     }
                     break;
@@ -291,8 +296,12 @@
                         ICarrierService carrierService =
                                 ICarrierService.Stub.asInterface(conn.service);
                         carrierService.getCarrierConfig(carrierId, resultReceiver);
+                        logWithLocalLog("fetch config for default app: "
+                                + mPlatformCarrierConfigPackage
+                                + " carrierid: " + carrierId.toString());
                     } catch (RemoteException e) {
-                        loge("Failed to get carrier config: " + e.toString());
+                        loge("Failed to get carrier config from default app: " +
+                                mPlatformCarrierConfigPackage + " err: " + e.toString());
                         mContext.unbindService(conn);
                         break; // So we don't set a timeout.
                     }
@@ -310,6 +319,7 @@
                     mContext.unbindService(mServiceConnection[phoneId]);
                     removeMessages(EVENT_FETCH_DEFAULT_TIMEOUT);
                     broadcastConfigChangedIntent(phoneId);
+                    loge("bind/fetch time out from " + mPlatformCarrierConfigPackage);
                     break;
                 }
 
@@ -359,6 +369,7 @@
                         } else {
                             // Send broadcast if bind fails.
                             broadcastConfigChangedIntent(phoneId);
+                            loge("bind to carrier app: " + carrierPackageName + " fails");
                         }
                     }
                     break;
@@ -388,7 +399,8 @@
                                     removeMessages(EVENT_FETCH_CARRIER_TIMEOUT);
                                     if (resultCode == RESULT_ERROR || resultData == null) {
                                         // On error, abort config fetching.
-                                        loge("Failed to get carrier config");
+                                        loge("Failed to get carrier config from carrier app: "
+                                                + getCarrierPackageForPhoneId(phoneId));
                                         broadcastConfigChangedIntent(phoneId);
                                         return;
                                     }
@@ -407,6 +419,9 @@
                         ICarrierService carrierService =
                                 ICarrierService.Stub.asInterface(conn.service);
                         carrierService.getCarrierConfig(carrierId, resultReceiver);
+                        logWithLocalLog("fetch config for carrier app: "
+                                + getCarrierPackageForPhoneId(phoneId)
+                                + " carrierid: " + carrierId.toString());
                     } catch (RemoteException e) {
                         loge("Failed to get carrier config: " + e.toString());
                         mContext.unbindService(conn);
@@ -426,6 +441,7 @@
                     mContext.unbindService(mServiceConnection[phoneId]);
                     removeMessages(EVENT_FETCH_CARRIER_TIMEOUT);
                     broadcastConfigChangedIntent(phoneId);
+                    loge("bind/fetch from carrier app timeout");
                     break;
                 }
 
@@ -525,7 +541,8 @@
     private void broadcastConfigChangedIntent(int phoneId, boolean addSubIdExtra) {
         Intent intent = new Intent(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
         intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT |
-                Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+                Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND |
+                Intent.FLAG_RECEIVER_FOREGROUND);
         // Include subId/carrier id extra only if SIM records are loaded
         TelephonyManager telephonyManager = TelephonyManager.from(mContext);
         int simApplicationState = telephonyManager.getSimApplicationState();
@@ -543,7 +560,7 @@
 
     /** Binds to the default or carrier config app. */
     private boolean bindToConfigPackage(String pkgName, int phoneId, int eventId) {
-        log("Binding to " + pkgName + " for phone " + phoneId);
+        logWithLocalLog("Binding to " + pkgName + " for phone " + phoneId);
         Intent carrierService = new Intent(CarrierService.CARRIER_SERVICE_INTERFACE);
         carrierService.setPackage(pkgName);
         mServiceConnection[phoneId] = new CarrierServiceConnection(phoneId, eventId);
@@ -654,7 +671,7 @@
     private void saveConfigToXml(String packageName, int phoneId, PersistableBundle config) {
         if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
                 != TelephonyManager.SIM_STATE_LOADED) {
-            log("Skip save config because SIM records are not loaded.");
+            loge("Skip save config because SIM records are not loaded.");
             return;
         }
 
@@ -679,6 +696,8 @@
             return;
         }
 
+        logWithLocalLog("save config to xml, packagename: " + packageName + " phoneId: " + phoneId);
+
         FileOutputStream outFile = null;
         try {
             outFile = new FileOutputStream(
@@ -729,7 +748,7 @@
         }
         if (SubscriptionManager.getSimStateForSlotIndex(phoneId)
                 != TelephonyManager.SIM_STATE_LOADED) {
-            log("Skip restoring config because SIM records are not yet loaded.");
+            loge("Skip restoring config because SIM records are not yet loaded.");
             return null;
         }
 
@@ -755,7 +774,7 @@
                 if (event == XmlPullParser.START_TAG && TAG_VERSION.equals(parser.getName())) {
                     String savedVersion = parser.nextText();
                     if (!version.equals(savedVersion)) {
-                        log("Saved version mismatch: " + version + " vs " + savedVersion);
+                        loge("Saved version mismatch: " + version + " vs " + savedVersion);
                         break;
                     }
                 }
@@ -973,6 +992,9 @@
             pw.println("");
             printConfig(mOverrideConfigs[i], pw, "mOverrideConfigs");
         }
+
+        pw.println("CarrierConfigLoadingLog=");
+        mCarrierConfigLoadingLog.dump(fd, pw, args);
     }
 
     private void printConfig(PersistableBundle configApp, PrintWriter pw, String name) {
@@ -1052,11 +1074,17 @@
         }
     }
 
-    private static void log(String msg) {
+    private void log(String msg) {
         Log.d(LOG_TAG, msg);
     }
 
-    private static void loge(String msg) {
+    private void logWithLocalLog(String msg) {
+        Log.d(LOG_TAG, msg);
+        mCarrierConfigLoadingLog.log(msg);
+    }
+
+    private void loge(String msg) {
         Log.e(LOG_TAG, msg);
+        mCarrierConfigLoadingLog.log(msg);
     }
 }
diff --git a/src/com/android/phone/EmergencyDialer.java b/src/com/android/phone/EmergencyDialer.java
index 38eb40d..812aac4 100644
--- a/src/com/android/phone/EmergencyDialer.java
+++ b/src/com/android/phone/EmergencyDialer.java
@@ -1111,13 +1111,6 @@
 
         mEmergencyInfoGroup.setOnConfirmClickListener(this);
 
-        // EmergencyActionGroup is replaced by EmergencyInfoGroup.
-        mEmergencyActionGroup.setVisibility(View.GONE);
-
-        // Setup dialpad title.
-        final View emergencyDialpadTitle = findViewById(R.id.emergency_dialpad_title_container);
-        emergencyDialpadTitle.setVisibility(View.VISIBLE);
-
         mEmergencyShortcutButtonList = new ArrayList<>();
         setupEmergencyCallShortcutButton();
 
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 94cd0f6..fed41b0 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -226,7 +226,8 @@
                     // Marks the event where the SIM goes into ready state.
                     // Right now, this is only used for the PUK-unlocking
                     // process.
-                    if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)) {
+                    if (msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_READY)
+                            || msg.obj.equals(IccCardConstants.INTENT_VALUE_ICC_LOADED)) {
                         // when the right event is triggered and there
                         // are UI objects in the foreground, we close
                         // them to display the lock panel.
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 0f7fcb3..cbda21b 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -75,6 +75,7 @@
 import android.telephony.PhoneCapability;
 import android.telephony.PhoneNumberRange;
 import android.telephony.RadioAccessFamily;
+import android.telephony.RadioAccessSpecifier;
 import android.telephony.Rlog;
 import android.telephony.ServiceState;
 import android.telephony.SignalStrength;
@@ -83,6 +84,7 @@
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyHistogram;
 import android.telephony.TelephonyManager;
+import android.telephony.TelephonyScanManager;
 import android.telephony.UiccCardInfo;
 import android.telephony.UiccSlotInfo;
 import android.telephony.UssdResponse;
@@ -4424,7 +4426,6 @@
             IBinder binder, String callingPackage) {
         TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
                 mApp, subId, "requestNetworkScan");
-
         LocationAccessPolicy.LocationPermissionResult locationResult =
                 LocationAccessPolicy.checkLocationPermission(mApp,
                         new LocationAccessPolicy.LocationPermissionQuery.Builder()
@@ -4434,18 +4435,51 @@
                                 .setMethod("requestNetworkScan")
                                 .setMinSdkVersionForFine(Build.VERSION_CODES.Q)
                                 .build());
-        switch (locationResult) {
-            case DENIED_HARD:
-                throw new SecurityException("Not allowed to request network scan -- location");
-            case DENIED_SOFT:
-                return -1;
+        if (locationResult != LocationAccessPolicy.LocationPermissionResult.ALLOWED) {
+            SecurityException e = checkNetworkRequestForSanitizedLocationAccess(request);
+            if (e != null) {
+                if (locationResult == LocationAccessPolicy.LocationPermissionResult.DENIED_HARD) {
+                    throw e;
+                } else {
+                    loge(e.getMessage());
+                    return TelephonyScanManager.INVALID_SCAN_ID;
+                }
+            }
         }
-
         return mNetworkScanRequestTracker.startNetworkScan(
                 request, messenger, binder, getPhone(subId),
                 callingPackage);
     }
 
+    private SecurityException checkNetworkRequestForSanitizedLocationAccess(
+            NetworkScanRequest request) {
+        if (mApp.checkCallingOrSelfPermission(android.Manifest.permission.NETWORK_SCAN)
+                != PERMISSION_GRANTED) {
+            return new SecurityException("permission.NETWORK_SCAN is needed for network scans"
+                    + " without location access.");
+        }
+
+        if (request.getSpecifiers() != null && request.getSpecifiers().length > 0) {
+            for (RadioAccessSpecifier ras : request.getSpecifiers()) {
+                if (ras.getChannels() != null && ras.getChannels().length > 0) {
+                    return new SecurityException("Specific channels must not be"
+                            + " scanned without location access.");
+                }
+            }
+        }
+
+        List<String> allowedMccMncs =
+                NetworkScanRequestTracker.getAllowedMccMncsForLocationRestrictedScan(mApp);
+        for (String mccmnc : request.getPlmns()) {
+            if (!allowedMccMncs.contains(mccmnc)) {
+                return new SecurityException("Requested mccmnc " + mccmnc + " is not known to the"
+                        + " device and cannot be scanned for without location access.");
+            }
+        }
+
+        return null;
+    }
+
     /**
      * Stops an existing network scan with the given scanId.
      *
@@ -6174,11 +6208,12 @@
      */
     @Override
     public boolean isDataRoamingEnabled(int subId) {
+        mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE,
+                null /* message */);
+
         boolean isEnabled = false;
         final long identity = Binder.clearCallingIdentity();
         try {
-            mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE,
-                    null /* message */);
             Phone phone = getPhone(subId);
             isEnabled =  phone != null ? phone.getDataRoamingEnabled() : false;
         } catch (Exception e) {
@@ -6203,11 +6238,11 @@
      */
     @Override
     public void setDataRoamingEnabled(int subId, boolean isEnabled) {
+        TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
+                mApp, subId, "setDataRoamingEnabled");
+
         final long identity = Binder.clearCallingIdentity();
         try {
-            TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
-                    mApp, subId, "setDataRoamingEnabled");
-
             Phone phone = getPhone(subId);
             if (phone != null) {
                 phone.setDataRoamingEnabled(isEnabled);
@@ -6219,11 +6254,12 @@
 
     @Override
     public boolean isManualNetworkSelectionAllowed(int subId) {
+        TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
+                mApp, subId, "isManualNetworkSelectionAllowed");
+
         boolean isAllowed = true;
         final long identity = Binder.clearCallingIdentity();
         try {
-            TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
-                    mApp, subId, "isManualNetworkSelectionAllowed");
             Phone phone = getPhone(subId);
             if (phone != null) {
                 isAllowed = phone.isCspPlmnEnabled();
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 956e0e2..a59c9c4 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -163,10 +163,10 @@
         pw.println("    Add(-a), Clear(-c), Print (-p) or Remove(-r) the emergency number list in"
                 + " the test mode");
         pw.println("      -a <emergency number address>: add an emergency number address for the"
-                + " test mode, only allows '0'-'9', '*', or '#'.");
+                + " test mode, only allows '0'-'9', '*', '#' or '+'.");
         pw.println("      -c: clear the emergency number list in the test mode.");
         pw.println("      -r <emergency number address>: remove an existing emergency number"
-                + " address added by the test mode, only allows '0'-'9', '*', or '#'.");
+                + " address added by the test mode, only allows '0'-'9', '*', '#' or '+'.");
         pw.println("      -p: get the full emergency number list in the test mode.");
     }
 
@@ -208,7 +208,7 @@
                 String emergencyNumberCmd = getNextArgRequired();
                 if (emergencyNumberCmd == null
                         || !EmergencyNumber.validateEmergencyNumberAddress(emergencyNumberCmd)) {
-                    errPw.println("An emergency number (only allow '0'-'9', '*', or '#') needs"
+                    errPw.println("An emergency number (only allow '0'-'9', '*', '#' or '+') needs"
                             + " to be specified after -a in the command ");
                     return -1;
                 }
@@ -243,7 +243,7 @@
                 String emergencyNumberCmd = getNextArgRequired();
                 if (emergencyNumberCmd == null
                         || !EmergencyNumber.validateEmergencyNumberAddress(emergencyNumberCmd)) {
-                    errPw.println("An emergency number (only allow '0'-'9', '*', or '#') needs"
+                    errPw.println("An emergency number (only allow '0'-'9', '*', '#' or '+') needs"
                             + " to be specified after -r in the command ");
                     return -1;
                 }
diff --git a/tests/Android.mk b/tests/Android.mk
index 2fde21a..44bf176 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -31,9 +31,9 @@
 LOCAL_INSTRUMENTATION_FOR := TeleService
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
-        android-support-test \
+        androidx.test.rules \
         mockito-target-minus-junit4 \
-        espresso-core \
+        androidx.test.espresso.core \
         truth-prebuilt
 
 LOCAL_COMPATIBILITY_SUITE := device-tests
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 0aa5be2..d434650 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -53,14 +53,14 @@
     <!--
         To run all tests:
             adb shell am instrument -w
-                com.android.phone.tests/android.support.test.runner.AndroidJUnitRunner
+                com.android.phone.tests/androidx.test.runner.AndroidJUnitRunner
 
         To run a single class test:
             adb shell am instrument -e class com.android.phone.unit.FooUnitTest
-                -w com.android.phone.tests/android.support.test.runner.AndroidJUnitRunner
+                -w com.android.phone.tests/androidx.test.runner.AndroidJUnitRunner
 
     -->
-    <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+    <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
         android:targetPackage="com.android.phone"
         android:label="Phone application tests." />
 </manifest>
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index cf757b4..4188ee2 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -24,7 +24,7 @@
     <option name="test-tag" value="TeleServiceTests" />
     <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
         <option name="package" value="com.android.phone.tests" />
-        <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
         <option name="hidden-api-checks" value="false"/>
     </test>
 </configuration>
diff --git a/tests/src/com/android/TelephonyTestBase.java b/tests/src/com/android/TelephonyTestBase.java
index 7b7bef2..d30ae6b 100644
--- a/tests/src/com/android/TelephonyTestBase.java
+++ b/tests/src/com/android/TelephonyTestBase.java
@@ -19,9 +19,10 @@
 import android.content.Context;
 import android.os.Handler;
 import android.os.Looper;
-import android.support.test.InstrumentationRegistry;
 import android.util.Log;
 
+import androidx.test.InstrumentationRegistry;
+
 import org.mockito.MockitoAnnotations;
 
 import java.util.concurrent.CountDownLatch;
diff --git a/tests/src/com/android/phone/CallFeaturesSettingTest.java b/tests/src/com/android/phone/CallFeaturesSettingTest.java
index 816642a..78d68e3 100644
--- a/tests/src/com/android/phone/CallFeaturesSettingTest.java
+++ b/tests/src/com/android/phone/CallFeaturesSettingTest.java
@@ -15,16 +15,16 @@
  */
 package com.android.phone;
 
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
+import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
+import static androidx.test.espresso.assertion.ViewAssertions.matches;
+import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static androidx.test.espresso.matcher.ViewMatchers.withText;
 
 import static org.mockito.Mockito.when;
 
-import android.support.test.filters.FlakyTest;
-import android.support.test.rule.ActivityTestRule;
+import androidx.test.filters.FlakyTest;
+import androidx.test.rule.ActivityTestRule;
 
 import com.android.internal.telephony.IccCard;
 import com.android.internal.telephony.Phone;
diff --git a/tests/src/com/android/phone/CdmaOptionsTest.java b/tests/src/com/android/phone/CdmaOptionsTest.java
index c0c6317..1a1516c 100644
--- a/tests/src/com/android/phone/CdmaOptionsTest.java
+++ b/tests/src/com/android/phone/CdmaOptionsTest.java
@@ -18,9 +18,10 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import android.os.PersistableBundle;
-import android.support.test.runner.AndroidJUnit4;
 import android.telephony.CarrierConfigManager;
 
+import androidx.test.runner.AndroidJUnit4;
+
 import com.android.internal.telephony.PhoneConstants;
 
 import org.junit.Test;
diff --git a/tests/src/com/android/phone/PhoneSearchIndexablesProviderTest.java b/tests/src/com/android/phone/PhoneSearchIndexablesProviderTest.java
index 34e3937..b655f3b 100644
--- a/tests/src/com/android/phone/PhoneSearchIndexablesProviderTest.java
+++ b/tests/src/com/android/phone/PhoneSearchIndexablesProviderTest.java
@@ -28,9 +28,10 @@
 import android.os.UserManager;
 import android.provider.SearchIndexablesContract;
 import android.provider.Settings;
-import android.support.test.runner.AndroidJUnit4;
 import android.telephony.euicc.EuiccManager;
 
+import androidx.test.runner.AndroidJUnit4;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/tests/src/com/android/phone/RoamingDialogFragmentTest.java b/tests/src/com/android/phone/RoamingDialogFragmentTest.java
index 62633e0..a9b32ea 100644
--- a/tests/src/com/android/phone/RoamingDialogFragmentTest.java
+++ b/tests/src/com/android/phone/RoamingDialogFragmentTest.java
@@ -15,31 +15,34 @@
  */
 package com.android.phone;
 
+import static androidx.test.espresso.Espresso.onData;
+import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.action.ViewActions.click;
+import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
+import static androidx.test.espresso.assertion.ViewAssertions.matches;
+import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
+import static androidx.test.espresso.matcher.ViewMatchers.isChecked;
+import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
+import static androidx.test.espresso.matcher.ViewMatchers.withText;
+
+import static com.google.common.truth.Truth.assertThat;
+
 import android.app.Activity;
 import android.content.pm.ActivityInfo;
 import android.provider.Settings.Global;
 import android.provider.Settings.SettingNotFoundException;
-import android.support.test.espresso.matcher.PreferenceMatchers;
-import android.support.test.rule.ActivityTestRule;
-import android.support.test.filters.FlakyTest;
-import com.google.common.truth.Truth;
+
+import androidx.test.espresso.matcher.PreferenceMatchers;
+import androidx.test.filters.FlakyTest;
+import androidx.test.rule.ActivityTestRule;
+
 import junit.framework.AssertionFailedError;
+
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
-import static android.support.test.espresso.Espresso.onData;
-import static android.support.test.espresso.Espresso.onView;
-import static android.support.test.espresso.action.ViewActions.click;
-import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
-import static android.support.test.espresso.assertion.ViewAssertions.matches;
-import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
-import static android.support.test.espresso.matcher.ViewMatchers.isChecked;
-import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
-import static android.support.test.espresso.matcher.ViewMatchers.withId;
-import static android.support.test.espresso.matcher.ViewMatchers.withText;
-import static com.google.common.truth.Truth.assertThat;
-
 /**
  * Espresso tests to check some properties of the dialog that appears when a user
  * tries to turn on data roaming.
diff --git a/tests/src/com/android/phone/ecc/EccDataTest.java b/tests/src/com/android/phone/ecc/EccDataTest.java
index 8f4abc5..911d3c5 100644
--- a/tests/src/com/android/phone/ecc/EccDataTest.java
+++ b/tests/src/com/android/phone/ecc/EccDataTest.java
@@ -18,8 +18,8 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
 
 import com.android.TelephonyTestBase;
 import com.android.phone.ecc.nano.ProtobufEccData;
diff --git a/tests/src/com/android/phone/euicc/EuiccUiDispatcherActivityTest.java b/tests/src/com/android/phone/euicc/EuiccUiDispatcherActivityTest.java
index 57df097..b8f2ec1 100644
--- a/tests/src/com/android/phone/euicc/EuiccUiDispatcherActivityTest.java
+++ b/tests/src/com/android/phone/euicc/EuiccUiDispatcherActivityTest.java
@@ -23,10 +23,11 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
 import android.telephony.euicc.EuiccManager;
 
+import androidx.test.InstrumentationRegistry;
+import androidx.test.runner.AndroidJUnit4;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/tests/src/com/android/phone/tests/CallForwardInfoTest.java b/tests/src/com/android/phone/tests/CallForwardInfoTest.java
index acf5955..064a06e 100644
--- a/tests/src/com/android/phone/tests/CallForwardInfoTest.java
+++ b/tests/src/com/android/phone/tests/CallForwardInfoTest.java
@@ -16,17 +16,18 @@
 
 package com.android.phone.tests;
 
-import android.support.test.runner.AndroidJUnit4;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
 import android.telephony.PhoneNumberUtils;
 
+import androidx.test.runner.AndroidJUnit4;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.Locale;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
 /**
  * Tests Related to CallForwardInfoTest
  */
diff --git a/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java b/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
index 73fe0af..f404945 100644
--- a/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
+++ b/tests/src/com/android/services/telephony/ConferenceParticipantConnectionTest.java
@@ -16,17 +16,17 @@
 
 package com.android.services.telephony;
 
+import static com.android.services.telephony.ConferenceParticipantConnection.getParticipantAddress;
+
+import static org.junit.Assert.assertEquals;
+
 import android.net.Uri;
-import android.support.test.runner.AndroidJUnit4;
-import android.telecom.Conference;
-import android.telecom.ConferenceParticipant;
+
+import androidx.test.runner.AndroidJUnit4;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import static com.android.services.telephony.ConferenceParticipantConnection.getParticipantAddress;
-import static org.junit.Assert.assertEquals;
-
 /**
  * Tests proper parsing of conference event package participant addresses.
  */
diff --git a/tests/src/com/android/services/telephony/HoldTrackerTest.java b/tests/src/com/android/services/telephony/HoldTrackerTest.java
index 0db10e4..772a1a2 100644
--- a/tests/src/com/android/services/telephony/HoldTrackerTest.java
+++ b/tests/src/com/android/services/telephony/HoldTrackerTest.java
@@ -20,9 +20,10 @@
 import static junit.framework.Assert.assertTrue;
 
 import android.content.ComponentName;
-import android.support.test.runner.AndroidJUnit4;
 import android.telecom.PhoneAccountHandle;
 
+import androidx.test.runner.AndroidJUnit4;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
index d9de2e8..8b46bf0 100644
--- a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
+++ b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
@@ -28,10 +28,11 @@
 
 import android.os.AsyncResult;
 import android.os.Handler;
-import android.support.test.runner.AndroidJUnit4;
 import android.telephony.ServiceState;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import androidx.test.runner.AndroidJUnit4;
+
 import com.android.TelephonyTestBase;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index a18adb8..1329a77 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -32,8 +32,6 @@
 import android.os.AsyncResult;
 import android.os.Bundle;
 import android.os.Handler;
-import android.support.test.filters.FlakyTest;
-import android.support.test.runner.AndroidJUnit4;
 import android.telecom.DisconnectCause;
 import android.telecom.TelecomManager;
 import android.telephony.RadioAccessFamily;
@@ -41,6 +39,9 @@
 import android.telephony.TelephonyManager;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import androidx.test.filters.FlakyTest;
+import androidx.test.runner.AndroidJUnit4;
+
 import com.android.TelephonyTestBase;
 import com.android.internal.telephony.CallStateException;
 import com.android.internal.telephony.Connection;