Merge "Bold text string update" into sc-dev
diff --git a/res/layout/preference_labeled_continuous_slider.xml b/res/layout/preference_labeled_continuous_slider.xml
new file mode 100644
index 0000000..00e8796
--- /dev/null
+++ b/res/layout/preference_labeled_continuous_slider.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 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.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:minHeight="?android:attr/listPreferredItemHeight"
+              android:gravity="center_vertical"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:orientation="vertical"
+              android:paddingStart="56dp"
+              android:paddingEnd="8dp"
+              android:paddingTop="16dp"
+              android:paddingBottom="16dp">
+
+    <TextView
+        android:id="@android:id/title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:paddingBottom="16dp"
+        android:layout_marginStart="16dp"
+        android:maxLines="1"
+        android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+        android:textColor="?android:attr/textColorPrimary" />
+
+    <SeekBar
+        android:id="@*android:id/seekbar"
+        android:layout_gravity="center_vertical"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="8dp"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@android:id/text1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="16dp"
+            android:layout_weight="1"
+            android:maxLines="1"
+            android:textAlignment="viewStart"/>
+
+        <TextView
+            android:id="@android:id/text2"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="16dp"
+            android:layout_weight="1"
+            android:maxLines="1"
+            android:textAlignment="viewEnd"/>
+    </LinearLayout>
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 25ec0b6..75884fa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4037,7 +4037,7 @@
     <string name="managed_profile_location_services">Location services for work</string>
 
     <!-- [CHAR LIMIT=60] Location settings screen, screen title -->
-    <string name="location_time_zone_detection_screen_title">Location time zone detection</string>
+    <string name="location_time_zone_detection_screen_title">Use location to set time zone</string>
     <!-- [CHAR LIMIT=50] Location settings screen, title for the setting that control whether the
          device can use its location for time zone detection. -->
     <string name="location_time_zone_detection_enabled_title">Location time zone detection</string>
@@ -4051,7 +4051,7 @@
     <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
          applicable due to other settings like the "automatic time zone detection enabled" setting
          being set to "off". -->
-    <string name="location_time_zone_detection_auto_is_off">Automatic time zone detection is disabled</string>
+    <string name="location_time_zone_detection_auto_is_off">Automatic time zone is off</string>
     <!-- [CHAR LIMIT=NONE] Location settings screen, summary when location time zone detection is not
          applicable for the user for unspecified reasons. More specific messages are used when there
          is a clear reason. -->
@@ -12801,6 +12801,8 @@
     <!-- Alert Dialog text when user didn't input the phone number [CHAR LIMIT=50]-->
     <string name="smart_forwarding_missing_alert_dialog_text">OK</string>
 
-    <!-- Enable 2G: Title for if user wants to enable 2G [CHAR LIMIT=40] -->
+    <!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=40] -->
     <string name="enable_2g_title">Allow 2G</string>
+    <!-- Title for toggle if user wants to enable 2G [CHAR LIMIT=NONE] -->
+    <string name="enable_2g_summary">Use 2G cellular connections. For emergency calls, 2G is always turned on.</string>
 </resources>
diff --git a/res/xml/mobile_network_settings.xml b/res/xml/mobile_network_settings.xml
index 86f5a83..7ab9893 100644
--- a/res/xml/mobile_network_settings.xml
+++ b/res/xml/mobile_network_settings.xml
@@ -258,5 +258,6 @@
     <SwitchPreference
         android:key="enable_2g"
         android:title="@string/enable_2g_title"
+        android:summary="@string/enable_2g_summary"
         settings:controller="com.android.settings.network.telephony.Enable2gPreferenceController" />
 </PreferenceScreen>
diff --git a/res/xml/reduce_bright_colors_settings.xml b/res/xml/reduce_bright_colors_settings.xml
index b9ca854..17e8b02 100644
--- a/res/xml/reduce_bright_colors_settings.xml
+++ b/res/xml/reduce_bright_colors_settings.xml
@@ -17,13 +17,16 @@
 
 <PreferenceScreen
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:persistent="false"
     android:title="@string/reduce_bright_colors_preference_title">
 
-    <com.android.settings.widget.SeekBarPreference
+    <com.android.settings.widget.LabeledContinuousSeekBarPreference
         android:key="rbc_intensity"
         android:persistent="false"
-        android:title="@string/reduce_bright_colors_intensity_preference_title"/>
+        android:title="@string/reduce_bright_colors_intensity_preference_title"
+        settings:textStart="@string/reduce_bright_colors_intensity_preference_start_label"
+        settings:textEnd="@string/reduce_bright_colors_intensity_preference_end_label"/>
 
     <SwitchPreference
         android:key="rbc_persist"
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index ff46722..dde5be1 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -128,8 +128,15 @@
 
     @Override
     protected void initSettingsPreference() {
+        // If the device doesn't support magnification area, it should hide the settings preference.
+        if (!getContext().getResources().getBoolean(
+                com.android.internal.R.bool.config_magnification_area)) {
+            return;
+        }
         mSettingsPreference = new Preference(getPrefContext());
         mSettingsPreference.setTitle(R.string.accessibility_menu_item_settings);
+        // TODO(b/177371954): "magnification area" should be brought up to the highest level of the
+        // settings UI so that it appears below "shortcut" to replace "settings.
         mSettingsPreference.setFragment(MagnificationSettingsFragment.class.getName());
         mSettingsPreference.setPersistent(false);
 
diff --git a/src/com/android/settings/connecteddevice/usb/UsbBackend.java b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
index 4773aca..244818f 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbBackend.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbBackend.java
@@ -28,7 +28,7 @@
 import android.hardware.usb.UsbManager;
 import android.hardware.usb.UsbPort;
 import android.hardware.usb.UsbPortStatus;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
 import android.os.UserHandle;
 import android.os.UserManager;
 
@@ -74,9 +74,8 @@
         mIsAdminUser = userManager.isAdminUser();
 
         mMidiSupported = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI);
-        ConnectivityManager cm =
-                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
-        mTetheringSupported = cm.isTetheringSupported();
+        final TetheringManager tm = context.getSystemService(TetheringManager.class);
+        mTetheringSupported = tm.isTetheringSupported();
 
         updatePorts();
     }
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
index 12e978f..668ec3f 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
@@ -16,14 +16,17 @@
 
 package com.android.settings.connecteddevice.usb;
 
-import static android.net.ConnectivityManager.TETHERING_USB;
+import static android.net.TetheringManager.TETHERING_USB;
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerExecutor;
+import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.preference.PreferenceScreen;
@@ -43,10 +46,13 @@
  * Provides options for selecting the default USB mode.
  */
 public class UsbDefaultFragment extends RadioButtonPickerFragment {
+
+    private static final String TAG = "UsbDefaultFragment";
+
     @VisibleForTesting
     UsbBackend mUsbBackend;
     @VisibleForTesting
-    ConnectivityManager mConnectivityManager;
+    TetheringManager mTetheringManager;
     @VisibleForTesting
     OnStartTetheringCallback mOnStartTetheringCallback = new OnStartTetheringCallback();
     @VisibleForTesting
@@ -57,6 +63,7 @@
     boolean mIsStartTethering = false;
 
     private UsbConnectionBroadcastReceiver mUsbReceiver;
+    private Handler mHandler = new Handler();
 
     @VisibleForTesting
     UsbConnectionBroadcastReceiver.UsbConnectionListener mUsbConnectionListener =
@@ -71,7 +78,7 @@
     public void onAttach(Context context) {
         super.onAttach(context);
         mUsbBackend = new UsbBackend(context);
-        mConnectivityManager = context.getSystemService(ConnectivityManager.class);
+        mTetheringManager = context.getSystemService(TetheringManager.class);
         mUsbReceiver = new UsbConnectionBroadcastReceiver(context, mUsbConnectionListener,
                 mUsbBackend);
         getSettingsLifecycle().addObserver(mUsbReceiver);
@@ -138,9 +145,9 @@
         if (!Utils.isMonkeyRunning()) {
             if (functions == UsbManager.FUNCTION_RNDIS) {
                 // We need to have entitlement check for usb tethering, so use API in
-                // ConnectivityManager.
+                // TetheringManager.
                 mIsStartTethering = true;
-                mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
+                mTetheringManager.startTethering(TETHERING_USB, new HandlerExecutor(mHandler),
                         mOnStartTetheringCallback);
             } else {
                 mIsStartTethering = false;
@@ -159,20 +166,19 @@
     }
 
     @VisibleForTesting
-    final class OnStartTetheringCallback extends
-            ConnectivityManager.OnStartTetheringCallback {
+    final class OnStartTetheringCallback implements
+            TetheringManager.StartTetheringCallback {
 
         @Override
         public void onTetheringStarted() {
-            super.onTetheringStarted();
             // Set default usb functions again to make internal data persistent
             mCurrentFunctions = UsbManager.FUNCTION_RNDIS;
             mUsbBackend.setDefaultUsbFunctions(UsbManager.FUNCTION_RNDIS);
         }
 
         @Override
-        public void onTetheringFailed() {
-            super.onTetheringFailed();
+        public void onTetheringFailed(int error) {
+            Log.w(TAG, "onTetheringFailed() error : " + error);
             mUsbBackend.setDefaultUsbFunctions(mPreviousFunctions);
             updateCandidates();
         }
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 99e9d50..40626fb 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -17,11 +17,12 @@
 package com.android.settings.connecteddevice.usb;
 
 import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
-import static android.net.ConnectivityManager.TETHERING_USB;
 
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
+import android.os.Handler;
+import android.os.HandlerExecutor;
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
@@ -55,7 +56,8 @@
     }
 
     private PreferenceCategory mProfilesContainer;
-    private ConnectivityManager mConnectivityManager;
+    private TetheringManager mTetheringManager;
+    private Handler mHandler = new Handler();
     @VisibleForTesting
     OnStartTetheringCallback mOnStartTetheringCallback;
     @VisibleForTesting
@@ -64,7 +66,7 @@
     public UsbDetailsFunctionsController(Context context, UsbDetailsFragment fragment,
             UsbBackend backend) {
         super(context, fragment, backend);
-        mConnectivityManager = context.getSystemService(ConnectivityManager.class);
+        mTetheringManager = context.getSystemService(TetheringManager.class);
         mOnStartTetheringCallback = new OnStartTetheringCallback();
         mPreviousFunction = mUsbBackend.getCurrentFunctions();
     }
@@ -130,7 +132,7 @@
                     + UsbManager.usbFunctionsToString(previousFunction));
         }
         if (function != previousFunction && !Utils.isMonkeyRunning()
-                && !shouldIgnoreClickEvent(function, previousFunction)) {
+                && !isClickEventIgnored(function, previousFunction)) {
             mPreviousFunction = previousFunction;
 
             //Update the UI in advance to make it looks smooth
@@ -144,8 +146,9 @@
 
             if (function == UsbManager.FUNCTION_RNDIS) {
                 // We need to have entitlement check for usb tethering, so use API in
-                // ConnectivityManager.
-                mConnectivityManager.startTethering(TETHERING_USB, true /* showProvisioningUi */,
+                // TetheringManager.
+                mTetheringManager.startTethering(
+                        TetheringManager.TETHERING_USB, new HandlerExecutor(mHandler),
                         mOnStartTetheringCallback);
             } else {
                 mUsbBackend.setCurrentFunctions(function);
@@ -153,7 +156,7 @@
         }
     }
 
-    private boolean shouldIgnoreClickEvent(long function, long previousFunction) {
+    private boolean isClickEventIgnored(long function, long previousFunction) {
         return isAccessoryMode(previousFunction) && function == UsbManager.FUNCTION_MTP;
     }
 
@@ -172,12 +175,11 @@
     }
 
     @VisibleForTesting
-    final class OnStartTetheringCallback extends
-            ConnectivityManager.OnStartTetheringCallback {
+    final class OnStartTetheringCallback implements TetheringManager.StartTetheringCallback {
 
         @Override
-        public void onTetheringFailed() {
-            super.onTetheringFailed();
+        public void onTetheringFailed(int error) {
+            Log.w(TAG, "onTetheringFailed() error : " + error);
             mUsbBackend.setCurrentFunctions(mPreviousFunction);
         }
     }
diff --git a/src/com/android/settings/datausage/DataSaverBackend.java b/src/com/android/settings/datausage/DataSaverBackend.java
index f13e88e..e39e41a 100644
--- a/src/com/android/settings/datausage/DataSaverBackend.java
+++ b/src/com/android/settings/datausage/DataSaverBackend.java
@@ -20,10 +20,7 @@
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
-import android.net.INetworkPolicyListener;
 import android.net.NetworkPolicyManager;
-import android.os.RemoteException;
-import android.telephony.SubscriptionPlan;
 import android.util.SparseIntArray;
 
 import com.android.settings.overlay.FeatureFactory;
@@ -180,33 +177,17 @@
 
     }
 
-    private final INetworkPolicyListener mPolicyListener = new INetworkPolicyListener.Stub() {
-        @Override
-        public void onUidRulesChanged(int uid, int uidRules) throws RemoteException {
-        }
-
+    private final NetworkPolicyManager.Listener mPolicyListener =
+            new NetworkPolicyManager.Listener() {
         @Override
         public void onUidPoliciesChanged(final int uid, final int uidPolicies) {
             ThreadUtils.postOnMainThread(() -> handleUidPoliciesChanged(uid, uidPolicies));
         }
 
         @Override
-        public void onMeteredIfacesChanged(String[] strings) throws RemoteException {
-        }
-
-        @Override
-        public void onRestrictBackgroundChanged(final boolean isDataSaving) throws RemoteException {
+        public void onRestrictBackgroundChanged(final boolean isDataSaving) {
             ThreadUtils.postOnMainThread(() -> handleRestrictBackgroundChanged(isDataSaving));
         }
-
-        @Override
-        public void onSubscriptionOverride(int subId, int overrideMask, int overrideValue,
-                int[] networkTypes) {
-        }
-
-        @Override
-        public void onSubscriptionPlansChanged(int subId, SubscriptionPlan[] plans) {
-        }
     };
 
     public interface Listener {
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index 245118d..f4ef0eb 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -85,7 +85,8 @@
         final Context prefContext = mCategoryRecentLocationRequests.getContext();
         final List<RecentLocationAccesses.Access> recentLocationAccesses = new ArrayList<>();
         final UserManager userManager = UserManager.get(mContext);
-        for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted()) {
+        for (RecentLocationAccesses.Access access : mRecentLocationApps.getAppListSorted(
+                /* showSystemApps= */ false)) {
             if (isRequestMatchesProfileType(userManager, access, mType)) {
                 recentLocationAccesses.add(access);
             }
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index aa70459..be8f257 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -70,6 +70,9 @@
         if (sActiveResultsForTesting != null) {
             return sActiveResultsForTesting;
         }
+        if (manager == null) {
+            return Collections.emptyList();
+        }
         final List<SubscriptionInfo> subscriptions = manager.getActiveSubscriptionInfoList();
         if (subscriptions == null) {
             return new ArrayList<>();
diff --git a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
index 2c6c963..8d037fb 100644
--- a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
@@ -32,6 +32,7 @@
 import com.android.settings.R;
 import com.android.settings.network.SubscriptionUtil;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -67,14 +68,22 @@
 
     @Override
     public int getAvailabilityStatus(int subId) {
-        return hasBackupCallingFeature(subId) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+        if (!hasBackupCallingFeature(subId)) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
+        List<SubscriptionInfo> subIdList = getActiveSubscriptionList();
+        SubscriptionInfo subInfo = getSubscriptionInfoFromList(subIdList, subId);
+        if (subInfo == null) {  // given subId is not actives
+            return CONDITIONALLY_UNAVAILABLE;
+        }
+        return (subIdList.size() > 1) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     /**
      * Implementation of abstract methods
      **/
     public boolean setChecked(boolean isChecked) {
-        ImsMmTelManager imsMmTelMgr = getImsMmTelManager();
+        ImsMmTelManager imsMmTelMgr = getImsMmTelManager(mSubId);
         if (imsMmTelMgr == null) {
             return false;
         }
@@ -92,7 +101,7 @@
      * Implementation of abstract methods
      **/
     public boolean isChecked() {
-        ImsMmTelManager imsMmTelMgr = getImsMmTelManager();
+        ImsMmTelManager imsMmTelMgr = getImsMmTelManager(mSubId);
         if (imsMmTelMgr == null) {
             return false;
         }
@@ -110,16 +119,17 @@
         if ((preference == null) || (!(preference instanceof SwitchPreference))) {
             return;
         }
+        SubscriptionInfo subInfo = getSubscriptionInfoFromActiveList(mSubId);
+
         mPreference = preference;
 
         final SwitchPreference switchPreference = (SwitchPreference) preference;
-        switchPreference.setChecked(isChecked());
+        switchPreference.setChecked((subInfo != null) ? isChecked() : false);
 
-        updateSummary(getLatestSummary());
+        updateSummary(getLatestSummary(subInfo));
     }
 
-    private String getLatestSummary() {
-        SubscriptionInfo subInfo = getSubscriptionInfo();
+    private String getLatestSummary(SubscriptionInfo subInfo) {
         return Objects.toString((subInfo == null) ? null
                 : SubscriptionUtil.getUniqueSubscriptionDisplayName(subInfo, mContext), "");
     }
@@ -144,19 +154,34 @@
                 CarrierConfigManager.KEY_CARRIER_CROSS_SIM_IMS_AVAILABLE_BOOL, false);
     }
 
-    private ImsMmTelManager getImsMmTelManager() {
-        if (!SubscriptionManager.isUsableSubscriptionId(mSubId)) {
+    private ImsMmTelManager getImsMmTelManager(int subId) {
+        if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
             return null;
         }
         ImsManager imsMgr = mContext.getSystemService(ImsManager.class);
-        return (imsMgr == null) ? null : imsMgr.getImsMmTelManager(mSubId);
+        return (imsMgr == null) ? null : imsMgr.getImsMmTelManager(subId);
     }
 
-    private SubscriptionInfo getSubscriptionInfo() {
-        SubscriptionManager subInfoMgr = mContext.getSystemService(SubscriptionManager.class);
-        if (subInfoMgr == null) {
+    private List<SubscriptionInfo> getActiveSubscriptionList() {
+        SubscriptionManager subscriptionManager =
+                mContext.getSystemService(SubscriptionManager.class);
+        return SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
+    }
+
+    private SubscriptionInfo getSubscriptionInfoFromList(
+            List<SubscriptionInfo> subInfoList, int subId) {
+        for (SubscriptionInfo subInfo : subInfoList) {
+            if ((subInfo != null) && (subInfo.getSubscriptionId() == subId)) {
+                return subInfo;
+            }
+        }
+        return null;
+    }
+
+    private SubscriptionInfo getSubscriptionInfoFromActiveList(int subId) {
+        if (!SubscriptionManager.isUsableSubscriptionId(subId)) {
             return null;
         }
-        return subInfoMgr.getActiveSubscriptionInfo(mSubId);
+        return getSubscriptionInfoFromList(getActiveSubscriptionList(), subId);
     }
 }
diff --git a/src/com/android/settings/security/RequestManageCredentials.java b/src/com/android/settings/security/RequestManageCredentials.java
index 4ee4fdf..eb7a7d8 100644
--- a/src/com/android/settings/security/RequestManageCredentials.java
+++ b/src/com/android/settings/security/RequestManageCredentials.java
@@ -208,7 +208,7 @@
                     .write();
             finishWithResultCancelled();
         });
-        allowButton.setOnClickListener(b -> setOrUpdateCredentialManagementApp());
+        allowButton.setOnClickListener(b -> setOrUpdateCredentialManagementAppAndFinish());
     }
 
     private void loadExtendedFloatingActionButton() {
@@ -220,13 +220,14 @@
         });
     }
 
-    private void setOrUpdateCredentialManagementApp() {
+    private void setOrUpdateCredentialManagementAppAndFinish() {
         try {
             mKeyChainConnection.getService().setCredentialManagementApp(
                     mCredentialManagerPackage, mAuthenticationPolicy);
             DevicePolicyEventLogger
                     .createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REQUEST_ACCEPTED)
                     .write();
+            setResult(RESULT_OK);
         } catch (RemoteException e) {
             Log.e(TAG, "Unable to set credential manager app", e);
             logRequestFailure();
diff --git a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
index 9c45ef4..e8eab68 100644
--- a/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
+++ b/src/com/android/settings/utils/AndroidKeystoreAliasLoader.java
@@ -28,6 +28,7 @@
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
 import java.security.UnrecoverableKeyException;
+import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -88,6 +89,10 @@
                 if (key != null) {
                     if (key instanceof PrivateKey) {
                         mKeyCertAliases.add(alias);
+                        final Certificate[] cert = keyStore.getCertificateChain(alias);
+                        if (cert != null && cert.length >= 2) {
+                            mCaCertAliases.add(alias);
+                        }
                     }
                 } else {
                     if (keyStore.getCertificate(alias) != null) {
diff --git a/src/com/android/settings/vpn2/ConfigDialog.java b/src/com/android/settings/vpn2/ConfigDialog.java
index a0c7a1e..42bc67d 100644
--- a/src/com/android/settings/vpn2/ConfigDialog.java
+++ b/src/com/android/settings/vpn2/ConfigDialog.java
@@ -24,8 +24,6 @@
 import android.net.ProxyInfo;
 import android.os.Bundle;
 import android.os.SystemProperties;
-import android.security.Credentials;
-import android.security.KeyStore;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.view.View;
@@ -42,10 +40,12 @@
 import com.android.internal.net.VpnProfile;
 import com.android.net.module.util.ProxyUtils;
 import com.android.settings.R;
+import com.android.settings.utils.AndroidKeystoreAliasLoader;
 
 import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
 /**
@@ -58,7 +58,7 @@
 class ConfigDialog extends AlertDialog implements TextWatcher,
         View.OnClickListener, AdapterView.OnItemSelectedListener,
         CompoundButton.OnCheckedChangeListener {
-    private final KeyStore mKeyStore = KeyStore.getInstance();
+    private static final String TAG = "ConfigDialog";
     private final DialogInterface.OnClickListener mListener;
     private final VpnProfile mProfile;
 
@@ -153,10 +153,13 @@
         mL2tpSecret.setTextAppearance(android.R.style.TextAppearance_DeviceDefault_Medium);
         mIpsecIdentifier.setText(mProfile.ipsecIdentifier);
         mIpsecSecret.setText(mProfile.ipsecSecret);
-        loadCertificates(mIpsecUserCert, Credentials.USER_PRIVATE_KEY, 0, mProfile.ipsecUserCert);
-        loadCertificates(mIpsecCaCert, Credentials.CA_CERTIFICATE,
+        AndroidKeystoreAliasLoader androidKeystoreAliasLoader =
+                new AndroidKeystoreAliasLoader(null);
+        loadCertificates(mIpsecUserCert, androidKeystoreAliasLoader.getKeyCertAliases(), 0,
+                mProfile.ipsecUserCert);
+        loadCertificates(mIpsecCaCert, androidKeystoreAliasLoader.getCaCertAliases(),
                 R.string.vpn_no_ca_cert, mProfile.ipsecCaCert);
-        loadCertificates(mIpsecServerCert, Credentials.USER_CERTIFICATE,
+        loadCertificates(mIpsecServerCert, androidKeystoreAliasLoader.getKeyCertAliases(),
                 R.string.vpn_no_server_cert, mProfile.ipsecServerCert);
         mSaveLogin.setChecked(mProfile.saveLogin);
         mAlwaysOnVpn.setChecked(mProfile.key.equals(VpnUtils.getLockdownVpn()));
@@ -511,27 +514,30 @@
         typeSpinner.setAdapter(adapter);
     }
 
-    private void loadCertificates(Spinner spinner, String prefix, int firstId, String selected) {
+    private void loadCertificates(Spinner spinner, Collection<String> choices, int firstId,
+            String selected) {
         Context context = getContext();
         String first = (firstId == 0) ? "" : context.getString(firstId);
-        String[] certificates = mKeyStore.list(prefix);
+        String[] myChoices;
 
-        if (certificates == null || certificates.length == 0) {
-            certificates = new String[] {first};
+        if (choices == null || choices.size() == 0) {
+            myChoices = new String[] {first};
         } else {
-            String[] array = new String[certificates.length + 1];
-            array[0] = first;
-            System.arraycopy(certificates, 0, array, 1, certificates.length);
-            certificates = array;
+            myChoices = new String[choices.size() + 1];
+            myChoices[0] = first;
+            int i = 1;
+            for (String c : choices) {
+                myChoices[i++] = c;
+            }
         }
 
         ArrayAdapter<String> adapter = new ArrayAdapter<String>(
-                context, android.R.layout.simple_spinner_item, certificates);
+                context, android.R.layout.simple_spinner_item, myChoices);
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
         spinner.setAdapter(adapter);
 
-        for (int i = 1; i < certificates.length; ++i) {
-            if (certificates[i].equals(selected)) {
+        for (int i = 1; i < myChoices.length; ++i) {
+            if (myChoices[i].equals(selected)) {
                 spinner.setSelection(i);
                 break;
             }
diff --git a/src/com/android/settings/vpn2/ConfigDialogFragment.java b/src/com/android/settings/vpn2/ConfigDialogFragment.java
index f339a69..b8825fe 100644
--- a/src/com/android/settings/vpn2/ConfigDialogFragment.java
+++ b/src/com/android/settings/vpn2/ConfigDialogFragment.java
@@ -25,7 +25,7 @@
 import android.os.RemoteException;
 import android.os.UserHandle;
 import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
 import android.util.Log;
 import android.view.View;
 import android.widget.Toast;
@@ -151,9 +151,8 @@
                 return;
             }
 
-            // Delete from KeyStore
-            KeyStore keyStore = KeyStore.getInstance();
-            keyStore.delete(Credentials.VPN + profile.key, KeyStore.UID_SELF);
+            // Delete from profile store.
+            LegacyVpnProfileStore.remove(Credentials.VPN + profile.key);
 
             updateLockdownVpn(false, profile);
         }
@@ -188,8 +187,7 @@
     }
 
     private void save(VpnProfile profile, boolean lockdown) {
-        KeyStore.getInstance().put(Credentials.VPN + profile.key, profile.encode(),
-                KeyStore.UID_SELF, /* flags */ 0);
+        LegacyVpnProfileStore.put(Credentials.VPN + profile.key, profile.encode());
 
         // Flush out old version of profile
         disconnect(profile);
diff --git a/src/com/android/settings/vpn2/VpnSettings.java b/src/com/android/settings/vpn2/VpnSettings.java
index 0a3b2b0..7635733 100644
--- a/src/com/android/settings/vpn2/VpnSettings.java
+++ b/src/com/android/settings/vpn2/VpnSettings.java
@@ -41,7 +41,7 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
 import android.util.ArrayMap;
 import android.util.ArraySet;
 import android.util.Log;
@@ -57,7 +57,6 @@
 import com.android.internal.net.LegacyVpnInfo;
 import com.android.internal.net.VpnConfig;
 import com.android.internal.net.VpnProfile;
-import com.android.internal.util.ArrayUtils;
 import com.android.settings.R;
 import com.android.settings.RestrictedSettingsFragment;
 import com.android.settings.widget.GearPreference;
@@ -94,8 +93,6 @@
     private UserManager mUserManager;
     private VpnManager mVpnManager;
 
-    private final KeyStore mKeyStore = KeyStore.getInstance();
-
     private Map<String, LegacyVpnPreference> mLegacyVpnPreferences = new ArrayMap<>();
     private Map<AppVpnInfo, AppPreference> mAppPreferences = new ArrayMap<>();
 
@@ -222,7 +219,7 @@
         final Context context = activity.getApplicationContext();
 
         // Run heavy RPCs before switching to UI thread
-        final List<VpnProfile> vpnProfiles = loadVpnProfiles(mKeyStore);
+        final List<VpnProfile> vpnProfiles = loadVpnProfiles();
         final List<AppVpnInfo> vpnApps = getVpnApps(context, /* includeProfiles */ true);
 
         final Map<String, LegacyVpnInfo> connectedLegacyVpns = getConnectedLegacyVpns();
@@ -540,12 +537,13 @@
         return result;
     }
 
-    static List<VpnProfile> loadVpnProfiles(KeyStore keyStore, int... excludeTypes) {
+    private static List<VpnProfile> loadVpnProfiles() {
         final ArrayList<VpnProfile> result = Lists.newArrayList();
 
-        for (String key : keyStore.list(Credentials.VPN)) {
-            final VpnProfile profile = VpnProfile.decode(key, keyStore.get(Credentials.VPN + key));
-            if (profile != null && !ArrayUtils.contains(excludeTypes, profile.type)) {
+        for (String key : LegacyVpnProfileStore.list(Credentials.VPN)) {
+            final VpnProfile profile = VpnProfile.decode(key,
+                    LegacyVpnProfileStore.get(Credentials.VPN + key));
+            if (profile != null) {
                 result.add(profile);
             }
         }
diff --git a/src/com/android/settings/vpn2/VpnUtils.java b/src/com/android/settings/vpn2/VpnUtils.java
index 4c9338c..d6a5578 100644
--- a/src/com/android/settings/vpn2/VpnUtils.java
+++ b/src/com/android/settings/vpn2/VpnUtils.java
@@ -20,7 +20,7 @@
 import android.os.RemoteException;
 import android.provider.Settings;
 import android.security.Credentials;
-import android.security.KeyStore;
+import android.security.LegacyVpnProfileStore;
 
 import com.android.internal.net.LegacyVpnInfo;
 import com.android.internal.net.VpnConfig;
@@ -28,27 +28,25 @@
 /**
  * Utility functions for vpn.
  *
- * Keystore methods should only be called in system user
+ * LegacyVpnProfileStore methods should only be called in system user
  */
 public class VpnUtils {
 
     private static final String TAG = "VpnUtils";
 
     public static String getLockdownVpn() {
-        final byte[] value = KeyStore.getInstance().get(
-            Credentials.LOCKDOWN_VPN, true /* suppressKeyNotFoundWarning */);
+        final byte[] value = LegacyVpnProfileStore.get(Credentials.LOCKDOWN_VPN);
         return value == null ? null : new String(value);
     }
 
     public static void clearLockdownVpn(Context context) {
-        KeyStore.getInstance().delete(Credentials.LOCKDOWN_VPN);
+        LegacyVpnProfileStore.remove(Credentials.LOCKDOWN_VPN);
         // Always notify VpnManager after keystore update
         getVpnManager(context).updateLockdownVpn();
     }
 
     public static void setLockdownVpn(Context context, String lockdownKey) {
-        KeyStore.getInstance().put(Credentials.LOCKDOWN_VPN, lockdownKey.getBytes(),
-                KeyStore.UID_SELF, /* flags */ 0);
+        LegacyVpnProfileStore.put(Credentials.LOCKDOWN_VPN, lockdownKey.getBytes());
         // Always notify VpnManager after keystore update
         getVpnManager(context).updateLockdownVpn();
     }
diff --git a/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java b/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java
new file mode 100644
index 0000000..e269818
--- /dev/null
+++ b/src/com/android/settings/widget/LabeledContinuousSeekBarPreference.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import com.android.settings.R;
+
+/** A continuous labeled slider preference */
+public class LabeledContinuousSeekBarPreference extends LabeledSeekBarPreference {
+    public LabeledContinuousSeekBarPreference(Context context) {
+        this(context, null);
+    }
+
+    public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs) {
+       this(context, attrs, 0);
+    }
+
+    public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs,
+            int defStyleAttr) {
+        this(context, attrs, defStyleAttr, 0);
+    }
+
+    public LabeledContinuousSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
+            int defStyleRes) {
+        super(context, attrs, defStyleAttr, defStyleRes);
+        setLayoutResource(R.layout.preference_labeled_continuous_slider);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
index 3df6221..0ed6747 100644
--- a/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragmentTest.java
@@ -31,6 +31,7 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
+import android.content.res.Resources;
 import android.os.Bundle;
 import android.provider.Settings;
 import android.view.LayoutInflater;
@@ -75,7 +76,8 @@
             "com.android.server.accessibility.MagnificationController";
 
     private TestToggleScreenMagnificationPreferenceFragment mFragment;
-    private Context mContext = ApplicationProvider.getApplicationContext();
+    private Context mContext;
+    private Resources mResources;
 
     @Mock
     private PreferenceManager mPreferenceManager;
@@ -86,10 +88,14 @@
     public void setUpTestFragment() {
         MockitoAnnotations.initMocks(this);
 
+        mContext = spy(ApplicationProvider.getApplicationContext());
         mFragment = spy(new TestToggleScreenMagnificationPreferenceFragment());
         when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
         when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
         when(mFragment.getContext()).thenReturn(mContext);
+        mResources = spy(mContext.getResources());
+        when(mContext.getResources()).thenReturn(mResources);
+        when(mFragment.getContext().getResources()).thenReturn(mResources);
         doReturn(null).when(mFragment).getPreferenceScreen();
         doReturn(mActivity).when(mFragment).getActivity();
     }
@@ -250,6 +256,16 @@
         assertThat(expectedType).isEqualTo(UserShortcutType.HARDWARE | UserShortcutType.TRIPLETAP);
     }
 
+    @Test
+    public void initSettingsPreference_notSupportsMagnificationArea_settingsPreferenceIsNull() {
+        when(mResources.getBoolean(
+                com.android.internal.R.bool.config_magnification_area))
+                .thenReturn(false);
+        mFragment.initSettingsPreference();
+
+        assertThat(mFragment.mSettingsPreference).isNull();
+    }
+
     private void putStringIntoSettings(String key, String componentName) {
         Settings.Secure.putString(mContext.getContentResolver(), key, componentName);
     }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
index b816a18..b3f732f 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbBackendTest.java
@@ -34,7 +34,7 @@
 import android.hardware.usb.UsbManager;
 import android.hardware.usb.UsbPort;
 import android.hardware.usb.UsbPortStatus;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
 import android.os.UserHandle;
 import android.os.UserManager;
 
@@ -57,7 +57,7 @@
     @Mock
     private UserManager mUserManager;
     @Mock
-    private ConnectivityManager mConnectivityManager;
+    private TetheringManager mTetheringManager;
     @Mock
     private UsbPort mUsbPort;
     @Mock
@@ -69,8 +69,8 @@
         when(mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_MIDI))
                 .thenReturn(true);
         when((Object) mContext.getSystemService(UsbManager.class)).thenReturn(mUsbManager);
-        when(mContext.getSystemService(Context.CONNECTIVITY_SERVICE))
-                .thenReturn(mConnectivityManager);
+        when((Object) mContext.getSystemService(
+                TetheringManager.class)).thenReturn(mTetheringManager);
         when(mUsbManager.getPorts()).thenReturn(Collections.singletonList(mUsbPort));
         when(mUsbPortStatus.isConnected()).thenReturn(true);
         when(mUsbPort.getStatus()).thenReturn(mUsbPortStatus);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
index 4afe22a..c751e98 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
@@ -18,11 +18,12 @@
 
 import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
 import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
-import static android.net.ConnectivityManager.TETHERING_USB;
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -30,7 +31,7 @@
 import static org.mockito.Mockito.when;
 
 import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
 
 import androidx.preference.PreferenceScreen;
 
@@ -50,7 +51,7 @@
     @Mock
     private UsbBackend mUsbBackend;
     @Mock
-    private ConnectivityManager mConnectivityManager;
+    private TetheringManager mTetheringManager;
 
     private UsbDefaultFragment mFragment;
 
@@ -59,7 +60,7 @@
         MockitoAnnotations.initMocks(this);
         mFragment = new TestFragment();
         mFragment.mUsbBackend = mUsbBackend;
-        mFragment.mConnectivityManager = mConnectivityManager;
+        mFragment.mTetheringManager = mTetheringManager;
     }
 
     @Test
@@ -136,8 +137,9 @@
 
         mFragment.setDefaultKey(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_RNDIS));
 
-        verify(mConnectivityManager).startTethering(TETHERING_USB, true,
-                mFragment.mOnStartTetheringCallback);
+        verify(mTetheringManager).startTethering(eq(TetheringManager.TETHERING_USB),
+                any(),
+                eq(mFragment.mOnStartTetheringCallback));
         assertThat(mFragment.mPreviousFunctions).isEqualTo(
                 UsbManager.FUNCTION_MTP);
     }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
index 3ea2756..9118645 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsControllerTest.java
@@ -18,11 +18,12 @@
 
 import static android.hardware.usb.UsbPortStatus.DATA_ROLE_DEVICE;
 import static android.hardware.usb.UsbPortStatus.POWER_ROLE_SINK;
-import static android.net.ConnectivityManager.TETHERING_USB;
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
@@ -31,7 +32,7 @@
 
 import android.content.Context;
 import android.hardware.usb.UsbManager;
-import android.net.ConnectivityManager;
+import android.net.TetheringManager;
 
 import androidx.fragment.app.FragmentActivity;
 import androidx.preference.PreferenceCategory;
@@ -73,7 +74,7 @@
     @Mock
     private FragmentActivity mActivity;
     @Mock
-    private ConnectivityManager mConnectivityManager;
+    private TetheringManager mTetheringManager;
 
     @Before
     public void setUp() {
@@ -89,7 +90,7 @@
         when(mFragment.getContext()).thenReturn(mContext);
         when(mFragment.getPreferenceManager()).thenReturn(mPreferenceManager);
         when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
-        when(mContext.getSystemService(ConnectivityManager.class)).thenReturn(mConnectivityManager);
+        when(mContext.getSystemService(TetheringManager.class)).thenReturn(mTetheringManager);
 
         mDetailsFunctionsController = new UsbDetailsFunctionsController(mContext, mFragment,
                 mUsbBackend);
@@ -245,8 +246,9 @@
 
         mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
 
-        verify(mConnectivityManager).startTethering(TETHERING_USB, true,
-                mDetailsFunctionsController.mOnStartTetheringCallback);
+        verify(mTetheringManager).startTethering(eq(TetheringManager.TETHERING_USB),
+                any(),
+                eq(mDetailsFunctionsController.mOnStartTetheringCallback));
         assertThat(mDetailsFunctionsController.mPreviousFunction).isEqualTo(
                 UsbManager.FUNCTION_MTP);
     }
@@ -295,15 +297,16 @@
         mDetailsFunctionsController.onRadioButtonClicked(mRadioButtonPreference);
 
         verify(mUsbBackend, never()).setCurrentFunctions(UsbManager.FUNCTION_PTP);
-        verify(mConnectivityManager, never()).startTethering(TETHERING_USB, true,
-                mDetailsFunctionsController.mOnStartTetheringCallback);
+        verify(mTetheringManager, never()).startTethering(eq(TetheringManager.TETHERING_USB),
+                any(),
+                eq(mDetailsFunctionsController.mOnStartTetheringCallback));
     }
 
     @Test
     public void onTetheringFailed_resetPreviousFunctions() {
         mDetailsFunctionsController.mPreviousFunction = UsbManager.FUNCTION_PTP;
 
-        mDetailsFunctionsController.mOnStartTetheringCallback.onTetheringFailed();
+        mDetailsFunctionsController.mOnStartTetheringCallback.onTetheringFailed(0);
 
         verify(mUsbBackend).setCurrentFunctions(UsbManager.FUNCTION_PTP);
     }
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
index 8a34930..323486e 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BaseBluetoothDialogPreferenceTest.java
@@ -105,6 +105,7 @@
     public void onBindDialogView_checkRadioButtonsText() {
         when(mView.findViewById(ID1)).thenReturn(mRadioButton1);
         when(mView.findViewById(ID2)).thenReturn(mRadioButton2);
+        when(mView.findViewById(TEXT_VIEW_ID)).thenReturn(mTextView);
 
         assertThat(mRadioButton1.getText()).isNotEqualTo(BUTTON1);
         assertThat(mRadioButton2.getText()).isNotEqualTo(BUTTON2);
@@ -118,6 +119,7 @@
     public void onBindDialogView_checkRadioButtonsState() {
         when(mView.findViewById(ID1)).thenReturn(mRadioButton1);
         when(mView.findViewById(ID2)).thenReturn(mRadioButton2);
+        when(mView.findViewById(TEXT_VIEW_ID)).thenReturn(mTextView);
         List<Integer> indexes = new ArrayList<>();
         indexes.add(0);
         when(mCallback.getSelectableIndex()).thenReturn(indexes);
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
index 5feee60..32c8627 100644
--- a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
@@ -98,7 +98,7 @@
     @Test
     @Ignore
     public void updateState_whenAppListIsEmpty_shouldDisplayTitleTextAndDetailsText() {
-        doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted();
+        doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted(false);
         mController.displayPreference(mScreen);
         mController.updateState(mLayoutPreference);