Merge "[MS48.2] Remove NetworkStatsHistory from CycleAdaptor"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8b8426d..7d47fef 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -114,6 +114,7 @@
     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
     <uses-permission android:name="android.permission.READ_APP_SPECIFIC_LOCALES" />
     <uses-permission android:name="android.permission.QUERY_ADMIN_POLICY" />
+    <uses-permission android:name="android.permission.READ_SAFETY_CENTER_STATUS" />
 
     <application
             android:name=".SettingsApplication"
diff --git a/res/drawable/ic_adaptive_font_download.xml b/res/drawable/ic_adaptive_font_download.xml
index 1993015..5b6eaeb 100644
--- a/res/drawable/ic_adaptive_font_download.xml
+++ b/res/drawable/ic_adaptive_font_download.xml
@@ -22,15 +22,6 @@
             android:height="@dimen/accessibility_icon_size"
             android:color="@color/accessibility_feature_background"/>
     </item>
-    <item android:gravity="center">
-        <vector
-            android:width="@dimen/accessibility_icon_foreground_size"
-            android:height="@dimen/accessibility_icon_foreground_size"
-            android:viewportWidth="24"
-            android:viewportHeight="24">
-            <path
-                android:fillColor="@android:color/white"
-                android:pathData="M6.4,18h2.1l1.1,-3.05h4.8L15.5,18h2.1L13.05,6h-2.1zM10.2,13.2l1.75,-4.95h0.1l1.75,4.95zM4,22q-0.825,0 -1.413,-0.587Q2,20.825 2,20L2,4q0,-0.825 0.587,-1.413Q3.175,2 4,2h16q0.825,0 1.413,0.587Q22,3.175 22,4v16q0,0.825 -0.587,1.413Q20.825,22 20,22zM4,20h16L20,4L4,4v16zM4,4v16L4,4z"/>
-        </vector>
-    </item>
+    <item android:gravity="center"
+        android:drawable="@drawable/ic_font_download"/>
 </layer-list>
\ No newline at end of file
diff --git a/res/drawable/ic_font_download.xml b/res/drawable/ic_font_download.xml
new file mode 100644
index 0000000..16366e9
--- /dev/null
+++ b/res/drawable/ic_font_download.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2022 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.
+-->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="@dimen/accessibility_icon_foreground_size"
+    android:height="@dimen/accessibility_icon_foreground_size"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+    <path
+        android:fillColor="@android:color/white"
+        android:pathData="M6.4,18h2.1l1.1,-3.05h4.8L15.5,18h2.1L13.05,6h-2.1zM10.2,13.2l1.75,-4.95h0.1l1.75,4.95zM4,22q-0.825,0 -1.413,-0.587Q2,20.825 2,20L2,4q0,-0.825 0.587,-1.413Q3.175,2 4,2h16q0.825,0 1.413,0.587Q22,3.175 22,4v16q0,0.825 -0.587,1.413Q20.825,22 20,22zM4,20h16L20,4L4,4v16zM4,4v16L4,4z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout/accessibility_text_reading_preview_mail_content.xml b/res/layout/accessibility_text_reading_preview_mail_content.xml
new file mode 100644
index 0000000..7b50ac1
--- /dev/null
+++ b/res/layout/accessibility_text_reading_preview_mail_content.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+    Copyright (C) 2022 The Android Open Source Project
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/subject"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/accessibility_text_reading_preview_mail_subject"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <TextView
+        android:id="@+id/from"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="16dp"
+        android:paddingTop="11dp"
+        android:text="@string/accessibility_text_reading_preview_mail_from"
+        android:textColor="?android:attr/textColorSecondary" />
+
+    <TextView
+        android:id="@+id/content"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/accessibility_text_reading_preview_mail_content"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+</LinearLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 9f0af97..4c515ad 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1596,4 +1596,15 @@
         <item>2</item>
         <item>4</item>
     </string-array>
+
+    <!-- All the preference when the open app supports TapPay -->
+    <string-array name="nfc_payment_favor">
+        <item>Always</item>
+        <item>Except when another payment app is open</item>
+    </string-array>
+    <!-- All the values of the preference when the open app supports TapPay -->
+    <string-array name="nfc_payment_favor_values">
+        <item>0</item>
+        <item>1</item>
+    </string-array>
 </resources>
diff --git a/res/values/config.xml b/res/values/config.xml
index 7a2f641..7901a4c 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -573,4 +573,17 @@
 
     <!-- Whether to give option to add restricted profiles -->
     <bool name="config_offer_restricted_profiles">false</bool>
+
+    <!-- An array of packages for which Applications whose per-app locale cannot be changed. -->
+    <string-array name="config_disallowed_app_localeChange_packages" translatable="false">
+        <!--
+        <item>com.example.package.first</item>
+        <item>com.example.package.second</item>
+        <item>...</item>
+        -->
+    </string-array>
+
+    <!-- The ratio to use when using the two-pane settings layout -->
+    <item name="config_activity_embed_split_ratio" format="float" type="dimen">0.5</item>
+
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ec72321..10f93cb 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5216,6 +5216,12 @@
     <string name="accessibility_introduction_title">About <xliff:g id="service" example="Select to Speak">%1$s</xliff:g></string>
     <!-- Title for the accessibility preference to adjust the display size, font size, bold text, and high contrast text features. [CHAR LIMIT=NONE] -->
     <string name="accessibility_text_reading_options_title">Text and reading options</string>
+    <!-- Subject for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_text_reading_preview_mail_subject">Email: Plans for time machine, v2</string>
+    <!-- Message for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_text_reading_preview_mail_from">From: bill@email.com</string>
+    <!-- Content for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_text_reading_preview_mail_content">Good morning! Following up on our last conversation, I’d like to check in on the progress of your time machine development plan. Will you be able to have a prototype ready to demo at E3 this year?</string>
     <!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
     <string name="accessibility_screen_option">Options</string>
     <!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
@@ -5457,6 +5463,8 @@
     <string name="accessibility_vibration_settings_title">Vibration &amp; haptics</string>
     <!-- Summary for preference screen for configuring vibrations. [CHAR LIMIT=NONE] -->
     <string name="accessibility_vibration_settings_summary">Control the vibration strength for different usages</string>
+    <!-- Summary for vibration preference shown when it is disabled because the device is in silent mode. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_vibration_setting_disabled_for_silent_mode_summary">Setting disabled because device is set to silent</string>
     <!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->
     <string name="accessibility_call_vibration_category_title">Calls</string>
     <!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
@@ -5481,6 +5489,8 @@
     <string name="accessibility_service_primary_open_title">Open <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g></string>
     <!-- Used in the accessibility service settings to show quick settings tooltips. [CHAR LIMIT=NONE] -->
     <string name="accessibility_service_quick_settings_tooltips_content">Swipe down to quickly turn <xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> on or off in quick settings</string>
+    <!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
     <!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
     <string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
     <!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
@@ -5823,7 +5833,8 @@
 
     <!-- Fast Pair setting summary in settings screen [CHAR LIMIT=50] -->
     <string name="fast_pair_settings_summary">Nearby detection of Fast Pair bluetooth devices.</string>
-
+    <!-- Title for Fast Pair main switch preferences. [CHAR LIMIT=50] -->
+    <string name="fast_pair_main_switch_title">Scan for nearby devices</string>
     <!-- Printing settings -->
     <skip />
 
@@ -7596,7 +7607,25 @@
     <string name="user_copy_apps_menu_title">Install available apps</string>
 
     <!-- NFC payment settings --><skip/>
+    <!-- Title for NFC payment settings page [CHAR LIMIT=40] -->
     <string name="nfc_payment_settings_title">Contactless payments</string>
+    <!-- Title for NFC default payment settings page [CHAR LIMIT=40] -->
+    <string name="nfc_default_payment_settings_title">Default payment app</string>
+    <!-- Text string explaining how Tap and Pay works [CHAR LIMIT=100] -->
+    <string name="nfc_default_payment_footer">To make a payment using a payment app, hold the back of your device to a payment terminal</string>
+    <!-- Text string linking to a page explaining how Tap and Pay works [CHAR LIMIT=40] -->
+    <string name="nfc_more_details">Learn more</string>
+
+    <!-- Strings shown in a dialog when a user tries to set a work app as a nfc default payment app --><skip/>
+    <!-- Title for the dialog [CHAR LIMIT=40] -->
+    <string name="nfc_default_payment_workapp_confirmation_title">Set work app as default payment app?</string>
+    <!-- Header text for the dialog [CHAR LIMIT=40] -->
+    <string name="nfc_default_payment_workapp_confirmation_message_title">To make a payment using a work app:</string>
+    <!-- Text string in the dialog [CHAR LIMIT=60] -->
+    <string name="nfc_default_payment_workapp_confirmation_message_1">work profile must be turned on.</string>
+    <!-- Text string in the dialog [CHAR LIMIT=60] -->
+    <string name="nfc_default_payment_workapp_confirmation_message_2">you\u2019ll need to enter your work profile lock if you have one.</string>
+
     <!-- Caption for button linking to a page explaining how Tap and Pay works-->
     <string name="nfc_payment_how_it_works">How it works</string>
     <!-- String shown when there are no NFC payment applications installed -->
@@ -7608,7 +7637,9 @@
     <!-- String indicating the label of the default payment app and a description of its state; eg Google Wallet - MasterCard 1234 -->
     <string name="nfc_payment_app_and_desc"><xliff:g id="app">%1$s</xliff:g> - <xliff:g id="description">%2$s</xliff:g></string>
     <!-- Header for what to do when the open app supports TapPay: use the default set app, or the open app -->
-    <string name="nfc_payment_use_default">Use default</string>
+    <string name="nfc_payment_use_default">Use default payment app</string>
+    <!-- Header for a dialog asking what to do when the open app supports TapPay [CHAR LIMIT=40] -->
+    <string name="nfc_payment_use_default_dialog">Use default payment app</string>
     <!-- Always use the default app (independent of what app is open) -->
     <string name="nfc_payment_favor_default">Always</string>
     <!-- If open app supports TapPay, use that app instead of the default -->
diff --git a/res/xml/fast_pair_settings.xml b/res/xml/fast_pair_settings.xml
index ec4cda9..3fd306f 100644
--- a/res/xml/fast_pair_settings.xml
+++ b/res/xml/fast_pair_settings.xml
@@ -21,4 +21,8 @@
     android:title="@string/fast_pair_settings"
     settings:keywords="@string/keywords_fast_pair">
 
-</PreferenceScreen>
\ No newline at end of file
+    <com.android.settingslib.widget.MainSwitchPreference
+        android:key="fast_pair_scan_switch"
+        android:title="@string/fast_pair_main_switch_title" />
+
+</PreferenceScreen>
diff --git a/res/xml/nfc_default_payment_settings.xml b/res/xml/nfc_default_payment_settings.xml
new file mode 100644
index 0000000..d9978cd
--- /dev/null
+++ b/res/xml/nfc_default_payment_settings.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:title="@string/nfc_default_payment_settings_title"/>
diff --git a/res/xml/nfc_payment_settings.xml b/res/xml/nfc_payment_settings.xml
index 8e55a39..d748a1c 100644
--- a/res/xml/nfc_payment_settings.xml
+++ b/res/xml/nfc_payment_settings.xml
@@ -19,16 +19,17 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/nfc_payment_settings_title">
 
-    <com.android.settings.nfc.NfcPaymentPreference
-        android:key="nfc_payment"
-        android:title="@string/nfc_payment_default"
-        android:dialogTitle="@string/nfc_payment_pay_with"
-        android:widgetLayout="@layout/preference_widget_gear"
-        settings:controller="com.android.settings.nfc.NfcPaymentPreferenceController"/>
+    <com.android.settings.widget.GearPreference
+        android:key="nfc_payment_app"
+        android:title="@string/nfc_default_payment_settings_title"
+        android:fragment="com.android.settings.nfc.DefaultPaymentSettings"/>
 
-    <DropDownPreference
+    <ListPreference
         android:key="nfc_foreground"
         android:title="@string/nfc_payment_use_default"
-        settings:controller="com.android.settings.nfc.NfcForegroundPreferenceController"/>
+        android:dialogTitle="@string/nfc_payment_use_default_dialog"
+        settings:controller="com.android.settings.nfc.NfcForegroundPreferenceController"
+        android:entries="@array/nfc_payment_favor"
+        android:entryValues="@array/nfc_payment_favor_values" />
 
 </PreferenceScreen>
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index bf655ae..e276484 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -33,7 +33,7 @@
 import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.security.SecuritySettingsFeatureProvider;
 
 import com.google.android.setupdesign.util.ThemeHelper;
@@ -152,7 +152,7 @@
         /** Redirects to SafetyCenter if enabled. */
         @VisibleForTesting
         public void handleSafetyCenterRedirection() {
-            if (SafetyCenterStatus.isEnabled()) {
+            if (SafetyCenterStatusHolder.get().isEnabled(this)) {
                 try {
                     startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
                     finish();
@@ -213,7 +213,7 @@
         /** Redirects to SafetyCenter if enabled. */
         @VisibleForTesting
         public void handleSafetyCenterRedirection() {
-            if (SafetyCenterStatus.isEnabled()) {
+            if (SafetyCenterStatusHolder.get().isEnabled(this)) {
                 try {
                     startActivity(new Intent(Intent.ACTION_SAFETY_CENTER));
                     finish();
diff --git a/src/com/android/settings/accessibility/AccessibilityQuickSettingUtils.java b/src/com/android/settings/accessibility/AccessibilityQuickSettingUtils.java
new file mode 100644
index 0000000..013136c
--- /dev/null
+++ b/src/com/android/settings/accessibility/AccessibilityQuickSettingUtils.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.text.TextUtils;
+
+import androidx.annotation.NonNull;
+
+import java.util.StringJoiner;
+
+/** Provides utility methods to accessibility quick settings only. */
+final class AccessibilityQuickSettingUtils {
+
+    private static final String ACCESSIBILITY_PERF = "accessibility_prefs";
+    private static final String KEY_TILE_SERVICE_SHOWN = "tile_service_shown";
+    private static final char COMPONENT_NAME_SEPARATOR = ':';
+    private static final TextUtils.SimpleStringSplitter sStringColonSplitter =
+            new TextUtils.SimpleStringSplitter(COMPONENT_NAME_SEPARATOR);
+
+    /**
+     * Opts in component name into {@link AccessibilityQuickSettingUtils#KEY_TILE_SERVICE_SHOWN}
+     * colon-separated string in {@link SharedPreferences}.
+     *
+     * @param context The current context.
+     * @param componentName The component name that need to be opted in SharedPreferences.
+     */
+    public static void optInValueToSharedPreferences(Context context,
+            @NonNull ComponentName componentName) {
+        final String targetString = getFromSharedPreferences(context);
+        if (hasValueInSharedPreferences(targetString, componentName)) {
+            return;
+        }
+
+        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
+        if (!TextUtils.isEmpty(targetString)) {
+            joiner.add(targetString);
+        }
+        joiner.add(componentName.flattenToString());
+
+        SharedPreferences.Editor editor = getSharedPreferences(context).edit();
+        editor.putString(KEY_TILE_SERVICE_SHOWN, joiner.toString()).apply();
+    }
+
+    /**
+     * Returns if component name existed in {@link
+     * AccessibilityQuickSettingUtils#KEY_TILE_SERVICE_SHOWN} string in {@link SharedPreferences}.
+     *
+     * @param context The current context.
+     * @param componentName The component name that need to be checked existed in SharedPreferences.
+     * @return {@code true} if componentName existed in SharedPreferences.
+     */
+    public static boolean hasValueInSharedPreferences(Context context,
+            @NonNull ComponentName componentName) {
+        final String targetString = getFromSharedPreferences(context);
+        return hasValueInSharedPreferences(targetString, componentName);
+    }
+
+    private static boolean hasValueInSharedPreferences(String targetString,
+            @NonNull ComponentName componentName) {
+        if (TextUtils.isEmpty(targetString)) {
+            return false;
+        }
+
+        sStringColonSplitter.setString(targetString);
+
+        while (sStringColonSplitter.hasNext()) {
+            final String name = sStringColonSplitter.next();
+            if (TextUtils.equals(componentName.flattenToString(), name)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static String getFromSharedPreferences(Context context) {
+        return getSharedPreferences(context).getString(KEY_TILE_SERVICE_SHOWN, "");
+    }
+
+    private static SharedPreferences getSharedPreferences(Context context) {
+        return context.getSharedPreferences(ACCESSIBILITY_PERF, Context.MODE_PRIVATE);
+    }
+
+    private AccessibilityQuickSettingUtils(){}
+}
diff --git a/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindow.java b/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindow.java
index a4986a0..f24934f 100644
--- a/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindow.java
+++ b/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindow.java
@@ -19,10 +19,14 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
 import android.os.Handler;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.View.AccessibilityDelegate;
+import android.view.accessibility.AccessibilityNodeInfo;
+import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
 import android.widget.LinearLayout;
 import android.widget.PopupWindow;
 import android.widget.TextView;
@@ -49,6 +53,25 @@
         this.mContext = context;
     }
 
+    private final AccessibilityDelegate mAccessibilityDelegate = new AccessibilityDelegate() {
+            @Override
+            public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
+                super.onInitializeAccessibilityNodeInfo(host, info);
+                final AccessibilityAction clickAction = new AccessibilityAction(
+                        AccessibilityNodeInfo.ACTION_CLICK,
+                        mContext.getString(R.string.accessibility_quick_settings_tooltips_dismiss));
+                info.addAction(clickAction);
+            }
+
+            @Override
+            public boolean performAccessibilityAction(View host, int action, Bundle args) {
+                if (action == AccessibilityNodeInfo.ACTION_CLICK) {
+                    dismiss();
+                    return true;
+                }
+                return super.performAccessibilityAction(host, action, args);
+            }
+        };
     /**
      * Sets up {@link #AccessibilityQuickSettingsTooltipWindow}'s layout and content.
      *
@@ -74,13 +97,16 @@
         final LayoutInflater inflater = mContext.getSystemService(LayoutInflater.class);
         final View popupView =
                 inflater.inflate(R.layout.accessibility_qs_tooltips, /* root= */ null);
+        popupView.setFocusable(/* focusable= */ true);
+        popupView.setAccessibilityDelegate(mAccessibilityDelegate);
         setContentView(popupView);
+
         final TextView textView = getContentView().findViewById(R.id.qs_content);
         textView.setText(text);
-
         setWidth(getWindowWidthWith(textView));
         setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
         setFocusable(/* focusable= */ true);
+        setOutsideTouchable(/* touchable= */ true);
     }
 
     /**
diff --git a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
index 98fd5f2..05dc784 100644
--- a/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceController.java
@@ -38,6 +38,12 @@
         }
 
         @Override
+        public boolean isRestrictedByRingerModeSilent() {
+            // Touch feedback is disabled when the phone is in silent mode.
+            return true;
+        }
+
+        @Override
         public int readIntensity() {
             final int hapticFeedbackEnabled = Settings.System.getInt(mContentResolver,
                     Settings.System.HAPTIC_FEEDBACK_ENABLED, ON);
diff --git a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
index cee45f6..951d322 100644
--- a/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceController.java
@@ -32,6 +32,12 @@
             super(context, Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
                     VibrationAttributes.USAGE_NOTIFICATION);
         }
+
+        @Override
+        public boolean isRestrictedByRingerModeSilent() {
+            // Notifications never vibrate when the phone is in silent mode.
+            return true;
+        }
     }
 
     public NotificationVibrationIntensityPreferenceController(Context context,
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java b/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
index da446d7..f4ec747 100644
--- a/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceConfig.java
@@ -36,6 +36,12 @@
     }
 
     @Override
+    public boolean isRestrictedByRingerModeSilent() {
+        // Incoming calls never vibrate when the phone is in silent mode.
+        return true;
+    }
+
+    @Override
     public int readIntensity() {
         final int vibrateWhenRinging = Settings.System.getInt(mContentResolver,
                 Settings.System.VIBRATE_WHEN_RINGING, ON);
diff --git a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
index b3e8168..6441eeb 100644
--- a/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationIntensityPreferenceController.java
@@ -58,12 +58,12 @@
 
     @Override
     public void onStart() {
-        mSettingsContentObserver.register(mContext.getContentResolver());
+        mSettingsContentObserver.register(mContext);
     }
 
     @Override
     public void onStop() {
-        mSettingsContentObserver.unregister(mContext.getContentResolver());
+        mSettingsContentObserver.unregister(mContext);
     }
 
     @Override
@@ -72,6 +72,7 @@
         final SeekBarPreference preference = screen.findPreference(getPreferenceKey());
         mSettingsContentObserver.onDisplayPreference(this, preference);
         preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
+        preference.setSummaryProvider(unused -> mPreferenceConfig.getSummary());
         // TODO: remove setContinuousUpdates and replace with a different way to play the haptic
         // preview without relying on the setting being propagated to the service.
         preference.setContinuousUpdates(true);
diff --git a/src/com/android/settings/accessibility/VibrationPreferenceConfig.java b/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
index 1b0b163..9208b18 100644
--- a/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
+++ b/src/com/android/settings/accessibility/VibrationPreferenceConfig.java
@@ -18,9 +18,13 @@
 
 import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
 
+import android.content.BroadcastReceiver;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.database.ContentObserver;
+import android.media.AudioManager;
 import android.net.Uri;
 import android.os.Handler;
 import android.os.VibrationAttributes;
@@ -28,8 +32,10 @@
 import android.os.Vibrator;
 import android.provider.Settings;
 
+import androidx.annotation.Nullable;
 import androidx.preference.Preference;
 
+import com.android.settings.R;
 import com.android.settingslib.core.AbstractPreferenceController;
 
 /**
@@ -45,8 +51,10 @@
     public static final String MAIN_SWITCH_SETTING_KEY = Settings.System.VIBRATE_ON;
 
     protected final ContentResolver mContentResolver;
+    private final AudioManager mAudioManager;
     private final Vibrator mVibrator;
     private final String mSettingKey;
+    private final String mRingerModeSilentSummary;
     private final int mDefaultIntensity;
     private final VibrationAttributes mVibrationAttributes;
 
@@ -58,6 +66,9 @@
     public VibrationPreferenceConfig(Context context, String settingKey, int vibrationUsage) {
         mContentResolver = context.getContentResolver();
         mVibrator = context.getSystemService(Vibrator.class);
+        mAudioManager = context.getSystemService(AudioManager.class);
+        mRingerModeSilentSummary = context.getString(
+                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary);
         mSettingKey = settingKey;
         mDefaultIntensity = mVibrator.getDefaultVibrationIntensity(vibrationUsage);
         mVibrationAttributes = new VibrationAttributes.Builder()
@@ -70,9 +81,24 @@
         return mSettingKey;
     }
 
+    /** Returns the summary string for this setting preference. */
+    @Nullable
+    public CharSequence getSummary() {
+        return isRestrictedByRingerModeSilent() && isRingerModeSilent()
+                ? mRingerModeSilentSummary : null;
+    }
+
     /** Returns true if this setting preference is enabled for user update. */
     public boolean isPreferenceEnabled() {
-        return isMainVibrationSwitchEnabled(mContentResolver);
+        return isMainVibrationSwitchEnabled(mContentResolver)
+                && (!isRestrictedByRingerModeSilent() || !isRingerModeSilent());
+    }
+
+    /**
+     * Returns true if this setting preference should be disabled when the device is in silent mode.
+     */
+    public boolean isRestrictedByRingerModeSilent() {
+        return false;
     }
 
     /** Returns the default intensity to be displayed when the setting value is not set. */
@@ -96,12 +122,23 @@
                 mVibrationAttributes);
     }
 
+    private boolean isRingerModeSilent() {
+        // AudioManager.isSilentMode() also returns true when ringer mode is VIBRATE.
+        // The vibration preferences are only disabled when the ringer mode is SILENT.
+        return mAudioManager.getRingerModeInternal() == AudioManager.RINGER_MODE_SILENT;
+    }
+
     /** {@link ContentObserver} for a setting described by a {@link VibrationPreferenceConfig}. */
     public static final class SettingObserver extends ContentObserver {
         private static final Uri MAIN_SWITCH_SETTING_URI =
                 Settings.System.getUriFor(MAIN_SWITCH_SETTING_KEY);
+        private static final IntentFilter INTERNAL_RINGER_MODE_CHANGED_INTENT_FILTER =
+                new IntentFilter(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
 
         private final Uri mUri;
+        @Nullable
+        private final BroadcastReceiver mRingerModeChangeReceiver;
+
         private AbstractPreferenceController mPreferenceController;
         private Preference mPreference;
 
@@ -109,35 +146,63 @@
         public SettingObserver(VibrationPreferenceConfig preferenceConfig) {
             super(new Handler(/* async= */ true));
             mUri = Settings.System.getUriFor(preferenceConfig.getSettingKey());
+
+            if (preferenceConfig.isRestrictedByRingerModeSilent()) {
+                // If this preference is restricted by AudioManager.getRingerModeInternal() result
+                // for the device mode, then listen to changes in that value using the broadcast
+                // intent action INTERNAL_RINGER_MODE_CHANGED_ACTION.
+                mRingerModeChangeReceiver = new BroadcastReceiver() {
+                    @Override
+                    public void onReceive(Context context, Intent intent) {
+                        final String action = intent.getAction();
+                        if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) {
+                            notifyChange();
+                        }
+                    }
+                };
+            } else {
+                // No need to register a receiver if this preference is not affected by ringer mode.
+                mRingerModeChangeReceiver = null;
+            }
         }
 
         @Override
         public void onChange(boolean selfChange, Uri uri) {
-            if (mPreferenceController == null || mPreference == null) {
-                // onDisplayPreference not triggered yet, nothing to update.
-                return;
-            }
             if (mUri.equals(uri) || MAIN_SWITCH_SETTING_URI.equals(uri)) {
+                notifyChange();
+            }
+        }
+
+        private void notifyChange() {
+            if (mPreferenceController != null && mPreference != null) {
                 mPreferenceController.updateState(mPreference);
             }
         }
 
         /**
-         * Register this observer to given {@link ContentResolver}, to be called from lifecycle
+         * Register this observer to given {@link Context}, to be called from lifecycle
          * {@code onStart} method.
          */
-        public void register(ContentResolver contentResolver) {
-            contentResolver.registerContentObserver(mUri, /* notifyForDescendants= */ false, this);
-            contentResolver.registerContentObserver(MAIN_SWITCH_SETTING_URI,
-                    /* notifyForDescendants= */ false, this);
+        public void register(Context context) {
+            if (mRingerModeChangeReceiver != null) {
+                context.registerReceiver(mRingerModeChangeReceiver,
+                        INTERNAL_RINGER_MODE_CHANGED_INTENT_FILTER);
+            }
+            context.getContentResolver().registerContentObserver(
+                    mUri, /* notifyForDescendants= */ false, this);
+            context.getContentResolver().registerContentObserver(
+                    MAIN_SWITCH_SETTING_URI, /* notifyForDescendants= */ false, this);
         }
 
         /**
-         * Unregister this observer from given {@link ContentResolver}, to be called from lifecycle
+         * Unregister this observer from given {@link Context}, to be called from lifecycle
          * {@code onStop} method.
          */
-        public void unregister(ContentResolver contentResolver) {
-            contentResolver.unregisterContentObserver(this);
+        public void unregister(Context context) {
+            if (mRingerModeChangeReceiver != null) {
+                context.unregisterReceiver(mRingerModeChangeReceiver);
+            }
+            context.getContentResolver().unregisterContentObserver(this);
         }
 
         /**
diff --git a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
index 37a0257..8d1b43e 100644
--- a/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceController.java
@@ -93,7 +93,7 @@
 
     @Override
     public void onStart() {
-        mRingSettingObserver.register(mContext.getContentResolver());
+        mRingSettingObserver.register(mContext);
         mContext.getContentResolver().registerContentObserver(
                 Settings.System.getUriFor(Settings.System.APPLY_RAMPING_RINGER),
                 /* notifyForDescendants= */ false,
@@ -102,7 +102,7 @@
 
     @Override
     public void onStop() {
-        mRingSettingObserver.unregister(mContext.getContentResolver());
+        mRingSettingObserver.unregister(mContext);
         mContext.getContentResolver().unregisterContentObserver(mSettingObserver);
     }
 
diff --git a/src/com/android/settings/accessibility/VibrationTogglePreferenceController.java b/src/com/android/settings/accessibility/VibrationTogglePreferenceController.java
index 8f158cc..c60158d 100644
--- a/src/com/android/settings/accessibility/VibrationTogglePreferenceController.java
+++ b/src/com/android/settings/accessibility/VibrationTogglePreferenceController.java
@@ -45,12 +45,12 @@
 
     @Override
     public void onStart() {
-        mSettingsContentObserver.register(mContext.getContentResolver());
+        mSettingsContentObserver.register(mContext);
     }
 
     @Override
     public void onStop() {
-        mSettingsContentObserver.unregister(mContext.getContentResolver());
+        mSettingsContentObserver.unregister(mContext);
     }
 
     @Override
@@ -66,6 +66,7 @@
         super.updateState(preference);
         if (preference != null) {
             preference.setEnabled(mPreferenceConfig.isPreferenceEnabled());
+            preference.setSummary(mPreferenceConfig.getSummary());
         }
     }
 
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
index 8484324..146151b 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingRulesController.java
@@ -17,9 +17,11 @@
 package com.android.settings.activityembedding;
 
 import android.app.Activity;
+import android.app.settings.SettingsEnums;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.util.FeatureFlagUtils;
 import android.util.LayoutDirection;
 import android.util.Log;
 
@@ -35,9 +37,11 @@
 import com.android.settings.SubSettings;
 import com.android.settings.biometrics.fingerprint.FingerprintEnrollEnrolling;
 import com.android.settings.biometrics.fingerprint.FingerprintEnrollIntroduction;
+import com.android.settings.core.FeatureFlags;
 import com.android.settings.homepage.DeepLinkHomepageActivity;
 import com.android.settings.homepage.SettingsHomepageActivity;
 import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
+import com.android.settings.overlay.FeatureFactory;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -92,7 +96,7 @@
                 clearTop,
                 ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(context),
                 ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(context),
-                ActivityEmbeddingUtils.SPLIT_RATIO,
+                ActivityEmbeddingUtils.getSplitRatio(context),
                 LayoutDirection.LOCALE));
     }
 
@@ -198,7 +202,7 @@
                 SplitRule.FINISH_ADJACENT,
                 ActivityEmbeddingUtils.getMinCurrentScreenSplitWidthPx(mContext),
                 ActivityEmbeddingUtils.getMinSmallestScreenSplitWidthPx(mContext),
-                ActivityEmbeddingUtils.SPLIT_RATIO,
+                ActivityEmbeddingUtils.getSplitRatio(mContext),
                 LayoutDirection.LOCALE);
 
         mSplitController.registerRule(placeholderRule);
@@ -206,11 +210,22 @@
 
     private void registerAlwaysExpandRule() {
         final Set<ActivityFilter> activityFilters = new HashSet<>();
+        if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
+            final Intent searchIntent = FeatureFactory.getFactory(mContext)
+                    .getSearchFeatureProvider()
+                    .buildSearchIntent(mContext, SettingsEnums.SETTINGS_HOMEPAGE);
+            addActivityFilter(activityFilters, searchIntent);
+        }
         addActivityFilter(activityFilters, FingerprintEnrollIntroduction.class);
         addActivityFilter(activityFilters, FingerprintEnrollEnrolling.class);
         mSplitController.registerRule(new ActivityRule(activityFilters, true /* alwaysExpand */));
     }
 
+    private static void addActivityFilter(Set<ActivityFilter> activityFilters, Intent intent) {
+        activityFilters.add(new ActivityFilter(new ComponentName("*" /* pkg */, "*" /* cls */),
+                intent.getAction()));
+    }
+
     private void addActivityFilter(Set<ActivityFilter> activityFilters,
             Class<? extends Activity> activityClass) {
         activityFilters.add(new ActivityFilter(new ComponentName(mContext, activityClass),
diff --git a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
index ab999ed..38af8d6 100644
--- a/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
+++ b/src/com/android/settings/activityembedding/ActivityEmbeddingUtils.java
@@ -24,9 +24,10 @@
 
 import androidx.window.embedding.SplitController;
 
+import com.android.settings.R;
+
 /** An util class collecting all common methods for the embedding activity features. */
 public class ActivityEmbeddingUtils {
-    public static final float SPLIT_RATIO = 0.5f;
     // The smallest value of current width of the window when the split should be used.
     private static final float MIN_CURRENT_SCREEN_SPLIT_WIDTH_DP = 720f;
     // The smallest value of the smallest-width (sw) of the window in any rotation when
@@ -51,6 +52,14 @@
                 TypedValue.COMPLEX_UNIT_DIP, MIN_SMALLEST_SCREEN_SPLIT_WIDTH_DP, dm);
     }
 
+    /**
+     * Get the ratio to use when splitting windows. This should be a float which describes
+     * the percentage of the screen which the first window should occupy.
+     */
+    public static float getSplitRatio(Context context) {
+        return context.getResources().getFloat(R.dimen.config_activity_embed_split_ratio);
+    }
+
     /** Whether to support embedding activity feature. */
     public static boolean isEmbeddingActivityEnabled(Context context) {
         final boolean isFlagEnabled = FeatureFlagUtils.isEnabled(context,
diff --git a/src/com/android/settings/applications/AppLocaleUtil.java b/src/com/android/settings/applications/AppLocaleUtil.java
new file mode 100644
index 0000000..e795b01
--- /dev/null
+++ b/src/com/android/settings/applications/AppLocaleUtil.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2022 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.applications;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+import com.android.settings.R;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+
+/** This class provides methods that help dealing with per app locale. */
+public class AppLocaleUtil {
+    private static final String TAG = AppLocaleUtil.class.getSimpleName();
+
+    /**
+     * Decides the UI display of per app locale.
+     */
+    public static boolean canDisplayLocaleUi(Context context, AppEntry app) {
+        return !isDisallowedPackage(context, app.info.packageName)
+                && !isSignedWithPlatformKey(context, app.info.packageName)
+                && app.hasLauncherEntry;
+    }
+
+    private static boolean isDisallowedPackage(Context context, String packageName) {
+        final String[] disallowedPackages = context.getResources().getStringArray(
+                R.array.config_disallowed_app_localeChange_packages);
+        for (String disallowedPackage : disallowedPackages) {
+            if (packageName.equals(disallowedPackage)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isSignedWithPlatformKey(Context context, String packageName) {
+        PackageInfo packageInfo = null;
+        PackageManager packageManager = context.getPackageManager();
+        ActivityManager activityManager = context.getSystemService(ActivityManager.class);
+        try {
+            packageInfo = packageManager.getPackageInfoAsUser(
+                    packageName, /* flags= */ 0,
+                    activityManager.getCurrentUser());
+        } catch (PackageManager.NameNotFoundException ex) {
+            Log.e(TAG, "package not found: " + packageName);
+        }
+        if (packageInfo == null) {
+            return false;
+        }
+        return packageInfo.applicationInfo.isSignedWithPlatformKey();
+    }
+}
diff --git a/src/com/android/settings/applications/AppStateLocaleBridge.java b/src/com/android/settings/applications/AppStateLocaleBridge.java
new file mode 100644
index 0000000..ebaf4ab
--- /dev/null
+++ b/src/com/android/settings/applications/AppStateLocaleBridge.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2022 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.applications;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.android.settingslib.applications.ApplicationsState;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+import com.android.settingslib.applications.ApplicationsState.AppFilter;
+
+import java.util.List;
+
+/**
+ * Creates a application filter to restrict UI display of applications.
+ * This is to avoid users from changing the per apps locale
+ * Also provides app filters that can use the info.
+ */
+public class AppStateLocaleBridge extends AppStateBaseBridge {
+    private static final String TAG = AppStateLocaleBridge.class.getSimpleName();
+
+    private final Context mContext;
+
+    public AppStateLocaleBridge(Context context, ApplicationsState appState,
+            Callback callback) {
+        super(appState, callback);
+        mContext = context;
+    }
+
+    @Override
+    protected void updateExtraInfo(AppEntry app, String packageName, int uid) {
+        app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app)
+                ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    @Override
+    protected void loadAllExtraInfo() {
+        final List<AppEntry> allApps = mAppSession.getAllApps();
+        for (int i = 0; i < allApps.size(); i++) {
+            AppEntry app = allApps.get(i);
+            app.extraInfo = AppLocaleUtil.canDisplayLocaleUi(mContext, app)
+                    ? Boolean.TRUE : Boolean.FALSE;
+        }
+    }
+
+    /** For the Settings which shows category of per app's locale. */
+    public static final AppFilter FILTER_APPS_LOCALE =
+            new AppFilter() {
+                @Override
+                public void init() {
+                }
+
+                @Override
+                public boolean filterApp(AppEntry entry) {
+                    if (entry.extraInfo == null) {
+                        Log.d(TAG, "No extra info.");
+                        return false;
+                    }
+                    return (Boolean) entry.extraInfo;
+                }
+            };
+
+
+}
diff --git a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
index 7fd43c2..aee360e 100644
--- a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -37,6 +37,8 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceGroup;
 
+import com.android.internal.app.LocalePicker;
+import com.android.internal.app.LocalePicker.LocaleInfo;
 import com.android.settings.R;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppInfoBase;
@@ -45,8 +47,11 @@
 import com.android.settingslib.widget.LayoutPreference;
 import com.android.settingslib.widget.RadioButtonPreference;
 
+import com.google.common.collect.Iterables;
+
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.List;
 import java.util.Locale;
 
 /**
@@ -200,8 +205,8 @@
         private TelephonyManager mTelephonyManager;
         private LocaleManager mLocaleManager;
 
-        private Collection<Locale> mSuggestedLocales = new ArrayList<>();;
-        private Collection<Locale> mSupportedLocales = new ArrayList<>();;
+        private Collection<Locale> mSuggestedLocales = new ArrayList<>();
+        private Collection<Locale> mSupportedLocales = new ArrayList<>();
 
         AppLocaleDetailsHelper(Context context, String packageName) {
             mContext = context;
@@ -230,25 +235,41 @@
         @VisibleForTesting
         void handleSuggestedLocales() {
             LocaleList currentSystemLocales = getCurrentSystemLocales();
-            Locale simLocale = mTelephonyManager.getSimLocale();
             Locale appLocale = getAppDefaultLocale(mContext, mPackageName);
+            String simCountry = mTelephonyManager.getSimCountryIso().toUpperCase(Locale.US);
+            String networkCountry = mTelephonyManager.getNetworkCountryIso().toUpperCase(Locale.US);
             // 1st locale in suggested languages group.
             if (appLocale != null) {
                 mSuggestedLocales.add(appLocale);
             }
             // 2nd locale in suggested languages group.
-            if (simLocale != null && !compareLocale(simLocale, appLocale)) {
-                mSuggestedLocales.add(simLocale);
+            final List<LocaleInfo> localeInfos = LocalePicker.getAllAssetLocales(mContext, false);
+            for (LocaleInfo localeInfo : localeInfos) {
+                Locale locale = localeInfo.getLocale();
+                String localeCountry = locale.getCountry().toUpperCase(Locale.US);
+                if (!compareLocale(locale, appLocale)
+                        && isCountrySuggestedLocale(localeCountry, simCountry, networkCountry)) {
+                    mSuggestedLocales.add(locale);
+                }
             }
             // Other locales in suggested languages group.
             for (int i = 0; i < currentSystemLocales.size(); i++) {
                 Locale locale = currentSystemLocales.get(i);
-                if (!compareLocale(locale, appLocale) && !compareLocale(locale, simLocale)) {
+                boolean isInSuggestedLocales = false;
+                for (int j = 0; j < mSuggestedLocales.size(); j++) {
+                    Locale suggestedLocale = Iterables.get(mSuggestedLocales, j);
+                    if (compareLocale(locale, suggestedLocale)) {
+                        isInSuggestedLocales = true;
+                        break;
+                    }
+                }
+                if (!isInSuggestedLocales) {
                     mSuggestedLocales.add(locale);
                 }
             }
         }
 
+        @VisibleForTesting
         static boolean compareLocale(Locale source, Locale target) {
             if (source == null && target == null) {
                 return true;
@@ -259,6 +280,13 @@
             }
         }
 
+        private static boolean isCountrySuggestedLocale(String localeCountry,
+                String simCountry,
+                String networkCountry) {
+            return ((!simCountry.isEmpty() && simCountry.equals(localeCountry))
+                    || (!networkCountry.isEmpty() && networkCountry.equals(localeCountry)));
+        }
+
         @VisibleForTesting
         void handleSupportedLocales() {
             //TODO Waiting for PackageManager api
diff --git a/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java
index f1e43ad..810d230 100644
--- a/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppLocalePreferenceController.java
@@ -20,20 +20,23 @@
 import android.util.FeatureFlagUtils;
 
 import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.AppLocaleUtil;
 
 /**
  * A controller to update current locale information of application.
  */
 public class AppLocalePreferenceController extends AppInfoPreferenceControllerBase {
+    private static final String TAG = AppLocalePreferenceController.class.getSimpleName();
+
     public AppLocalePreferenceController(Context context, String key) {
         super(context, key);
     }
 
     @Override
     public int getAvailabilityStatus() {
-        return FeatureFlagUtils
-                .isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION)
-                ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+        boolean isFeatureOn = FeatureFlagUtils
+                .isEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION);
+        return isFeatureOn && canDisplayLocaleUi() ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
     }
 
     @Override
@@ -45,4 +48,8 @@
     public CharSequence getSummary() {
         return AppLocaleDetails.getSummary(mContext, mParent.getAppEntry().info.packageName);
     }
+
+    boolean canDisplayLocaleUi() {
+        return AppLocaleUtil.canDisplayLocaleUi(mContext, mParent.getAppEntry());
+    }
 }
diff --git a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
index d1d4f62..6e67815 100644
--- a/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
+++ b/src/com/android/settings/applications/manageapplications/AppFilterRegistry.java
@@ -21,6 +21,7 @@
 import com.android.settings.R;
 import com.android.settings.applications.AppStateAlarmsAndRemindersBridge;
 import com.android.settings.applications.AppStateInstallAppsBridge;
+import com.android.settings.applications.AppStateLocaleBridge;
 import com.android.settings.applications.AppStateManageExternalStorageBridge;
 import com.android.settings.applications.AppStateMediaManagementAppsBridge;
 import com.android.settings.applications.AppStateNotificationBridge;
@@ -54,6 +55,7 @@
             FILTER_APPS_BLOCKED,
             FILTER_ALARMS_AND_REMINDERS,
             FILTER_APPS_MEDIA_MANAGEMENT,
+            FILTER_APPS_LOCALE,
     })
     @interface FilterType {
     }
@@ -79,14 +81,15 @@
     public static final int FILTER_MANAGE_EXTERNAL_STORAGE = 17;
     public static final int FILTER_ALARMS_AND_REMINDERS = 18;
     public static final int FILTER_APPS_MEDIA_MANAGEMENT = 19;
-    // Next id: 20. If you add an entry here, length of mFilters should be updated
+    public static final int FILTER_APPS_LOCALE = 20;
+    // Next id: 21. If you add an entry here, length of mFilters should be updated
 
     private static AppFilterRegistry sRegistry;
 
     private final AppFilterItem[] mFilters;
 
     private AppFilterRegistry() {
-        mFilters = new AppFilterItem[20];
+        mFilters = new AppFilterItem[21];
 
         // High power allowlist, on
         mFilters[FILTER_APPS_POWER_ALLOWLIST] = new AppFilterItem(
@@ -203,8 +206,16 @@
                 AppStateMediaManagementAppsBridge.FILTER_MEDIA_MANAGEMENT_APPS,
                 FILTER_APPS_MEDIA_MANAGEMENT,
                 R.string.media_management_apps_title);
+
+        // Apps that can configurate appication's locale.
+        mFilters[FILTER_APPS_LOCALE] = new AppFilterItem(
+                AppStateLocaleBridge.FILTER_APPS_LOCALE,
+            FILTER_APPS_LOCALE,
+                R.string.app_locale_picker_title);
     }
 
+
+
     public static AppFilterRegistry getInstance() {
         if (sRegistry == null) {
             sRegistry = new AppFilterRegistry();
@@ -235,6 +246,8 @@
                 return FILTER_ALARMS_AND_REMINDERS;
             case ManageApplications.LIST_TYPE_MEDIA_MANAGEMENT_APPS:
                 return FILTER_APPS_MEDIA_MANAGEMENT;
+            case ManageApplications.LIST_TYPE_APPS_LOCALE:
+                return FILTER_APPS_LOCALE;
             default:
                 return FILTER_APPS_ALL;
         }
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index d985482..01bc2f1 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -95,6 +95,7 @@
 import com.android.settings.applications.AppStateAppOpsBridge.PermissionState;
 import com.android.settings.applications.AppStateBaseBridge;
 import com.android.settings.applications.AppStateInstallAppsBridge;
+import com.android.settings.applications.AppStateLocaleBridge;
 import com.android.settings.applications.AppStateManageExternalStorageBridge;
 import com.android.settings.applications.AppStateMediaManagementAppsBridge;
 import com.android.settings.applications.AppStateNotificationBridge;
@@ -232,7 +233,7 @@
     public static final int LIST_MANAGE_EXTERNAL_STORAGE = 11;
     public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 12;
     public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 13;
-    public static final int LIST_TYPE_APPS_LOCAL = 14;
+    public static final int LIST_TYPE_APPS_LOCALE = 14;
 
     // List types that should show instant apps.
     public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -321,7 +322,7 @@
             mNotificationBackend = new NotificationBackend();
             mSortOrder = R.id.sort_order_recent_notification;
         } else if (className.equals(AppLocaleDetails.class.getName())) {
-            mListType = LIST_TYPE_APPS_LOCAL;
+            mListType = LIST_TYPE_APPS_LOCALE;
         } else {
             mListType = LIST_TYPE_MAIN;
         }
@@ -504,7 +505,7 @@
                 return SettingsEnums.ALARMS_AND_REMINDERS;
             case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
                 return SettingsEnums.MEDIA_MANAGEMENT_APPS;
-            case LIST_TYPE_APPS_LOCAL:
+            case LIST_TYPE_APPS_LOCALE:
                 return SettingsEnums.APPS_LOCALE_LIST;
             default:
                 return SettingsEnums.PAGE_UNKNOWN;
@@ -629,7 +630,7 @@
                 startAppInfoFragment(MediaManagementAppsDetails.class,
                         R.string.media_management_apps_title);
                 break;
-            case LIST_TYPE_APPS_LOCAL:
+            case LIST_TYPE_APPS_LOCALE:
                 startAppInfoFragment(AppLocaleDetails.class,
                         R.string.app_locale_picker_title);
                 break;
@@ -743,9 +744,9 @@
                 && mSortOrder != R.id.sort_order_size);
 
         mOptionsMenu.findItem(R.id.show_system).setVisible(!mShowSystem
-                && mListType != LIST_TYPE_HIGH_POWER);
+                && mListType != LIST_TYPE_HIGH_POWER && mListType != LIST_TYPE_APPS_LOCALE);
         mOptionsMenu.findItem(R.id.hide_system).setVisible(mShowSystem
-                && mListType != LIST_TYPE_HIGH_POWER);
+                && mListType != LIST_TYPE_HIGH_POWER && mListType != LIST_TYPE_APPS_LOCALE);
 
         mOptionsMenu.findItem(R.id.reset_app_preferences).setVisible(mListType == LIST_TYPE_MAIN);
 
@@ -1100,6 +1101,8 @@
                 mExtraInfoBridge = new AppStateAlarmsAndRemindersBridge(mContext, mState, this);
             } else if (mManageApplications.mListType == LIST_TYPE_MEDIA_MANAGEMENT_APPS) {
                 mExtraInfoBridge = new AppStateMediaManagementAppsBridge(mContext, mState, this);
+            } else if (mManageApplications.mListType == LIST_TYPE_APPS_LOCALE) {
+                mExtraInfoBridge = new AppStateLocaleBridge(mContext, mState, this);
             } else {
                 mExtraInfoBridge = null;
             }
@@ -1533,7 +1536,7 @@
                 case LIST_TYPE_MEDIA_MANAGEMENT_APPS:
                     holder.setSummary(MediaManagementAppsDetails.getSummary(mContext, entry));
                     break;
-                case LIST_TYPE_APPS_LOCAL:
+                case LIST_TYPE_APPS_LOCALE:
                     holder.setSummary(AppLocaleDetails
                             .getSummary(mContext, entry.info.packageName));
                     break;
diff --git a/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
index 4ebc0cd..feb757f 100644
--- a/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
+++ b/src/com/android/settings/connecteddevice/NfcAndPaymentFragment.java
@@ -17,6 +17,12 @@
 package com.android.settings.connecteddevice;
 
 import android.app.settings.SettingsEnums;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.pm.UserInfo;
+import android.os.UserHandle;
+import android.os.UserManager;
+
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
@@ -54,5 +60,16 @@
      * For Search.
      */
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-            new BaseSearchIndexProvider(R.xml.nfc_and_payment_settings);
+            new BaseSearchIndexProvider(R.xml.nfc_and_payment_settings) {
+            @Override
+                protected boolean isPageSearchEnabled(Context context) {
+                    final UserManager userManager = context.getSystemService(UserManager.class);
+                    final UserInfo myUserInfo = userManager.getUserInfo(UserHandle.myUserId());
+                    if (myUserInfo.isGuest()) {
+                        return false;
+                    }
+                    final PackageManager pm = context.getPackageManager();
+                    return pm.hasSystemFeature(PackageManager.FEATURE_NFC);
+                }
+            };
 }
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index 7f0c2e0..1a97ca9 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -28,4 +28,6 @@
     public static final String CONDITIONAL_CARDS = "settings_conditionals";
     public static final String TETHER_ALL_IN_ONE = "settings_tether_all_in_one";
     public static final String CONTEXTUAL_HOME = "settings_contextual_home";
+    public static final String SETTINGS_SEARCH_ALWAYS_EXPAND =
+            "settings_search_always_expand";
 }
diff --git a/src/com/android/settings/dashboard/profileselector/UserAdapter.java b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
index 46c87a1..0b3a7fc 100644
--- a/src/com/android/settings/dashboard/profileselector/UserAdapter.java
+++ b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
@@ -55,8 +55,8 @@
             Drawable icon;
             if (userInfo.isManagedProfile()) {
                 mName = context.getString(R.string.managed_user_title);
-                icon = context.getDrawable(
-                        com.android.internal.R.drawable.ic_corp_badge);
+                icon = context.getPackageManager().getUserBadgeForDensityNoBackground(
+                        userHandle, /* density= */ 0);
             } else {
                 mName = userInfo.name;
                 final int userId = userInfo.id;
diff --git a/src/com/android/settings/fuelgauge/BatteryBackupHelper.java b/src/com/android/settings/fuelgauge/BatteryBackupHelper.java
index fdbd12a..f5e21dd 100644
--- a/src/com/android/settings/fuelgauge/BatteryBackupHelper.java
+++ b/src/com/android/settings/fuelgauge/BatteryBackupHelper.java
@@ -68,6 +68,9 @@
     static final String KEY_OPTIMIZATION_LIST = "optimization_mode_list";
 
     @VisibleForTesting
+    List<ApplicationInfo> mTestApplicationInfoList = null;
+
+    @VisibleForTesting
     PowerAllowlistBackend mPowerAllowlistBackend;
     @VisibleForTesting
     IDeviceIdleController mIDeviceIdleController;
@@ -267,6 +270,9 @@
     }
 
     private List<ApplicationInfo> getInstalledApplications() {
+        if (mTestApplicationInfoList != null) {
+            return mTestApplicationInfoList;
+        }
         final List<ApplicationInfo> applications = new ArrayList<>();
         final UserManager um = mContext.getSystemService(UserManager.class);
         for (UserInfo userInfo : um.getProfiles(UserHandle.myUserId())) {
diff --git a/src/com/android/settings/nearby/FastPairSettingsFragment.java b/src/com/android/settings/nearby/FastPairSettingsFragment.java
index 094725b..7657bc3 100644
--- a/src/com/android/settings/nearby/FastPairSettingsFragment.java
+++ b/src/com/android/settings/nearby/FastPairSettingsFragment.java
@@ -17,11 +17,16 @@
 package com.android.settings.nearby;
 
 import android.app.settings.SettingsEnums;
+import android.os.Bundle;
+import android.provider.Settings;
 
 import com.android.settings.R;
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.widget.MainSwitchPreference;
+
+import java.util.Objects;
 
 /**
  * Fragment with the top level fast pair settings.
@@ -29,6 +34,21 @@
 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 public class FastPairSettingsFragment extends SettingsPreferenceFragment {
 
+    private static final String SCAN_SWITCH_KEY = "fast_pair_scan_switch";
+
+    @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        MainSwitchPreference mainSwitchPreference = Objects.requireNonNull(
+                findPreference(SCAN_SWITCH_KEY));
+        mainSwitchPreference.addOnSwitchChangeListener(
+                (switchView, isChecked) ->
+                        Settings.Secure.putInt(getContentResolver(),
+                                Settings.Secure.FAST_PAIR_SCAN_ENABLED, isChecked ? 1 : 0));
+        mainSwitchPreference.setChecked(isFastPairScanAvailable());
+    }
+
     @Override
     public int getMetricsCategory() {
         return SettingsEnums.CONNECTION_DEVICE_ADVANCED_FAST_PAIR;
@@ -47,4 +67,8 @@
     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
             new BaseSearchIndexProvider(R.xml.fast_pair_settings);
 
+    private boolean isFastPairScanAvailable() {
+        return Settings.Secure.getInt(getContentResolver(),
+                Settings.Secure.FAST_PAIR_SCAN_ENABLED, 1) != 0;
+    }
 }
diff --git a/src/com/android/settings/nfc/DefaultPaymentSettings.java b/src/com/android/settings/nfc/DefaultPaymentSettings.java
new file mode 100644
index 0000000..4dceefc
--- /dev/null
+++ b/src/com/android/settings/nfc/DefaultPaymentSettings.java
@@ -0,0 +1,278 @@
+/*
+ * Copyright (C) 2022 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.nfc;
+
+import android.app.settings.SettingsEnums;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.os.UserHandle;
+import android.os.UserManager;
+import android.text.Layout;
+import android.text.SpannableString;
+import android.text.Spanned;
+import android.text.TextUtils;
+import android.text.style.AlignmentSpan;
+import android.text.style.BulletSpan;
+import android.text.style.ClickableSpan;
+import android.text.style.RelativeSizeSpan;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.applications.defaultapps.DefaultAppPickerFragment;
+import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
+import com.android.settingslib.widget.CandidateInfo;
+import com.android.settingslib.widget.FooterPreference;
+import com.android.settingslib.widget.SelectorWithWidgetPreference;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * DefaultPaymentSettings handles the NFC default payment app selection.
+ */
+public class DefaultPaymentSettings extends DefaultAppPickerFragment {
+    public static final String TAG = "DefaultPaymentSettings";
+
+    private PaymentBackend mPaymentBackend;
+    private List<PaymentAppInfo> mAppInfos;
+    private Preference mFooterPreference;
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.NFC_PAYMENT;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.nfc_default_payment_settings;
+    }
+
+    @Override
+    protected String getDefaultKey() {
+        PaymentAppInfo defaultAppInfo = mPaymentBackend.getDefaultApp();
+        if (defaultAppInfo != null) {
+            return defaultAppInfo.componentName.flattenToString() + " "
+                    + defaultAppInfo.userHandle.getIdentifier();
+        }
+        return null;
+    }
+
+    @Override
+    protected boolean setDefaultKey(String key) {
+        String[] keys = key.split(" ");
+        if (keys.length >= 2) {
+            mPaymentBackend.setDefaultPaymentApp(ComponentName.unflattenFromString(keys[0]),
+                    Integer.parseInt(keys[1]));
+        }
+        return true;
+    }
+
+    @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        mPaymentBackend = new PaymentBackend(getActivity());
+        mAppInfos = mPaymentBackend.getPaymentAppInfos();
+    }
+
+    @Override
+    protected void addStaticPreferences(PreferenceScreen screen) {
+        if (mFooterPreference == null) {
+            setupFooterPreference();
+        }
+        screen.addPreference(mFooterPreference);
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        mPaymentBackend.onResume();
+    }
+
+    @Override
+    public void onPause() {
+        super.onPause();
+        mPaymentBackend.onPause();
+    }
+
+    /**
+     * Comparator for NfcPaymentCandidateInfo.
+     */
+    public class NfcPaymentCandidateInfoComparator implements Comparator<NfcPaymentCandidateInfo> {
+        /**
+         * Compare the NfcPaymentCandidateInfo by the label string.
+         */
+        public int compare(NfcPaymentCandidateInfo obj1, NfcPaymentCandidateInfo obj2) {
+            if (obj1.loadLabel() == obj2.loadLabel()) {
+                return 0;
+            }
+            if (obj1.loadLabel() == null) {
+                return -1;
+            }
+            if (obj2.loadLabel() == null) {
+                return 1;
+            }
+            return obj1.loadLabel().toString().compareTo(obj2.loadLabel().toString());
+        }
+    }
+
+    @Override
+    public void bindPreferenceExtra(SelectorWithWidgetPreference pref, String key,
+            CandidateInfo info, String defaultKey, String systemDefaultKey) {
+        final NfcPaymentCandidateInfo candidateInfo = (NfcPaymentCandidateInfo) info;
+        if (candidateInfo.isManagedProfile()) {
+            pref.setSummary("Work");
+        }
+    }
+
+    @Override
+    protected List<? extends CandidateInfo> getCandidates() {
+        final List<NfcPaymentCandidateInfo> candidates = new ArrayList<>();
+        for (PaymentAppInfo appInfo: mAppInfos) {
+            UserManager um = getContext().createContextAsUser(
+                    appInfo.userHandle, /*flags=*/0).getSystemService(UserManager.class);
+            boolean isManagedProfile = um.isManagedProfile(appInfo.userHandle.getIdentifier());
+
+            CharSequence label;
+            label = appInfo.label;
+            candidates.add(new NfcPaymentCandidateInfo(
+                    appInfo.componentName.flattenToString(),
+                    label,
+                    appInfo.icon,
+                    appInfo.userHandle.getIdentifier(),
+                    isManagedProfile));
+        }
+        Collections.sort(candidates, new NfcPaymentCandidateInfoComparator());
+        return candidates;
+    }
+
+    @VisibleForTesting
+    class NfcPaymentCandidateInfo extends CandidateInfo {
+        private final String mKey;
+        private final CharSequence mLabel;
+        private final Drawable mDrawable;
+        private final int mUserId;
+        private final boolean mIsManagedProfile;
+
+        NfcPaymentCandidateInfo(String key, CharSequence label, Drawable drawable, int userId,
+                boolean isManagedProfile) {
+            super(true /* enabled */);
+            mKey = key;
+            mLabel = label;
+            mDrawable = drawable;
+            mUserId = userId;
+            mIsManagedProfile = isManagedProfile;
+        }
+
+        @Override
+        public CharSequence loadLabel() {
+            return mLabel;
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return mDrawable;
+        }
+
+        @Override
+        public String getKey() {
+            return mKey + " " + mUserId;
+        }
+
+        public boolean isManagedProfile() {
+            return mIsManagedProfile;
+        }
+    }
+
+    @Override
+    protected CharSequence getConfirmationMessage(CandidateInfo appInfo) {
+        if (appInfo == null) {
+            return null;
+        }
+        NfcPaymentCandidateInfo paymentInfo = (NfcPaymentCandidateInfo) appInfo;
+        UserManager um = getContext().createContextAsUser(UserHandle.of(paymentInfo.mUserId),
+                /*flags=*/0).getSystemService(UserManager.class);
+        boolean isManagedProfile = um.isManagedProfile(paymentInfo.mUserId);
+        if (!isManagedProfile) {
+            return null;
+        }
+
+        final String title = getContext().getString(
+                R.string.nfc_default_payment_workapp_confirmation_title);
+        final String messageTitle = getContext().getString(
+                R.string.nfc_default_payment_workapp_confirmation_message_title);
+        final String messageOne = getContext().getString(
+                R.string.nfc_default_payment_workapp_confirmation_message_1);
+        final String messageTwo = getContext().getString(
+                R.string.nfc_default_payment_workapp_confirmation_message_2);
+        final SpannableString titleString = new SpannableString(title);
+        final SpannableString messageString = new SpannableString(messageTitle);
+        final SpannableString oneString = new SpannableString(messageOne);
+        final SpannableString twoString = new SpannableString(messageTwo);
+
+        titleString.setSpan(new RelativeSizeSpan(1.5f), 0, title.length(),
+                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        titleString.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0,
+                title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        messageString.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0,
+                messageTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        oneString.setSpan(new BulletSpan(20), 0, messageOne.length(),
+                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        twoString.setSpan(new BulletSpan(20), 0, messageTwo.length(),
+                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+        return TextUtils.concat(titleString, "\n\n", messageString, "\n\n", oneString, "\n",
+                twoString);
+    }
+
+    private void setupFooterPreference() {
+        final String textNfcDefaultPaymentFooter = getResources().getString(
+                R.string.nfc_default_payment_footer);
+        final String textMoreDetails = getResources().getString(R.string.nfc_more_details);
+
+        final SpannableString spannableString = new SpannableString(
+                textNfcDefaultPaymentFooter + System.lineSeparator()
+                + System.lineSeparator() + textMoreDetails);
+        final ClickableSpan clickableSpan = new ClickableSpan() {
+            @Override
+            public void onClick(@NonNull View widget) {
+                Intent howItWorksIntent = new Intent(getActivity(), HowItWorks.class);
+                startActivity(howItWorksIntent);
+            }
+        };
+
+        if (textNfcDefaultPaymentFooter != null && textMoreDetails != null) {
+            spannableString.setSpan(clickableSpan, textNfcDefaultPaymentFooter.length() + 1,
+                    textNfcDefaultPaymentFooter.length() + textMoreDetails.length() + 2,
+                    Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+        }
+
+        mFooterPreference = new FooterPreference(getContext());
+        mFooterPreference.setLayoutResource(R.layout.preference_footer);
+        mFooterPreference.setTitle(spannableString);
+        mFooterPreference.setSelectable(false);
+        mFooterPreference.setIcon(R.drawable.ic_info_outline_24dp);
+    }
+}
diff --git a/src/com/android/settings/nfc/NfcDefaultPaymentPreferenceController.java b/src/com/android/settings/nfc/NfcDefaultPaymentPreferenceController.java
new file mode 100644
index 0000000..6bcacb1
--- /dev/null
+++ b/src/com/android/settings/nfc/NfcDefaultPaymentPreferenceController.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2022 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.nfc;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.nfc.NfcAdapter;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.applications.defaultapps.DefaultAppPreferenceController;
+import com.android.settings.nfc.PaymentBackend.PaymentAppInfo;
+import com.android.settingslib.applications.DefaultAppInfo;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnPause;
+import com.android.settingslib.core.lifecycle.events.OnResume;
+
+import java.util.List;
+
+/**
+ * NfcDefaultPaymentPreferenceController shows an app icon and text summary for current selected
+ * default payment, and links to the nfc default payment selection page.
+ */
+public class NfcDefaultPaymentPreferenceController extends DefaultAppPreferenceController implements
+        PaymentBackend.Callback, LifecycleObserver, OnResume, OnPause {
+
+    private static final String TAG = "NfcDefaultPaymentController";
+    private static final String KEY = "nfc_payment_app";
+
+    private PaymentBackend mPaymentBackend;
+    private Preference mPreference;
+    private Context mContext;
+
+    public NfcDefaultPaymentPreferenceController(Context context, Lifecycle lifecycle) {
+        super(context);
+        mContext = context;
+        mPaymentBackend = new PaymentBackend(context);
+        if (lifecycle != null) {
+            lifecycle.addObserver(this);
+        }
+    }
+
+    @Override
+    public boolean isAvailable() {
+        final PackageManager pm = mContext.getPackageManager();
+        if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC)) {
+            return false;
+        }
+        if (NfcAdapter.getDefaultAdapter(mContext) == null) {
+            return false;
+        }
+        if (mPaymentBackend == null) {
+            mPaymentBackend = new PaymentBackend(mContext);
+        }
+        final List<PaymentAppInfo> appInfos = mPaymentBackend.getPaymentAppInfos();
+        return (appInfos != null && !appInfos.isEmpty())
+                ? true
+                : false;
+    }
+
+    @Override
+    public String getPreferenceKey() {
+        return KEY;
+    }
+
+    @Override
+    public void onResume() {
+        if (mPaymentBackend != null) {
+            mPaymentBackend.registerCallback(this);
+            mPaymentBackend.onResume();
+        }
+    }
+
+    @Override
+    public void onPause() {
+        if (mPaymentBackend != null) {
+            mPaymentBackend.unregisterCallback(this);
+            mPaymentBackend.onPause();
+        }
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        mPreference = screen.findPreference(getPreferenceKey());
+        super.displayPreference(screen);
+    }
+
+    @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        preference.setIconSpaceReserved(true);
+    }
+
+    @Override
+    public void onPaymentAppsChanged() {
+        updateState(mPreference);
+    }
+
+    /**
+     * PaymentDefaultAppInfo is used to store the default payment app info.
+     */
+    public static class PaymentDefaultAppInfo extends DefaultAppInfo {
+        public PaymentAppInfo mInfo;
+
+        public PaymentDefaultAppInfo(Context context, PackageManager pm, int userId,
+                PaymentAppInfo info) {
+            super(context, pm, userId, info.componentName);
+            mInfo = info;
+        }
+
+        @Override
+        public Drawable loadIcon() {
+            return mInfo.icon;
+        }
+    }
+
+    @Override
+    protected DefaultAppInfo getDefaultAppInfo() {
+        if (mPaymentBackend == null) {
+            return null;
+        }
+        final PaymentAppInfo defaultApp = mPaymentBackend.getDefaultApp();
+        if (defaultApp != null) {
+            return new PaymentDefaultAppInfo(mContext, mPackageManager,
+                    defaultApp.userHandle.getIdentifier(), defaultApp);
+        }
+        return null;
+    }
+}
diff --git a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
index b02608e..246bdb9 100644
--- a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
@@ -16,11 +16,9 @@
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.pm.PackageManager;
-import android.text.TextUtils;
 
-import androidx.preference.DropDownPreference;
+import androidx.preference.ListPreference;
 import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
@@ -36,13 +34,18 @@
         PaymentBackend.Callback, Preference.OnPreferenceChangeListener,
         LifecycleObserver, OnStart, OnStop {
 
-    private DropDownPreference mPreference;
+    private ListPreference mPreference;
     private PaymentBackend mPaymentBackend;
     private MetricsFeatureProvider mMetricsFeatureProvider;
 
+    private final String[] mListValues;
+    private final String[] mListEntries;
+
     public NfcForegroundPreferenceController(Context context, String key) {
         super(context, key);
         mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
+        mListValues = context.getResources().getStringArray(R.array.nfc_payment_favor_values);
+        mListEntries = context.getResources().getStringArray(R.array.nfc_payment_favor);
     }
 
     public void setPaymentBackend(PaymentBackend backend) {
@@ -79,47 +82,35 @@
     }
 
     @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-        mPreference = screen.findPreference(getPreferenceKey());
-        if (mPreference == null) {
-            return;
-        }
-
-        mPreference.setEntries(new CharSequence[]{
-                mContext.getText(R.string.nfc_payment_favor_open),
-                mContext.getText(R.string.nfc_payment_favor_default)
-        });
-        mPreference.setEntryValues(new CharSequence[]{"1", "0"});
-    }
-
-    @Override
     public void onPaymentAppsChanged() {
         updateState(mPreference);
     }
 
     @Override
     public void updateState(Preference preference) {
-        if (preference instanceof DropDownPreference) {
-            ((DropDownPreference) preference).setValue(
-                    mPaymentBackend.isForegroundMode() ? "1" : "0");
-        }
         super.updateState(preference);
+        if (!(preference instanceof ListPreference)) {
+            return;
+        }
+        final ListPreference listPreference = (ListPreference) preference;
+        listPreference.setIconSpaceReserved(true);
+        listPreference.setValue(mListValues[mPaymentBackend.isForegroundMode() ? 1 : 0]);
     }
 
     @Override
     public CharSequence getSummary() {
-        return mPreference.getEntry();
+        return mListEntries[mPaymentBackend.isForegroundMode() ? 1 : 0];
     }
 
     @Override
     public boolean onPreferenceChange(Preference preference, Object newValue) {
-        if (!(preference instanceof DropDownPreference)) {
+        if (!(preference instanceof ListPreference)) {
             return false;
         }
-        final DropDownPreference pref = (DropDownPreference) preference;
+
+        final ListPreference listPreference = (ListPreference) preference;
         final String newValueString = (String) newValue;
-        pref.setSummary(pref.getEntries()[pref.findIndexOfValue(newValueString)]);
+        listPreference.setSummary(mListEntries[listPreference.findIndexOfValue(newValueString)]);
         final boolean foregroundMode = Integer.parseInt(newValueString) != 0;
         mPaymentBackend.setForegroundMode(foregroundMode);
         mMetricsFeatureProvider.action(mContext,
@@ -127,12 +118,4 @@
                         : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
         return true;
     }
-
-    @Override
-    public void updateNonIndexableKeys(List<String> keys) {
-        final String key = getPreferenceKey();
-        if (!TextUtils.isEmpty(key)) {
-            keys.add(key);
-        }
-    }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/nfc/PaymentBackend.java b/src/com/android/settings/nfc/PaymentBackend.java
index 542c95b..0cfed20 100644
--- a/src/com/android/settings/nfc/PaymentBackend.java
+++ b/src/com/android/settings/nfc/PaymentBackend.java
@@ -20,6 +20,7 @@
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
 import android.nfc.NfcAdapter;
 import android.nfc.cardemulation.ApduServiceInfo;
 import android.nfc.cardemulation.CardEmulation;
@@ -50,6 +51,7 @@
         public ComponentName componentName;
         public ComponentName settingsComponent;
         public UserHandle userHandle;
+        public Drawable icon;
     }
 
     /**
@@ -131,6 +133,7 @@
                     appInfo.settingsComponent = null;
                 }
                 appInfo.description = service.getDescription();
+                appInfo.icon = pm.getUserBadgedIcon(service.loadIcon(pm), appInfo.userHandle);
 
                 appInfos.add(appInfo);
             }
diff --git a/src/com/android/settings/nfc/PaymentSettings.java b/src/com/android/settings/nfc/PaymentSettings.java
index bbe5f29..a1f75bc 100644
--- a/src/com/android/settings/nfc/PaymentSettings.java
+++ b/src/com/android/settings/nfc/PaymentSettings.java
@@ -18,15 +18,11 @@
 
 import android.app.settings.SettingsEnums;
 import android.content.Context;
-import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.content.pm.UserInfo;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.os.UserManager;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 
@@ -37,8 +33,12 @@
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.search.SearchIndexable;
 
+import java.util.ArrayList;
+import java.util.List;
 
 @SearchIndexable
 public class PaymentSettings extends DashboardFragment {
@@ -62,12 +62,23 @@
     }
 
     @Override
+    protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+        return buildPreferenceControllers(context, getSettingsLifecycle());
+    }
+
+    private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
+            Lifecycle lifecycle) {
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
+        controllers.add(new NfcDefaultPaymentPreferenceController(context, lifecycle));
+
+        return controllers;
+    }
+
+    @Override
     public void onAttach(Context context) {
         super.onAttach(context);
         mPaymentBackend = new PaymentBackend(getActivity());
-        setHasOptionsMenu(true);
 
-        use(NfcPaymentPreferenceController.class).setPaymentBackend(mPaymentBackend);
         use(NfcForegroundPreferenceController.class).setPaymentBackend(mPaymentBackend);
     }
 
@@ -93,15 +104,6 @@
         mPaymentBackend.onPause();
     }
 
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        super.onCreateOptionsMenu(menu, inflater);
-        MenuItem menuItem = menu.add(R.string.nfc_payment_how_it_works);
-        Intent howItWorksIntent = new Intent(getActivity(), HowItWorks.class);
-        menuItem.setIntent(howItWorksIntent);
-        menuItem.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_NEVER);
-    }
-
     @VisibleForTesting
     boolean isShowEmptyImage(PreferenceScreen screen) {
         for (int i = 0; i < screen.getPreferenceCount(); i++) {
@@ -127,4 +129,4 @@
                     return pm.hasSystemFeature(PackageManager.FEATURE_NFC);
                 }
             };
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/nfc/SecureNfcEnabler.java b/src/com/android/settings/nfc/SecureNfcEnabler.java
index 9acaf64..f31a382 100644
--- a/src/com/android/settings/nfc/SecureNfcEnabler.java
+++ b/src/com/android/settings/nfc/SecureNfcEnabler.java
@@ -18,9 +18,8 @@
 
 import android.content.Context;
 import android.nfc.NfcAdapter;
-import android.provider.Settings;
+import android.os.UserManager;
 
-import androidx.annotation.VisibleForTesting;
 import androidx.preference.SwitchPreference;
 
 import com.android.settings.R;
@@ -32,10 +31,12 @@
  */
 public class SecureNfcEnabler extends BaseNfcEnabler {
     private final SwitchPreference mPreference;
+    private final UserManager mUserManager;
 
     public SecureNfcEnabler(Context context, SwitchPreference preference) {
         super(context);
         mPreference = preference;
+        mUserManager = context.getSystemService(UserManager.class);
     }
 
     @Override
@@ -48,7 +49,7 @@
             case NfcAdapter.STATE_ON:
                 mPreference.setSummary(R.string.nfc_secure_toggle_summary);
                 mPreference.setChecked(mPreference.isChecked());
-                mPreference.setEnabled(true);
+                mPreference.setEnabled(isToggleable());
                 break;
             case NfcAdapter.STATE_TURNING_ON:
                 mPreference.setEnabled(false);
@@ -58,4 +59,11 @@
                 break;
         }
     }
+
+    private boolean isToggleable() {
+        if (mUserManager.isGuestUser()) {
+            return false;
+        }
+        return true;
+    }
 }
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index c2aeeaf..7aa65b7 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -22,7 +22,7 @@
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.notification.LockScreenNotificationPreferenceController;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -93,7 +93,7 @@
 
                 @Override
                 protected boolean isPageSearchEnabled(Context context) {
-                    return !SafetyCenterStatus.isEnabled();
+                    return !SafetyCenterStatusHolder.get().isEnabled(context);
                 }
             };
 }
diff --git a/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceController.java b/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceController.java
index dcc68ff..87daf7f 100644
--- a/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceController.java
+++ b/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceController.java
@@ -20,7 +20,7 @@
 import android.content.Context;
 
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 
 /** The preference controller for the top level privacy tile. */
 public class TopLevelPrivacyEntryPreferenceController  extends BasePreferenceController {
@@ -31,7 +31,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        if (!SafetyCenterStatus.isEnabled()) {
+        if (!SafetyCenterStatusHolder.get().isEnabled(mContext)) {
             return AVAILABLE;
         }
         return CONDITIONALLY_UNAVAILABLE;
diff --git a/src/com/android/settings/safetycenter/SafetyCenterStatus.java b/src/com/android/settings/safetycenter/SafetyCenterStatus.java
deleted file mode 100644
index d96bb32..0000000
--- a/src/com/android/settings/safetycenter/SafetyCenterStatus.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.safetycenter;
-
-import android.provider.DeviceConfig;
-
-import com.android.internal.annotations.VisibleForTesting;
-
-/** Knows whether safety center is enabled or disabled. */
-public class SafetyCenterStatus {
-
-    /** Whether SafetyCenter page is enabled. */
-    @VisibleForTesting
-    public static final String SAFETY_CENTER_IS_ENABLED = "safety_center_is_enabled";
-
-    /** Returns true is SafetyCenter page is enabled, false otherwise. */
-    public static boolean isEnabled() {
-        // TODO(b/208625216): use SafetyManager API instead
-        return DeviceConfig.getBoolean(
-                DeviceConfig.NAMESPACE_PRIVACY, SAFETY_CENTER_IS_ENABLED, false);
-    }
-}
diff --git a/src/com/android/settings/safetycenter/SafetyCenterStatusHolder.java b/src/com/android/settings/safetycenter/SafetyCenterStatusHolder.java
new file mode 100644
index 0000000..014c600
--- /dev/null
+++ b/src/com/android/settings/safetycenter/SafetyCenterStatusHolder.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2022 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.safetycenter;
+
+import android.content.Context;
+import android.safetycenter.SafetyCenterManager;
+import android.util.Log;
+
+import com.android.internal.annotations.VisibleForTesting;
+
+/** Knows whether safety center is enabled or disabled. */
+public class SafetyCenterStatusHolder {
+
+    private static final String TAG = "SafetyCenterStatusHolder";
+
+    @VisibleForTesting
+    public static SafetyCenterStatusHolder sInstance;
+
+    private SafetyCenterStatusHolder() {}
+
+    /** Returns an instance of {@link SafetyCenterStatusHolder}. */
+    public static SafetyCenterStatusHolder get() {
+        if (sInstance == null) {
+            sInstance = new SafetyCenterStatusHolder();
+        }
+        return sInstance;
+    }
+
+    /** Returns true is SafetyCenter page is enabled, false otherwise. */
+    public boolean isEnabled(Context context) {
+        if (context == null) {
+            Log.e(TAG, "Context is null at SafetyCenterStatusHolder#isEnabled");
+            return false;
+        }
+        SafetyCenterManager safetyCenterManager =
+                context.getSystemService(SafetyCenterManager.class);
+        if (safetyCenterManager == null) {
+            Log.w(TAG, "System service SAFETY_CENTER_SERVICE (SafetyCenterManager) is null");
+            return false;
+        }
+        try {
+            return safetyCenterManager.isSafetyCenterEnabled();
+        } catch (RuntimeException e) {
+            Log.e(TAG, "Calling isSafetyCenterEnabled failed.", e);
+            return false;
+        }
+    }
+}
diff --git a/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceController.java b/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceController.java
index b3b49b0..b00c084 100644
--- a/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceController.java
+++ b/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceController.java
@@ -37,7 +37,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        if (SafetyCenterStatus.isEnabled()) {
+        if (SafetyCenterStatusHolder.get().isEnabled(mContext)) {
             return AVAILABLE;
         }
         return CONDITIONALLY_UNAVAILABLE;
diff --git a/src/com/android/settings/search/SearchResultTrampoline.java b/src/com/android/settings/search/SearchResultTrampoline.java
index 8b041b6..ab2d27c 100644
--- a/src/com/android/settings/search/SearchResultTrampoline.java
+++ b/src/com/android/settings/search/SearchResultTrampoline.java
@@ -25,6 +25,7 @@
 import android.os.Bundle;
 import android.provider.Settings;
 import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 
 import com.android.settings.SettingsActivity;
@@ -32,6 +33,7 @@
 import com.android.settings.SubSettings;
 import com.android.settings.activityembedding.ActivityEmbeddingRulesController;
 import com.android.settings.activityembedding.ActivityEmbeddingUtils;
+import com.android.settings.core.FeatureFlags;
 import com.android.settings.homepage.SettingsHomepageActivity;
 import com.android.settings.overlay.FeatureFactory;
 
@@ -97,20 +99,26 @@
         if (!ActivityEmbeddingUtils.isEmbeddingActivityEnabled(this)) {
             startActivity(intent);
         } else if (isSettingsIntelligence(callingActivity)) {
-            // Register SplitPairRule for SubSettings, set clearTop false to prevent unexpected back
-            // navigation behavior.
-            ActivityEmbeddingRulesController.registerSubSettingsPairRule(this,
-                    false /* clearTop */);
+            if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
+                startActivity(SettingsActivity.getTrampolineIntent(intent, highlightMenuKey)
+                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+                                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS));
+            } else {
+                // Register SplitPairRule for SubSettings, set clearTop false to prevent unexpected
+                // back navigation behavior.
+                ActivityEmbeddingRulesController.registerSubSettingsPairRule(this,
+                        false /* clearTop */);
 
-            intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
-            startActivity(intent);
+                intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
+                startActivity(intent);
 
-            // Pass menu key to homepage
-            final SettingsHomepageActivity homeActivity =
-                    ((SettingsApplication) getApplicationContext()).getHomeActivity();
-            if (homeActivity != null) {
-                homeActivity.getMainFragment().setHighlightMenuKey(highlightMenuKey,
-                        /* scrollNeeded= */ true);
+                // Pass menu key to homepage
+                final SettingsHomepageActivity homeActivity =
+                        ((SettingsApplication) getApplicationContext()).getHomeActivity();
+                if (homeActivity != null) {
+                    homeActivity.getMainFragment().setHighlightMenuKey(highlightMenuKey,
+                            /* scrollNeeded= */ true);
+                }
             }
         } else {
             // Two-pane case
diff --git a/src/com/android/settings/search/SearchStateReceiver.java b/src/com/android/settings/search/SearchStateReceiver.java
index d1f6f16..37ac6cb 100644
--- a/src/com/android/settings/search/SearchStateReceiver.java
+++ b/src/com/android/settings/search/SearchStateReceiver.java
@@ -20,9 +20,11 @@
 import android.content.Context;
 import android.content.Intent;
 import android.text.TextUtils;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 
 import com.android.settings.SettingsApplication;
+import com.android.settings.core.FeatureFlags;
 import com.android.settings.homepage.SettingsHomepageActivity;
 
 /**
@@ -36,6 +38,11 @@
 
     @Override
     public void onReceive(Context context, Intent intent) {
+        if (FeatureFlagUtils.isEnabled(context, FeatureFlags.SETTINGS_SEARCH_ALWAYS_EXPAND)) {
+            // Not needed to show/hide the highlight when search is full screen
+            return;
+        }
+
         if (intent == null) {
             Log.w(TAG, "Null intent");
             return;
diff --git a/src/com/android/settings/security/SecurityAdvancedSettings.java b/src/com/android/settings/security/SecurityAdvancedSettings.java
index 4a73eb7..ce4a59c 100644
--- a/src/com/android/settings/security/SecurityAdvancedSettings.java
+++ b/src/com/android/settings/security/SecurityAdvancedSettings.java
@@ -26,7 +26,7 @@
 import com.android.settings.biometrics.fingerprint.FingerprintProfileStatusPreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
 import com.android.settings.widget.PreferenceCategoryController;
@@ -60,11 +60,14 @@
 
     @Override
     public String getCategoryKey() {
-        if (SafetyCenterStatus.isEnabled()) {
+        final Context context = getContext();
+        if (context == null) {
+            return CATEGORY_SECURITY_LEGACY_ADVANCED_SETTINGS;
+        } else if (SafetyCenterStatusHolder.get().isEnabled(context)) {
             return CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS;
         } else {
             final SecuritySettingsFeatureProvider securitySettingsFeatureProvider =
-                    FeatureFactory.getFactory(getContext())
+                    FeatureFactory.getFactory(context)
                             .getSecuritySettingsFeatureProvider();
 
             if (securitySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment()) {
diff --git a/src/com/android/settings/security/SecuritySettings.java b/src/com/android/settings/security/SecuritySettings.java
index 0d31ca2..6bfbf6c 100644
--- a/src/com/android/settings/security/SecuritySettings.java
+++ b/src/com/android/settings/security/SecuritySettings.java
@@ -25,7 +25,7 @@
 import com.android.settings.biometrics.fingerprint.FingerprintStatusPreferenceController;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.search.BaseSearchIndexProvider;
 import com.android.settings.security.trustagent.TrustAgentListPreferenceController;
 import com.android.settings.widget.PreferenceCategoryController;
@@ -129,7 +129,7 @@
                 protected boolean isPageSearchEnabled(Context context) {
                     return !FeatureFactory.getFactory(context).getSecuritySettingsFeatureProvider()
                             .hasAlternativeSecuritySettingsFragment()
-                            && !SafetyCenterStatus.isEnabled();
+                            && !SafetyCenterStatusHolder.get().isEnabled(context);
                 }
             };
 }
diff --git a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
index 2d98606..11d1dc3 100644
--- a/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
+++ b/src/com/android/settings/security/TopLevelSecurityEntryPreferenceController.java
@@ -24,7 +24,7 @@
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 
 public class TopLevelSecurityEntryPreferenceController extends BasePreferenceController {
 
@@ -38,7 +38,7 @@
 
     @Override
     public int getAvailabilityStatus() {
-        if (!SafetyCenterStatus.isEnabled()) {
+        if (!SafetyCenterStatusHolder.get().isEnabled(mContext)) {
             return AVAILABLE;
         }
         return CONDITIONALLY_UNAVAILABLE;
diff --git a/src/com/android/settings/users/UserDetailsSettings.java b/src/com/android/settings/users/UserDetailsSettings.java
index 8f89a5f..c3657be 100644
--- a/src/com/android/settings/users/UserDetailsSettings.java
+++ b/src/com/android/settings/users/UserDetailsSettings.java
@@ -74,6 +74,9 @@
     private static final int DIALOG_SETUP_USER = 4;
     private static final int DIALOG_CONFIRM_RESET_GUEST = 5;
 
+    /** Whether to enable the app_copying fragment. */
+    private static final boolean SHOW_APP_COPYING_PREF = false;
+
     private UserManager mUserManager;
     private UserCapabilities mUserCaps;
     private boolean mGuestUserAutoCreated;
@@ -298,6 +301,9 @@
                 if (mGuestUserAutoCreated) {
                     mRemoveUserPref.setEnabled((mUserInfo.flags & UserInfo.FLAG_INITIALIZED) != 0);
                 }
+                if (!SHOW_APP_COPYING_PREF) {
+                    removePreference(KEY_APP_COPYING);
+                }
             } else {
                 mPhonePref.setChecked(!mUserManager.hasUserRestriction(
                         UserManager.DISALLOW_OUTGOING_CALLS, new UserHandle(userId)));
@@ -410,6 +416,9 @@
     }
 
     private void openAppCopyingScreen() {
+        if (!SHOW_APP_COPYING_PREF) {
+            return;
+        }
         final Bundle extras = new Bundle();
         extras.putInt(AppRestrictionsFragment.EXTRA_USER_ID, mUserInfo.id);
         new SubSettingLauncher(getContext())
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index dc4bca3..9398d20 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -503,7 +503,8 @@
     private void onAddSupervisedUserClicked() {
         final Intent intent = new Intent()
                 .setAction(UserManager.ACTION_CREATE_SUPERVISED_USER)
-                .setPackage(mConfigSupervisedUserCreationPackage);
+                .setPackage(mConfigSupervisedUserCreationPackage)
+                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
         // TODO(b/209659998): [to-be-removed] fallback activity for supervised user creation.
         if (getActivity().getPackageManager().resolveActivity(intent, 0) == null) {
diff --git a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
index 46f4414..3f5ef48 100644
--- a/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
+++ b/src/com/android/settings/wifi/addappnetworks/AddAppNetworksFragment.java
@@ -414,6 +414,9 @@
     }
 
     private void updateSingleNetworkSignalIcon(int level) {
+        if (level == WifiEntry.WIFI_LEVEL_UNREACHABLE) {
+            return;
+        }
         // TODO: Check level of the network to show signal icon.
         final Drawable wifiIcon = mActivity.getDrawable(
                 Utils.getWifiIconResource(level)).mutate();
diff --git a/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java b/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
index e7a0090..e4495f4 100644
--- a/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
+++ b/tests/robotests/src/com/android/settings/ResetNetworkConfirmTest.java
@@ -18,6 +18,15 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
+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.content.Context;
+import android.net.wifi.p2p.WifiP2pManager;
+import android.os.Looper;
 import android.view.LayoutInflater;
 import android.widget.TextView;
 
@@ -25,7 +34,6 @@
 
 import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
 import com.android.settings.testutils.shadow.ShadowRecoverySystem;
-import com.android.settings.testutils.shadow.ShadowWifiP2pManager;
 
 import org.junit.After;
 import org.junit.Before;
@@ -39,27 +47,31 @@
 import org.robolectric.annotation.Config;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowRecoverySystem.class,
-        ShadowWifiP2pManager.class, ShadowBluetoothAdapter.class
-})
+@Config(shadows = {ShadowRecoverySystem.class, ShadowBluetoothAdapter.class})
 public class ResetNetworkConfirmTest {
 
     private FragmentActivity mActivity;
+
+    @Mock
+    private WifiP2pManager mWifiP2pManager;
     @Mock
     private ResetNetworkConfirm mResetNetworkConfirm;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        when(mWifiP2pManager.initialize(any(Context.class), any(Looper.class), any()))
+                .thenReturn(mock(WifiP2pManager.Channel.class));
+
         mResetNetworkConfirm = new ResetNetworkConfirm();
-        mActivity = Robolectric.setupActivity(FragmentActivity.class);
+        mActivity = spy(Robolectric.setupActivity(FragmentActivity.class));
+        when(mActivity.getSystemService(Context.WIFI_P2P_SERVICE)).thenReturn(mWifiP2pManager);
         mResetNetworkConfirm.mActivity = mActivity;
     }
 
     @After
     public void tearDown() {
         ShadowRecoverySystem.reset();
-        ShadowWifiP2pManager.reset();
     }
 
     @Test
@@ -88,11 +100,10 @@
      * Test for WifiP2pManager factoryReset method.
      */
     @Test
-    @Ignore
     public void testResetNetworkData_resetP2p() {
         mResetNetworkConfirm.p2pFactoryReset(mActivity);
 
-        assertThat(ShadowWifiP2pManager.getFactoryResetCount()).isEqualTo(1);
+        verify(mWifiP2pManager).factoryReset(any(WifiP2pManager.Channel.class), any());
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingUtilsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingUtilsTest.java
new file mode 100644
index 0000000..a9bbade
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingUtilsTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.ComponentName;
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+/** Tests for {@link AccessibilityQuickSettingUtils}. */
+@RunWith(RobolectricTestRunner.class)
+public final class AccessibilityQuickSettingUtilsTest {
+    private static final String DUMMY_PACKAGE_NAME = "com.mock.example";
+    private static final String DUMMY_CLASS_NAME = DUMMY_PACKAGE_NAME + ".mock_a11y_service";
+    private static final String DUMMY_CLASS_NAME2 = DUMMY_PACKAGE_NAME + ".mock_a11y_service2";
+    private static final ComponentName DUMMY_COMPONENT_NAME = new ComponentName(DUMMY_PACKAGE_NAME,
+            DUMMY_CLASS_NAME);
+    private static final ComponentName DUMMY_COMPONENT_NAME2 = new ComponentName(DUMMY_PACKAGE_NAME,
+            DUMMY_CLASS_NAME2);
+    private final Context mContext = ApplicationProvider.getApplicationContext();
+
+    @Test
+    public void optInValueToSharedPreferences_optInValue_haveMatchString() {
+        AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME);
+
+        assertThat(AccessibilityQuickSettingUtils.hasValueInSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME)).isTrue();
+    }
+
+    @Test
+    public void optInValueToSharedPreferences_optInTwoValues_haveMatchString() {
+        AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME);
+        AccessibilityQuickSettingUtils.optInValueToSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME2);
+
+        assertThat(AccessibilityQuickSettingUtils.hasValueInSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME)).isTrue();
+        assertThat(AccessibilityQuickSettingUtils.hasValueInSharedPreferences(mContext,
+                DUMMY_COMPONENT_NAME2)).isTrue();
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindowTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindowTest.java
index f1e1121b..be67977 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindowTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityQuickSettingsTooltipWindowTest.java
@@ -22,6 +22,7 @@
 
 import android.content.Context;
 import android.view.View;
+import android.view.accessibility.AccessibilityNodeInfo;
 import android.widget.PopupWindow;
 
 import androidx.test.core.app.ApplicationProvider;
@@ -53,52 +54,68 @@
 
     private static final String TEST_PACKAGE_NAME = "com.test.package";
     private final Context mContext = ApplicationProvider.getApplicationContext();
-    private AccessibilityQuickSettingsTooltipWindow mToolTipView;
+    private AccessibilityQuickSettingsTooltipWindow mTooltipView;
     private View mView;
 
     @Before
     public void setUp() {
-        mToolTipView = new AccessibilityQuickSettingsTooltipWindow(mContext);
+        mTooltipView = new AccessibilityQuickSettingsTooltipWindow(mContext);
         mView = new View(RuntimeEnvironment.application);
     }
 
     @Test
-    public void initToolTipView_atMostAvailableTextWidth() {
+    public void initTooltipView_atMostAvailableTextWidth() {
         final String quickSettingsTooltipsContent = mContext.getString(
                 R.string.accessibility_service_quick_settings_tooltips_content, TEST_PACKAGE_NAME);
-        mToolTipView.setup(quickSettingsTooltipsContent);
+        mTooltipView.setup(quickSettingsTooltipsContent);
 
-        final int getMaxWidth = mToolTipView.getAvailableWindowWidth();
-        assertThat(mToolTipView.getWidth()).isAtMost(getMaxWidth);
+        final int getMaxWidth = mTooltipView.getAvailableWindowWidth();
+        assertThat(mTooltipView.getWidth()).isAtMost(getMaxWidth);
     }
 
     @Test
-    public void showToolTipView_success() {
-        mToolTipView.setup(TEST_PACKAGE_NAME);
+    public void showTooltipView_success() {
+        mTooltipView.setup(TEST_PACKAGE_NAME);
         assertThat(getLatestPopupWindow()).isNull();
 
-        mToolTipView.showAtTopCenter(mView);
+        mTooltipView.showAtTopCenter(mView);
 
-        assertThat(getLatestPopupWindow()).isSameInstanceAs(mToolTipView);
+        assertThat(getLatestPopupWindow()).isSameInstanceAs(mTooltipView);
     }
 
     @Test
-    public void dismiss_toolTipViewShown_shouldInvokeCallbackAndNotShowing() {
-        mToolTipView.setup(TEST_PACKAGE_NAME);
-        mToolTipView.setOnDismissListener(mMockOnDismissListener);
-        mToolTipView.showAtTopCenter(mView);
+    public void accessibilityClickActionOnTooltipViewShown_shouldInvokeCallbackAndNotShowing() {
+        mTooltipView.setup(TEST_PACKAGE_NAME);
+        mTooltipView.setOnDismissListener(mMockOnDismissListener);
+        mTooltipView.showAtTopCenter(mView);
 
-        mToolTipView.dismiss();
+        final boolean isActionPerformed =
+                mTooltipView.getContentView().performAccessibilityAction(
+                        AccessibilityNodeInfo.AccessibilityAction.ACTION_CLICK.getId(),
+                        /* arguments= */ null);
+
+        assertThat(isActionPerformed).isTrue();
+        verify(mMockOnDismissListener).onDismiss();
+        assertThat(getLatestPopupWindow().isShowing()).isFalse();
+    }
+
+    @Test
+    public void dismiss_tooltipViewShown_shouldInvokeCallbackAndNotShowing() {
+        mTooltipView.setup(TEST_PACKAGE_NAME);
+        mTooltipView.setOnDismissListener(mMockOnDismissListener);
+        mTooltipView.showAtTopCenter(mView);
+
+        mTooltipView.dismiss();
 
         verify(mMockOnDismissListener).onDismiss();
         assertThat(getLatestPopupWindow().isShowing()).isFalse();
     }
 
     @Test
-    public void waitAutoCloseDelayTime_toolTipViewShown_shouldInvokeCallbackAndNotShowing() {
-        mToolTipView.setup(TEST_PACKAGE_NAME, /* closeDelayTimeMillis= */ 1);
-        mToolTipView.setOnDismissListener(mMockOnDismissListener);
-        mToolTipView.showAtTopCenter(mView);
+    public void waitAutoCloseDelayTime_tooltipViewShown_shouldInvokeCallbackAndNotShowing() {
+        mTooltipView.setup(TEST_PACKAGE_NAME, /* closeDelayTimeMillis= */ 1);
+        mTooltipView.setOnDismissListener(mMockOnDismissListener);
+        mTooltipView.showAtTopCenter(mView);
 
         ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
 
diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
index 2273a3e..9d87c93 100644
--- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackIntensityPreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -48,6 +50,7 @@
     private static final int ON = 1;
 
     @Mock private PreferenceScreen mScreen;
+    @Mock private AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -59,7 +62,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new HapticFeedbackIntensityPreferenceController(mContext, PREFERENCE_KEY,
                 Vibrator.VIBRATION_INTENSITY_HIGH);
@@ -89,6 +94,54 @@
     }
 
     @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+        // TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
+//        assertThat(mPreference.getSummary()).isNotNull();
+//        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+//                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
+    @Test
+    public void updateState_hapticFeedbackDisabled_shouldDisplayAlwaysOff() {
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, OFF);
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    @Test
     public void updateState_shouldDisplayIntensityInSliderPosition() {
         updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
index f992b0e..3e8aeac 100644
--- a/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/HapticFeedbackTogglePreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -29,6 +31,7 @@
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -48,6 +51,7 @@
     private static final int ON = 1;
 
     @Mock private PreferenceScreen mScreen;
+    @Mock AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -59,7 +63,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new HapticFeedbackTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
@@ -84,6 +90,54 @@
         assertThat(mPreference.isChecked()).isTrue();
     }
 
+
+    @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+        assertThat(mPreference.getSummary()).isNotNull();
+        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
+    @Test
+    public void updateState_hapticFeedbackDisabled_shouldDisplayAlwaysOff() {
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_ENABLED, OFF);
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
     @Test
     public void updateState_shouldDisplayOnOffState() {
         updateSetting(Settings.System.HAPTIC_FEEDBACK_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
diff --git a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
index d0be8b5..9533c53 100644
--- a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationIntensityPreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -46,6 +48,7 @@
     private static final String PREFERENCE_KEY = "preference_key";
 
     @Mock private PreferenceScreen mScreen;
+    @Mock private AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -57,7 +60,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new NotificationVibrationIntensityPreferenceController(mContext,
                 PREFERENCE_KEY, Vibrator.VIBRATION_INTENSITY_HIGH);
@@ -86,6 +91,34 @@
                 mVibrator.getDefaultVibrationIntensity(VibrationAttributes.USAGE_NOTIFICATION));
     }
 
+
+    @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+        // TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
+//        assertThat(mPreference.getSummary()).isNotNull();
+//        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+//                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
     @Test
     public void updateState_shouldDisplayIntensityInSliderPosition() {
         updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
diff --git a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
index adf9436..4b6f686 100644
--- a/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/NotificationVibrationTogglePreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -29,6 +31,7 @@
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -46,6 +49,7 @@
     private static final String PREFERENCE_KEY = "preference_key";
 
     @Mock private PreferenceScreen mScreen;
+    @Mock private AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -57,7 +61,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new NotificationVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
@@ -83,6 +89,32 @@
     }
 
     @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+        assertThat(mPreference.getSummary()).isNotNull();
+        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
+    @Test
     public void updateState_shouldDisplayOnOffState() {
         updateSetting(Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
                 Vibrator.VIBRATION_INTENSITY_HIGH);
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
index d891926..2bffaf4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationIntensityPreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -49,6 +51,7 @@
     private static final int ON = 1;
 
     @Mock private PreferenceScreen mScreen;
+    @Mock private AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -60,7 +63,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new RingVibrationIntensityPreferenceController(mContext, PREFERENCE_KEY,
                 Vibrator.VIBRATION_INTENSITY_HIGH);
@@ -90,6 +95,55 @@
     }
 
     @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+        // TODO(b/136805769): summary is broken in SeekBarPreference, enable this once fixed
+//        assertThat(mPreference.getSummary()).isNotNull();
+//        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+//                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_LOW);
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
+    @Test
+    public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
+        when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
+        updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
+    }
+
+    @Test
     public void updateState_shouldDisplayIntensityInSliderPosition() {
         updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
         mController.updateState(mPreference);
@@ -109,7 +163,6 @@
         assertThat(mPreference.getProgress()).isEqualTo(Vibrator.VIBRATION_INTENSITY_OFF);
     }
 
-
     @Test
     @Ignore
     public void setProgress_updatesIntensityAndDependentSettings() throws Exception {
diff --git a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
index 8e85c86..08ad1cd 100644
--- a/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/RingVibrationTogglePreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.media.AudioManager;
 import android.os.VibrationAttributes;
 import android.os.Vibrator;
 import android.provider.Settings;
@@ -29,6 +31,7 @@
 import androidx.preference.SwitchPreference;
 import androidx.test.core.app.ApplicationProvider;
 
+import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
@@ -48,6 +51,7 @@
     private static final int ON = 1;
 
     @Mock private PreferenceScreen mScreen;
+    @Mock private AudioManager mAudioManager;
 
     private Lifecycle mLifecycle;
     private Context mContext;
@@ -59,7 +63,9 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mLifecycle = new Lifecycle(() -> mLifecycle);
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mVibrator = mContext.getSystemService(Vibrator.class);
         mController = new RingVibrationTogglePreferenceController(mContext, PREFERENCE_KEY);
         mLifecycle.addObserver(mController);
@@ -85,6 +91,54 @@
     }
 
     @Test
+    public void updateState_ringerModeUpdates_shouldPreserveSettingAndDisplaySummary() {
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_SILENT);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+        assertThat(mPreference.getSummary()).isNotNull();
+        assertThat(mPreference.getSummary().toString()).isEqualTo(mContext.getString(
+                R.string.accessibility_vibration_setting_disabled_for_silent_mode_summary));
+        assertThat(mPreference.isEnabled()).isFalse();
+
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_VIBRATE);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isTrue();
+        assertThat(mPreference.getSummary()).isNull();
+        assertThat(mPreference.isEnabled()).isTrue();
+    }
+
+    @Test
+    public void updateState_vibrateWhenRingingAndRampingRingerOff_shouldDisplayAlwaysOff() {
+        when(mAudioManager.isRampingRingerEnabled()).thenReturn(false);
+        updateSetting(Settings.System.VIBRATE_WHEN_RINGING, OFF);
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY,
+                Vibrator.VIBRATION_INTENSITY_MEDIUM);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_LOW);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+
+        updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_OFF);
+        mController.updateState(mPreference);
+        assertThat(mPreference.isChecked()).isFalse();
+    }
+
+    @Test
     public void updateState_shouldDisplayOnOffState() {
         updateSetting(Settings.System.RING_VIBRATION_INTENSITY, Vibrator.VIBRATION_INTENSITY_HIGH);
         mController.updateState(mPreference);
diff --git a/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
index 1f2c0d9..9e31130 100644
--- a/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/VibrationRampingRingerTogglePreferenceControllerTest.java
@@ -70,6 +70,7 @@
         mContext = spy(ApplicationProvider.getApplicationContext());
         when(mContext.getSystemService(Context.TELEPHONY_SERVICE)).thenReturn(mTelephonyManager);
         when(mContext.getSystemService(Context.AUDIO_SERVICE)).thenReturn(mAudioManager);
+        when(mAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
         mController = new VibrationRampingRingerTogglePreferenceController(mContext,
                 PREFERENCE_KEY, mDeviceConfigProvider);
         mLifecycle.addObserver(mController);
diff --git a/tests/robotests/src/com/android/settings/dream/DreamPickerControllerTest.java b/tests/robotests/src/com/android/settings/dream/DreamPickerControllerTest.java
index 1048970..c6c2436 100644
--- a/tests/robotests/src/com/android/settings/dream/DreamPickerControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/DreamPickerControllerTest.java
@@ -48,7 +48,6 @@
 
 @RunWith(RobolectricTestRunner.class)
 public class DreamPickerControllerTest {
-    private DreamPickerController mController;
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private DreamBackend mBackend;
     private Context mContext;
@@ -63,31 +62,36 @@
 
         mPreference = new LayoutPreference(mContext, R.layout.dream_picker_layout);
         when(mScreen.findPreference(anyString())).thenReturn(mPreference);
+    }
 
-        mController = new DreamPickerController(
+    private DreamPickerController buildController() {
+        final DreamPickerController controller = new DreamPickerController(
                 mContext,
                 /* preferenceKey= */ "test",
                 mBackend);
-
-        mController.displayPreference(mScreen);
+        controller.displayPreference(mScreen);
+        return controller;
     }
 
     @Test
     public void isDisabledIfNoDreamsAvailable() {
         when(mBackend.getDreamInfos()).thenReturn(new ArrayList<>(0));
-        assertThat(mController.isAvailable()).isFalse();
+        final DreamPickerController controller = buildController();
+        assertThat(controller.isAvailable()).isFalse();
     }
 
     @Test
     public void isEnabledIfDreamsAvailable() {
         when(mBackend.getDreamInfos()).thenReturn(Collections.singletonList(new DreamInfo()));
-        assertThat(mController.isAvailable()).isTrue();
+        final DreamPickerController controller = buildController();
+        assertThat(controller.isAvailable()).isTrue();
     }
 
     @Test
     public void testDreamDisplayedInList() {
         when(mBackend.getDreamInfos()).thenReturn(Collections.singletonList(new DreamInfo()));
-        mController.updateState(mPreference);
+        final DreamPickerController controller = buildController();
+        controller.updateState(mPreference);
 
         RecyclerView view = mPreference.findViewById(R.id.dream_list);
         assertThat(view.getAdapter().getItemCount()).isEqualTo(1);
@@ -100,7 +104,8 @@
         mockDreamInfo.isActive = true;
 
         when(mBackend.getDreamInfos()).thenReturn(Collections.singletonList(mockDreamInfo));
-        mController.updateState(mPreference);
+        final DreamPickerController controller = buildController();
+        controller.updateState(mPreference);
 
         Button view = mPreference.findViewById(R.id.preview_button);
         view.performClick();
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
index 5173b63..fd0cf5f 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPickerTest.java
@@ -29,6 +29,7 @@
 import com.android.settingslib.dream.DreamBackend;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -38,6 +39,7 @@
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
+@Ignore
 public class WhenToDreamPickerTest {
 
     private WhenToDreamPicker mPicker;
diff --git a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
index acb2a80..a0188f8 100644
--- a/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/WhenToDreamPreferenceControllerTest.java
@@ -28,6 +28,7 @@
 import com.android.settingslib.dream.DreamBackend.WhenToDream;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -37,6 +38,7 @@
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
+@Ignore
 public class WhenToDreamPreferenceControllerTest {
 
     private WhenToDreamPreferenceController mController;
diff --git a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
index 5a05ecc..34853c6 100644
--- a/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/BugReportsPreferenceControllerTest.java
@@ -22,13 +22,13 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
 
 import java.util.Date;
-import org.robolectric.RobolectricTestRunner;
 
 @RunWith(RobolectricTestRunner.class)
 public class BugReportsPreferenceControllerTest
-    extends AdminActionPreferenceControllerTestBase {
+        extends AdminActionPreferenceControllerTestBase {
 
     @Override
     public void setUp() {
@@ -39,7 +39,7 @@
     @Override
     public void setDate(Date date) {
         when(mFeatureFactory.enterprisePrivacyFeatureProvider.getLastBugReportRequestTime())
-            .thenReturn(date);
+                .thenReturn(date);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBackupHelperTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBackupHelperTest.java
index 3424f8d..ca1797a 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryBackupHelperTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryBackupHelperTest.java
@@ -53,7 +53,6 @@
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -202,7 +201,6 @@
     }
 
     @Test
-    @Ignore
     public void backupOptimizationMode_backupOptimizationMode() throws Exception {
         final List<String> allowlistedApps = Arrays.asList(PACKAGE_NAME1);
         createTestingData(PACKAGE_NAME1, PACKAGE_NAME2, PACKAGE_NAME3);
@@ -215,7 +213,6 @@
     }
 
     @Test
-    @Ignore
     public void backupOptimizationMode_backupOptimizationModeAndIgnoreSystemApp()
             throws Exception {
         final List<String> allowlistedApps = Arrays.asList(PACKAGE_NAME1);
@@ -232,7 +229,6 @@
     }
 
     @Test
-    @Ignore
     public void backupOptimizationMode_backupOptimizationModeAndIgnoreDefaultApp()
             throws Exception {
         final List<String> allowlistedApps = Arrays.asList(PACKAGE_NAME1);
@@ -387,6 +383,8 @@
                         AppOpsManager.OP_RUN_ANY_IN_BACKGROUND,
                         applicationInfo2.uid,
                         applicationInfo2.packageName);
+        mBatteryBackupHelper.mTestApplicationInfoList =
+                Arrays.asList(applicationInfo1, applicationInfo2, applicationInfo3);
     }
 
     @Implements(UserHandle.class)
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
deleted file mode 100644
index 2ddd383..0000000
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDatabaseManagerTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2018 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.fuelgauge;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.Mockito.spy;
-
-import android.content.Context;
-import android.text.format.DateUtils;
-import android.util.SparseLongArray;
-
-import com.android.settings.fuelgauge.batterytip.AnomalyDatabaseHelper;
-import com.android.settings.fuelgauge.batterytip.AppInfo;
-import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
-import com.android.settings.testutils.DatabaseTestUtils;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@RunWith(RobolectricTestRunner.class)
-@Ignore
-public class BatteryDatabaseManagerTest {
-    private static String PACKAGE_NAME_NEW = "com.android.app1";
-    private static int UID_NEW = 345;
-    private static int TYPE_NEW = 1;
-    private static String PACKAGE_NAME_OLD = "com.android.app2";
-    private static int UID_OLD = 543;
-    private static int TYPE_OLD = 2;
-    private static long NOW = System.currentTimeMillis();
-    private static long ONE_DAY_BEFORE = NOW - DateUtils.DAY_IN_MILLIS;
-    private static long TWO_DAYS_BEFORE = NOW - 2 * DateUtils.DAY_IN_MILLIS;
-
-    private Context mContext;
-    private BatteryDatabaseManager mBatteryDatabaseManager;
-    private AppInfo mNewAppInfo;
-    private AppInfo mOldAppInfo;
-    private AppInfo mCombinedAppInfo;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        mContext = RuntimeEnvironment.application;
-        mBatteryDatabaseManager = spy(BatteryDatabaseManager.getInstance(mContext));
-
-        mNewAppInfo = new AppInfo.Builder()
-                .setUid(UID_NEW)
-                .setPackageName(PACKAGE_NAME_NEW)
-                .addAnomalyType(TYPE_NEW)
-                .build();
-        mOldAppInfo = new AppInfo.Builder()
-                .setUid(UID_OLD)
-                .setPackageName(PACKAGE_NAME_OLD)
-                .addAnomalyType(TYPE_OLD)
-                .build();
-        mCombinedAppInfo = new AppInfo.Builder()
-                .setUid(UID_NEW)
-                .setPackageName(PACKAGE_NAME_NEW)
-                .addAnomalyType(TYPE_NEW)
-                .addAnomalyType(TYPE_OLD)
-                .build();
-    }
-
-    @After
-    public void cleanUp() {
-        DatabaseTestUtils.clearDb(mContext);
-    }
-
-    @Test
-    public void allAnomalyFunctions() {
-        mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_NEW,
-                AnomalyDatabaseHelper.State.NEW, NOW);
-        mBatteryDatabaseManager.insertAnomaly(UID_OLD, PACKAGE_NAME_OLD, TYPE_OLD,
-                AnomalyDatabaseHelper.State.NEW, TWO_DAYS_BEFORE);
-
-        // In database, it contains two record
-        List<AppInfo> totalAppInfos = mBatteryDatabaseManager.queryAllAnomalies(0 /* timeMsAfter */,
-                AnomalyDatabaseHelper.State.NEW);
-        assertThat(totalAppInfos).containsExactly(mNewAppInfo, mOldAppInfo);
-
-        // Only one record shows up if we query by timestamp
-        List<AppInfo> appInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
-                AnomalyDatabaseHelper.State.NEW);
-        assertThat(appInfos).containsExactly(mNewAppInfo);
-
-        mBatteryDatabaseManager.deleteAllAnomaliesBeforeTimeStamp(ONE_DAY_BEFORE);
-
-        // The obsolete record is removed from database
-        List<AppInfo> appInfos1 = mBatteryDatabaseManager.queryAllAnomalies(0 /* timeMsAfter */,
-                AnomalyDatabaseHelper.State.NEW);
-        assertThat(appInfos1).containsExactly(mNewAppInfo);
-    }
-
-    @Test
-    public void updateAnomalies_updateSuccessfully() {
-        mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_NEW,
-                AnomalyDatabaseHelper.State.NEW, NOW);
-        mBatteryDatabaseManager.insertAnomaly(UID_OLD, PACKAGE_NAME_OLD, TYPE_OLD,
-                AnomalyDatabaseHelper.State.NEW, NOW);
-        final AppInfo appInfo = new AppInfo.Builder().setPackageName(PACKAGE_NAME_OLD).build();
-        final List<AppInfo> updateAppInfos = new ArrayList<>();
-        updateAppInfos.add(appInfo);
-
-        // Change state of PACKAGE_NAME_OLD to handled
-        mBatteryDatabaseManager.updateAnomalies(updateAppInfos,
-                AnomalyDatabaseHelper.State.HANDLED);
-
-        // The state of PACKAGE_NAME_NEW is still new
-        List<AppInfo> newAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
-                AnomalyDatabaseHelper.State.NEW);
-        assertThat(newAppInfos).containsExactly(mNewAppInfo);
-
-        // The state of PACKAGE_NAME_OLD is changed to handled
-        List<AppInfo> handledAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
-                AnomalyDatabaseHelper.State.HANDLED);
-        assertThat(handledAppInfos).containsExactly(mOldAppInfo);
-    }
-
-    @Test
-    public void queryAnomalies_removeDuplicateByUid() {
-        mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_NEW,
-                AnomalyDatabaseHelper.State.NEW, NOW);
-        mBatteryDatabaseManager.insertAnomaly(UID_NEW, PACKAGE_NAME_NEW, TYPE_OLD,
-                AnomalyDatabaseHelper.State.NEW, NOW);
-
-        // Only contain one AppInfo with multiple types
-        List<AppInfo> newAppInfos = mBatteryDatabaseManager.queryAllAnomalies(ONE_DAY_BEFORE,
-                AnomalyDatabaseHelper.State.NEW);
-        assertThat(newAppInfos).containsExactly(mCombinedAppInfo);
-    }
-
-    @Test
-    public void allActionFunctions() {
-        final long timestamp = System.currentTimeMillis();
-        mBatteryDatabaseManager.insertAction(AnomalyDatabaseHelper.ActionType.RESTRICTION, UID_OLD,
-                PACKAGE_NAME_OLD, 0);
-        mBatteryDatabaseManager.insertAction(AnomalyDatabaseHelper.ActionType.RESTRICTION, UID_OLD,
-                PACKAGE_NAME_OLD, 1);
-        mBatteryDatabaseManager.insertAction(AnomalyDatabaseHelper.ActionType.RESTRICTION, UID_NEW,
-                PACKAGE_NAME_NEW, timestamp);
-
-        final SparseLongArray timeArray = mBatteryDatabaseManager.queryActionTime(
-                AnomalyDatabaseHelper.ActionType.RESTRICTION);
-        assertThat(timeArray.size()).isEqualTo(2);
-        assertThat(timeArray.get(UID_OLD)).isEqualTo(1);
-        assertThat(timeArray.get(UID_NEW)).isEqualTo(timestamp);
-
-        mBatteryDatabaseManager.deleteAction(AnomalyDatabaseHelper.ActionType.RESTRICTION, UID_NEW,
-                PACKAGE_NAME_NEW);
-        final SparseLongArray recentTimeArray = mBatteryDatabaseManager.queryActionTime(
-                AnomalyDatabaseHelper.ActionType.RESTRICTION);
-        assertThat(recentTimeArray.size()).isEqualTo(1);
-        assertThat(timeArray.get(UID_OLD)).isEqualTo(1);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardsFragmentTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardsFragmentTest.java
index e6aeea7..e71af57 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardsFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardsFragmentTest.java
@@ -41,7 +41,6 @@
 import com.android.settings.testutils.shadow.ShadowFragment;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -75,12 +74,11 @@
     }
 
     @Test
-    @Ignore
     public void onStart_shouldRegisterBothReceivers() {
         mFragment.onStart();
 
         verify(mActivity).registerReceiver(eq(mFragment.mKeyEventReceiver),
-                any(IntentFilter.class));
+                any(IntentFilter.class), eq(Context.RECEIVER_EXPORTED));
         verify(mActivity).registerReceiver(eq(mFragment.mScreenOffReceiver),
                 any(IntentFilter.class));
     }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionControllerTest.java
index 6fa83f2..69be131 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/HotspotConditionControllerTest.java
@@ -18,29 +18,32 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
 import android.content.Context;
 import android.net.wifi.SoftApConfiguration;
 import android.net.wifi.WifiManager;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.testutils.shadow.ShadowWifiManager;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.annotation.Config;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowWifiManager.class})
 public class HotspotConditionControllerTest {
 
     private static final String WIFI_AP_SSID = "Test Hotspot";
 
     @Mock
+    private WifiManager mWifiManager;
+    @Mock
     private ConditionManager mConditionManager;
 
     private Context mContext;
@@ -48,12 +51,14 @@
 
     @Before
     public void setUp() {
-        mContext = RuntimeEnvironment.application;
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(WifiManager.class)).thenReturn(mWifiManager);
+
         mController = new HotspotConditionController(mContext, mConditionManager);
     }
 
     @Test
-    @Ignore
     public void buildContextualCard_hasWifiAp_shouldHaveWifiApSsid() {
         setupSoftApConfiguration();
 
@@ -63,7 +68,6 @@
     }
 
     @Test
-    @Ignore
     public void buildContextualCard_noWifiAp_shouldHaveEmptySsid() {
         final ContextualCard card = mController.buildContextualCard();
 
@@ -73,6 +77,6 @@
     private void setupSoftApConfiguration() {
         final SoftApConfiguration wifiApConfig = new SoftApConfiguration.Builder()
                 .setSsid(WIFI_AP_SSID).build();
-        mContext.getSystemService(WifiManager.class).setSoftApConfiguration(wifiApConfig);
+        when(mWifiManager.getSoftApConfiguration()).thenReturn(wifiApConfig);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
index b1c74ca..cf8d361 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
@@ -26,19 +26,25 @@
 import static org.mockito.Mockito.verify;
 
 import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
 import android.net.Uri;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.Button;
 
+import androidx.core.graphics.drawable.IconCompat;
 import androidx.lifecycle.LifecycleOwner;
 import androidx.lifecycle.LiveData;
 import androidx.recyclerview.widget.LinearLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
 import androidx.slice.Slice;
 import androidx.slice.SliceProvider;
 import androidx.slice.widget.SliceLiveData;
 
+
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
 import com.android.settings.homepage.contextualcards.ContextualCardsFragment;
@@ -46,7 +52,6 @@
 import com.android.settings.wifi.slice.ContextualWifiSlice;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -56,7 +61,6 @@
 import org.robolectric.android.controller.ActivityController;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class SliceContextualCardRendererTest {
 
     private static final Uri TEST_SLICE_URI = Uri.parse("content://test/test");
@@ -287,7 +291,7 @@
     }
 
     private ContextualCard buildContextualCard(Uri sliceUri) {
-        final Slice slice = new ContextualWifiSlice(mActivity).getSlice();
+        final Slice slice = buildSlice();
         return new ContextualCard.Builder()
                 .setName("test_name")
                 .setCardType(ContextualCard.CardType.SLICE)
@@ -296,4 +300,23 @@
                 .setSlice(slice)
                 .build();
     }
+
+    private Slice buildSlice() {
+        final String title = "test_title";
+        final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+        final PendingIntent pendingIntent = PendingIntent.getActivity(
+                mActivity,
+                title.hashCode() /* requestCode */,
+                new Intent("test action"),
+                PendingIntent.FLAG_IMMUTABLE);
+        final SliceAction action
+                = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+        return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+                .addRow(new ListBuilder.RowBuilder()
+                        .addEndItem(icon, ListBuilder.ICON_IMAGE)
+                        .setTitle(title)
+                        .setPrimaryAction(action))
+                .addAction(SliceAction.createToggle(pendingIntent, null /* actionTitle */, true))
+                .build();
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
index ad928da..ae62724 100644
--- a/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationInjectedServicesPreferenceControllerTest.java
@@ -43,7 +43,6 @@
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -98,16 +97,15 @@
     }
 
     @Test
-    @Ignore
     public void onResume_shouldRegisterListener() {
         mController.onResume();
 
         verify(mContext).registerReceiver(eq(mController.mInjectedSettingsReceiver),
-                eq(mController.INTENT_FILTER_INJECTED_SETTING_CHANGED));
+                eq(mController.INTENT_FILTER_INJECTED_SETTING_CHANGED),
+                anyInt());
     }
 
     @Test
-    @Ignore
     public void onPause_shouldUnregisterListener() {
         mController.onResume();
         mController.onPause();
diff --git a/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
index 925b000..4a7c273 100644
--- a/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/WifiConnectionPreferenceControllerTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -33,6 +34,7 @@
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceScreen;
 
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.wifi.WifiConnectionPreferenceController;
 import com.android.settings.wifi.WifiEntryPreference;
 import com.android.settingslib.core.lifecycle.Lifecycle;
@@ -40,7 +42,6 @@
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
@@ -50,7 +51,6 @@
 import org.robolectric.RuntimeEnvironment;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class WifiConnectionPreferenceControllerTest {
     private static final String KEY = "wifi_connection";
 
@@ -72,6 +72,10 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
+                any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
+                .thenReturn(mWifiPickerTracker);
         mLifecycleOwner = () -> mLifecycle;
         mLifecycle = new Lifecycle(mLifecycleOwner);
         when(mScreen.findPreference(eq(KEY))).thenReturn(mPreferenceCategory);
diff --git a/tests/robotests/src/com/android/settings/nfc/NfcForegroundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/NfcForegroundPreferenceControllerTest.java
index 4c2195c..63fa320 100644
--- a/tests/robotests/src/com/android/settings/nfc/NfcForegroundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/NfcForegroundPreferenceControllerTest.java
@@ -26,7 +26,7 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 
-import androidx.preference.DropDownPreference;
+import androidx.preference.ListPreference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
@@ -39,7 +39,6 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 
@@ -56,7 +55,7 @@
     private PackageManager mManager;
 
     private Context mContext;
-    private DropDownPreference mPreference;
+    private ListPreference mPreference;
     private NfcForegroundPreferenceController mController;
     private FakeFeatureFactory mFakeFeatureFactory;
 
@@ -67,7 +66,9 @@
         when(mContext.getPackageManager()).thenReturn(mManager);
         mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = new NfcForegroundPreferenceController(mContext, PREF_KEY);
-        mPreference = new DropDownPreference(mContext);
+        mPreference = new ListPreference(mContext);
+        mPreference.setEntries(R.array.nfc_payment_favor);
+        mPreference.setEntryValues(R.array.nfc_payment_favor_values);
         when(mScreen.findPreference(PREF_KEY)).thenReturn(mPreference);
     }
 
@@ -146,17 +147,14 @@
         final CharSequence favorDefault = mContext.getText(R.string.nfc_payment_favor_default);
         final CharSequence favorOpen = mContext.getText(R.string.nfc_payment_favor_open);
 
-        assertThat(mPreference.getEntry()).isEqualTo(favorDefault);
-        assertThat(mPreference.getSummary()).isEqualTo(favorDefault);
-
-        mPreference.setValueIndex(0);
-        mPreference.callChangeListener(mPreference.getEntryValues()[0]);
+        mPreference.setValueIndex(1);
+        mPreference.callChangeListener(mPreference.getEntryValues()[1]);
         verify(mPaymentBackend).setForegroundMode(true);
         assertThat(mPreference.getEntry()).isEqualTo(favorOpen);
         assertThat(mPreference.getSummary()).isEqualTo(favorOpen);
 
-        mPreference.setValueIndex(1);
-        mPreference.callChangeListener(mPreference.getEntryValues()[1]);
+        mPreference.setValueIndex(0);
+        mPreference.callChangeListener(mPreference.getEntryValues()[0]);
         verify(mPaymentBackend).setForegroundMode(false);
         assertThat(mPreference.getEntry()).isEqualTo(favorDefault);
         assertThat(mPreference.getSummary()).isEqualTo(favorDefault);
@@ -168,16 +166,16 @@
         mController.displayPreference(mScreen);
         mController.onPaymentAppsChanged();
 
-        mPreference.setValueIndex(0);
-        mPreference.callChangeListener(mPreference.getEntryValues()[0]);
+        mPreference.setValueIndex(1);
+        mPreference.callChangeListener(mPreference.getEntryValues()[1]);
         verify(mPaymentBackend).setForegroundMode(true);
         verify(mFakeFeatureFactory.metricsFeatureProvider).action(mContext,
                 SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING);
 
-        mPreference.setValueIndex(1);
-        mPreference.callChangeListener(mPreference.getEntryValues()[1]);
+        mPreference.setValueIndex(0);
+        mPreference.callChangeListener(mPreference.getEntryValues()[0]);
         verify(mPaymentBackend).setForegroundMode(false);
         verify(mFakeFeatureFactory.metricsFeatureProvider).action(mContext,
                 SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
index 32eedd8..458bc93 100644
--- a/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/PaymentSettingsTest.java
@@ -53,7 +53,7 @@
 @Config(shadows = {PaymentSettingsTest.ShadowPaymentBackend.class, ShadowNfcAdapter.class})
 public class PaymentSettingsTest {
 
-    static final String PAYMENT_KEY = "nfc_payment";
+    static final String PAYMENT_KEY = "nfc_payment_app";
     static final String FOREGROUND_KEY = "nfc_foreground";
 
     private Context mContext;
@@ -160,4 +160,4 @@
             return mAppInfos;
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
index 5c13e2f..2c694ac 100644
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -664,6 +664,7 @@
     public void onPreferenceClick_addSupervisedUserClicked_startIntentWithAction() {
         final String intentPackage = "testPackage";
         final String intentAction = UserManager.ACTION_CREATE_SUPERVISED_USER;
+        final int intentFlags = Intent.FLAG_ACTIVITY_NEW_TASK;
         final int metricsAction = SettingsEnums.ACTION_USER_SUPERVISED_ADD;
         try {
             setConfigSupervisedUserCreationPackage(intentPackage);
@@ -676,6 +677,7 @@
             verify(mFragment).startActivity(captor.capture());
             assertThat(captor.getValue().getPackage()).isEqualTo(intentPackage);
             assertThat(captor.getValue().getAction()).isEqualTo(intentAction);
+            assertThat(captor.getValue().getFlags() & intentFlags).isGreaterThan(0);
 
             verify(mMetricsFeatureProvider).action(any(), eq(metricsAction));
         } finally {
diff --git a/tests/robotests/src/com/android/settings/wifi/AddNetworkFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/AddNetworkFragmentTest.java
index 3ba13b4..d491355 100644
--- a/tests/robotests/src/com/android/settings/wifi/AddNetworkFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/AddNetworkFragmentTest.java
@@ -18,16 +18,21 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+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.content.Context;
+import android.net.wifi.WifiManager;
 import android.view.View;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
 import com.android.settings.testutils.shadow.ShadowConnectivityManager;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.MockitoAnnotations;
@@ -44,37 +49,36 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        Context context = spy(ApplicationProvider.getApplicationContext());
+        when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mock(WifiManager.class));
+
         mAddNetworkFragment = spy(new AddNetworkFragment());
+        when(mAddNetworkFragment.getContext()).thenReturn(context);
         FragmentController.setupFragment(mAddNetworkFragment);
     }
 
     @Test
-    @Ignore
     public void getMetricsCategory_shouldReturnAddNetwork() {
         assertThat(mAddNetworkFragment.getMetricsCategory()).isEqualTo(
                 MetricsEvent.SETTINGS_WIFI_ADD_NETWORK);
     }
 
     @Test
-    @Ignore
     public void getMode_shouldBeModeConnected() {
         assertThat(mAddNetworkFragment.getMode()).isEqualTo(WifiConfigUiBase2.MODE_CONNECT);
     }
 
     @Test
-    @Ignore
     public void launchFragment_shouldShowSubmitButton() {
         assertThat(mAddNetworkFragment.getSubmitButton()).isNotNull();
     }
 
     @Test
-    @Ignore
     public void launchFragment_shouldShowCancelButton() {
         assertThat(mAddNetworkFragment.getCancelButton()).isNotNull();
     }
 
     @Test
-    @Ignore
     public void onClickSubmitButton_shouldHandleSubmitAction() {
         View submitButton = mAddNetworkFragment.getView().findViewById(
                 AddNetworkFragment.SUBMIT_BUTTON_ID);
@@ -85,7 +89,6 @@
     }
 
     @Test
-    @Ignore
     public void onClickCancelButton_shouldHandleCancelAction() {
         View cancelButton = mAddNetworkFragment.getView().findViewById(
                 AddNetworkFragment.CANCEL_BUTTON_ID);
@@ -96,7 +99,6 @@
     }
 
     @Test
-    @Ignore
     public void dispatchSubmit_shouldHandleSubmitAction() {
         mAddNetworkFragment.dispatchSubmit();
 
diff --git a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java
index f7ae660..f8f45dd 100644
--- a/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/ConfigureWifiEntryFragmentTest.java
@@ -18,16 +18,21 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+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;
+import android.content.Context;
+import android.net.wifi.WifiManager;
 import android.os.Bundle;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.wifitrackerlib.NetworkDetailsTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -36,7 +41,6 @@
 import org.robolectric.shadows.androidx.fragment.FragmentController;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class ConfigureWifiEntryFragmentTest {
 
     private static final String KEY_SSID = "key_ssid";
@@ -50,13 +54,16 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        Bundle bundle = new Bundle();
+        Context context = spy(ApplicationProvider.getApplicationContext());
+        when(context.getSystemService(Context.WIFI_SERVICE)).thenReturn(mock(WifiManager.class));
 
+        Bundle bundle = new Bundle();
         bundle.putString(KEY_SSID, "Test AP");
         bundle.putInt(KEY_SECURITY, 1 /* WEP */);
         mConfigureWifiEntryFragment = spy(new ConfigureWifiEntryFragment());
         mConfigureWifiEntryFragment.setArguments(bundle);
         mConfigureWifiEntryFragment.mNetworkDetailsTracker = mNetworkDetailsTracker;
+        when(mConfigureWifiEntryFragment.getContext()).thenReturn(context);
 
         FragmentController.setupFragment(mConfigureWifiEntryFragment);
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
index 460e644..fb20045 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogActivityTest.java
@@ -19,6 +19,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -35,13 +36,12 @@
 import androidx.annotation.Nullable;
 import androidx.appcompat.app.AlertDialog;
 
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
 import com.android.settings.wifi.NetworkRequestErrorDialogFragment.ERROR_DIALOG_TYPE;
-import com.android.settingslib.wifi.WifiTracker;
-import com.android.settingslib.wifi.WifiTrackerFactory;
+import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.MockitoAnnotations;
@@ -55,7 +55,6 @@
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = ShadowAlertDialogCompat.class)
 public class NetworkRequestDialogActivityTest {
 
@@ -69,11 +68,11 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-
         mContext = spy(RuntimeEnvironment.application);
-
-        WifiTracker wifiTracker = mock(WifiTracker.class);
-        WifiTrackerFactory.setTestingWifiTracker(wifiTracker);
+        FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
+                any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
+                .thenReturn(mock(WifiPickerTracker.class));
 
         NetworkRequestDialogActivity activity =
             Robolectric.setupActivity(NetworkRequestDialogActivity.class);
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index 496fe87..e08a14a 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -18,6 +18,8 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
@@ -38,15 +40,16 @@
 import androidx.fragment.app.FragmentActivity;
 
 import com.android.settings.R;
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
 import com.android.wifitrackerlib.WifiEntry;
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InOrder;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
@@ -56,7 +59,6 @@
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = ShadowAlertDialogCompat.class)
 public class NetworkRequestDialogFragmentTest {
 
@@ -69,6 +71,12 @@
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
+                any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
+                .thenReturn(mock(WifiPickerTracker.class));
+
         mActivity = Robolectric.buildActivity(FragmentActivity.class,
                 new Intent().putExtra(NetworkRequestDialogFragment.EXTRA_APP_NAME,
                         TEST_APP_NAME)).setup().get();
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
index 8e95db8..f4e018f 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestErrorDialogFragmentTest.java
@@ -19,9 +19,12 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
 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 static org.mockito.internal.verification.VerificationModeFactory.times;
 
 import android.content.DialogInterface;
@@ -32,22 +35,21 @@
 import androidx.appcompat.app.AlertDialog;
 
 import com.android.settings.R;
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
 import com.android.settings.wifi.NetworkRequestErrorDialogFragment.ERROR_DIALOG_TYPE;
-import com.android.settingslib.wifi.WifiTracker;
-import com.android.settingslib.wifi.WifiTrackerFactory;
+import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = ShadowAlertDialogCompat.class)
 public class NetworkRequestErrorDialogFragmentTest {
 
@@ -56,8 +58,11 @@
 
     @Before
     public void setUp() {
-        WifiTracker wifiTracker = mock(WifiTracker.class);
-        WifiTrackerFactory.setTestingWifiTracker(wifiTracker);
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        when(fakeFeatureFactory.wifiTrackerLibProvider.createWifiPickerTracker(
+                any(), any(), any(), any(), any(), anyLong(), anyLong(), any()))
+                .thenReturn(mock(WifiPickerTracker.class));
 
         mActivity = Robolectric.setupActivity(NetworkRequestDialogActivity.class);
         mFragment = spy(NetworkRequestErrorDialogFragment.newInstance());
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
index 9952c06..8ecbaf6 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiConfigControllerTest.java
@@ -22,6 +22,7 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 import static org.robolectric.Shadows.shadowOf;
 
@@ -45,19 +46,19 @@
 import android.widget.Spinner;
 import android.widget.TextView;
 
+import androidx.test.core.app.ApplicationProvider;
+
 import com.android.settings.R;
 import com.android.settings.network.SubscriptionUtil;
 import com.android.settings.testutils.shadow.ShadowConnectivityManager;
 import com.android.settingslib.wifi.AccessPoint;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
 import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
 import org.robolectric.shadows.ShadowInputMethodManager;
@@ -66,7 +67,6 @@
 import java.util.Arrays;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = ShadowConnectivityManager.class)
 public class WifiConfigControllerTest {
 
@@ -96,7 +96,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getSystemService(Context.WIFI_SERVICE)).thenReturn(mock(WifiManager.class));
         when(mConfigUiBase.getContext()).thenReturn(mContext);
         when(mAccessPoint.getSecurity()).thenReturn(AccessPoint.SECURITY_PSK);
         mView = LayoutInflater.from(mContext).inflate(R.layout.wifi_dialog, null);
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index d442d4e..c83ec49 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -60,7 +60,6 @@
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -71,7 +70,6 @@
 import org.robolectric.shadows.ShadowToast;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 public class WifiSettingsTest {
 
     private static final int NUM_NETWORKS = 4;
@@ -94,6 +92,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
+        when(mContext.getSystemService(UserManager.class)).thenReturn(mock(UserManager.class));
 
         mWifiSettings = spy(new WifiSettings());
         doReturn(mContext).when(mWifiSettings).getContext();
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
index e6d584a..99040db 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSummaryUpdaterTest.java
@@ -19,7 +19,11 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
@@ -34,7 +38,6 @@
 import com.android.settingslib.wifi.WifiStatusTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -54,15 +57,18 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+        doReturn(mock(Intent.class)).when(mContext).registerReceiver(any(), any(), anyInt());
+        doNothing().when(mContext).unregisterReceiver(any(BroadcastReceiver.class));
+
         mSummaryUpdater = new WifiSummaryUpdater(mContext, mListener, mWifiTracker);
     }
 
     @Test
-    @Ignore
     public void register_true_shouldRegisterListenerAndTracker() {
         mSummaryUpdater.register(true);
 
-        verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
+        verify(mContext).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class),
+                anyInt());
         verify(mWifiTracker).setListening(true);
     }
 
@@ -75,7 +81,6 @@
     }
 
     @Test
-    @Ignore
     public void register_false_shouldUnregisterListenerAndTracker() {
         mSummaryUpdater.register(true);
         mSummaryUpdater.register(false);
diff --git a/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java
index 869356f..332cf14 100644
--- a/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/p2p/WifiP2pSettingsTest.java
@@ -49,7 +49,6 @@
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -68,7 +67,7 @@
 
     private Context mContext;
     private FragmentActivity mActivity;
-    private WifiP2pSettings mFragment;
+    private TestWifiP2pSettings mFragment;
 
     @Mock
     public WifiP2pManager mWifiP2pManager;
@@ -86,8 +85,10 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
+        TestWifiP2pSettings.sMockWifiP2pManager = mWifiP2pManager;
+
         mActivity = Robolectric.setupActivity(FragmentActivity.class);
-        mFragment = new WifiP2pSettings();
+        mFragment = new TestWifiP2pSettings();
         mFragment.mWifiP2pManager = mWifiP2pManager;
         doReturn(mChannel).when(mWifiP2pManager).initialize(any(), any(), any());
         FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
@@ -504,7 +505,6 @@
     }
 
     @Test
-    @Ignore
     public void onActivityCreate_withNullP2pManager_shouldGetP2pManagerAgain() {
         mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
         mFragment.mWifiP2pManager = null;
@@ -542,4 +542,13 @@
         wifiP2pDevice.deviceName = "testName";
         mWifiP2pPeer.device = wifiP2pDevice;
     }
+
+    public static class TestWifiP2pSettings extends WifiP2pSettings {
+        static WifiP2pManager sMockWifiP2pManager;
+        @Override
+        protected Object getSystemService(final String name) {
+            if (Context.WIFI_P2P_SERVICE.equals(name)) return sMockWifiP2pManager;
+            return getActivity().getSystemService(name);
+        }
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
index 28798df..f31c216 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
@@ -27,8 +27,9 @@
 
 import android.content.ContentResolver;
 import android.content.Context;
+import android.net.Network;
 import android.net.NetworkCapabilities;
-import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
 
 import androidx.core.graphics.drawable.IconCompat;
@@ -45,9 +46,10 @@
 import com.android.settings.testutils.shadow.ShadowConnectivityManager;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
@@ -55,29 +57,40 @@
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = ShadowConnectivityManager.class)
 public class ContextualWifiSliceTest {
+    private static final String SSID = "123";
+
+    @Mock
+    private WifiManager mWifiManager;
+    @Mock
+    private WifiInfo mWifiInfo;
+    @Mock
+    private Network mNetwork;
 
     private Context mContext;
     private ContentResolver mResolver;
-    private WifiManager mWifiManager;
     private ContextualWifiSlice mWifiSlice;
     private FakeFeatureFactory mFeatureFactory;
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
         mResolver = mock(ContentResolver.class);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mFeatureFactory.slicesFeatureProvider = new SlicesFeatureProviderImpl();
         mFeatureFactory.slicesFeatureProvider.newUiSession();
         doReturn(mResolver).when(mContext).getContentResolver();
-        mWifiManager = mContext.getSystemService(WifiManager.class);
+        doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
+        doReturn(true).when(mWifiManager).isWifiEnabled();
+        doReturn(WifiManager.WIFI_STATE_ENABLED).when(mWifiManager).getWifiState();
+        doReturn(mWifiInfo).when(mWifiManager).getConnectionInfo();
+        doReturn(SSID).when(mWifiInfo).getSSID();
+        doReturn(mNetwork).when(mWifiManager).getCurrentNetwork();
 
         // Set-up specs for SliceMetadata.
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-        mWifiManager.setWifiEnabled(true);
 
         mWifiSlice = new ContextualWifiSlice(mContext);
     }
@@ -121,7 +134,7 @@
         mWifiSlice.sApRowCollapsed = true;
         connectToWifi(makeValidatedNetworkCapabilities());
 
-        mWifiManager.disconnect();
+        doReturn(null).when(mWifiManager).getCurrentNetwork();
         final Slice wifiSlice = mWifiSlice.getSlice();
 
         assertWifiHeader(wifiSlice);
@@ -138,11 +151,7 @@
     }
 
     private void connectToWifi(NetworkCapabilities nc) {
-        final WifiConfiguration config = new WifiConfiguration();
-        config.SSID = "123";
-        mWifiManager.connect(config, null /* listener */);
-        ShadowConnectivityManager.getShadow().setNetworkCapabilities(
-                mWifiManager.getCurrentNetwork(), nc);
+        ShadowConnectivityManager.getShadow().setNetworkCapabilities(mNetwork, nc);
     }
 
     private NetworkCapabilities makeValidatedNetworkCapabilities() {
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 6fb8bb2..b4a8b05 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -50,9 +50,10 @@
 import com.android.wifitrackerlib.WifiEntry.ConnectedState;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
@@ -63,7 +64,6 @@
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Ignore
 @Config(shadows = WifiSliceTest.ShadowSliceBackgroundWorker.class)
 public class WifiSliceTest {
 
@@ -71,21 +71,24 @@
     private static final String AP2_NAME = "ap2";
     private static final String AP3_NAME = "ap3";
 
+    @Mock
+    private WifiManager mWifiManager;
+
     private Context mContext;
     private ContentResolver mResolver;
-    private WifiManager mWifiManager;
     private WifiSlice mWifiSlice;
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
         mResolver = mock(ContentResolver.class);
         doReturn(mResolver).when(mContext).getContentResolver();
-        mWifiManager = mContext.getSystemService(WifiManager.class);
+        doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
+        doReturn(WifiManager.WIFI_STATE_ENABLED).when(mWifiManager).getWifiState();
 
         // Set-up specs for SliceMetadata.
         SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
-        mWifiManager.setWifiEnabled(true);
 
         mWifiSlice = new WifiSlice(mContext);
     }
@@ -108,7 +111,7 @@
 
     @Test
     public void getWifiSlice_wifiOff_shouldReturnSingleRow() {
-        mWifiManager.setWifiEnabled(false);
+        doReturn(WifiManager.WIFI_STATE_DISABLED).when(mWifiManager).getWifiState();
 
         final Slice wifiSlice = mWifiSlice.getSlice();
 
diff --git a/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java b/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java
new file mode 100644
index 0000000..22a055f
--- /dev/null
+++ b/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2022 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.applications;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class AppLocaleUtilTest {
+    @Mock
+    private PackageManager mPackageManager;
+    @Mock
+    private ActivityManager mActivityManager;
+    @Mock
+    private AppEntry mEntry;
+    @Mock
+    private ApplicationInfo mApplicationInfo;
+    @Mock
+    private Resources mResources;
+
+    private Context mContext;
+    private String mDisallowedPackage = "com.disallowed.package";
+    private String mAallowedPackage = "com.allowed.package";
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        when(mContext.getPackageManager()).thenReturn(mPackageManager);
+        when(mContext.getSystemService(ActivityManager.class)).thenReturn(mActivityManager);
+    }
+
+    @Test
+    public void isDisplayLocaleUi_showUI() throws PackageManager.NameNotFoundException {
+        setTestAppEntry(mAallowedPackage);
+        setDisallowedPackageName(mDisallowedPackage);
+        setApplicationInfo(/*no platform key*/false);
+        mEntry.hasLauncherEntry = true;
+
+        assertTrue(AppLocaleUtil.canDisplayLocaleUi(mContext, mEntry));
+    }
+
+    @Test
+    public void isDisplayLocaleUi_notShowUI_hasPlatformKey()
+            throws PackageManager.NameNotFoundException {
+        setTestAppEntry(mAallowedPackage);
+        setDisallowedPackageName(mDisallowedPackage);
+        setApplicationInfo(/*has platform key*/true);
+        mEntry.hasLauncherEntry = true;
+
+        assertFalse(AppLocaleUtil.canDisplayLocaleUi(mContext, mEntry));
+    }
+
+    @Test
+    public void isDisplayLocaleUi_notShowUI_noLauncherEntry()
+            throws PackageManager.NameNotFoundException {
+        setTestAppEntry(mAallowedPackage);
+        setDisallowedPackageName(mDisallowedPackage);
+        setApplicationInfo(/*no platform key*/false);
+        mEntry.hasLauncherEntry = false;
+
+        assertFalse(AppLocaleUtil.canDisplayLocaleUi(mContext, mEntry));
+    }
+
+    @Test
+    public void isDisplayLocaleUi_notShowUI_matchDisallowedPackageList()
+            throws PackageManager.NameNotFoundException {
+        setTestAppEntry(mDisallowedPackage);
+        setDisallowedPackageName(mDisallowedPackage);
+        setApplicationInfo(/*no platform key*/false);
+        mEntry.hasLauncherEntry = false;
+
+        assertFalse(AppLocaleUtil.canDisplayLocaleUi(mContext, mEntry));
+    }
+
+    private void setTestAppEntry(String packageName) {
+        mEntry.info = mApplicationInfo;
+        mApplicationInfo.packageName = packageName;
+    }
+
+    private void setDisallowedPackageName(String packageName) {
+        when(mContext.getResources()).thenReturn(mResources);
+        when(mResources.getStringArray(anyInt())).thenReturn(new String[]{packageName});
+    }
+
+    private void setApplicationInfo(boolean signedWithPlatformKey)
+            throws PackageManager.NameNotFoundException {
+        ApplicationInfo applicationInfo = new ApplicationInfo();
+        if (signedWithPlatformKey) {
+            applicationInfo.privateFlags = applicationInfo.privateFlags
+                    | ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY;
+        }
+
+        PackageInfo packageInfo = new PackageInfo();
+        packageInfo.applicationInfo = applicationInfo;
+        when(mPackageManager.getPackageInfoAsUser(anyString(), anyInt(), anyInt())).thenReturn(
+                packageInfo);
+    }
+}
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
index e185354..1042a6a 100644
--- a/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocaleDetailsTest.java
@@ -53,7 +53,6 @@
 
     private Context mContext;
     private LocaleList mSystemLocales;
-    private Locale mSimLocale;
     private LocaleList mAppLocale;
     private String[] mAssetLocales;
 
@@ -69,7 +68,8 @@
         when(mContext.getSystemService(LocaleManager.class)).thenReturn(mLocaleManager);
 
         setupInitialLocales("en",
-                "uk",
+                "tw",
+                "jp",
                 "en, uk, jp, ne",
                 new String[]{"en", "ne", "ms", "pa"});
     }
@@ -88,6 +88,8 @@
     @Test
     @UiThreadTest
     public void handleAllLocalesData_1stLocaleOfSuggestedLocaleListIsAppLocale() {
+        Locale simCountryLocale = new Locale("zh", "TW");
+        Locale networkCountryLocale = new Locale("ja", "JP");
         DummyAppLocaleDetailsHelper helper =
                 new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
 
@@ -95,25 +97,17 @@
 
         Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
         assertTrue(locale.equals(mAppLocale.get(0)));
+        assertTrue(helper.getSuggestedLocales().contains(simCountryLocale));
+        assertTrue(helper.getSuggestedLocales().contains(networkCountryLocale));
     }
 
     @Test
     @UiThreadTest
-    public void handleAllLocalesData_2ndLocaleOfSuggestedLocaleListIsSimLocale() {
-        DummyAppLocaleDetailsHelper helper =
-                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
-
-        helper.handleAllLocalesData();
-
-        Locale locale = Iterables.get(helper.getSuggestedLocales(), 1);
-        assertTrue(locale.equals(mSimLocale));
-    }
-
-    @Test
-    @UiThreadTest
-    public void handleAllLocalesData_withoutAppLocale_1stLocaleOfSuggestedLocaleListIsSimLocal() {
+    public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsSimCountryLocale() {
+        Locale simCountryLocale = new Locale("zh", "TW");
         setupInitialLocales("",
-                "uk",
+                "tw",
+                "",
                 "en, uk, jp, ne",
                 new String[]{"en", "ne", "ms", "pa"});
         DummyAppLocaleDetailsHelper helper =
@@ -122,14 +116,35 @@
         helper.handleAllLocalesData();
 
         Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
-        assertTrue(locale.equals(mSimLocale));
+        assertTrue(locale.equals(simCountryLocale));
+        assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
     }
 
     @Test
     @UiThreadTest
-    public void handleAllLocalesData_noAppAndSimLocale_1stLocaleIsFirstOneInSystemLocales() {
+    public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsNetworkCountryLocale() {
+        Locale networkCountryLocale = new Locale("en", "GB");
         setupInitialLocales("",
                 "",
+                "gb",
+                "en, uk, jp, ne",
+                new String[]{"en", "ne", "ms", "pa"});
+        DummyAppLocaleDetailsHelper helper =
+                new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
+
+        helper.handleAllLocalesData();
+
+        Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
+        assertTrue(locale.equals(networkCountryLocale));
+        assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
+    }
+
+    @Test
+    @UiThreadTest
+    public void handleAllLocalesData_noAppAndSimNetworkLocale_1stLocaleIsFirstOneInSystemLocales() {
+        setupInitialLocales("",
+                "",
+                "",
                 "en, uk, jp, ne",
                 new String[]{"en", "ne", "ms", "pa"});
         DummyAppLocaleDetailsHelper helper =
@@ -175,25 +190,34 @@
     /**
      * Sets the initial Locale data
      *
-     * @param appLocale     Application locale, it shall be a language tag.
-     *                      example: "en"
-     * @param simLocale     SIM carrier locale, it shall be a language tag.
-     *                      example: "en"
-     * @param systemLocales System locales, a locale list by a multiple language tags with comma.
-     *                      example: "en, uk, jp"
-     * @param assetLocales  Asset locales, a locale list by a multiple language tags with String
-     *                      array.
-     *                      example: new String[] {"en", "ne", "ms", "pa"}
+     * @param appLocale      Application locale, it shall be a language tag.
+     *                       example: "en"
+     *
+     * @param simCountry     The ISO-3166-1 alpha-2 country code equivalent for the SIM
+     *                       provider's country code.
+     *                       example: "us"
+     *
+     * @param networkCountry The ISO-3166-1 alpha-2 country code equivalent of the MCC
+     *                       (Mobile Country Code) of the current registered operato
+     *                       or the cell nearby.
+     *                       example: "us"
+     *
+     * @param systemLocales  System locales, a locale list by a multiple language tags with comma.
+     *                       example: "en, uk, jp"
+     * @param assetLocales   Asset locales, a locale list by a multiple language tags with String
+     *                       array.
+     *                       example: new String[] {"en", "ne", "ms", "pa"}
      */
     private void setupInitialLocales(String appLocale,
-            String simLocale,
+            String simCountry,
+            String networkCountry,
             String systemLocales,
             String[] assetLocales) {
         mAppLocale = LocaleList.forLanguageTags(appLocale);
-        mSimLocale = Locale.forLanguageTag(simLocale);
         mSystemLocales = LocaleList.forLanguageTags(systemLocales);
         mAssetLocales = assetLocales;
-        when(mTelephonyManager.getSimLocale()).thenReturn(simLocale.isEmpty() ? null : mSimLocale);
+        when(mTelephonyManager.getSimCountryIso()).thenReturn(simCountry);
+        when(mTelephonyManager.getNetworkCountryIso()).thenReturn(networkCountry);
         when(mLocaleManager.getApplicationLocales(anyString())).thenReturn(mAppLocale);
     }
 
diff --git a/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java
index d7e3f92..526b6cc 100644
--- a/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/applications/appinfo/AppLocalePreferenceControllerTest.java
@@ -18,8 +18,6 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.Mockito.spy;
-
 import android.content.Context;
 import android.util.FeatureFlagUtils;
 
@@ -37,20 +35,27 @@
 public class AppLocalePreferenceControllerTest {
 
     private Context mContext;
+    private boolean mCanDisplayLocaleUi;
     private AppLocalePreferenceController mController;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mContext = spy(ApplicationProvider.getApplicationContext());
+        mContext = ApplicationProvider.getApplicationContext();
 
-        mController = spy(new AppLocalePreferenceController(mContext, "test_key"));
+        mController = new AppLocalePreferenceController(mContext, "test_key") {
+            @Override
+            boolean canDisplayLocaleUi() {
+                return mCanDisplayLocaleUi;
+            }
+        };
         FeatureFlagUtils
                 .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, true);
     }
 
     @Test
-    public void getAvailabilityStatus_featureFlagOff_shouldReturnUnavailable() {
+    public void getAvailabilityStatus_canShowUiButFeatureFlagOff_shouldReturnUnavailable() {
+        mCanDisplayLocaleUi = true;
         FeatureFlagUtils
                 .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, false);
 
@@ -59,8 +64,28 @@
     }
 
     @Test
-    public void getAvailabilityStatus_featureFlagOn_shouldReturnAvailable() {
+    public void getAvailabilityStatus_canShowUiAndFeatureFlagOn_shouldReturnAvailable() {
+        mCanDisplayLocaleUi = true;
+
         assertThat(mController.getAvailabilityStatus())
                 .isEqualTo(BasePreferenceController.AVAILABLE);
     }
+
+    @Test
+    public void getAvailabilityStatus_featureFlagOnButCanNotShowUi_shouldReturnUnavailable() {
+        mCanDisplayLocaleUi = false;
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_featureFlagOffAndCanNotShowUi_shouldReturnUnavailable() {
+        mCanDisplayLocaleUi = false;
+        FeatureFlagUtils
+                .setEnabled(mContext, FeatureFlagUtils.SETTINGS_APP_LANGUAGE_SELECTION, false);
+
+        assertThat(mController.getAvailabilityStatus())
+                .isEqualTo(BasePreferenceController.CONDITIONALLY_UNAVAILABLE);
+    }
 }
diff --git a/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java b/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java
index 2365553..d4df97f 100644
--- a/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java
+++ b/tests/unit/src/com/android/settings/privacy/PrivacyDashboardActivityTest.java
@@ -23,34 +23,39 @@
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
+import android.content.Context;
 import android.content.Intent;
-import android.provider.DeviceConfig;
 
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.platform.app.InstrumentationRegistry;
 
 import com.android.settings.Settings;
 import com.android.settings.SettingsActivity;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
 @RunWith(AndroidJUnit4.class)
 public class PrivacyDashboardActivityTest {
 
     private static final String DEFAULT_FRAGMENT_CLASSNAME = "DefaultFragmentClassname";
 
+    @Mock
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
     private Settings.PrivacyDashboardActivity mActivity;
 
     @Before
-    public void setUp() {
-        DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
+    public void setUp() throws Exception {
+        MockitoAnnotations.initMocks(this);
+
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
         final Intent intent = new Intent();
         intent.setAction(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
         intent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
@@ -71,19 +76,9 @@
         doNothing().when(mActivity).startActivity(any(Intent.class));
     }
 
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
     @Test
     public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(true);
         final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
 
         mActivity.handleSafetyCenterRedirection();
@@ -94,12 +89,7 @@
 
     @Test
     public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
-
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
         mActivity.handleSafetyCenterRedirection();
 
         verify(mActivity, times(0)).startActivity(any());
diff --git a/tests/unit/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceControllerTest.java b/tests/unit/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceControllerTest.java
index 570df73..495700a 100644
--- a/tests/unit/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/privacy/TopLevelPrivacyEntryPreferenceControllerTest.java
@@ -18,20 +18,22 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.content.Context;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
 
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.security.TopLevelSecurityEntryPreferenceController;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
 @RunWith(AndroidJUnit4.class)
 public class TopLevelPrivacyEntryPreferenceControllerTest {
@@ -41,30 +43,21 @@
     private TopLevelPrivacyEntryPreferenceController mTopLevelPrivacyEntryPreferenceController;
 
     @Mock
-    private Context mContext;
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
 
     @Before
     public void setUp() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
+        MockitoAnnotations.initMocks(this);
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
 
         mTopLevelPrivacyEntryPreferenceController =
-                new TopLevelPrivacyEntryPreferenceController(mContext, PREFERENCE_KEY);
-    }
-
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
+                new TopLevelPrivacyEntryPreferenceController(
+                        ApplicationProvider.getApplicationContext(), PREFERENCE_KEY);
     }
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterEnabled_returnsUnavailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(true);
 
         assertThat(mTopLevelPrivacyEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSecurityEntryPreferenceController.CONDITIONALLY_UNAVAILABLE);
@@ -72,11 +65,7 @@
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterDisabled_returnsAvailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
 
         assertThat(mTopLevelPrivacyEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSecurityEntryPreferenceController.AVAILABLE);
diff --git a/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusHolderTest.java b/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusHolderTest.java
new file mode 100644
index 0000000..2a31eb8
--- /dev/null
+++ b/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusHolderTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2022 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.safetycenter;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.safetycenter.SafetyCenterManager;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class SafetyCenterStatusHolderTest {
+
+    @Mock
+    private Context mContext;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+    }
+
+    @Test
+    public void isEnabled_whenContextNull_returnsFalse() {
+        assertThat(SafetyCenterStatusHolder.get().isEnabled(null)).isFalse();
+    }
+
+    @Test
+    public void isEnabled_whenSystemServiceNull_returnsFalse() {
+        when(mContext.getSystemService(SafetyCenterManager.class)).thenReturn(null);
+
+        assertThat(SafetyCenterStatusHolder.get().isEnabled(mContext)).isFalse();
+    }
+}
diff --git a/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusTest.java b/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusTest.java
deleted file mode 100644
index f36fbe1..0000000
--- a/tests/unit/src/com/android/settings/safetycenter/SafetyCenterStatusTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.safetycenter;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.provider.DeviceConfig;
-import android.provider.Settings;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-public class SafetyCenterStatusTest {
-
-    @Before
-    public void setUp() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
-    @Test
-    public void isEnabled_whenFlagTrue_returnsTrue() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
-
-        assertThat(SafetyCenterStatus.isEnabled()).isTrue();
-    }
-
-    @Test
-    public void isEnabled_whenFlagFalse_returnsFalse() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
-
-        assertThat(SafetyCenterStatus.isEnabled()).isFalse();
-    }
-}
diff --git a/tests/unit/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceControllerTest.java b/tests/unit/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceControllerTest.java
index 907fb99..e9c451e 100644
--- a/tests/unit/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/safetycenter/TopLevelSafetyCenterEntryPreferenceControllerTest.java
@@ -22,18 +22,16 @@
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.content.Intent;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
 
 import androidx.preference.Preference;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,11 +49,15 @@
     private Preference mPreference;
 
     @Mock
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
+
+    @Mock
     private Context mContext;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
 
         mPreference = new Preference(ApplicationProvider.getApplicationContext());
         mPreference.setKey(PREFERENCE_KEY);
@@ -63,14 +65,6 @@
         doNothing().when(mContext).startActivity(any(Intent.class));
         mTopLevelSafetyCenterEntryPreferenceController =
                 new TopLevelSafetyCenterEntryPreferenceController(mContext, PREFERENCE_KEY);
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
     }
 
     @Test
@@ -110,11 +104,7 @@
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterDisabled_returnsUnavailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
 
         assertThat(mTopLevelSafetyCenterEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSafetyCenterEntryPreferenceController.CONDITIONALLY_UNAVAILABLE);
@@ -122,11 +112,7 @@
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterEnabled_returnsAvailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(true);
 
         assertThat(mTopLevelSafetyCenterEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSafetyCenterEntryPreferenceController.AVAILABLE);
diff --git a/tests/unit/src/com/android/settings/security/SecurityAdvancedSettingsTest.java b/tests/unit/src/com/android/settings/security/SecurityAdvancedSettingsTest.java
index e18b258..ac91abb 100644
--- a/tests/unit/src/com/android/settings/security/SecurityAdvancedSettingsTest.java
+++ b/tests/unit/src/com/android/settings/security/SecurityAdvancedSettingsTest.java
@@ -18,17 +18,18 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.os.Looper;
-import android.provider.DeviceConfig;
 
 import androidx.test.annotation.UiThreadTest;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.ResourcesUtils;
 import com.android.settingslib.drawer.CategoryKey;
@@ -36,6 +37,8 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
 @RunWith(AndroidJUnit4.class)
 public class SecurityAdvancedSettingsTest {
@@ -47,16 +50,22 @@
     private Context mContext;
     private SecurityAdvancedSettings mSecurityAdvancedSettings;
 
+    @Mock
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
+
     @Before
     @UiThreadTest
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         if (Looper.myLooper() == null) {
             Looper.prepare();
         }
 
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
         mContext = ApplicationProvider.getApplicationContext();
 
-        mSecurityAdvancedSettings = new SecurityAdvancedSettings();
+        mSecurityAdvancedSettings = spy(new SecurityAdvancedSettings());
+        when(mSecurityAdvancedSettings.getContext()).thenReturn(mContext);
     }
 
     @Test
@@ -67,7 +76,7 @@
 
     @Test
     public void getCategoryKey_whenSafetyCenterIsEnabled_returnsSecurity() {
-        setSafetyCenterEnabled(true);
+        when(mSafetyCenterStatusHolder.isEnabled(any())).thenReturn(true);
 
         assertThat(mSecurityAdvancedSettings.getCategoryKey())
                 .isEqualTo(CategoryKey.CATEGORY_SECURITY_ADVANCED_SETTINGS);
@@ -75,7 +84,7 @@
 
     @Test
     public void getCategoryKey_whenAlternativeFragmentPresented_returnsAlternative() {
-        setSafetyCenterEnabled(false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
         setupAlternativeFragment(true, ALTERNATIVE_CATEGORY_KEY);
 
         assertThat(mSecurityAdvancedSettings.getCategoryKey())
@@ -84,7 +93,7 @@
 
     @Test
     public void getCategoryKey_whenNoAlternativeFragmentPresented_returnsLegacy() {
-        setSafetyCenterEnabled(false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
         setupAlternativeFragment(false, null);
 
         assertThat(mSecurityAdvancedSettings.getCategoryKey())
@@ -95,14 +104,6 @@
         return ResourcesUtils.getResourcesId(mContext, "xml", resName);
     }
 
-    private void setSafetyCenterEnabled(boolean isEnabled) {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(isEnabled),
-                /* makeDefault = */ false);
-    }
-
     private void setupAlternativeFragment(boolean hasAlternativeFragment,
             String alternativeCategoryKey) {
         final FakeFeatureFactory fakeFeatureFactory = FakeFeatureFactory.setupForTest();
diff --git a/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
index 0406616..3348663 100644
--- a/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
+++ b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
@@ -25,22 +25,22 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.content.Context;
 import android.content.Intent;
-import android.provider.DeviceConfig;
 
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.platform.app.InstrumentationRegistry;
 
 import com.android.settings.Settings;
 import com.android.settings.SettingsActivity;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.testutils.FakeFeatureFactory;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 
 @RunWith(AndroidJUnit4.class)
@@ -52,13 +52,16 @@
     private Settings.SecurityDashboardActivity mActivity;
     private Intent mDefaultIntent;
 
+    @Mock
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
+
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
         mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
-        DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
+
         mDefaultIntent = new Intent();
         mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
         mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
@@ -79,12 +82,6 @@
         doNothing().when(mActivity).startActivity(any(Intent.class));
     }
 
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(android.provider.Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
     @Test
     public void noAvailableAlternativeFragmentAvailable_defaultFragmentSet() {
         when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
@@ -125,11 +122,7 @@
 
     @Test
     public void onCreate_whenSafetyCenterEnabled_redirectsToSafetyCenter() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(true);
         final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
 
         mActivity.handleSafetyCenterRedirection();
@@ -140,11 +133,7 @@
 
     @Test
     public void onCreate_whenSafetyCenterDisabled_doesntRedirectToSafetyCenter() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
 
         mActivity.handleSafetyCenterRedirection();
 
diff --git a/tests/unit/src/com/android/settings/security/TopLevelSecurityEntryPreferenceControllerTest.java b/tests/unit/src/com/android/settings/security/TopLevelSecurityEntryPreferenceControllerTest.java
index 7e83ca7..81ebda6 100644
--- a/tests/unit/src/com/android/settings/security/TopLevelSecurityEntryPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/security/TopLevelSecurityEntryPreferenceControllerTest.java
@@ -25,18 +25,15 @@
 
 import android.content.Context;
 import android.content.Intent;
-import android.provider.DeviceConfig;
-import android.provider.Settings;
 
 import androidx.preference.Preference;
 import androidx.test.core.app.ApplicationProvider;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import com.android.settings.SettingsActivity;
-import com.android.settings.safetycenter.SafetyCenterStatus;
+import com.android.settings.safetycenter.SafetyCenterStatusHolder;
 import com.android.settings.testutils.FakeFeatureFactory;
 
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -57,15 +54,15 @@
 
     @Mock
     private Context mContext;
+    @Mock
+    private SafetyCenterStatusHolder mSafetyCenterStatusHolder;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
-
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
+        SafetyCenterStatusHolder.sInstance = mSafetyCenterStatusHolder;
 
         mPreference = new Preference(ApplicationProvider.getApplicationContext());
         mPreference.setKey(PREFERENCE_KEY);
@@ -75,12 +72,6 @@
                 new TopLevelSecurityEntryPreferenceController(mContext, PREFERENCE_KEY);
     }
 
-    @After
-    public void tearDown() {
-        DeviceConfig.resetToDefaults(Settings.RESET_MODE_PACKAGE_DEFAULTS,
-                DeviceConfig.NAMESPACE_PRIVACY);
-    }
-
     @Test
     public void handlePreferenceTreeClick_forDifferentPreferenceKey_isNotHandled() {
         Preference preference = new Preference(ApplicationProvider.getApplicationContext());
@@ -137,11 +128,7 @@
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterEnabled_returnsUnavailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(true),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(true);
 
         assertThat(mTopLevelSecurityEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSecurityEntryPreferenceController.CONDITIONALLY_UNAVAILABLE);
@@ -149,11 +136,7 @@
 
     @Test
     public void getAvailabilityStatus_whenSafetyCenterDisabled_returnsAvailable() {
-        DeviceConfig.setProperty(
-                DeviceConfig.NAMESPACE_PRIVACY,
-                SafetyCenterStatus.SAFETY_CENTER_IS_ENABLED,
-                /* value = */ Boolean.toString(false),
-                /* makeDefault = */ false);
+        when(mSafetyCenterStatusHolder.isEnabled(any(Context.class))).thenReturn(false);
 
         assertThat(mTopLevelSecurityEntryPreferenceController.getAvailabilityStatus())
                 .isEqualTo(TopLevelSecurityEntryPreferenceController.AVAILABLE);