Merge "Pass CDC text as credential-only to BiometricPrompt"
diff --git a/res/layout/palette_listview_item.xml b/res/layout/palette_listview_item.xml
index e8cc940..3342ef1 100644
--- a/res/layout/palette_listview_item.xml
+++ b/res/layout/palette_listview_item.xml
@@ -22,10 +22,12 @@
     <TextView
         android:id="@+id/item_textview"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingLeft="10dp"
-        android:textSize="20dp"
+        android:layout_height="42dp"
+        android:fontFamily="roboto-bold"
+        android:gravity="center_vertical"
         android:maxLength="20"
-        android:singleLine="true"/>
+        android:paddingLeft="@dimen/accessibility_layout_margin_start_end"
+        android:singleLine="true"
+        android:textSize="14dp" />
 
 </FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index f79874c..ad5c294 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -266,7 +266,7 @@
     <dimen name="message_metadata_top_padding">4dp</dimen>
 
     <!-- Accessibility Settings -->
-    <dimen name="accessibility_layout_margin_start_end">24dp</dimen>
+    <dimen name="accessibility_layout_margin_start_end">16dp</dimen>
     <dimen name="accessibility_button_preference_padding_top_bottom">18dp</dimen>
 
     <!-- Accessibility, Screen magnification. These values are meant to be relative values and the actual layout value will be set programmatically. -->
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index b7b88ed..914cc7a 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -24,8 +24,7 @@
         android:fragment="com.android.settings.accessibility.AccessibilityShortcutPreferenceFragment"
         android:key="accessibility_shortcut_preference"
         android:persistent="false"
-        android:title="@string/accessibility_global_gesture_preference_title"
-        settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/>
+        android:title="@string/accessibility_global_gesture_preference_title" />
 
     <PreferenceCategory
         android:key="user_installed_services_category"
diff --git a/res/xml/accessibility_shortcut_settings.xml b/res/xml/accessibility_shortcut_settings.xml
index 0bfd6b6..7708551 100644
--- a/res/xml/accessibility_shortcut_settings.xml
+++ b/res/xml/accessibility_shortcut_settings.xml
@@ -17,11 +17,6 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/accessibility_global_gesture_preference_title">
 
-    <Preference
-        android:fragment="com.android.settings.accessibility.ShortcutServicePickerFragment"
-        android:key="accessibility_shortcut_service"
-        android:title="@string/accessibility_shortcut_service_title" />
-
     <SwitchPreference
         android:key="accessibility_shortcut_on_lock_screen"
         android:title="@string/accessibility_shortcut_service_on_lock_screen_title" />
diff --git a/res/xml/manage_external_storage_permission_details.xml b/res/xml/manage_external_storage_permission_details.xml
index b540ff6..29ff297 100644
--- a/res/xml/manage_external_storage_permission_details.xml
+++ b/res/xml/manage_external_storage_permission_details.xml
@@ -14,7 +14,9 @@
      limitations under the License.
 -->
 
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="manage_external_storage_permission_details"
     android:title="@string/manage_external_storage_title">
 
@@ -22,8 +24,9 @@
         android:key="app_ops_settings_switch"
         android:title="@string/permit_manage_external_storage"/>
 
-    <Preference
-        android:summary="@string/allow_manage_external_storage_description"
-        android:selectable="false"/>
+    <com.android.settingslib.widget.FooterPreference
+        android:title="@string/allow_manage_external_storage_description"
+        android:selectable="false"
+        settings:searchable="false"/>
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 1722c99..3817730 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -31,7 +31,6 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.UserHandle;
-import android.provider.DeviceConfig;
 import android.provider.Settings;
 import android.text.TextUtils;
 import android.util.ArrayMap;
@@ -49,6 +48,7 @@
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
+import com.android.settings.accessibility.AccessibilityUtil.State;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.display.DarkUIPreferenceController;
 import com.android.settings.search.BaseSearchIndexProvider;
@@ -121,8 +121,6 @@
     // presentation.
     private static final long DELAY_UPDATE_SERVICES_MILLIS = 1000;
 
-    static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
-
     private final Handler mHandler = new Handler();
 
     private final Runnable mUpdateRunnable = new Runnable() {
@@ -257,11 +255,15 @@
     }
 
     public static CharSequence getServiceSummary(Context context, AccessibilityServiceInfo info,
-            boolean serviceEnabled) {
-        final String serviceState = serviceEnabled
+            @State int state) {
+        final CharSequence serviceSummary = info.loadSummary(context.getPackageManager());
+        if (state == State.UNKNOWN) {
+            return serviceSummary;
+        }
+
+        final String serviceState = (state == State.ON)
                 ? context.getString(R.string.accessibility_summary_state_enabled)
                 : context.getString(R.string.accessibility_summary_state_disabled);
-        final CharSequence serviceSummary = info.loadSummary(context.getPackageManager());
         final String stateSummaryCombo = context.getString(
                 R.string.preference_summary_default_combination,
                 serviceState, serviceSummary);
@@ -269,15 +271,13 @@
         return (TextUtils.isEmpty(serviceSummary))
                 ? serviceState
                 : stateSummaryCombo;
+
     }
 
     @VisibleForTesting
     static boolean isRampingRingerEnabled(final Context context) {
-        return (Settings.Global.getInt(
-                        context.getContentResolver(),
-                        Settings.Global.APPLY_RAMPING_RINGER, 0) == 1)
-                && DeviceConfig.getBoolean(
-                        DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
+        return Settings.Global.getInt(
+                context.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0) == 1;
     }
 
     private void initializeAllPreferences() {
@@ -377,13 +377,18 @@
                 description = getString(R.string.accessibility_service_default_description);
             }
 
+            final int fragmentType = AccessibilityUtil.getAccessibilityServiceFragmentType(info);
             if (serviceEnabled && info.crashed) {
                 // Update the summaries for services that have crashed.
                 preference.setSummary(R.string.accessibility_summary_state_stopped);
                 description = getString(R.string.accessibility_description_state_stopped);
             } else {
+                int serviceState = serviceEnabled ? State.ON : State.OFF;
+                if (fragmentType == AccessibilityServiceFragmentType.INVISIBLE) {
+                    serviceState = State.UNKNOWN;
+                }
                 final CharSequence serviceSummary = getServiceSummary(getContext(), info,
-                        serviceEnabled);
+                        serviceState);
                 preference.setSummary(serviceSummary);
             }
 
@@ -403,7 +408,7 @@
                 preference.setEnabled(true);
             }
 
-            switch (AccessibilityUtil.getAccessibilityServiceFragmentType(info)) {
+            switch (fragmentType) {
                 case AccessibilityServiceFragmentType.LEGACY:
                     preference.setFragment(
                             LegacyAccessibilityServicePreferenceFragment.class.getName());
@@ -514,6 +519,8 @@
             experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
             mDisplayDaltonizerPreferenceScreen.setOrder(
                     mDisplayMagnificationPreferenceScreen.getOrder() + 1);
+            mDisplayDaltonizerPreferenceScreen.setSummary(AccessibilityUtil.getSummary(
+                    getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED));
             mToggleInversionPreference.setOrder(
                     mDisplayDaltonizerPreferenceScreen.getOrder() + 1);
             mToggleLargePointerIconPreference.setOrder(
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java
deleted file mode 100644
index af0a99f..0000000
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceController.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2019 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.accessibility;
-
-import android.content.Context;
-import android.os.UserHandle;
-import android.view.accessibility.AccessibilityManager;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-import com.android.settingslib.accessibility.AccessibilityUtils;
-
-public class AccessibilityShortcutPreferenceController extends BasePreferenceController {
-    public AccessibilityShortcutPreferenceController(Context context, String preferenceKey) {
-        super(context, preferenceKey);
-    }
-
-    @Override
-    public int getAvailabilityStatus() {
-        return AccessibilityManager
-                .getInstance(mContext).getInstalledAccessibilityServiceList().isEmpty()
-                ? DISABLED_DEPENDENT_SETTING : AVAILABLE;
-    }
-
-    @Override
-    public CharSequence getSummary() {
-        if (AccessibilityManager.getInstance(mContext)
-                .getInstalledAccessibilityServiceList().isEmpty()) {
-            return mContext.getString(R.string.accessibility_no_services_installed);
-        } else {
-            final boolean shortcutEnabled =
-                    AccessibilityUtils.isShortcutEnabled(mContext, UserHandle.myUserId());
-            return shortcutEnabled
-                    ? AccessibilityShortcutPreferenceFragment.getServiceName(mContext)
-                    : mContext.getString(R.string.accessibility_feature_state_off);
-        }
-    }
-}
diff --git a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
index 659eaca..ca3c2e8 100644
--- a/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceFragment.java
@@ -50,10 +50,8 @@
 public class AccessibilityShortcutPreferenceFragment extends ToggleFeaturePreferenceFragment
         implements Indexable {
 
-    public static final String SHORTCUT_SERVICE_KEY = "accessibility_shortcut_service";
     public static final String ON_LOCK_SCREEN_KEY = "accessibility_shortcut_on_lock_screen";
 
-    private Preference mServicePreference;
     private SwitchPreference mOnLockScreenSwitchPreference;
     private final ContentObserver mContentObserver = new ContentObserver(new Handler()) {
         @Override
@@ -75,8 +73,6 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-
-        mServicePreference = findPreference(SHORTCUT_SERVICE_KEY);
         mOnLockScreenSwitchPreference = (SwitchPreference) findPreference(ON_LOCK_SCREEN_KEY);
         mOnLockScreenSwitchPreference.setOnPreferenceChangeListener((Preference p, Object o) -> {
             Settings.Secure.putInt(getContentResolver(),
@@ -94,7 +90,7 @@
         preferenceScreen.findPreference(KEY_GENERAL_CATEGORY).setVisible(false);
 
         preferenceScreen.setOrderingAsAdded(false);
-        mToggleServiceDividerSwitchPreference.setOrder(mServicePreference.getOrder() - 1);
+        mToggleServiceDividerSwitchPreference.setVisible(false);
     }
 
     @Override
@@ -118,56 +114,13 @@
     }
 
     @Override
-    protected void onRemoveSwitchPreferenceToggleSwitch() {
-        super.onRemoveSwitchPreferenceToggleSwitch();
-        mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
-    }
-
-    @Override
-    protected void onInstallSwitchPreferenceToggleSwitch() {
-        super.onInstallSwitchPreferenceToggleSwitch();
-        mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener((preference) -> {
-            boolean enabled = ((SwitchPreference) preference).isChecked();
-            Context context = getContext();
-            if (enabled && !shortcutFeatureAvailable(context)) {
-                // If no service is configured, we'll disable the shortcut shortly. Give the user
-                // a chance to select a service. We'll update the preferences when we resume.
-                Settings.Secure.putInt(getContentResolver(),
-                        Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
-                mServicePreference.setEnabled(true);
-                mServicePreference.performClick();
-            } else {
-                onPreferenceToggled(Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, enabled);
-            }
-            return true;
-        });
-    }
-
-    @Override
     protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
         Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? ON : OFF);
         updatePreferences();
     }
 
-    @Override
-    protected void updateToggleServiceTitle(SwitchPreference switchPreference) {
-        final String switchBarText = getString(R.string.accessibility_service_master_switch_title,
-                getString(R.string.accessibility_global_gesture_preference_title));
-        switchPreference.setTitle(switchBarText);
-    }
-
     private void updatePreferences() {
         ContentResolver cr = getContentResolver();
-        Context context = getContext();
-        mServicePreference.setSummary(getServiceName(context));
-        if (!shortcutFeatureAvailable(context)) {
-            // If no service is configured, make sure the overall shortcut is turned off
-            Settings.Secure.putInt(
-                    getContentResolver(), Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, OFF);
-        }
-        boolean isEnabled = Settings.Secure
-                .getInt(cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON) == ON;
-        mToggleServiceDividerSwitchPreference.setChecked(isEnabled);
         // The shortcut is enabled by default on the lock screen as long as the user has
         // enabled the shortcut with the warning dialog
         final int dialogShown = Settings.Secure.getInt(
@@ -175,9 +128,6 @@
         final boolean enabledFromLockScreen = Settings.Secure.getInt(
                 cr, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, dialogShown) == ON;
         mOnLockScreenSwitchPreference.setChecked(enabledFromLockScreen);
-        // Only enable changing the service and lock screen behavior if the shortcut is on
-        mServicePreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
-        mOnLockScreenSwitchPreference.setEnabled(mToggleServiceDividerSwitchPreference.isChecked());
     }
 
     /**
@@ -214,8 +164,7 @@
         return getServiceInfo(context) != null;
     }
 
-    private static @Nullable
-    ComponentName getShortcutComponent(Context context) {
+    private static @Nullable ComponentName getShortcutComponent(Context context) {
         String componentNameString = AccessibilityUtils.getShortcutTargetServiceComponentNameString(
                 context, UserHandle.myUserId());
         if (componentNameString == null) return null;
diff --git a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
index e53afeb..17c6016 100644
--- a/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilitySlicePreferenceController.java
@@ -16,6 +16,10 @@
 
 package com.android.settings.accessibility;
 
+import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
+import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
+import static com.android.settings.accessibility.AccessibilityUtil.State.UNKNOWN;
+
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -23,6 +27,7 @@
 import android.provider.Settings;
 import android.view.accessibility.AccessibilityManager;
 
+import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
 import com.android.settings.core.TogglePreferenceController;
 import com.android.settingslib.accessibility.AccessibilityUtils;
 
@@ -39,8 +44,7 @@
 
     private final ComponentName mComponentName;
 
-    private final int ON = 1;
-    private final int OFF = 0;
+    private static final String EMPTY_STRING = "";
 
     public AccessibilitySlicePreferenceController(Context context, String preferenceKey) {
         super(context, preferenceKey);
@@ -55,8 +59,13 @@
     @Override
     public CharSequence getSummary() {
         final AccessibilityServiceInfo serviceInfo = getAccessibilityServiceInfo();
-        return serviceInfo == null
-                ? "" : AccessibilitySettings.getServiceSummary(mContext, serviceInfo, isChecked());
+        int serviceState = isChecked() ? ON : OFF;
+        if (AccessibilityUtil.getAccessibilityServiceFragmentType(serviceInfo)
+                == AccessibilityServiceFragmentType.INVISIBLE) {
+            serviceState = UNKNOWN;
+        }
+        return serviceInfo == null ? EMPTY_STRING : AccessibilitySettings.getServiceSummary(
+                mContext, serviceInfo, serviceState);
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/AccessibilityUtil.java b/src/com/android/settings/accessibility/AccessibilityUtil.java
index 8da6fbb..6159f92 100644
--- a/src/com/android/settings/accessibility/AccessibilityUtil.java
+++ b/src/com/android/settings/accessibility/AccessibilityUtil.java
@@ -98,6 +98,7 @@
     /** Denotes the accessibility enabled status */
     @Retention(RetentionPolicy.SOURCE)
     public @interface State {
+        int UNKNOWN = -1;
         int OFF = 0;
         int ON = 1;
     }
diff --git a/src/com/android/settings/accessibility/DaltonizerPreferenceController.java b/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
index 2922b76..c859d8c 100644
--- a/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
+++ b/src/com/android/settings/accessibility/DaltonizerPreferenceController.java
@@ -19,15 +19,10 @@
 import android.content.Context;
 import android.provider.Settings;
 
-import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 
-import com.google.common.primitives.Ints;
-
 /** Controller that shows and updates the color correction summary. */
 public class DaltonizerPreferenceController extends BasePreferenceController {
-
-    private static final String DALTONIZER_TYPE = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER;
     private static final String DALTONIZER_ENABLED =
             Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
 
@@ -42,21 +37,6 @@
 
     @Override
     public CharSequence getSummary() {
-        final String[] daltonizerSummaries = mContext.getResources().getStringArray(
-                R.array.daltonizer_mode_summaries);
-        final int[] daltonizerValues = mContext.getResources().getIntArray(
-                R.array.daltonizer_type_values);
-        final int timeoutValue =
-                DaltonizerRadioButtonPreferenceController.getSecureAccessibilityDaltonizerValue(
-                        mContext.getContentResolver(), DALTONIZER_TYPE);
-        final int idx = Ints.indexOf(daltonizerValues, timeoutValue);
-        final String serviceSummary = daltonizerSummaries[idx == -1 ? 0 : idx];
-
-        final CharSequence serviceState = AccessibilityUtil.getSummary(mContext,
-                DALTONIZER_ENABLED);
-
-        return mContext.getString(
-                R.string.preference_summary_default_combination,
-                serviceState, serviceSummary);
+        return AccessibilityUtil.getSummary(mContext, DALTONIZER_ENABLED);
     }
 }
diff --git a/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java b/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
index dd5eb10..f6f554e 100644
--- a/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
+++ b/src/com/android/settings/accessibility/DaltonizerRadioButtonPreferenceController.java
@@ -20,6 +20,7 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.provider.Settings;
+import android.view.View;
 import android.view.accessibility.AccessibilityManager;
 
 import androidx.lifecycle.LifecycleObserver;
@@ -122,6 +123,7 @@
         mPreference = (RadioButtonPreference)
                 screen.findPreference(getPreferenceKey());
         mPreference.setOnClickListener(this);
+        mPreference.setAppendixVisibility(View.GONE);
         updateState(mPreference);
     }
 
diff --git a/src/com/android/settings/accessibility/MagnificationPreferenceController.java b/src/com/android/settings/accessibility/MagnificationPreferenceController.java
index 8b214a2..7ac7bef 100644
--- a/src/com/android/settings/accessibility/MagnificationPreferenceController.java
+++ b/src/com/android/settings/accessibility/MagnificationPreferenceController.java
@@ -18,7 +18,6 @@
 
 import android.content.Context;
 import android.os.Bundle;
-import android.provider.Settings;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
@@ -41,22 +40,8 @@
 
     @Override
     public CharSequence getSummary() {
-        final boolean tripleTapEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED, 0) == 1;
-        final boolean buttonEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, 0) == 1;
-
-        int summaryResId = 0;
-        if (!tripleTapEnabled && !buttonEnabled) {
-            summaryResId = R.string.accessibility_feature_state_off;
-        } else if (!tripleTapEnabled && buttonEnabled) {
-            summaryResId = R.string.accessibility_screen_magnification_navbar_title;
-        } else if (tripleTapEnabled && !buttonEnabled) {
-            summaryResId = R.string.accessibility_screen_magnification_gestures_title;
-        } else {
-            summaryResId = R.string.accessibility_screen_magnification_state_navbar_gesture;
-        }
-        return mContext.getResources().getText(summaryResId);
+        return mContext.getResources().getText(
+                R.string.accessibility_screen_magnification_navbar_title);
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/PaletteListPreference.java b/src/com/android/settings/accessibility/PaletteListPreference.java
index de35112..c5c4205 100644
--- a/src/com/android/settings/accessibility/PaletteListPreference.java
+++ b/src/com/android/settings/accessibility/PaletteListPreference.java
@@ -26,7 +26,7 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceViewHolder;
 
-import com.android.settingslib.widget.R;
+import com.android.settings.R;
 
 /** Preference that easier preview by matching name to color. */
 public class PaletteListPreference extends Preference {
diff --git a/src/com/android/settings/accessibility/PaletteListView.java b/src/com/android/settings/accessibility/PaletteListView.java
index 0030817..ef010e2 100644
--- a/src/com/android/settings/accessibility/PaletteListView.java
+++ b/src/com/android/settings/accessibility/PaletteListView.java
@@ -35,7 +35,7 @@
 
 import androidx.annotation.VisibleForTesting;
 
-import com.android.settingslib.widget.R;
+import com.android.settings.R;
 
 import com.google.common.collect.Iterables;
 
@@ -55,13 +55,13 @@
  * display also the view background shows the color beside the text variable end point.
  */
 public class PaletteListView extends ListView {
-    private static final float VIEW_PITCH = 0.05f;
     private final Context mContext;
     private final DisplayAdapter mDisplayAdapter;
     private final LayoutInflater mLayoutInflater;
     private final String mDefaultGradientColorCodeString;
     private final int mDefaultGradientColor;
     private float mTextBound;
+    private static final float LANDSCAPE_MAX_WIDTH_PERCENTAGE = 100f;
 
     public PaletteListView(Context context) {
         this(context, null);
@@ -206,8 +206,17 @@
         final float textWidth = textView.getPaint().measureText(textView.getText().toString());
         // Computes rate of text width compare to screen width, and measures the round the double
         // to two decimal places manually.
-        final float textBound = Math.round(textWidth / getScreenWidth(windowManager) * 100) / 100f;
-        mTextBound = textBound + VIEW_PITCH;
+        final float textBound = Math.round(
+                textWidth / getScreenWidth(windowManager) * LANDSCAPE_MAX_WIDTH_PERCENTAGE)
+                / LANDSCAPE_MAX_WIDTH_PERCENTAGE;
+
+        // Left padding and right padding with color preview.
+        final float paddingPixel = getResources().getDimension(
+                R.dimen.accessibility_layout_margin_start_end);
+        final float paddingWidth =
+                Math.round(paddingPixel / getScreenWidth(windowManager)
+                        * LANDSCAPE_MAX_WIDTH_PERCENTAGE) / LANDSCAPE_MAX_WIDTH_PERCENTAGE;
+        mTextBound = textBound + paddingWidth + paddingWidth;
     }
 
     private static class ViewHolder {
diff --git a/src/com/android/settings/applications/AppStateAppOpsBridge.java b/src/com/android/settings/applications/AppStateAppOpsBridge.java
index 8c001d8..b4f6e48 100755
--- a/src/com/android/settings/applications/AppStateAppOpsBridge.java
+++ b/src/com/android/settings/applications/AppStateAppOpsBridge.java
@@ -61,6 +61,7 @@
         this(context, appState, callback, appOpsOpCode, permissions,
                 AppGlobals.getPackageManager());
     }
+
     AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
             int[] appOpsOpCodes, String[] permissions) {
         this(context, appState, callback, appOpsOpCodes, permissions,
@@ -70,9 +71,10 @@
     @VisibleForTesting
     AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
             int appOpsOpCode, String[] permissions, IPackageManager packageManager) {
-        this(context, appState, callback, new int[] {appOpsOpCode}, permissions,
+        this(context, appState, callback, new int[]{appOpsOpCode}, permissions,
                 packageManager);
     }
+
     AppStateAppOpsBridge(Context context, ApplicationsState appState, Callback callback,
             int[] appOpsOpCodes, String[] permissions, IPackageManager packageManager) {
         super(appState, callback);
@@ -155,8 +157,12 @@
         for (int i = 0; i < N; i++) {
             AppEntry app = apps.get(i);
             int userId = UserHandle.getUserId(app.info.uid);
-            ArrayMap<String, PermissionState> userMap = entries.get(userId);
-            app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
+            if (entries != null) {
+                ArrayMap<String, PermissionState> userMap = entries.get(userId);
+                app.extraInfo = userMap != null ? userMap.get(app.info.packageName) : null;
+            } else {
+                app.extraInfo = null;
+            }
         }
     }
 
@@ -247,6 +253,10 @@
      * a particular package.
      */
     private void loadAppOpsStates(SparseArray<ArrayMap<String, PermissionState>> entries) {
+        if (entries == null) {
+            return;
+        }
+
         // Find out which packages have been granted permission from AppOps.
         final List<AppOpsManager.PackageOps> packageOps = mAppOpsManager.getPackagesForOps(
                 mAppOpsOpCodes);
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 0f7a8c2..eb6515e 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -410,7 +410,7 @@
                 mApplications.mHasReceivedBridgeCallback =
                         savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
             }
-            int userId = mIsWorkOnly ? mWorkUserId : UserHandle.getUserId(mCurrentUid);
+            int userId = mIsWorkOnly ? mWorkUserId : UserHandle.myUserId();
             if (mStorageType == STORAGE_TYPE_MUSIC) {
                 Context context = getContext();
                 mApplications.setExtraViewController(
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 128f4da..0f429c7 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -83,7 +83,7 @@
         final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
         synchronized (mBluetoothA2dpConfigStore) {
             if (mBluetoothA2dp != null) {
-                setCodecConfigPreference(mBluetoothA2dp.getActiveDevice(), codecConfig);
+                setCodecConfigPreference(null, codecConfig);    // Use current active device
             }
         }
         // Because the setting is not persisted into permanent storage, we cannot call update state
@@ -102,14 +102,13 @@
 
     @Override
     public void updateState(Preference preference) {
-        BluetoothDevice activeDevice = mBluetoothA2dp.getActiveDevice();
-        if (getCodecConfig(activeDevice) == null || mPreference == null) {
+        if (getCodecConfig(null) == null || mPreference == null) { // Use current active device
             return;
         }
 
         BluetoothCodecConfig codecConfig;
         synchronized (mBluetoothA2dpConfigStore) {
-            codecConfig = getCodecConfig(activeDevice);
+            codecConfig = getCodecConfig(null);         // Use current active device
         }
 
         final int index = getCurrentA2dpSettingIndex(codecConfig);
diff --git a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
index 6f1eab0..71907b6 100644
--- a/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceController.java
@@ -80,7 +80,7 @@
         }
         writeConfigurationValues(index);
         final BluetoothCodecConfig codecConfig = mBluetoothA2dpConfigStore.createCodecConfig();
-        bluetoothA2dp.setCodecConfigPreference(bluetoothA2dp.getActiveDevice(), codecConfig);
+        bluetoothA2dp.setCodecConfigPreference(null, codecConfig);
         mPreference.setSummary(((BaseBluetoothDialogPreference) mPreference).generateSummary(
                 index));
     }
@@ -146,8 +146,7 @@
         if (bluetoothA2dp == null) {
             return null;
         }
-        final BluetoothCodecStatus codecStatus =
-                bluetoothA2dp.getCodecStatus(bluetoothA2dp.getActiveDevice());
+        final BluetoothCodecStatus codecStatus = bluetoothA2dp.getCodecStatus(null);
         if (codecStatus == null) {
             Log.d(TAG, "Unable to get current codec config. Codec status is null");
             return null;
@@ -178,8 +177,7 @@
      * @return {@link BluetoothCodecConfig}.
      */
     protected BluetoothCodecConfig getSelectableByCodecType(int codecTypeValue) {
-        final BluetoothCodecConfig[] configs = getSelectableConfigs(
-            mBluetoothA2dp.getActiveDevice());
+        final BluetoothCodecConfig[] configs = getSelectableConfigs(null);
         if (configs == null) {
             Log.d(TAG, "Unable to get selectable config. Selectable configs is empty.");
             return null;
diff --git a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
index 8eecec9..c2977a8 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceController.java
@@ -83,9 +83,9 @@
             return index;
         }
         // Check HD audio is enabled, display the available list.
-        if (bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
+        if (bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
                 == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED) {
-            BluetoothCodecConfig[] configs = getSelectableConfigs(bluetoothA2dp.getActiveDevice());
+            BluetoothCodecConfig[] configs = getSelectableConfigs(null);
             if (configs != null) {
                 return getIndexFromConfig(configs);
             }
@@ -101,8 +101,7 @@
         int codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
         switch (index) {
             case 0:
-                codecTypeValue = getHighestCodec(getSelectableConfigs(
-                    mBluetoothA2dp.getActiveDevice()));
+                codecTypeValue = getHighestCodec(getSelectableConfigs(null));
                 codecPriorityValue = BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST;
                 break;
             case 1:
diff --git a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
index 714b9ab..8008188 100644
--- a/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
+++ b/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceController.java
@@ -58,11 +58,11 @@
             mPreference.setEnabled(false);
             return;
         }
-        final boolean supported = (bluetoothA2dp.isOptionalCodecsSupported(activeDevice)
+        final boolean supported = (bluetoothA2dp.supportsOptionalCodecs(activeDevice)
                 == BluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
         mPreference.setEnabled(supported);
         if (supported) {
-            final boolean isEnabled = bluetoothA2dp.isOptionalCodecsEnabled(activeDevice)
+            final boolean isEnabled = bluetoothA2dp.getOptionalCodecsEnabled(activeDevice)
                     == BluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED;
             ((SwitchPreference) mPreference).setChecked(isEnabled);
         }
diff --git a/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java b/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
index e368aab..4862cfe 100644
--- a/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
+++ b/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceController.java
@@ -26,6 +26,7 @@
 import android.provider.Settings;
 
 import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.core.BasePreferenceController;
@@ -80,6 +81,12 @@
     }
 
     @Override
+    public void updateState(Preference preference) {
+        final FooterPreference footerPref = (FooterPreference) preference;
+        footerPref.setVisible(isAvailable());
+    }
+
+    @Override
     public void onGraphicsDriverContentChanged() {
         updateState(mPreference);
     }
diff --git a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
index 1986965..d7e07d9 100644
--- a/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
+++ b/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogController.java
@@ -27,6 +27,7 @@
 import android.os.IBinder;
 import android.os.PersistableBundle;
 import android.os.RemoteException;
+import android.telephony.AccessNetworkConstants;
 import android.telephony.Annotation;
 import android.telephony.CarrierConfigManager;
 import android.telephony.CellBroadcastIntents;
@@ -42,6 +43,9 @@
 import android.telephony.TelephonyManager;
 import android.telephony.UiccCardInfo;
 import android.telephony.euicc.EuiccManager;
+import android.telephony.ims.ImsException;
+import android.telephony.ims.ImsMmTelManager;
+import android.telephony.ims.ImsReasonInfo;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -107,11 +111,27 @@
             new OnSubscriptionsChangedListener() {
                 @Override
                 public void onSubscriptionsChanged() {
-                    mSubscriptionInfo = mSubscriptionManager.getActiveSubscriptionInfo(
-                            mSubscriptionInfo.getSubscriptionId());
-                    mTelephonyManager = mTelephonyManager.createForSubscriptionId(
-                            mSubscriptionInfo.getSubscriptionId());
-                    updateNetworkProvider();
+                    final int prevSubId = (mSubscriptionInfo != null)
+                            ? mSubscriptionInfo.getSubscriptionId()
+                            : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+                    mSubscriptionInfo = getPhoneSubscriptionInfo(mSlotIndex);
+
+                    final int nextSubId = (mSubscriptionInfo != null)
+                            ? mSubscriptionInfo.getSubscriptionId()
+                            : SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+                    if (prevSubId != nextSubId) {
+                        if (SubscriptionManager.isValidSubscriptionId(prevSubId)) {
+                            unregisterImsRegistrationCallback(prevSubId);
+                        }
+                        if (SubscriptionManager.isValidSubscriptionId(nextSubId)) {
+                            mTelephonyManager =
+                                    mTelephonyManager.createForSubscriptionId(nextSubId);
+                            registerImsRegistrationCallback(nextSubId);
+                        }
+                    }
+                    updateSubscriptionStatus();
                 }
             };
 
@@ -201,13 +221,17 @@
         }
 
         mPhoneStateListener = getPhoneStateListener();
+        updateLatestAreaInfo();
+        updateSubscriptionStatus();
+    }
+
+    private void updateSubscriptionStatus() {
         updateNetworkProvider();
 
         final ServiceState serviceState = mTelephonyManager.getServiceState();
         final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
 
         updatePhoneNumber();
-        updateLatestAreaInfo();
         updateServiceState(serviceState);
         updateSignalStrength(signalStrength);
         updateNetworkType();
@@ -241,6 +265,7 @@
                         | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
                         | PhoneStateListener.LISTEN_SERVICE_STATE);
         mSubscriptionManager.addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
+        registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
 
         if (mShowLatestAreaInfo) {
             updateAreaInfoText();
@@ -255,6 +280,7 @@
             return;
         }
 
+        unregisterImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
         mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
         mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
 
@@ -525,21 +551,68 @@
         }
     }
 
-    private void updateImsRegistrationState() {
+    private boolean isImsRegistrationStateShowUp() {
         final int subscriptionId = mSubscriptionInfo.getSubscriptionId();
         final PersistableBundle carrierConfig =
                 mCarrierConfigManager.getConfigForSubId(subscriptionId);
-        final boolean showImsRegState = carrierConfig == null ? false :
+        return carrierConfig == null ? false :
                 carrierConfig.getBoolean(
                         CarrierConfigManager.KEY_SHOW_IMS_REGISTRATION_STATUS_BOOL);
-        if (showImsRegState) {
-            final boolean isImsRegistered = mTelephonyManager.isImsRegistered(subscriptionId);
-            mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(isImsRegistered ?
-                    R.string.ims_reg_status_registered : R.string.ims_reg_status_not_registered));
-        } else {
-            mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
-            mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
+    }
+
+    private void updateImsRegistrationState() {
+        if (isImsRegistrationStateShowUp()) {
+            return;
         }
+        mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_LABEL_ID);
+        mDialog.removeSettingFromScreen(IMS_REGISTRATION_STATE_VALUE_ID);
+    }
+
+    private ImsMmTelManager.RegistrationCallback mImsRegStateCallback =
+            new ImsMmTelManager.RegistrationCallback() {
+        @Override
+        public void onRegistered(@AccessNetworkConstants.TransportType int imsTransportType) {
+            mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+                    R.string.ims_reg_status_registered));
+        }
+        @Override
+        public void onRegistering(@AccessNetworkConstants.TransportType int imsTransportType) {
+            mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+                    R.string.ims_reg_status_not_registered));
+        }
+        @Override
+        public void onUnregistered(@Nullable ImsReasonInfo info) {
+            mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+                    R.string.ims_reg_status_not_registered));
+        }
+        @Override
+        public void onTechnologyChangeFailed(
+                @AccessNetworkConstants.TransportType int imsTransportType,
+                @Nullable ImsReasonInfo info) {
+            mDialog.setText(IMS_REGISTRATION_STATE_VALUE_ID, mRes.getString(
+                    R.string.ims_reg_status_not_registered));
+        }
+    };
+
+    private void registerImsRegistrationCallback(int subId) {
+        if (!isImsRegistrationStateShowUp()) {
+            return;
+        }
+        try {
+            final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
+            imsMmTelMgr.registerImsRegistrationCallback(mDialog.getContext().getMainExecutor(),
+                    mImsRegStateCallback);
+        } catch (ImsException exception) {
+            Log.w(TAG, "fail to register IMS status for subId=" + subId, exception);
+        }
+    }
+
+    private void unregisterImsRegistrationCallback(int subId) {
+        if (!isImsRegistrationStateShowUp()) {
+            return;
+        }
+        final ImsMmTelManager imsMmTelMgr = ImsMmTelManager.createForSubscriptionId(subId);
+        imsMmTelMgr.unregisterImsRegistrationCallback(mImsRegStateCallback);
     }
 
     private SubscriptionInfo getPhoneSubscriptionInfo(int slotId) {
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index f87ff33..c2a0b62 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -20,7 +20,6 @@
 import static com.android.settings.dashboard.profileselector.ProfileSelectFragment.WORK_TAB;
 
 import android.app.settings.SettingsEnums;
-import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.TypedArray;
@@ -173,7 +172,7 @@
         if (intent != null) {
             intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
 
-            launchIntent(intent);
+            Utils.launchIntent(mFragment, intent);
             return true;
         }
 
@@ -467,24 +466,6 @@
         }
     }
 
-    private void launchIntent(Intent intent) {
-        try {
-            final int userId = intent.getIntExtra(Intent.EXTRA_USER_ID, -1);
-
-            // b/33117269: Note that launchIntent may launch activity in different task which set
-            // different launchMode (e.g. Files), using startActivityForesult to set task as
-            // source task, and set requestCode as 0 means don't care about returnCode currently.
-            if (userId == -1) {
-                mFragment.startActivityForResult(intent, 0 /* requestCode not used */);
-            } else {
-                mFragment.getActivity().startActivityForResultAsUser(intent,
-                        0 /* requestCode not used */, new UserHandle(userId));
-            }
-        } catch (ActivityNotFoundException e) {
-            Log.w(TAG, "No activity found for " + intent);
-        }
-    }
-
     private static long totalValues(StorageMeasurement.MeasurementDetails details, int userId,
             String... keys) {
         long total = 0;
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 31e8239..52fc99c 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -163,19 +163,30 @@
      * @param intent action performed
      */
     public void handleEnhanced4gLteChanged(Intent intent) {
-        final int subId = getDefaultVoiceSubId();
+        // skip checking when no toggle state update contained within Intent
+        final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE, false);
+        if (newValue != intent.getBooleanExtra(EXTRA_TOGGLE_STATE, true)) {
+            notifyEnhanced4gLteUpdate();
+            return;
+        }
 
-        if (SubscriptionManager.isValidSubscriptionId(subId)) {
-            final VolteQueryImsState queryState = queryImsState(subId);
-            if (queryState.isVoLteProvisioned()) {
-                final boolean currentValue = queryState.isEnabledByUser()
-                        && queryState.isAllowUserControl();
-                final boolean newValue = intent.getBooleanExtra(EXTRA_TOGGLE_STATE,
-                        currentValue);
-                if (newValue != currentValue) {
-                    setEnhanced4gLteModeSetting(subId, newValue);
-                }
-            }
+        final int subId = getDefaultVoiceSubId();
+        if (!SubscriptionManager.isValidSubscriptionId(subId)) {
+            notifyEnhanced4gLteUpdate();
+            return;
+        }
+
+        final VolteQueryImsState queryState = queryImsState(subId);
+        final boolean currentValue = queryState.isEnabledByUser()
+                && queryState.isAllowUserControl();
+        if (newValue == currentValue) {
+            notifyEnhanced4gLteUpdate();
+            return;
+        }
+
+        // isVoLteProvisioned() is the last item to check since it might block the main thread
+        if (queryState.isVoLteProvisioned()) {
+            setEnhanced4gLteModeSetting(subId, newValue);
         }
         notifyEnhanced4gLteUpdate();
     }
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 325e7f9..0adc6d5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -22,7 +22,6 @@
 import static org.mockito.Mockito.spy;
 
 import android.content.Context;
-import android.provider.DeviceConfig;
 import android.provider.Settings;
 import android.view.accessibility.AccessibilityManager;
 
@@ -72,11 +71,9 @@
 
     @Test
     @Config(shadows = {ShadowDeviceConfig.class})
-    public void testIsRampingRingerEnabled_bothFlagsOn_Enabled() {
+    public void testIsRampingRingerEnabled_settingsFlagOn_Enabled() {
         Settings.Global.putInt(
                 mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
         assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isTrue();
     }
 
@@ -87,12 +84,4 @@
                 mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 0 /* OFF */);
         assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
     }
-
-    @Test
-    @Config(shadows = {ShadowDeviceConfig.class})
-    public void testIsRampingRingerEnabled_deviceConfigFlagOff_Disabled() {
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                AccessibilitySettings.RAMPING_RINGER_ENABLED, "false", false /* makeDefault*/);
-        assertThat(AccessibilitySettings.isRampingRingerEnabled(mContext)).isFalse();
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java
deleted file mode 100644
index ad4195e..0000000
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityShortcutPreferenceControllerTest.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2019 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.accessibility;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.accessibilityservice.AccessibilityServiceInfo;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.provider.Settings;
-import android.view.accessibility.AccessibilityManager;
-
-import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
-import org.robolectric.annotation.Implementation;
-import org.robolectric.annotation.Implements;
-import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowAccessibilityManager;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-public class AccessibilityShortcutPreferenceControllerTest {
-    private final static String PACKAGE_NAME = "com.foo.bar";
-    private final static String CLASS_NAME = PACKAGE_NAME + ".fake_a11y_service";
-    private final static String COMPONENT_NAME = PACKAGE_NAME + "/" + CLASS_NAME;
-    private final static String SERVICE_NAME = "fake_a11y_service";
-    private final static int ON = 1;
-    private final static int OFF = 0;
-
-    private Context mContext;
-    private AccessibilityShortcutPreferenceController mController;
-    private ShadowAccessibilityManager mShadowAccessibilityManager;
-
-    @Before
-    public void setUp() {
-        mContext = RuntimeEnvironment.application;
-        mController = new AccessibilityShortcutPreferenceController(mContext, "shortcut_key");
-        mShadowAccessibilityManager = Shadow.extract(AccessibilityManager.getInstance(mContext));
-        mShadowAccessibilityManager.setInstalledAccessibilityServiceList(getMockServiceList());
-    }
-
-    @Test
-    public void getAvailabilityStatus_hasInstalledA11yServices_shouldReturnAvailable() {
-        assertThat(mController.getAvailabilityStatus())
-                .isEqualTo(BasePreferenceController.AVAILABLE);
-    }
-
-    @Test
-    public void getAvailabilityStatus_noInstalledServices_shouldReturnDisabledDependentSetting() {
-        mShadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
-
-        assertThat(mController.getAvailabilityStatus())
-                .isEqualTo(BasePreferenceController.DISABLED_DEPENDENT_SETTING);
-    }
-
-    @Test
-    @Config(shadows = {ShadowAccessibilityShortcutPreferenceFragment.class})
-    public void getSummary_enabledAndSelectedA11yServices_shouldReturnSelectedServiceName() {
-        ShadowAccessibilityShortcutPreferenceFragment.setServiceName(SERVICE_NAME);
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
-
-        assertThat(mController.getSummary()).isEqualTo(SERVICE_NAME);
-    }
-
-    @Test
-    public void getSummary_enabledAndNoA11yServices_shouldReturnNoServiceInstalled() {
-        mShadowAccessibilityManager.setInstalledAccessibilityServiceList(new ArrayList<>());
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, ON);
-
-        assertThat(mController.getSummary())
-                .isEqualTo(mContext.getString(R.string.accessibility_no_services_installed));
-    }
-
-    @Test
-    public void getSummary_disabledShortcut_shouldReturnOffSummary() {
-        Settings.Secure.putInt(mContext.getContentResolver(),
-                Settings.Secure.ACCESSIBILITY_SHORTCUT_ENABLED, OFF);
-
-        assertThat(mController.getSummary())
-                .isEqualTo(mContext.getString(R.string.accessibility_feature_state_off));
-    }
-
-    @Implements(AccessibilityShortcutPreferenceFragment.class)
-    private static class ShadowAccessibilityShortcutPreferenceFragment {
-        private static String sSelectedServiceName;
-
-        public static void setServiceName(String selectedServiceName) {
-            sSelectedServiceName = selectedServiceName;
-        }
-
-        @Implementation
-        protected static CharSequence getServiceName(Context context) {
-            return sSelectedServiceName;
-        }
-    }
-
-    private AccessibilityServiceInfo getMockAccessibilityServiceInfo() {
-        final ApplicationInfo applicationInfo = new ApplicationInfo();
-        final ServiceInfo serviceInfo = new ServiceInfo();
-        applicationInfo.packageName = PACKAGE_NAME;
-        serviceInfo.packageName = PACKAGE_NAME;
-        serviceInfo.name = CLASS_NAME;
-        serviceInfo.applicationInfo = applicationInfo;
-
-        final ResolveInfo resolveInfo = new ResolveInfo();
-        resolveInfo.serviceInfo = serviceInfo;
-
-        try {
-            final AccessibilityServiceInfo info = new AccessibilityServiceInfo(resolveInfo,
-                    mContext);
-            ComponentName componentName = ComponentName.unflattenFromString(COMPONENT_NAME);
-            info.setComponentName(componentName);
-            return info;
-        } catch (XmlPullParserException | IOException e) {
-            // Do nothing
-        }
-
-        return null;
-    }
-
-    private List<AccessibilityServiceInfo> getMockServiceList() {
-        final List<AccessibilityServiceInfo> infoList = new ArrayList<>();
-        infoList.add(getMockAccessibilityServiceInfo());
-        return infoList;
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
index d23d2f0..cd1d17e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationPreferenceFragmentTest.java
@@ -20,10 +20,8 @@
 
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.provider.DeviceConfig;
 import android.provider.Settings;
 
 import com.android.settings.testutils.shadow.ShadowDeviceConfig;
@@ -54,8 +52,6 @@
         // Turn on both flags to enable ramping ringer.
         Settings.Global.putInt(
                 mContext.getContentResolver(), Settings.Global.APPLY_RAMPING_RINGER, 1 /* ON */);
-        DeviceConfig.setProperty(DeviceConfig.NAMESPACE_TELEPHONY,
-                AccessibilitySettings.RAMPING_RINGER_ENABLED, "true", false /* makeDefault*/);
         assertThat(mFragment.getVibrationEnabledSetting()).isEqualTo(
             Settings.Global.APPLY_RAMPING_RINGER);
     }
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
index 7ff179e..802f871 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/AbstractBluetoothDialogPreferenceControllerTest.java
@@ -103,15 +103,13 @@
     @Test
     public void onIndexUpdated_checkFlow() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         when(mBluetoothA2dpConfigStore.createCodecConfig()).thenReturn(mCodecConfigAAC);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.onIndexUpdated(mCurrentConfig);
 
         verify(mController).writeConfigurationValues(mCurrentConfig);
-        verify(mBluetoothA2dp).setCodecConfigPreference(
-                mBluetoothA2dp.getActiveDevice(), mCodecConfigAAC);
+        verify(mBluetoothA2dp).setCodecConfigPreference(null, mCodecConfigAAC);
         assertThat(mPreference.getSummary()).isEqualTo(SUMMARY);
     }
 
@@ -136,15 +134,14 @@
         assertThat(mController.getCurrentCodecConfig()).isNull();
 
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
-        when(mBluetoothA2dp.getCodecStatus(mBluetoothA2dp.getActiveDevice())).thenReturn(null);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(null);
         assertThat(mController.getCurrentCodecConfig()).isNull();
     }
 
     @Test
     public void getCurrentCodecConfig_verifyConfig() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, null);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         assertThat(mController.getCurrentCodecConfig()).isEqualTo(mCodecConfigAAC);
@@ -153,8 +150,7 @@
     @Test
     public void getSelectableConfigs_verifyConfig() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         assertThat(mController.getSelectableConfigs(null)).isEqualTo(mCodecConfigs);
@@ -163,8 +159,7 @@
     @Test
     public void getSelectableByCodecType_verifyConfig() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         assertThat(mController.getSelectableByCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC))
@@ -174,8 +169,7 @@
     @Test
     public void getSelectableByCodecType_unavailable() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         assertThat(mController.getSelectableByCodecType(
@@ -185,8 +179,7 @@
     @Test
     public void onBluetoothServiceConnected_verifyBluetoothA2dpConfigStore() {
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         verify(mBluetoothA2dpConfigStore).setCodecType(mCodecConfigAAC.getCodecType());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
index 7c5e86e..0061fc0 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothBitPerSampleDialogPreferenceControllerTest.java
@@ -92,8 +92,7 @@
     public void writeConfigurationValues_selectDefault_setHighest() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         mController.writeConfigurationValues(0);
@@ -122,8 +121,7 @@
     public void getSelectableIndex_verifyList() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         List<Integer> indexList = new ArrayList<>();
         indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
index 32651ba..326cc22 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothChannelModeDialogPreferenceControllerTest.java
@@ -92,8 +92,7 @@
     public void writeConfigurationValues_selectDefault_setHighest() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         mController.writeConfigurationValues(0);
@@ -119,8 +118,7 @@
     public void getSelectableIndex_verifyList() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         List<Integer> indexList = new ArrayList<>();
         indexList.add(mPreference.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
index f93766f..f4ed811 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothCodecDialogPreferenceControllerTest.java
@@ -99,8 +99,7 @@
     public void writeConfigurationValues_selectDefault_setHighest() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         mController.writeConfigurationValues(0);
@@ -112,8 +111,7 @@
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
                 mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigSBC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         mController.writeConfigurationValues(1);
@@ -140,8 +138,7 @@
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC, mCodecConfigAPTX,
                 mCodecConfigAPTXHD, mCodecConfigLDAC, mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.writeConfigurationValues(2);
 
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
index 0701e78..1f0daa3 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothHDAudioPreferenceControllerTest.java
@@ -91,7 +91,7 @@
     @Test
     public void updateState_codecSupported_setEnable() {
         when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
-        when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
@@ -102,7 +102,7 @@
     @Test
     public void updateState_codecNotSupported_setDisable() {
         when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
-        when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_NOT_SUPPORTED);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
@@ -113,9 +113,9 @@
     @Test
     public void updateState_codecSupportedAndEnabled_checked() {
         when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
-        when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
-        when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_PREF_ENABLED);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
@@ -126,9 +126,9 @@
     @Test
     public void updateState_codecSupportedAndDisabled_notChecked() {
         when(mBluetoothA2dp.getActiveDevice()).thenReturn(mActiveDevice);
-        when(mBluetoothA2dp.isOptionalCodecsSupported(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.supportsOptionalCodecs(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_SUPPORTED);
-        when(mBluetoothA2dp.isOptionalCodecsEnabled(mActiveDevice)).thenReturn(
+        when(mBluetoothA2dp.getOptionalCodecsEnabled(mActiveDevice)).thenReturn(
                 mBluetoothA2dp.OPTIONAL_CODECS_PREF_DISABLED);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
index 30e3f31..35bd704 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothQualityDialogPreferenceControllerTest.java
@@ -110,8 +110,7 @@
     public void updateState_codeTypeIsLDAC_enablePreference() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigLDAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
 
@@ -122,8 +121,7 @@
     public void updateState_codeTypeAAC_disablePreference() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigLDAC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         mController.updateState(mPreference);
 
diff --git a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
index 089acc5..d274a57 100644
--- a/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/bluetooth/BluetoothSampleRateDialogPreferenceControllerTest.java
@@ -93,8 +93,7 @@
         mCodecConfigSBC = new BluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC);
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
 
         mController.writeConfigurationValues(0);
@@ -126,8 +125,7 @@
     public void getSelectableIndex_verifyList() {
         BluetoothCodecConfig[] mCodecConfigs = {mCodecConfigAAC, mCodecConfigSBC};
         mCodecStatus = new BluetoothCodecStatus(mCodecConfigAAC, null, mCodecConfigs);
-        when(mBluetoothA2dp.getCodecStatus(
-            mBluetoothA2dp.getActiveDevice())).thenReturn(mCodecStatus);
+        when(mBluetoothA2dp.getCodecStatus(null)).thenReturn(mCodecStatus);
         mController.onBluetoothServiceConnected(mBluetoothA2dp);
         List<Integer> indexList = new ArrayList<>();
         indexList.add(mController.getDefaultIndex());
diff --git a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
index 1dac131..a2d23b6 100644
--- a/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/graphicsdriver/GraphicsDriverFooterPreferenceControllerTest.java
@@ -105,4 +105,20 @@
 
         verify(mGraphicsDriverContentObserver).unregister(mResolver);
     }
+
+    @Test
+    public void updateState_available_visible() {
+        when(mController.getAvailabilityStatus()).thenReturn(AVAILABLE_UNSEARCHABLE);
+        mController.updateState(mPreference);
+
+        verify(mPreference).setVisible(true);
+    }
+
+    @Test
+    public void updateState_unavailable_invisible() {
+        when(mController.getAvailabilityStatus()).thenReturn(CONDITIONALLY_UNAVAILABLE);
+        mController.updateState(mPreference);
+
+        verify(mPreference).setVisible(false);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
index 851dfe0..395c8a4 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/simstatus/SimStatusDialogControllerTest.java
@@ -43,6 +43,7 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.robolectric.Shadows.shadowOf;
 
 import android.content.Context;
 import android.content.pm.PackageInfo;
@@ -80,6 +81,7 @@
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowPackageManager;
+import org.robolectric.shadows.ShadowTelephonyManager;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
@@ -93,7 +95,6 @@
 
     @Mock
     private SimStatusDialogFragment mDialog;
-    @Mock
     private TelephonyManager mTelephonyManager;
     @Mock
     private SubscriptionInfo mSubscriptionInfo;
@@ -115,7 +116,6 @@
     private PersistableBundle mPersistableBundle;
     @Mock
     private EuiccManager mEuiccManager;
-    @Mock
     private SubscriptionManager mSubscriptionManager;
 
     private SimStatusDialogController mController;
@@ -131,10 +131,22 @@
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mContext = spy(RuntimeEnvironment.application);
         when(mDialog.getContext()).thenReturn(mContext);
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
+
+        mSubscriptionManager = spy(mContext.getSystemService(SubscriptionManager.class));
+
+        mTelephonyManager = spy(mContext.getSystemService(TelephonyManager.class));
+        final ShadowTelephonyManager shadowTelephonyMgr = shadowOf(mTelephonyManager);
+        shadowTelephonyMgr.setTelephonyManagerForSubscriptionId(
+                SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, mTelephonyManager);
+        doReturn(2).when(mTelephonyManager).getCardIdForDefaultEuicc();
+        doReturn(TelephonyManager.NETWORK_TYPE_LTE).when(mTelephonyManager).getDataNetworkType();
+
+        doReturn(mEuiccManager).when(mContext).getSystemService(EuiccManager.class);
+
         mController = spy(new SimStatusDialogController(mDialog, mLifecycle, 0 /* phone id */));
         ShadowDeviceInfoUtils.setPhoneNumber("");
         //CellSignalStrength setup
@@ -156,9 +168,9 @@
         ReflectionHelpers.setField(mController, "mSubscriptionManager", mSubscriptionManager);
 
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
-        when(mTelephonyManager.getUiccCardsInfo()).thenReturn(new ArrayList<UiccCardInfo>());
-        when(mTelephonyManager.getLogicalToPhysicalSlotMapping()).thenReturn(
-                new HashMap<Integer, Integer>());
+        doReturn(new ArrayList<UiccCardInfo>()).when(mTelephonyManager).getUiccCardsInfo();
+        doReturn(new HashMap<Integer, Integer>()).when(mTelephonyManager)
+                .getLogicalToPhysicalSlotMapping();
 
         when(mEuiccManager.isEnabled()).thenReturn(false);
         when(mEuiccManager.getEid()).thenReturn("");
@@ -168,7 +180,6 @@
         when(mPersistableBundle.getBoolean(
                 CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
                 .thenReturn(true);
-        when(mTelephonyManager.createForSubscriptionId(anyInt())).thenReturn(mTelephonyManager);
         doReturn(mServiceState).when(mTelephonyManager).getServiceState();
         doReturn(mSignalStrength).when(mTelephonyManager).getSignalStrength();
 
@@ -185,7 +196,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateNetworkProviderWithFoobarCarrier_shouldUpdateCarrierWithFoobar() {
         final CharSequence carrierName = "foobar";
         doReturn(carrierName).when(mSubscriptionInfo).getCarrierName();
@@ -196,7 +206,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updatePhoneNumberWith1111111111_shouldUpdatePhoneNumber() {
         ShadowDeviceInfoUtils.setPhoneNumber("1111111111");
 
@@ -209,7 +218,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateLatestAreaInfoWithCdmaPhone_shouldRemoveOperatorInfoSetting() {
         when(mTelephonyManager.getPhoneType()).thenReturn(TelephonyManager.PHONE_TYPE_CDMA);
 
@@ -220,7 +228,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateServiceStateWithInService_shouldUpdateTextToBeCInService() {
         when(mServiceState.getState()).thenReturn(ServiceState.STATE_IN_SERVICE);
 
@@ -231,7 +238,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateServiceStateWithPowerOff_shouldUpdateTextAndResetSignalStrength() {
         when(mServiceState.getState()).thenReturn(ServiceState.STATE_POWER_OFF);
         when(mPersistableBundle.getBoolean(
@@ -245,7 +251,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateVoiceDataOutOfService_shouldUpdateSettingAndResetSignalStrength() {
         when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
         when(mServiceState.getDataRegistrationState()).thenReturn(
@@ -261,7 +266,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateTextToBeInService() {
         when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
         when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -275,7 +279,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateSignalStrengthWithLte50Wcdma40_shouldUpdateSignalStrengthTo50() {
         final int lteDbm = 50;
         final int lteAsu = 50;
@@ -293,7 +296,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateSignalStrengthWithLte50Cdma30_shouldUpdateSignalStrengthTo50() {
         final int lteDbm = 50;
         final int lteAsu = 50;
@@ -311,7 +313,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateVoiceOutOfServiceDataInService_shouldUpdateSignalStrengthTo50() {
         when(mServiceState.getState()).thenReturn(ServiceState.STATE_OUT_OF_SERVICE);
         when(mServiceState.getDataRegistrationState()).thenReturn(ServiceState.STATE_IN_SERVICE);
@@ -332,7 +333,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateVoiceNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
         when(mTelephonyManager.getVoiceNetworkType()).thenReturn(
                 TelephonyManager.NETWORK_TYPE_EDGE);
@@ -344,7 +344,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateDataNetworkTypeWithEdge_shouldUpdateSettingToEdge() {
         when(mTelephonyManager.getDataNetworkType()).thenReturn(
                 TelephonyManager.NETWORK_TYPE_EDGE);
@@ -356,7 +355,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateRoamingStatusIsRoaming_shouldSetSettingToRoaming() {
         when(mServiceState.getRoaming()).thenReturn(true);
 
@@ -367,7 +365,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateRoamingStatusNotRoaming_shouldSetSettingToRoamingOff() {
         when(mServiceState.getRoaming()).thenReturn(false);
 
@@ -378,7 +375,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_doNotShowIccid_shouldRemoveIccidSetting() {
         when(mPersistableBundle.getBoolean(
                 CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL)).thenReturn(false);
@@ -390,7 +386,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_doNotShowSignalStrength_shouldRemoveSignalStrengthSetting() {
         when(mPersistableBundle.getBoolean(
                 CarrierConfigManager.KEY_SHOW_SIGNAL_STRENGTH_IN_SIM_STATUS_BOOL))
@@ -403,7 +398,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_showSignalStrengthAndIccId_shouldShowSignalStrengthAndIccIdSetting() {
         // getConfigForSubId is nullable, so make sure the default behavior is correct
         when(mCarrierConfigManager.getConfigForSubId(anyInt())).thenReturn(null);
@@ -416,7 +410,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_showIccid_shouldSetIccidToSetting() {
         final String iccid = "12351351231241";
         when(mPersistableBundle.getBoolean(
@@ -429,7 +422,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldNotSetEid() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
@@ -468,7 +460,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldSetEidFromCard() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
@@ -507,7 +498,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldSetEidFromManager() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
@@ -549,7 +539,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldRemoveEid() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_DUAL_SIM);
 
@@ -589,7 +578,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldNotSetEidInSingleSimMode() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
@@ -619,7 +607,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldSetEidInSingleSimModeWithEnabledEuicc() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
@@ -651,7 +638,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldSetEidInSingleSimModeWithDisabledEuicc() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
@@ -683,7 +669,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_updateEid_shouldRemoveEidInSingleSimMode() {
         when(mTelephonyManager.getActiveModemCount()).thenReturn(MAX_PHONE_COUNT_SINGLE_SIM);
 
@@ -763,7 +748,6 @@
     }
 
     @Test
-    @Ignore
     public void initialize_nullSignalStrength_noCrash() {
         doReturn(null).when(mTelephonyManager).getSignalStrength();
         // we should not crash when running the following line
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index ebb5292..5e49aa0 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -20,7 +20,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.mock;
@@ -120,7 +119,7 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mActivity).startActivityForResultAsUser(argumentCaptor.capture(), anyInt(),
+        verify(mActivity).startActivityAsUser(argumentCaptor.capture(),
                 nullable(UserHandle.class));
 
         final Intent intent = argumentCaptor.getValue();
@@ -138,8 +137,8 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
         final Intent intent = argumentCaptor.getValue();
 
         assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -165,8 +164,8 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
 
         final Intent intent = argumentCaptor.getValue();
         assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -184,8 +183,8 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
 
         Intent intent = argumentCaptor.getValue();
         assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -221,8 +220,8 @@
             .isTrue();
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
 
         Intent intent = argumentCaptor.getValue();
         Intent browseIntent = mVolume.buildBrowseIntent();
@@ -238,8 +237,8 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
 
         Intent intent = argumentCaptor.getValue();
         assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
@@ -256,8 +255,8 @@
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityForResultAsUser(argumentCaptor.capture(),
-                anyInt(), nullable(UserHandle.class));
+        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
+                nullable(UserHandle.class));
 
         Intent intent = argumentCaptor.getValue();
         assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);