Merge "In Media Switch output panel, Switch access shouldn't select the first device when selecting the device list" into rvc-dev
diff --git a/res/layout/notification_sbn_log_row.xml b/res/layout/notification_sbn_log_row.xml
index 3b731ac..049e940 100644
--- a/res/layout/notification_sbn_log_row.xml
+++ b/res/layout/notification_sbn_log_row.xml
@@ -14,119 +14,132 @@
      limitations under the License.
 -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:paddingTop="6dp"
-    android:minHeight="48dp"
-    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:orientation="vertical"
-    android:background="?android:attr/selectableItemBackground"
-    >
-
-    <LinearLayout
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:paddingTop="6dp"
+              android:minHeight="48dp"
+              android:orientation="vertical"
+              android:background="?android:attr/selectableItemBackground"
+>
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:minHeight="@*android:dimen/status_bar_icon_size"
-        android:paddingBottom="6dp">
-
-        <ImageView
-            android:id="@+id/icon"
-            android:layout_height="@*android:dimen/status_bar_icon_size"
-            android:layout_width="@*android:dimen/status_bar_icon_size"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="0dp"
-            android:layout_marginEnd="8dp"
-            android:contentDescription="@null"
-            android:adjustViewBounds="true"
-            android:tint="?android:attr/textColorPrimary"
-            android:scaleType="fitCenter" />
-
-        <TextView
-            android:id="@+id/pkgname"
-            android:layout_weight="1"
-            android:layout_width="0dp"
-            android:layout_height="wrap_content"
-            android:layout_centerVertical="true"
-            android:ellipsize="end"
-            android:singleLine="true"
-            android:textColor="?android:attr/textColorPrimary"
-            android:textAppearance="?android:attr/textAppearanceSmall"
-            android:marqueeRepeatLimit = "marquee_forever"
-            android:scrollHorizontally = "true"
-            android:textStyle="bold"
-            android:textAlignment="viewStart" />
-
-        <ImageView
-            android:id="@+id/alerted_icon"
-            android:layout_width="@*android:dimen/status_bar_icon_size"
-            android:layout_height="@*android:dimen/status_bar_icon_size"
-            android:layout_centerVertical="true"
-            android:layout_marginStart="6dp"
-            android:paddingTop="1dp"
-            android:scaleType="fitCenter"
-            android:visibility="gone"
-            android:tint="?android:attr/textColorSecondary"
-            android:src="@drawable/ic_notifications_alert"
-        />
-
-        <ImageView
-            android:id="@+id/profile_badge"
-            android:layout_width="@*android:dimen/status_bar_icon_size"
-            android:layout_height="@*android:dimen/status_bar_icon_size"
-            android:layout_centerVertical="true"
-            android:layout_marginEnd="6dp"
-            android:paddingTop="1dp"
-            android:scaleType="fitCenter"
-            android:contentDescription="@*android:string/notification_work_profile_content_description"
-            android:layout_toStartOf="@id/timestamp"
-        />
-
-        <DateTimeView
-            android:id="@+id/timestamp"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:minHeight="@*android:dimen/status_bar_icon_size"
-            android:layout_alignBottom="@android:id/widget_frame"
-            android:layout_alignParentEnd="true"
-            android:layout_alignTop="@android:id/widget_frame"
-            android:layout_centerVertical="true"
-            android:ellipsize="end"
-            android:singleLine="true"
-            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
-            android:textAlignment="viewEnd"
-            />
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+        android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
         android:orientation="vertical"
-        android:layout_marginStart="30dp"
-        android:layout_marginBottom="6dp"
         >
 
-        <TextView
-            android:id="@+id/title"
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_gravity="left|center_vertical"
-            android:ellipsize="end"
-            android:singleLine="true"
-            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
-            android:textAlignment="viewStart"
-        />
+            android:minHeight="@*android:dimen/status_bar_icon_size"
+            android:paddingBottom="6dp">
 
-        <TextView
-            android:id="@+id/text"
+            <ImageView
+                android:id="@+id/icon"
+                android:layout_height="@*android:dimen/status_bar_icon_size"
+                android:layout_width="@*android:dimen/status_bar_icon_size"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="0dp"
+                android:layout_marginEnd="8dp"
+                android:contentDescription="@null"
+                android:adjustViewBounds="true"
+                android:tint="?android:attr/textColorPrimary"
+                android:scaleType="fitCenter" />
+
+            <TextView
+                android:id="@+id/pkgname"
+                android:layout_weight="1"
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_centerVertical="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textColor="?android:attr/textColorPrimary"
+                android:textAppearance="?android:attr/textAppearanceSmall"
+                android:marqueeRepeatLimit = "marquee_forever"
+                android:scrollHorizontally = "true"
+                android:textStyle="bold"
+                android:textAlignment="viewStart" />
+
+            <ImageView
+                android:id="@+id/alerted_icon"
+                android:layout_width="@*android:dimen/status_bar_icon_size"
+                android:layout_height="@*android:dimen/status_bar_icon_size"
+                android:layout_centerVertical="true"
+                android:layout_marginStart="6dp"
+                android:paddingTop="1dp"
+                android:scaleType="fitCenter"
+                android:visibility="gone"
+                android:tint="?android:attr/textColorSecondary"
+                android:src="@drawable/ic_notifications_alert"
+            />
+
+            <ImageView
+                android:id="@+id/profile_badge"
+                android:layout_width="@*android:dimen/status_bar_icon_size"
+                android:layout_height="@*android:dimen/status_bar_icon_size"
+                android:layout_centerVertical="true"
+                android:layout_marginEnd="6dp"
+                android:paddingTop="1dp"
+                android:scaleType="fitCenter"
+                android:contentDescription="@*android:string/notification_work_profile_content_description"
+                android:layout_toStartOf="@id/timestamp"
+            />
+
+            <DateTimeView
+                android:id="@+id/timestamp"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:minHeight="@*android:dimen/status_bar_icon_size"
+                android:layout_alignBottom="@android:id/widget_frame"
+                android:layout_alignParentEnd="true"
+                android:layout_alignTop="@android:id/widget_frame"
+                android:layout_centerVertical="true"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
+                android:textAlignment="viewEnd"
+                />
+        </LinearLayout>
+
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_gravity="left|center_vertical"
-            android:ellipsize="end"
-            android:singleLine="true"
-            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
-            android:textAlignment="viewStart"
-        />
+            android:orientation="vertical"
+            android:layout_marginStart="30dp"
+            android:layout_marginBottom="6dp"
+            >
+
+            <TextView
+                android:id="@+id/title"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="left|center_vertical"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification.Title"
+                android:textAlignment="viewStart"
+            />
+
+            <TextView
+                android:id="@+id/text"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_gravity="left|center_vertical"
+                android:ellipsize="end"
+                android:singleLine="true"
+                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Notification"
+                android:textAlignment="viewStart"
+            />
+
+        </LinearLayout>
 
     </LinearLayout>
-</LinearLayout>
+    <View
+        android:id="@+id/divider"
+        android:layout_width="match_parent"
+        android:layout_height="0.5dp"
+        android:layout_marginTop="17dp"
+        android:background="@color/material_grey_300" />
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/preference_multiline_title.xml b/res/layout/preference_multiline_title.xml
index ae93ead..f64b27f 100644
--- a/res/layout/preference_multiline_title.xml
+++ b/res/layout/preference_multiline_title.xml
@@ -36,6 +36,7 @@
             android:layout_height="wrap_content"
             android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
             android:textColor="?android:attr/textColorPrimary"
+            android:textAlignment="center"
             android:ellipsize="marquee"
             android:fadingEdge="horizontal" />
 
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 897cfea..366254f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11818,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 d8f5e87..98f340c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -546,8 +546,8 @@
         <!-- 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>
+        <!-- Padding between content and the start icon is 0dp -->
+        <item name="contentStartPadding">0dp</item>
 
         <!-- 0dp start padding for the end item -->
         <item name="endItemStartPadding">0dp</item>
@@ -555,8 +555,8 @@
         <item name="endItemEndPadding">24dp</item>
 
         <!-- Align text with slider -->
-        <item name="titleStartPadding">6dp</item>
-        <item name="subContentStartPadding">6dp</item>
+        <item name="titleStartPadding">11dp</item>
+        <item name="subContentStartPadding">11dp</item>
     </style>
 
     <style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index 2420b03..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
diff --git a/res/xml/storage_dashboard_fragment.xml b/res/xml/storage_dashboard_fragment.xml
index 51d4935..91634fc 100644
--- a/res/xml/storage_dashboard_fragment.xml
+++ b/res/xml/storage_dashboard_fragment.xml
@@ -20,7 +20,7 @@
     android:title="@string/storage_settings"
     android:orderingFromXml="false">
     <com.android.settings.deviceinfo.storage.StorageSummaryDonutPreference
-        android:key="pref_summary"
+        android:key="storage_summary"
         android:order="0"
         settings:searchable="false"
         settings:controller="com.android.settings.deviceinfo.storage.StorageSummaryDonutPreferenceController"/>
diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java
index 2391fe8..d34dbcf 100644
--- a/src/com/android/settings/Utils.java
+++ b/src/com/android/settings/Utils.java
@@ -42,6 +42,7 @@
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.pm.ResolveInfo;
 import android.content.pm.UserInfo;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.database.Cursor;
@@ -1101,4 +1102,13 @@
                 context.getString(R.string.config_settingsintelligence_package_name));
         return isSettingsIntelligence;
     }
+
+    /**
+     * Returns true if the night mode is enabled.
+     */
+    public static boolean isNightMode(Context context) {
+        final int currentNightMode =
+                context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+        return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
+    }
 }
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index f8b64fb..2386911 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -126,15 +126,6 @@
                     getPrefContext());
             setPreferenceScreen(preferenceScreen);
         }
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
-        mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
-            removeDialog(DialogEnums.EDIT_SHORTCUT);
-            mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
-        };
 
         final List<String> shortcutFeatureKeys = new ArrayList<>();
         shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
@@ -146,6 +137,15 @@
                 updateShortcutPreference();
             }
         };
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        mTouchExplorationStateChangeListener = isTouchExplorationEnabled -> {
+            removeDialog(DialogEnums.EDIT_SHORTCUT);
+            mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
+        };
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
diff --git a/src/com/android/settings/accounts/AccountTypePreferenceLoader.java b/src/com/android/settings/accounts/AccountTypePreferenceLoader.java
index d32b630..c639d1d 100644
--- a/src/com/android/settings/accounts/AccountTypePreferenceLoader.java
+++ b/src/com/android/settings/accounts/AccountTypePreferenceLoader.java
@@ -197,14 +197,7 @@
         ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
         ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
         try {
-            if (resolvedActivityInfo.exported) {
-                if (resolvedActivityInfo.permission == null) {
-                    return true; // exported activity without permission.
-                } else if (pm.checkPermission(resolvedActivityInfo.permission,
-                    authDesc.packageName) == PackageManager.PERMISSION_GRANTED) {
-                    return true;
-                }
-            }
+            // Allows to launch only authenticator owned activities.
             ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
             return resolvedAppInfo.uid == authenticatorAppInf.uid;
         } catch (NameNotFoundException e) {
diff --git a/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java
index 8860de9..ce2ff32 100644
--- a/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppPermissionPreferenceController.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.applications.appinfo;
 
+import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
@@ -123,21 +124,28 @@
 
     private void startManagePermissionsActivity() {
         // start new activity to manage app permissions
-        final Intent intent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
-        intent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
-        intent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
-        String action = mParent.getActivity().getIntent().getAction();
-        long sessionId = mParent.getActivity().getIntent().getLongExtra(
-                Intent.ACTION_AUTO_REVOKE_PERMISSIONS, INVALID_SESSION_ID);
-        if ((action != null && action.equals(Intent.ACTION_AUTO_REVOKE_PERMISSIONS))
-                || sessionId != INVALID_SESSION_ID) {
-            while (sessionId == INVALID_SESSION_ID) {
-                sessionId = new Random().nextLong();
+        final Intent permIntent = new Intent(Intent.ACTION_MANAGE_APP_PERMISSIONS);
+        permIntent.putExtra(Intent.EXTRA_PACKAGE_NAME, mParent.getAppEntry().info.packageName);
+        permIntent.putExtra(EXTRA_HIDE_INFO_BUTTON, true);
+        Activity activity = mParent.getActivity();
+        Intent intent = activity != null ? activity.getIntent() : null;
+        if (intent != null) {
+            String action = intent.getAction();
+            long sessionId = intent.getLongExtra(
+                    Intent.ACTION_AUTO_REVOKE_PERMISSIONS, INVALID_SESSION_ID);
+            if ((action != null && action.equals(Intent.ACTION_AUTO_REVOKE_PERMISSIONS))
+                    || sessionId != INVALID_SESSION_ID) {
+                // If intent is Auto revoke, and we don't already have a session ID, make one
+                while (sessionId == INVALID_SESSION_ID) {
+                    sessionId = new Random().nextLong();
+                }
+                permIntent.putExtra(Intent.ACTION_AUTO_REVOKE_PERMISSIONS, sessionId);
             }
-            intent.putExtra(Intent.ACTION_AUTO_REVOKE_PERMISSIONS, sessionId);
         }
         try {
-            mParent.getActivity().startActivityForResult(intent, mParent.SUB_INFO_FRAGMENT);
+            if (activity != null) {
+                activity.startActivityForResult(permIntent, mParent.SUB_INFO_FRAGMENT);
+            }
         } catch (ActivityNotFoundException e) {
             Log.w(TAG, "No app can handle android.intent.action.MANAGE_APP_PERMISSIONS");
         }
diff --git a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
index 62dc1cf..2a3bfb2 100644
--- a/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/BiometricStatusPreferenceController.java
@@ -23,6 +23,7 @@
 import android.content.Intent;
 import android.os.UserHandle;
 import android.os.UserManager;
+import android.text.TextUtils;
 
 import androidx.preference.Preference;
 
@@ -100,29 +101,31 @@
         } else {
             preference.setVisible(true);
         }
-        final int userId = getUserId();
-        final String clazz;
-        if (hasEnrolledBiometrics()) {
-            preference.setSummary(getSummaryTextEnrolled());
-            clazz = getSettingsClassName();
-        } else {
-            preference.setSummary(getSummaryTextNoneEnrolled());
-            clazz = getEnrollClassName();
+        preference.setSummary(hasEnrolledBiometrics() ? getSummaryTextEnrolled()
+                : getSummaryTextNoneEnrolled());
+    }
+
+    @Override
+    public boolean handlePreferenceTreeClick(Preference preference) {
+        if (!TextUtils.equals(preference.getKey(), getPreferenceKey())) {
+            return super.handlePreferenceTreeClick(preference);
         }
-        preference.setOnPreferenceClickListener(target -> {
-            final Context context = target.getContext();
-            final UserManager userManager = UserManager.get(context);
-            if (Utils.startQuietModeDialogIfNecessary(context, userManager,
-                    userId)) {
-                return false;
-            }
-            Intent intent = new Intent();
-            intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
-            intent.putExtra(Intent.EXTRA_USER_ID, userId);
-            intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
-            context.startActivity(intent);
-            return true;
-        });
+
+        final Context context = preference.getContext();
+        final UserManager userManager = UserManager.get(context);
+        final int userId = getUserId();
+        if (Utils.startQuietModeDialogIfNecessary(context, userManager, userId)) {
+            return false;
+        }
+
+        final Intent intent = new Intent();
+        final String clazz = hasEnrolledBiometrics() ? getSettingsClassName()
+                : getEnrollClassName();
+        intent.setClassName(SETTINGS_PACKAGE_NAME, clazz);
+        intent.putExtra(Intent.EXTRA_USER_ID, userId);
+        intent.putExtra(EXTRA_FROM_SETTINGS_SUMMARY, true);
+        context.startActivity(intent);
+        return true;
     }
 
     protected int getUserId() {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
index 1c1b81d..a4da759 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -35,6 +35,8 @@
 import com.android.settings.SettingsActivity;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.widget.LayoutPreference;
 
 import java.util.List;
@@ -80,12 +82,14 @@
         void onRemoved();
     }
 
+    private Preference mPreference;
     private Button mButton;
     private Listener mListener;
     private SettingsActivity mActivity;
     private int mUserId;
     private boolean mRemoving;
 
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
     private final Context mContext;
     private final FaceManager mFaceManager;
     private final FaceManager.RemovalCallback mRemovalCallback = new FaceManager.RemovalCallback() {
@@ -141,6 +145,7 @@
         super(context, preferenceKey);
         mContext = context;
         mFaceManager = context.getSystemService(FaceManager.class);
+        mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
     public FaceSettingsRemoveButtonPreferenceController(Context context) {
@@ -155,6 +160,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
 
+        mPreference = preference;
         mButton = ((LayoutPreference) preference)
                 .findViewById(R.id.security_settings_face_settings_remove_button);
         mButton.setOnClickListener(this);
@@ -179,6 +185,7 @@
     @Override
     public void onClick(View v) {
         if (v == mButton) {
+            mMetricsFeatureProvider.logClickedPreference(mPreference, getMetricsCategory());
             mRemoving = true;
             ConfirmRemoveDialog dialog = new ConfirmRemoveDialog();
             dialog.setOnClickListener(mOnClickListener);
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/deviceinfo/StorageDashboardFragment.java b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
index bbd87ab..10c3a43 100644
--- a/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
+++ b/src/com/android/settings/deviceinfo/StorageDashboardFragment.java
@@ -63,7 +63,7 @@
         implements
         LoaderManager.LoaderCallbacks<SparseArray<StorageAsyncLoader.AppsStorageResult>> {
     private static final String TAG = "StorageDashboardFrag";
-    private static final String SUMMARY_PREF_KEY = "pref_summary";
+    private static final String SUMMARY_PREF_KEY = "storage_summary";
     private static final int STORAGE_JOB_ID = 0;
     private static final int ICON_JOB_ID = 1;
     private static final int VOLUME_SIZE_JOB_ID = 2;
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
index cf50596..caf5b4e 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreference.java
@@ -19,10 +19,7 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.Typeface;
 import android.os.storage.StorageManager;
-import android.text.TextPaint;
-import android.text.style.StyleSpan;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.Button;
@@ -31,8 +28,10 @@
 import androidx.preference.PreferenceViewHolder;
 
 import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.widget.DonutView;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /**
  * StorageSummaryDonutPreference is a preference which summarizes the used and remaining storage left
@@ -79,23 +78,14 @@
     @Override
     public void onClick(View v) {
         if (v != null && R.id.deletion_helper_button == v.getId()) {
-            Context context = getContext();
-            FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(
-                    context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
-            Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
-            getContext().startActivity(intent);
-        }
-    }
-
-    private static class BoldLinkSpan extends StyleSpan {
-        public BoldLinkSpan() {
-            super(Typeface.BOLD);
-        }
-
-        @Override
-        public void updateDrawState(TextPaint ds) {
-            super.updateDrawState(ds);
-            ds.setColor(ds.linkColor);
+            final Context context = getContext();
+            final MetricsFeatureProvider metricsFeatureProvider =
+                    FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+            metricsFeatureProvider.logClickedPreference(this,
+                    getExtras().getInt(DashboardFragment.CATEGORY));
+            metricsFeatureProvider.action(context, SettingsEnums.STORAGE_FREE_UP_SPACE_NOW);
+            final Intent intent = new Intent(StorageManager.ACTION_MANAGE_STORAGE);
+            context.startActivity(intent);
         }
     }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
index 0fcde26..7fd8a2f 100644
--- a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
+++ b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
@@ -18,6 +18,8 @@
 
 import static android.app.slice.Slice.HINT_ERROR;
 
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
+
 import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -94,6 +96,11 @@
             return false;
         }
 
+        if (card.getCategory() == STICKY_VALUE) {
+            Log.d(TAG, "Sticky card, skip checking. Uri = " + card.getSliceUri());
+            return true;
+        }
+
         final Slice slice = bindSlice(uri);
 
         if (isSliceToggleable(slice)) {
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 25a6841..79be26d 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -105,9 +105,6 @@
             return null;
         }
 
-        // Reload theme for switching dark mode on/off
-        mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
-
         final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
                 .setAccentColor(COLOR_NOT_TINTED);
 
diff --git a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
index 1c1bedc..f934d58 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/DarkThemeSlice.java
@@ -24,7 +24,6 @@
 import android.app.UiModeManager;
 import android.content.Context;
 import android.content.Intent;
-import android.content.res.Configuration;
 import android.database.ContentObserver;
 import android.net.Uri;
 import android.os.BatteryManager;
@@ -107,7 +106,7 @@
         final IconCompat icon =
                 IconCompat.createWithResource(mContext, R.drawable.dark_theme);
 
-        final boolean isChecked = isDarkThemeMode(mContext);
+        final boolean isChecked = Utils.isNightMode(mContext);
         if (sPreChecked != isChecked) {
             // Dark(Night) mode changed and reset the sSliceClicked.
             resetValue(isChecked, false);
@@ -157,7 +156,7 @@
     @VisibleForTesting
     boolean isAvailable(Context context) {
         // check if dark theme mode is enabled or if dark theme scheduling is on.
-        if (isDarkThemeMode(context) || isNightModeScheduled()) {
+        if (Utils.isNightMode(context) || isNightModeScheduled()) {
             return false;
         }
         // checking the current battery level
@@ -167,13 +166,6 @@
         return level <= BATTERY_LEVEL_THRESHOLD;
     }
 
-    @VisibleForTesting
-    static boolean isDarkThemeMode(Context context) {
-        final int currentNightMode =
-                context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
-        return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
-    }
-
     private void resetValue(boolean preChecked, boolean clicked) {
         sPreChecked = preChecked;
         sSliceClicked = clicked;
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index 52249ff..92cc0e3 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -174,6 +174,15 @@
         return mLocalMediaManager.getSelectedMediaDevice();
     }
 
+    boolean isSelectedMediaDevice(MediaDevice device) {
+        for (MediaDevice selectedMediaDevice : getSelectedMediaDevice()) {
+            if (TextUtils.equals(selectedMediaDevice.getId(), device.getId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     void adjustSessionVolume(String sessionId, int volume) {
         mLocalMediaManager.adjustSessionVolume(sessionId, volume);
     }
diff --git a/src/com/android/settings/media/MediaOutputGroupSlice.java b/src/com/android/settings/media/MediaOutputGroupSlice.java
index be6c298..ba29ab7 100644
--- a/src/com/android/settings/media/MediaOutputGroupSlice.java
+++ b/src/com/android/settings/media/MediaOutputGroupSlice.java
@@ -75,8 +75,6 @@
 
     @Override
     public Slice getSlice() {
-        // Reload theme for switching dark mode on/off
-        mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
         final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
                 .setAccentColor(COLOR_NOT_TINTED);
         // Add "Group" row
@@ -238,7 +236,7 @@
                             + ") is unavailable");
                     return;
                 }
-                if (TextUtils.equals(device.getClientPackageName(), getWorker().getPackageName())) {
+                if (getWorker().isSelectedMediaDevice(device)) {
                     getWorker().removeDeviceFromPlayMedia(device);
                 } else {
                     getWorker().addDeviceToPlayMedia(device);
diff --git a/src/com/android/settings/media/MediaOutputIndicatorSlice.java b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
index 7ec0d3a..17c8ef8 100644
--- a/src/com/android/settings/media/MediaOutputIndicatorSlice.java
+++ b/src/com/android/settings/media/MediaOutputIndicatorSlice.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.media;
 
+import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
+
 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_INDICATOR_SLICE_URI;
 
 import android.annotation.ColorInt;
@@ -61,7 +63,7 @@
         final CharSequence title = mContext.getString(R.string.media_output_label_title,
                 Utils.getApplicationLabel(mContext, getWorker().getPackageName()));
         final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext,
-                0 /* requestCode */, getMediaOutputSliceIntent(), 0 /* flags */);
+                0 /* requestCode */, getMediaOutputSliceIntent(), FLAG_UPDATE_CURRENT);
         final SliceAction primarySliceAction = SliceAction.createDeeplink(
                 primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
         @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index df9538b..773013e 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -81,9 +81,6 @@
 
     @Override
     public Slice getSlice() {
-        // Reload theme for switching dark mode on/off
-        mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
-
         final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
                 .setAccentColor(COLOR_NOT_TINTED);
         if (!isVisible()) {
diff --git a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
index 52fc99c..9e46158 100644
--- a/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
+++ b/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelper.java
@@ -18,6 +18,8 @@
 
 import static android.app.slice.Slice.EXTRA_TOGGLE_STATE;
 
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
+
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
@@ -274,6 +276,7 @@
      */
     private PendingIntent getActivityIntent(String action) {
         final Intent intent = new Intent(action);
+        intent.setPackage(SETTINGS_PACKAGE_NAME);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 49f7981..528e5c7 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -73,7 +73,7 @@
     private String mClickedPrefKey;
 
     private ActiveSubsciptionsListener mActiveSubsciptionsListener;
-    private boolean mActiveSubsciptionsListenerStarting;
+    private boolean mDropFirstSubscriptionChangeNotify;
     private int mActiveSubsciptionsListenerCount;
 
     public MobileNetworkSettings() {
@@ -207,20 +207,20 @@
     public void onResume() {
         super.onResume();
         if (mActiveSubsciptionsListener == null) {
-            mActiveSubsciptionsListenerStarting = true;
             mActiveSubsciptionsListener = new ActiveSubsciptionsListener(
                     getContext().getMainLooper(), getContext(), mSubId) {
                 public void onChanged() {
                     onSubscriptionDetailChanged();
                 }
             };
-            mActiveSubsciptionsListenerStarting = false;
+            mDropFirstSubscriptionChangeNotify = true;
         }
         mActiveSubsciptionsListener.start();
     }
 
     private void onSubscriptionDetailChanged() {
-        if (mActiveSubsciptionsListenerStarting) {
+        if (mDropFirstSubscriptionChangeNotify) {
+            mDropFirstSubscriptionChangeNotify = false;
             Log.d(LOG_TAG, "Callback during onResume()");
             return;
         }
@@ -235,6 +235,14 @@
         });
     }
 
+    @Override
+    public void onDestroy() {
+        if (mActiveSubsciptionsListener != null) {
+            mActiveSubsciptionsListener.stop();
+        }
+        super.onDestroy();
+    }
+
     @VisibleForTesting
     void onRestoreInstance(Bundle icicle) {
         if (icicle != null) {
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index c45242e..8b4bc9d 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -266,9 +266,6 @@
             mSnoozedRv.setLayoutManager(lm);
             mSnoozedRv.setAdapter(
                     new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
-            DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(
-                    mSnoozedRv.getContext(), lm.getOrientation());
-            mSnoozedRv.addItemDecoration(dividerItemDecoration);
             mSnoozedRv.setNestedScrollingEnabled(false);
 
             if (snoozed == null || snoozed.length == 0) {
@@ -284,9 +281,6 @@
             mDismissedRv.setLayoutManager(dismissLm);
             mDismissedRv.setAdapter(
                 new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
-            DividerItemDecoration dismissDivider = new DividerItemDecoration(
-                mDismissedRv.getContext(), dismissLm.getOrientation());
-            mDismissedRv.addItemDecoration(dismissDivider);
             mDismissedRv.setNestedScrollingEnabled(false);
 
             if (dismissed == null || dismissed.length == 0) {
diff --git a/src/com/android/settings/notification/history/NotificationSbnAdapter.java b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
index c7f68ab..5d4e716 100644
--- a/src/com/android/settings/notification/history/NotificationSbnAdapter.java
+++ b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
@@ -94,6 +94,7 @@
             holder.setTitle(getTitleString(sbn.getNotification()));
             holder.setSummary(getTextString(mContext, sbn.getNotification()));
             holder.setPostedTime(sbn.getPostTime());
+            holder.setDividerVisible(position < (mValues.size() -1));
             int userId = normalizeUserId(sbn);
             if (!mUserBadgeCache.containsKey(userId)) {
                 Drawable profile = mContext.getPackageManager().getUserBadgeForDensity(
diff --git a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
index 42a2100..3f1197d 100644
--- a/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
+++ b/src/com/android/settings/notification/history/NotificationSbnViewHolder.java
@@ -45,6 +45,7 @@
     private final TextView mTitle;
     private final TextView mSummary;
     private final ImageView mProfileBadge;
+    private final View mDivider;
 
     NotificationSbnViewHolder(View itemView) {
         super(itemView);
@@ -54,6 +55,7 @@
         mTitle = itemView.findViewById(R.id.title);
         mSummary = itemView.findViewById(R.id.text);
         mProfileBadge = itemView.findViewById(R.id.profile_badge);
+        mDivider = itemView.findViewById(R.id.divider);
     }
 
     void setSummary(CharSequence summary) {
@@ -85,6 +87,10 @@
         mProfileBadge.setVisibility(badge != null ? View.VISIBLE : View.GONE);
     }
 
+    void setDividerVisible(boolean visible) {
+        mDivider.setVisibility(visible ? View.VISIBLE : View.GONE);
+    }
+
     void addOnClick(String pkg, int userId, PendingIntent pi) {
         Intent appIntent = itemView.getContext().getPackageManager()
                 .getLaunchIntentForPackage(pkg);
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 6bf016e..68cb8d5 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -66,6 +66,7 @@
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+        getApplicationContext().getTheme().rebase();
         createOrUpdatePanel(true /* shouldForceCreation */);
         getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
     }
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index ca7590b..c532366 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -215,7 +215,6 @@
 
     private void updateDisplay() {
         if (isLockToAppEnabled(getActivity())) {
-            mFooterPreference.setVisible(false);
             mUseScreenLock.setVisible(true);
             mUseScreenLock.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
                 @Override
@@ -226,7 +225,6 @@
             mUseScreenLock.setChecked(isScreenLockUsed());
             mUseScreenLock.setTitle(getCurrentSecurityTitle());
         } else {
-            mFooterPreference.setVisible(true);
             mFooterPreference.setSummary(getAppPinningContent());
             mUseScreenLock.setVisible(false);
         }
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index 0aaf85d..6c245ce 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -140,8 +140,11 @@
     @VisibleForTesting
     Map<Uri, SliceData> mSliceWeakDataCache;
 
+    @VisibleForTesting
     final Map<Uri, SliceBackgroundWorker> mPinnedWorkers = new ArrayMap<>();
 
+    private boolean mNightMode;
+
     public SettingsSliceProvider() {
         super(READ_SEARCH_INDEXABLES);
     }
@@ -150,6 +153,8 @@
     public boolean onCreateSliceProvider() {
         mSlicesDatabaseAccessor = new SlicesDatabaseAccessor(getContext());
         mSliceWeakDataCache = new WeakHashMap<>();
+        mNightMode = Utils.isNightMode(getContext());
+        getContext().setTheme(R.style.Theme_SettingsBase);
         return true;
     }
 
@@ -201,6 +206,13 @@
                 return null;
             }
 
+            final boolean nightMode = Utils.isNightMode(getContext());
+            if (mNightMode != nightMode) {
+                Log.d(TAG, "Night mode changed, reload theme");
+                mNightMode = nightMode;
+                getContext().getTheme().rebase();
+            }
+
             // Before adding a slice to {@link CustomSliceManager}, please get approval
             // from the Settings team.
             if (CustomSliceRegistry.isValidUri(sliceUri)) {
diff --git a/src/com/android/settings/slices/SliceBuilderUtils.java b/src/com/android/settings/slices/SliceBuilderUtils.java
index 2d5b4aa..391e9fd 100644
--- a/src/com/android/settings/slices/SliceBuilderUtils.java
+++ b/src/com/android/settings/slices/SliceBuilderUtils.java
@@ -73,8 +73,6 @@
      * {@param sliceData} is an inline controller.
      */
     public static Slice buildSlice(Context context, SliceData sliceData) {
-        // Reload theme for switching dark mode on/off
-        context.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
         Log.d(TAG, "Creating slice for: " + sliceData.getPreferenceController());
         final BasePreferenceController controller = getPreferenceController(context, sliceData);
         FeatureFactory.getFactory(context).getMetricsFeatureProvider()
diff --git a/src/com/android/settings/widget/MasterSwitchController.java b/src/com/android/settings/widget/MasterSwitchController.java
index 9159584..92e3884 100644
--- a/src/com/android/settings/widget/MasterSwitchController.java
+++ b/src/com/android/settings/widget/MasterSwitchController.java
@@ -18,7 +18,10 @@
 
 import androidx.preference.Preference;
 
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 /*
  * The switch controller that is used to update the switch widget in the MasterSwitchPreference
@@ -28,9 +31,12 @@
     Preference.OnPreferenceChangeListener {
 
     private final MasterSwitchPreference mPreference;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
 
     public MasterSwitchController(MasterSwitchPreference preference) {
         mPreference = preference;
+        mMetricsFeatureProvider = FeatureFactory.getFactory(preference.getContext())
+                .getMetricsFeatureProvider();
     }
 
     @Override
@@ -65,7 +71,12 @@
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
         if (mListener != null) {
-            return mListener.onSwitchToggled((Boolean) newValue);
+            final boolean result = mListener.onSwitchToggled((Boolean) newValue);
+            if (result) {
+                mMetricsFeatureProvider.logClickedPreference(preference,
+                        preference.getExtras().getInt(DashboardFragment.CATEGORY));
+            }
+            return result;
         }
         return false;
     }
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index 008df24..a48358f 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -124,6 +124,9 @@
     List<Integer> mResultCodeArrayList;
     @VisibleForTesting
     WifiPickerTracker mWifiPickerTracker;
+    // Worker thread used for WifiPickerTracker work
+    @VisibleForTesting
+    HandlerThread mWorkerThread;
 
     private boolean mIsSingleNetwork;
     private boolean mAnyNetworkSavedSuccess;
@@ -133,8 +136,6 @@
     private UiConfigurationItemAdapter mUiConfigurationItemAdapter;
     private WifiManager.ActionListener mSaveListener;
     private WifiManager mWifiManager;
-    // Worker thread used for WifiPickerTracker work
-    private HandlerThread mWorkerThread;
 
     private final Handler mHandler = new Handler() {
         @Override
@@ -203,6 +204,13 @@
     }
 
     @Override
+    public void onDestroy() {
+        mWorkerThread.quit();
+
+        super.onDestroy();
+    }
+
+    @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
 
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
index 958db7e..26d742d 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSliceHelper.java
@@ -20,6 +20,7 @@
 
 import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_PREFERENCE_URI;
 import static com.android.settings.slices.CustomSliceRegistry.WIFI_CALLING_URI;
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
 
 import android.app.PendingIntent;
 import android.content.ComponentName;
@@ -554,6 +555,7 @@
      */
     private PendingIntent getActivityIntent(String action) {
         final Intent intent = new Intent(action);
+        intent.setPackage(SETTINGS_PACKAGE_NAME);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index fd27970..a489b05 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -86,9 +86,6 @@
 
     @Override
     public Slice getSlice() {
-        // Reload theme for switching dark mode on/off
-        mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true /* force */);
-
         final boolean isWifiEnabled = isWifiEnabled();
         ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* accessPoint */);
         if (!isWifiEnabled) {
diff --git a/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
index ec924e5..2dfc347 100644
--- a/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/face/FaceStatusPreferenceControllerTest.java
@@ -113,7 +113,6 @@
         assertThat(mPreference.getSummary()).isEqualTo(
                 mContext.getString(R.string.security_settings_face_preference_summary_none));
         assertThat(mPreference.isVisible()).isTrue();
-        assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
     }
 
     @Test
@@ -129,6 +128,5 @@
         assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources()
                 .getString(R.string.security_settings_face_preference_summary));
         assertThat(mPreference.isVisible()).isTrue();
-        assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
     }
 }
diff --git a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
index 18a05fd..14ca1f8 100644
--- a/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/biometrics/fingerprint/FingerprintStatusPreferenceControllerTest.java
@@ -115,7 +115,6 @@
         assertThat(mPreference.getSummary()).isEqualTo(
                 mContext.getString(R.string.security_settings_fingerprint_preference_summary_none));
         assertThat(mPreference.isVisible()).isTrue();
-        assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
     }
 
     @Test
@@ -130,6 +129,5 @@
         assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
                 R.plurals.security_settings_fingerprint_preference_summary, 1, 1));
         assertThat(mPreference.isVisible()).isTrue();
-        assertThat(mPreference.getOnPreferenceClickListener()).isNotNull();
     }
 }
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/display/darkmode/DarkModeScheduleSelectorControllerTest.java b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
index 1bbbe7d..141177c 100644
--- a/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorControllerTest.java
@@ -98,6 +98,7 @@
     public void nightMode_updateStateNone_dropDownValueChangedToNone() {
         when(mUiService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_YES);
         mController.displayPreference(mScreen);
+        mController.updateState(mScreen);
         verify(mPreference).setValueIndex(0);
     }
 
@@ -105,6 +106,7 @@
     public void nightMode_updateStateNone_dropDownValueChangedToAuto() {
         when(mUiService.getNightMode()).thenReturn(UiModeManager.MODE_NIGHT_AUTO);
         mController.displayPreference(mScreen);
+        mController.updateState(mScreen);
         verify(mPreference).setValueIndex(1);
     }
 
@@ -112,6 +114,7 @@
     public void batterySaver_dropDown_disabledSelector() {
         when(mPM.isPowerSaveMode()).thenReturn(true);
         mController.displayPreference(mScreen);
+        mController.updateState(mScreen);
         verify(mPreference).setEnabled(eq(false));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
index 23ae2f3..e236919 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/EligibleCardCheckerTest.java
@@ -18,11 +18,15 @@
 
 import static android.app.slice.Slice.HINT_ERROR;
 
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.STICKY_VALUE;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 
 import android.content.Context;
 import android.net.Uri;
@@ -65,6 +69,32 @@
     }
 
     @Test
+    public void isCardEligibleToDisplay_stickyCard_returnTrue() {
+        final ContextualCard card = new ContextualCard.Builder()
+                .setName("test_card")
+                .setCardType(ContextualCard.CardType.SLICE)
+                .setCategory(STICKY_VALUE)
+                .setSliceUri(CustomSliceRegistry.FLASHLIGHT_SLICE_URI)
+                .build();
+
+        assertThat(mEligibleCardChecker.isCardEligibleToDisplay(card)).isTrue();
+    }
+
+    @Test
+    public void isCardEligibleToDisplay_stickyCard_shouldNotPrebind() {
+        final ContextualCard card = new ContextualCard.Builder()
+                .setName("test_card")
+                .setCardType(ContextualCard.CardType.SLICE)
+                .setCategory(STICKY_VALUE)
+                .setSliceUri(CustomSliceRegistry.FLASHLIGHT_SLICE_URI)
+                .build();
+
+        mEligibleCardChecker.isCardEligibleToDisplay(card);
+
+        verify(mEligibleCardChecker, never()).bindSlice(CustomSliceRegistry.FLASHLIGHT_SLICE_URI);
+    }
+
+    @Test
     public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
         final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
         final Slice slice = wifiSlice.getSlice();
diff --git a/tests/robotests/src/com/android/settings/media/MediaOutputGroupSliceTest.java b/tests/robotests/src/com/android/settings/media/MediaOutputGroupSliceTest.java
index 12e066b..9da18d50 100644
--- a/tests/robotests/src/com/android/settings/media/MediaOutputGroupSliceTest.java
+++ b/tests/robotests/src/com/android/settings/media/MediaOutputGroupSliceTest.java
@@ -212,11 +212,9 @@
     }
 
     @Test
-    public void onNotifyChange_sessionOperation_differentClient_verifyAddSession() {
-        mSelectableDevices.add(mDevice1);
+    public void onNotifyChange_sendSelectableDevice_verifyAddSession() {
         mSelectableDevices.add(mDevice2);
         mSelectedDevices.add(mDevice1);
-        when(mDevice2.getClientPackageName()).thenReturn(TEST_PACKAGE_NAME2);
         when(mLocalMediaManager.getMediaDeviceById(mSelectableDevices, TEST_DEVICE_2_ID))
                 .thenReturn(mDevice2);
         sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectableDevices);
@@ -229,16 +227,13 @@
 
         verify(sMediaDeviceUpdateWorker).addDeviceToPlayMedia(mDevice2);
     }
-
     @Test
-    public void onNotifyChange_sessionOperation_sameClient_verifyRemoveSession() {
-        mSelectableDevices.add(mDevice1);
-        mSelectableDevices.add(mDevice2);
+    public void onNotifyChange_sendSelectedDevice_verifyRemoveSession() {
         mSelectedDevices.add(mDevice1);
-        when(mDevice2.getClientPackageName()).thenReturn(TEST_PACKAGE_NAME);
-        when(mLocalMediaManager.getMediaDeviceById(mSelectableDevices, TEST_DEVICE_2_ID))
+        mSelectedDevices.add(mDevice2);
+        when(mLocalMediaManager.getMediaDeviceById(mSelectedDevices, TEST_DEVICE_2_ID))
                 .thenReturn(mDevice2);
-        sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectableDevices);
+        sMediaDeviceUpdateWorker.onDeviceListUpdate(mSelectedDevices);
         when(sMediaDeviceUpdateWorker.getSelectedMediaDevice()).thenReturn(mSelectedDevices);
         final Intent intent = new Intent();
         intent.putExtra(MEDIA_DEVICE_ID, TEST_DEVICE_2_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
index 50446ad..416e2f0 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/Enhanced4gLteSliceHelperTest.java
@@ -20,6 +20,7 @@
 import static android.app.slice.Slice.HINT_TITLE;
 import static android.app.slice.SliceItem.FORMAT_TEXT;
 
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -248,6 +249,7 @@
 
     private PendingIntent getActivityIntent(String action) {
         final Intent intent = new Intent(action);
+        intent.setPackage(SETTINGS_PACKAGE_NAME);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }
diff --git a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
index 0a9d8cb..0fa249d 100644
--- a/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
+++ b/tests/robotests/src/com/android/settings/slices/SettingsSliceProviderTest.java
@@ -20,6 +20,8 @@
 import static android.content.ContentResolver.SCHEME_CONTENT;
 import static android.content.pm.PackageManager.PERMISSION_DENIED;
 import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import static android.content.res.Configuration.UI_MODE_NIGHT_NO;
+import static android.content.res.Configuration.UI_MODE_NIGHT_YES;
 
 import static com.google.common.truth.Truth.assertThat;
 
@@ -39,6 +41,7 @@
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources.Theme;
 import android.net.Uri;
 import android.os.StrictMode;
 import android.provider.Settings;
@@ -96,7 +99,8 @@
 @Config(shadows = {ShadowUserManager.class, ShadowUtils.class,
         SlicesDatabaseAccessorTest.ShadowApplicationPackageManager.class,
         ShadowBluetoothAdapter.class, ShadowLockPatternUtils.class,
-        SettingsSliceProviderTest.ShadowWifiScanWorker.class})
+        SettingsSliceProviderTest.ShadowWifiScanWorker.class,
+        SettingsSliceProviderTest.ShadowTheme.class})
 public class SettingsSliceProviderTest {
 
     private static final String KEY = "KEY";
@@ -162,6 +166,7 @@
     @After
     public void cleanUp() {
         ShadowThreadUtils.reset();
+        ShadowTheme.reset();
         DatabaseTestUtils.clearDb(mContext);
     }
 
@@ -264,6 +269,28 @@
     }
 
     @Test
+    public void onBindSlice_nightModeChanged_shouldReloadTheme() {
+        mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_YES;
+
+        final SliceData data = getDummyData();
+        mProvider.mSliceWeakDataCache.put(data.getUri(), data);
+        mProvider.onBindSlice(data.getUri());
+
+        assertThat(ShadowTheme.isThemeRebased()).isTrue();
+    }
+
+    @Test
+    public void onBindSlice_nightModeNotChanged_shouldNotReloadTheme() {
+        mContext.getResources().getConfiguration().uiMode = UI_MODE_NIGHT_NO;
+
+        SliceData data = getDummyData();
+        mProvider.mSliceWeakDataCache.put(data.getUri(), data);
+        mProvider.onBindSlice(data.getUri());
+
+        assertThat(ShadowTheme.isThemeRebased()).isFalse();
+    }
+
+    @Test
     public void getDescendantUris_fullActionUri_returnsSelf() {
         final Collection<Uri> descendants = mProvider.onGetSliceDescendants(ACTION_SLICE_URI);
 
@@ -722,4 +749,23 @@
             return sSetThreadPolicyCount != 0;
         }
     }
+
+    @Implements(Theme.class)
+    public static class ShadowTheme {
+        private static boolean sThemeRebased;
+
+        @Resetter
+        public static void reset() {
+            sThemeRebased = false;
+        }
+
+        @Implementation
+        public void rebase() {
+            sThemeRebased = true;
+        }
+
+        static boolean isThemeRebased() {
+            return sThemeRebased;
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/SliceTester.java b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
index 6fb2c49..f2cce3c 100644
--- a/tests/robotests/src/com/android/settings/testutils/SliceTester.java
+++ b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
@@ -137,16 +137,19 @@
      */
     public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
         final SliceMetadata metadata = SliceMetadata.from(context, slice);
-
-        final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
-        final int color = colorItem.getInt();
-        assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
-
         final SliceAction primaryAction = metadata.getPrimaryAction();
 
-        final IconCompat expectedIcon = IconCompat.createWithResource(context,
-                sliceData.getIconResource());
-        assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
+        final IconCompat icon = primaryAction.getIcon();
+        if (icon == null) {
+            final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
+            final int color = colorItem.getInt();
+            assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
+
+        } else {
+            final IconCompat expectedIcon = IconCompat.createWithResource(context,
+                    sliceData.getIconResource());
+            assertThat(expectedIcon.toString()).isEqualTo(icon.toString());
+        }
 
         final long sliceTTL = metadata.getExpiry();
         assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
diff --git a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
index ac25689..3f02e2e 100644
--- a/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragmentTest.java
@@ -19,7 +19,9 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.settings.SettingsEnums;
@@ -27,6 +29,7 @@
 import android.net.wifi.WifiManager;
 import android.net.wifi.WifiNetworkSuggestion;
 import android.os.Bundle;
+import android.os.HandlerThread;
 import android.os.Parcelable;
 import android.provider.Settings;
 import android.widget.TextView;
@@ -247,6 +250,19 @@
                 SCANED_LEVEL0);
     }
 
+    @Test
+    public void onDestroy_quitWorkerThread() {
+        mAddAppNetworksFragment.mWorkerThread = mock(HandlerThread.class);
+
+        try {
+            mAddAppNetworksFragment.onDestroy();
+        } catch (IllegalArgumentException e) {
+            // Ignore the exception from super class.
+        }
+
+        verify(mAddAppNetworksFragment.mWorkerThread).quit();
+    }
+
     private void setUpOneScannedNetworkWithScanedLevel4() {
         final ArrayList list = new ArrayList<>();
         list.add(mMockWifiEntry);
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
index 0013234..0b9ef55 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSliceHelperTest.java
@@ -20,6 +20,7 @@
 import static android.app.slice.Slice.HINT_TITLE;
 import static android.app.slice.SliceItem.FORMAT_TEXT;
 
+import static com.android.settings.Utils.SETTINGS_PACKAGE_NAME;
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -400,6 +401,7 @@
 
     private PendingIntent getActivityIntent(String action) {
         final Intent intent = new Intent(action);
+        intent.setPackage(SETTINGS_PACKAGE_NAME);
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */);
     }