Merge "Add setPackage for PendingIntent in SliceHelper" into rvc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3684056..366254f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4944,7 +4944,7 @@
     <string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, you can zoom in on your screen.\n\n<b>To zoom</b>, start magnification, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, start magnification, then touch &amp; hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
     <!-- Title for the accessibility tutorial dialog in accessibility service with button. [CHAR LIMIT=50] -->
     <string name="accessibility_tutorial_dialog_title_button">Use accessibility button to open</string>
-    <!-- Title for the accessibility tutorial dialog in accessibility service with volume keys. [CHAR LIMIT=50] -->
+    <!-- Title for the accessibility tutorial dialog in accessibility service with volume keys. [CHAR LIMIT=100] -->
     <string name="accessibility_tutorial_dialog_title_volume">Hold volume keys to open</string>
     <!-- Title for the accessibility tutorial dialog in accessibility service with triple tap. [CHAR LIMIT=100] -->
     <string name="accessibility_tutorial_dialog_title_triple">Triple tap screen to open</string>
@@ -8197,8 +8197,6 @@
 
     <!-- Configure Notifications: Title for the notification bubbles option. [CHAR LIMIT=60] -->
     <string name="notification_bubbles_title">Bubbles</string>
-    <!-- Developer setting summary for bubbles [CHAR LIMIT=NONE] -->
-    <string name="notification_bubbles_developer_setting_summary">Some notifications can appear as bubbles on the screen</string>
     <!-- Feature education for bubbles. [CHAR LIMIT=NONE] -->
     <string name="bubbles_feature_education">Some notifications and other content can appear as bubbles on the screen. To open a bubble, tap it. To dismiss it, drag it down the screen.</string>
     <!-- Title for the toggle shown on the app-level bubbles page  [CHAR LIMIT=60] -->
@@ -8666,7 +8664,7 @@
     <!-- Settings text. This text lets a user know that they should only connect work and personal apps
     if they trust the work app with their personal data. The work app could potentially show that data
     to the user's IT admin. [CHAR LIMIT=NONE] -->
-    <string name="interact_across_profiles_summary_2">Only connect apps that you trust with your personal data. Work apps may expose your data to your IT admin.</string>
+    <string name="interact_across_profiles_summary_2">Only connect apps if you trust them not to share personal data with your IT admin.</string>
 
     <!-- Dialog title. This dialog is shown when a user tries to connect a work app to a personal
     app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
@@ -8677,7 +8675,7 @@
     app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
     connect the apps only if they trust the work app with their personal data.
     The placeholder is the app name. [CHAR LIMIT=NONE] -->
-    <string name="interact_across_profiles_consent_dialog_summary"><xliff:g id="name" example="Calendar">%1$s</xliff:g> may expose your personal data to your IT admin.</string>
+    <string name="interact_across_profiles_consent_dialog_summary">Only connect apps if you trust them not to share personal data with your IT admin.</string>
 
     <!-- Title of a section in a dialog. This section shows the app data that will be
     accessible when work and personal apps are connected. [CHAR LIMIT=NONE] -->
@@ -8708,12 +8706,12 @@
     <!-- Banner title. This banner lets a user know that they need to install an app in their
     work profile in order to connect it to the corresponding personal app.
     The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
-    <string name="interact_across_profiles_install_work_app_title">Install work <xliff:g id="name" example="Calendar">%1$s</xliff:g> to connect these apps</string>
+    <string name="interact_across_profiles_install_work_app_title">To connect these apps, install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your work profile</string>
 
     <!-- Banner title. This banner lets a user know that they need to install an app in their
     personal profile in order to connect it to the corresponding work app.
     The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
-    <string name="interact_across_profiles_install_personal_app_title">Install personal <xliff:g id="name" example="Calendar">%1$s</xliff:g> to connect these apps</string>
+    <string name="interact_across_profiles_install_personal_app_title">To connect these apps, install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your personal profile</string>
 
     <!-- Banner text. This banner lets a user know that they need to install an app in their
     work/personal profile in order to connect it to the corresponding personal app.
@@ -11820,11 +11818,6 @@
     <!-- Summary for the top level Privacy Settings [CHAR LIMIT=NONE]-->
     <string name="privacy_dashboard_summary">Permissions, account activity, personal data</string>
 
-    <!-- UI debug setting: show media player on quick settings title [CHAR LIMIT=60] -->
-    <string name="quick_settings_media_player">Media resumption</string>
-    <!-- UI debug setting: show media player on quick settings summary [CHAR_LIMIT=NONE] -->
-    <string name="quick_settings_media_player_summary">Shows and persists media player in Quick Settings. Requires reboot.</string>
-
     <!-- Label for button in contextual card for users to remove the card [CHAR LIMIT=30] -->
     <string name="contextual_card_dismiss_remove">Remove</string>
     <!-- Label for button in contextual card for users to keep the card [CHAR LIMIT=30] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8393f80..d8f5e87 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -501,6 +501,11 @@
         <item name="rowStyle">@style/SliceRow.Settings</item>
     </style>
 
+    <style name="Widget.SliceView.ContextualCard">
+        <item name="rowStyle">@style/SliceRow</item>
+        <item name="android:background">@color/contextual_card_background</item>
+    </style>
+
     <style name="Widget.SliceView.Panel">
         <item name="titleSize">16sp</item>
         <item name="rowStyle">@style/SliceRow</item>
@@ -511,35 +516,6 @@
         <item name="rowStyle">@style/SliceRow.Slider</item>
     </style>
 
-    <style name="SliceRow.Slider">
-        <!-- 2dp start padding for the start icon -->
-        <item name="titleItemStartPadding">10dp</item>
-        <item name="titleItemEndPadding">0dp</item>
-
-        <!-- Padding between content and the start icon is 14dp -->
-        <item name="contentStartPadding">5dp</item>
-        <!-- Padding between content and end items is 16dp -->
-        <item name="contentEndPadding">16dp</item>
-
-        <!-- Both side margins of end item are 16dp -->
-        <item name="endItemStartPadding">0dp</item>
-        <item name="endItemEndPadding">24dp</item>
-
-        <!-- Both side margins of bottom divider are 12dp -->
-        <item name="bottomDividerStartPadding">12dp</item>
-        <item name="bottomDividerEndPadding">12dp</item>
-
-        <item name="actionDividerHeight">32dp</item>
-        <!-- Align text with slider -->
-        <item name="titleStartPadding">6dp</item>
-        <item name="subContentStartPadding">6dp</item>
-    </style>
-
-    <style name="Widget.SliceView.ContextualCard">
-        <item name="rowStyle">@style/SliceRow</item>
-        <item name="android:background">@color/contextual_card_background</item>
-    </style>
-
     <style name="SliceRow">
         <!-- 2dp start padding for the start icon -->
         <item name="titleItemStartPadding">2dp</item>
@@ -566,6 +542,23 @@
         <item name="contentStartPadding">8dp</item>
     </style>
 
+    <style name="SliceRow.Slider">
+        <!-- 10dp start padding for the start icon -->
+        <item name="titleItemStartPadding">10dp</item>
+
+        <!-- Padding between content and the start icon is 5dp -->
+        <item name="contentStartPadding">5dp</item>
+
+        <!-- 0dp start padding for the end item -->
+        <item name="endItemStartPadding">0dp</item>
+        <!-- 24dp end padding for the end item -->
+        <item name="endItemEndPadding">24dp</item>
+
+        <!-- Align text with slider -->
+        <item name="titleStartPadding">6dp</item>
+        <item name="subContentStartPadding">6dp</item>
+    </style>
+
     <style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
         <item name="android:layout_margin">16dp</item>
         <item name="android:paddingStart">8dp</item>
diff --git a/res/xml/accessibility_color_inversion_settings.xml b/res/xml/accessibility_color_inversion_settings.xml
new file mode 100644
index 0000000..44702db
--- /dev/null
+++ b/res/xml/accessibility_color_inversion_settings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:persistent="false"
+    android:title="@string/accessibility_display_inversion_preference_title">
+</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index d1473e5..cce0a37 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -527,11 +527,6 @@
             android:title="@string/usb_audio_disable_routing"
             android:summary="@string/usb_audio_disable_routing_summary" />
 
-        <SwitchPreference
-            android:key="quick_settings_media_player"
-            android:title="@string/quick_settings_media_player"
-            android:summary="@string/quick_settings_media_player_summary" />
-
     </PreferenceCategory>
 
     <PreferenceCategory
@@ -638,12 +633,6 @@
         <Preference
             android:key="reset_shortcut_manager_throttling"
             android:title="@string/reset_shortcut_manager_throttling" />
-
-        <SwitchPreference
-            android:key="notification_bubbles"
-            android:title="@string/notification_bubbles_title"
-            android:summary="@string/notification_bubbles_developer_setting_summary"/>
-
     </PreferenceCategory>
 
     <com.android.settings.development.autofill.AutofillPreferenceCategory
diff --git a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
index cae1b25..dfdcd9e 100644
--- a/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleColorInversionPreferenceFragment.java
@@ -57,6 +57,11 @@
     }
 
     @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.accessibility_color_inversion_settings;
+    }
+
+    @Override
     protected void onRemoveSwitchPreferenceToggleSwitch() {
         super.onRemoveSwitchPreferenceToggleSwitch();
         mToggleServiceDividerSwitchPreference.setOnPreferenceClickListener(null);
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 6b0759a..f8b64fb 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -30,6 +30,7 @@
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Handler;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.text.Html;
@@ -96,6 +97,7 @@
     private int mUserShortcutTypes = UserShortcutType.EMPTY;
     private CheckBox mSoftwareTypeCheckBox;
     private CheckBox mHardwareTypeCheckBox;
+    private SettingsContentObserver mSettingsContentObserver;
 
     // For html description of accessibility service, must follow the rule, such as
     // <img src="R.drawable.fileName"/>, a11y settings will get the resources successfully.
@@ -133,6 +135,17 @@
             removeDialog(DialogEnums.EDIT_SHORTCUT);
             mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
         };
+
+        final List<String> shortcutFeatureKeys = new ArrayList<>();
+        shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
+        shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
+        mSettingsContentObserver = new SettingsContentObserver(new Handler(), shortcutFeatureKeys) {
+            @Override
+            public void onChange(boolean selfChange, Uri uri) {
+                updateShortcutPreferenceData();
+                updateShortcutPreference();
+            }
+        };
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
@@ -229,6 +242,7 @@
         final AccessibilityManager am = getPrefContext().getSystemService(
                 AccessibilityManager.class);
         am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+        mSettingsContentObserver.register(getContentResolver());
         updateShortcutPreferenceData();
         updateShortcutPreference();
     }
@@ -238,6 +252,7 @@
         final AccessibilityManager am = getPrefContext().getSystemService(
                 AccessibilityManager.class);
         am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+        mSettingsContentObserver.unregister(getContentResolver());
         super.onPause();
     }
 
@@ -618,7 +633,7 @@
                 getShortcutTypeSummary(getPrefContext()));
     }
 
-    private void updateShortcutPreferenceData() {
+    protected void updateShortcutPreferenceData() {
         if (mComponentName == null) {
             return;
         }
@@ -651,7 +666,7 @@
         mShortcutPreference.setTitle(title);
     }
 
-    private void updateShortcutPreference() {
+    protected void updateShortcutPreference() {
         if (mComponentName == null) {
             return;
         }
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 23fb153..52f8f71 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -467,7 +467,8 @@
         showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
     }
 
-    private void updateShortcutPreferenceData() {
+    @Override
+    protected void updateShortcutPreferenceData() {
         // Get the user shortcut type from settings provider.
         mUserShortcutType = getUserShortcutTypeFromSettings(getPrefContext());
         if (mUserShortcutType != UserShortcutType.EMPTY) {
@@ -489,7 +490,8 @@
         mShortcutPreference.setTitle(title);
     }
 
-    private void updateShortcutPreference() {
+    @Override
+    protected void updateShortcutPreference() {
         final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
         mShortcutPreference.setChecked(
                 hasMagnificationValuesInSettings(getPrefContext(), shortcutTypes));
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index ad47c03..8b1497e 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -255,11 +255,6 @@
         dialogTitle.setText(
                 getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel));
 
-        final TextView dialogSummary = dialogView.findViewById(
-                R.id.interact_across_profiles_consent_dialog_summary);
-        dialogSummary.setText(
-                getString(R.string.interact_across_profiles_consent_dialog_summary, mAppLabel));
-
         final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
         appDataSummary.setText(getString(
                 R.string.interact_across_profiles_consent_dialog_app_data_summary, mAppLabel));
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index 6492560..eaccebf 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -496,7 +496,6 @@
         controllers.add(new DebugNonRectClipOperationsPreferenceController(context));
         controllers.add(new ForceDarkPreferenceController(context));
         controllers.add(new EnableBlursPreferenceController(context));
-        controllers.add(new QuickSettingsMediaPlayerPreferenceController(context));
         controllers.add(new ForceMSAAPreferenceController(context));
         controllers.add(new HardwareOverlaysPreferenceController(context));
         controllers.add(new SimulateColorSpacePreferenceController(context));
diff --git a/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceController.java b/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceController.java
deleted file mode 100644
index 47f3adc..0000000
--- a/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceController.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2020 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.development;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-import androidx.preference.SwitchPreference;
-
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-
-/**
- * Controls whether the media player should be visible in quick settings.
- */
-public class QuickSettingsMediaPlayerPreferenceController extends
-        DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
-        PreferenceControllerMixin {
-    private static final String PREFERENCE_KEY = "quick_settings_media_player";
-    @VisibleForTesting
-    static final String SETTING_NAME = Settings.Global.SHOW_MEDIA_ON_QUICK_SETTINGS;
-    @VisibleForTesting
-    static final int SETTING_VALUE_ON = 1;
-    @VisibleForTesting
-    static final int SETTING_VALUE_OFF = 0;
-
-    public QuickSettingsMediaPlayerPreferenceController(Context context) {
-        super(context);
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return PREFERENCE_KEY;
-    }
-
-    @Override
-    public boolean onPreferenceChange(Preference preference, Object newValue) {
-        final boolean isEnabled = (Boolean) newValue;
-        Settings.Global.putInt(mContext.getContentResolver(), SETTING_NAME,
-                isEnabled ? SETTING_VALUE_ON : SETTING_VALUE_OFF);
-        return true;
-    }
-
-    @Override
-    public void updateState(Preference preference) {
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(), SETTING_NAME,
-                SETTING_VALUE_OFF);
-        ((SwitchPreference) mPreference).setChecked(mode != SETTING_VALUE_OFF);
-    }
-
-    @Override
-    protected void onDeveloperOptionsSwitchDisabled() {
-        super.onDeveloperOptionsSwitchDisabled();
-        Settings.Global.putInt(mContext.getContentResolver(), SETTING_NAME, SETTING_VALUE_OFF);
-        ((SwitchPreference) mPreference).setChecked(false);
-    }
-}
diff --git a/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java b/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
index fb2dbc3..ef11e00 100644
--- a/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
@@ -74,7 +74,7 @@
         if (String.valueOf(ColorDisplayManager.AUTO_MODE_TWILIGHT).equals(newValue)
                 && !mLocationManager.isLocationEnabled()) {
             TwilightLocationDialog.show(mContext);
-            return false;
+            return true;
         }
         return mColorDisplayManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
     }
diff --git a/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java b/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
index 6acaf82..2ac9a9f 100644
--- a/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
+++ b/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
@@ -33,7 +33,7 @@
  */
 public class DarkModeScheduleSelectorController extends BasePreferenceController
         implements Preference.OnPreferenceChangeListener {
-
+    private static final String TAG = DarkModeScheduleSelectorController.class.getSimpleName();
     private final UiModeManager mUiModeManager;
     private PowerManager mPowerManager;
     private DropDownPreference mPreference;
@@ -51,7 +51,6 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
-        init();
     }
 
     @Override
@@ -59,7 +58,8 @@
         return BasePreferenceController.AVAILABLE;
     }
 
-    private void init() {
+    @Override
+    public final void updateState(Preference preference) {
         final boolean batterySaver = mPowerManager.isPowerSaveMode();
         mPreference.setEnabled(!batterySaver);
         mCurrentMode = getCurrentMode();
@@ -87,25 +87,25 @@
         if (newMode == mCurrentMode) {
             return false;
         }
-        mCurrentMode = newMode;
-        if (mCurrentMode == mPreference.findIndexOfValue(
+        if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_never))) {
             boolean active = (mContext.getResources().getConfiguration().uiMode
                     & Configuration.UI_MODE_NIGHT_YES) != 0;
             int mode = active ? UiModeManager.MODE_NIGHT_YES
                     : UiModeManager.MODE_NIGHT_NO;
             mUiModeManager.setNightMode(mode);
-        } else if (mCurrentMode == mPreference.findIndexOfValue(
+        } else if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_auto))) {
             if (!mLocationManager.isLocationEnabled()) {
                 TwilightLocationDialog.show(mContext);
-                return false;
+                return true;
             }
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
-        } else if (mCurrentMode == mPreference.findIndexOfValue(
+        } else if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_custom))) {
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
         }
+        mCurrentMode = newMode;
         return true;
     }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 33faee0..4d420d1 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -56,6 +56,7 @@
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowAppUtils;
 import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.widget.LoadingViewController;
 import com.android.settingslib.applications.ApplicationsState;
@@ -76,7 +77,7 @@
 import java.util.ArrayList;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowUserManager.class)
+@Config(shadows = {ShadowUserManager.class, ShadowAppUtils.class})
 public class ManageApplicationsTest {
 
     @Mock
diff --git a/tests/robotests/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceControllerTest.java
deleted file mode 100644
index 10eed2f..0000000
--- a/tests/robotests/src/com/android/settings/development/QuickSettingsMediaPlayerPreferenceControllerTest.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2020 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.development;
-
-import static com.android.settings.development.QuickSettingsMediaPlayerPreferenceController.SETTING_NAME;
-import static com.android.settings.development.QuickSettingsMediaPlayerPreferenceController.SETTING_VALUE_OFF;
-import static com.android.settings.development.QuickSettingsMediaPlayerPreferenceController.SETTING_VALUE_ON;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.provider.Settings;
-
-import androidx.preference.PreferenceScreen;
-import androidx.preference.SwitchPreference;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class QuickSettingsMediaPlayerPreferenceControllerTest {
-    @Mock
-    private SwitchPreference mPreference;
-    @Mock
-    private PreferenceScreen mPreferenceScreen;
-    @Rule
-    public MockitoRule mMockitoRule = MockitoJUnit.rule();
-
-    private Context mContext;
-    private QuickSettingsMediaPlayerPreferenceController mController;
-
-    @Before
-    public void setup() {
-        mContext = RuntimeEnvironment.application;
-        mController = new QuickSettingsMediaPlayerPreferenceController(mContext);
-        when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
-            .thenReturn(mPreference);
-        mController.displayPreference(mPreferenceScreen);
-    }
-
-    @Test
-    public void onPreferenceChanged_turnOnPreference_shouldEnable() {
-        mController.onPreferenceChange(mPreference, true /* new value */);
-
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                SETTING_NAME, -1 /* default */);
-
-        assertThat(mode).isEqualTo(SETTING_VALUE_ON);
-    }
-
-    @Test
-    public void onPreferenceChanged_turnOffPreference_shouldDisable() {
-        mController.onPreferenceChange(mPreference, false /* new value */);
-
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                SETTING_NAME, -1 /* default */);
-
-        assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
-    }
-
-    @Test
-    public void updateState_settingEnabled_preferenceShouldBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(), SETTING_NAME, SETTING_VALUE_ON);
-        mController.updateState(mPreference);
-
-        verify(mPreference).setChecked(true);
-    }
-
-    @Test
-    public void updateState_settingDisabled_preferenceShouldNotBeChecked() {
-        Settings.Global.putInt(mContext.getContentResolver(), SETTING_NAME, SETTING_VALUE_OFF);
-        mController.updateState(mPreference);
-
-        verify(mPreference).setChecked(false);
-    }
-
-    @Test
-    public void onDeveloperOptionsSwitchDisabled_shouldDisable() {
-        mController.onDeveloperOptionsSwitchDisabled();
-        final int mode = Settings.Global.getInt(mContext.getContentResolver(),
-                SETTING_NAME, -1 /* default */);
-
-        assertThat(mode).isEqualTo(SETTING_VALUE_OFF);
-        verify(mPreference).setEnabled(false);
-        verify(mPreference).setChecked(false);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java
new file mode 100644
index 0000000..871a536
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 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.testutils.shadow;
+
+import android.content.Context;
+
+import com.android.settingslib.applications.AppUtils;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Implements(AppUtils.class)
+public class ShadowAppUtils {
+
+    private static Map<String, String> sAppContentDesMap;
+
+    @Implementation
+    protected static CharSequence getAppContentDescription(Context context, String packageName,
+            int userId) {
+        if (sAppContentDesMap != null) {
+            return sAppContentDesMap.get(packageName);
+        }
+        return null;
+    }
+
+    public static void setAppContentDescription(String packageName, String appContentDes) {
+        if (sAppContentDesMap == null) {
+            sAppContentDesMap = new HashMap<>();
+        }
+        sAppContentDesMap.put(packageName, appContentDes);
+    }
+}