Merge "Do not prebind sticky slices." 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/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/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/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/display/NightDisplayAutoModePreferenceController.java b/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
index ef11e00..fb2dbc3 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 true;
+            return false;
         }
         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 2ac9a9f..6acaf82 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,6 +51,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
+        init();
     }
 
     @Override
@@ -58,8 +59,7 @@
         return BasePreferenceController.AVAILABLE;
     }
 
-    @Override
-    public final void updateState(Preference preference) {
+    private void init() {
         final boolean batterySaver = mPowerManager.isPowerSaveMode();
         mPreference.setEnabled(!batterySaver);
         mCurrentMode = getCurrentMode();
@@ -87,25 +87,25 @@
         if (newMode == mCurrentMode) {
             return false;
         }
-        if (newMode == mPreference.findIndexOfValue(
+        mCurrentMode = newMode;
+        if (mCurrentMode == 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 (newMode == mPreference.findIndexOfValue(
+        } else if (mCurrentMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_auto))) {
             if (!mLocationManager.isLocationEnabled()) {
                 TwilightLocationDialog.show(mContext);
-                return true;
+                return false;
             }
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
-        } else if (newMode == mPreference.findIndexOfValue(
+        } else if (mCurrentMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_custom))) {
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
         }
-        mCurrentMode = newMode;
         return true;
     }
 }
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/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/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/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/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/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);