Merge "Extract app label from component name in notification access confirmation UI" into tm-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 60815aa..ae87edb 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1452,8 +1452,7 @@
         <activity
             android:name=".datausage.AppDataUsageActivity"
             android:exported="true"
-            android:noHistory="true"
-            android:permission="android.permission.QUERY_ALL_PACKAGES">
+            android:noHistory="true">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1523,7 +1522,6 @@
         <activity-alias android:name=".applications.InstalledAppDetails"
                 android:label="@string/application_info_label"
                 android:exported="true"
-                android:permission="android.permission.QUERY_ALL_PACKAGES"
                 android:targetActivity=".applications.InstalledAppDetailsTop">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APPLICATION_DETAILS_SETTINGS" />
@@ -1537,8 +1535,7 @@
 
         <activity android:name=".applications.InstalledAppOpenByDefaultActivity"
                   android:label="@string/application_info_label"
-                  android:exported="true"
-                  android:permission="android.permission.QUERY_ALL_PACKAGES">
+                  android:exported="true">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APP_OPEN_BY_DEFAULT_SETTINGS" />
                 <!-- Also catch legacy "com." prefixed action. -->
@@ -1781,6 +1778,10 @@
                 <action android:name="android.settings.PRIVACY_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
+            <intent-filter>
+                <action android:name="android.settings.PRIVACY_ADVANCED_SETTINGS" />
+                <category android:name="android.intent.category.DEFAULT" />
+            </intent-filter>
             <intent-filter android:priority="1">
                 <action android:name="android.settings.REQUEST_ENABLE_CONTENT_CAPTURE" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -1909,8 +1910,7 @@
         <activity
             android:name="Settings$AppUsageAccessSettingsActivity"
             android:exported="true"
-            android:label="@string/usage_access_title"
-            android:permission="android.permission.QUERY_ALL_PACKAGES">
+            android:label="@string/usage_access_title">
             <intent-filter>
                 <action android:name="android.settings.USAGE_ACCESS_SETTINGS"/>
                 <category android:name="android.intent.category.DEFAULT"/>
diff --git a/res/drawable/bluetooth_broadcast_dialog_done.xml b/res/drawable/bluetooth_broadcast_dialog_done.xml
new file mode 100644
index 0000000..b2a5cc6
--- /dev/null
+++ b/res/drawable/bluetooth_broadcast_dialog_done.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="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24"
+    android:tint="?attr/colorControlNormal">
+  <path
+      android:fillColor="@android:color/white"
+      android:pathData="M9.55,18 L3.85,12.3 5.275,10.875 9.55,15.15 18.725,5.975 20.15,7.4Z"/>
+</vector>
diff --git a/res/layout/admin_disabled_other_options_footer.xml b/res/layout/admin_disabled_other_options_footer.xml
index 31327bb..f5c6b86 100644
--- a/res/layout/admin_disabled_other_options_footer.xml
+++ b/res/layout/admin_disabled_other_options_footer.xml
@@ -25,6 +25,7 @@
     <TextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:id="@+id/admin_disabled_other_options_text"
             android:text="@string/admin_disabled_other_options" />
     <TextView android:id="@+id/admin_more_details_link"
             android:layout_width="wrap_content"
diff --git a/res/layout/bluetooth_find_broadcast_password_dialog.xml b/res/layout/bluetooth_find_broadcast_password_dialog.xml
new file mode 100644
index 0000000..f9df3f5
--- /dev/null
+++ b/res/layout/bluetooth_find_broadcast_password_dialog.xml
@@ -0,0 +1,43 @@
+<?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:paddingLeft="?android:attr/dialogPreferredPadding"
+    android:paddingRight="?android:attr/dialogPreferredPadding"
+    android:orientation="vertical">
+    <TextView
+        android:id="@+id/broadcast_name_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:minHeight="48dp"
+        android:textAlignment="viewStart"/>
+    <EditText
+        android:id="@+id/broadcast_edit_text"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:minHeight="48dp"
+        android:textAlignment="viewStart"/>
+    <TextView
+        android:id="@+id/broadcast_error_message"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="6dp"
+        style="@style/TextAppearance.ErrorText"
+        android:visibility="invisible"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index 5b4560e..a01f3a9 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -22,7 +22,7 @@
     android:id="@+id/setup_wizard_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    app:sudDescriptionText="@string/security_settings_fingerprint_enroll_introduction_message">
+    app:sudDescriptionText="@string/security_settings_fingerprint_enroll_introduction_v2_message">
 
     <LinearLayout
         style="@style/SudContentFrame"
diff --git a/res/layout/user_select_item.xml b/res/layout/user_select_item.xml
index fa0c91a..894f59a 100644
--- a/res/layout/user_select_item.xml
+++ b/res/layout/user_select_item.xml
@@ -15,9 +15,9 @@
 -->
 <RelativeLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@android:id/widget_frame"
     android:layout_width="120dp"
-    android:layout_height="112dp">
+    android:layout_height="112dp"
+    android:importantForAccessibility="no">
 
     <FrameLayout
         android:id="@+id/button"
@@ -41,7 +41,7 @@
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
         android:layout_centerHorizontal="true"
-        android:labelFor="@android:id/icon"
         android:textSize="14sp"
+        android:importantForAccessibility="no"
         style="@style/TextAppearance.PreferenceTitle.SettingsLib"/>
 </RelativeLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 63db309..68de584 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -968,8 +968,12 @@
     <string name="security_settings_fingerprint_enroll_consent_introduction_title">Allow fingerprint unlock</string>
     <!-- Introduction title shown in fingerprint enrollment to introduce the fingerprint feature, when fingerprint unlock is disabled by device admin [CHAR LIMIT=40] -->
     <string name="security_settings_fingerprint_enroll_introduction_title_unlock_disabled">Use your fingerprint</string>
-    <!-- Introduction detail message shown in fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
-    <string name="security_settings_fingerprint_enroll_introduction_message">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps or approve a purchase.</string>
+    <!-- Introduction detail message shown in fingerprint enrollment dialog (tablet) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_enroll_introduction_v2_message" product="tablet">Use your fingerprint to unlock your tablet or verify it\u2019s you, like when you sign in to apps or approve a purchase.</string>
+    <!-- Introduction detail message shown in fingerprint enrollment dialog (device) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_enroll_introduction_v2_message" product="device">Use your fingerprint to unlock your device or verify it\u2019s you, like when you sign in to apps or approve a purchase.</string>
+    <!-- Introduction detail message shown in fingerprint enrollment dialog (default) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_enroll_introduction_v2_message" product="default">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps or approve a purchase.</string>
     <!-- Introduction detail message shown in fingerprint enrollment dialog when asking for parental consent [CHAR LIMIT=NONE]-->
     <string name="security_settings_fingerprint_enroll_introduction_consent_message">Allow your child to use their fingerprint to unlock their phone or verify it\u2019s them. This happens when they sign in to apps, approve a purchase, and more.</string>
     <!-- Introduction title shown in the bottom of fingerprint enrollment dialog [CHAR LIMIT=NONE]-->
@@ -1044,8 +1048,12 @@
     <!-- Acquire message received during fingerprint enrollment to inform the user they've reached the maximum number of enrollments. [CHAR LIMIT=NONE]-->
     <string name="security_settings_fingerprint_v2_enroll_error_max_attempts">You\u2019ve reached the maximum number of attempts</string>
 
-    <!-- Message shown in fingerprint security settings home screen. [CHAR LIMIT=NONE]-->
-    <string name="security_settings_fingerprint_v2_home_screen">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps\n\n<annotation id="url">Learn more</annotation></string>
+    <!-- Message text only shown in fingerprint security settings home screen. (tablet) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_v2_home_screen_text" product="tablet">Use your fingerprint to unlock your tablet or verify it\u2019s you, like when you sign in to apps</string>
+    <!-- Message text only shown in fingerprint security settings home screen. (device) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_v2_home_screen_text" product="device">Use your fingerprint to unlock your device or verify it\u2019s you, like when you sign in to apps</string>
+    <!-- Message text only shown in fingerprint security settings home screen. (phone) [CHAR LIMIT=NONE]-->
+    <string name="security_settings_fingerprint_v2_home_screen_text" product="default">Use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps</string>
 
     <!-- Biometric settings --><skip />
     <!-- Title shown for menu item that launches biometric settings. [CHAR LIMIT=66] -->
@@ -1149,8 +1157,12 @@
     <string name="security_settings_udfps_enroll_progress_a11y_message">Enrolling fingerprint <xliff:g id="percentage" example="10">%d</xliff:g> percent</string>
     <!-- Title shown in fingerprint enrollment dialog once enrollment is completed [CHAR LIMIT=29] -->
     <string name="security_settings_fingerprint_enroll_finish_title">Fingerprint added</string>
-    <!-- Message shown in fingerprint enrollment dialog once enrollment is completed -->
-    <string name="security_settings_fingerprint_enroll_finish_message">Now you can use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps</string>
+    <!-- Message shown in fingerprint enrollment dialog once enrollment is completed (tablet) [CHAR LIMIT=NONE] -->
+    <string name="security_settings_fingerprint_enroll_finish_v2_message" product="tablet">Now you can use your fingerprint to unlock your tablet or verify it\u2019s you, like when you sign in to apps</string>
+    <!-- Message shown in fingerprint enrollment dialog once enrollment is completed (device) [CHAR LIMIT=NONE] -->
+    <string name="security_settings_fingerprint_enroll_finish_v2_message" product="device">Now you can use your fingerprint to unlock your device or verify it\u2019s you, like when you sign in to apps</string>
+    <!-- Message shown in fingerprint enrollment dialog once enrollment is completed (default) [CHAR LIMIT=NONE] -->
+    <string name="security_settings_fingerprint_enroll_finish_v2_message" product="default">Now you can use your fingerprint to unlock your phone or verify it\u2019s you, like when you sign in to apps</string>
     <!-- Button text to skip enrollment of fingerprint [CHAR LIMIT=40] -->
     <string name="security_settings_fingerprint_enroll_enrolling_skip">Do it later</string>
     <!-- Accessibility message for fingerprint enrollment asking the user to place the tip of their finger on the fingerprint sensor [CHAR LIMIT=NONE] -->
@@ -1402,7 +1414,7 @@
     <string name="lock_settings_picker_biometric_message">Choose your backup screen lock method</string>
 
     <!-- Text shown on the screen lock menu. This text is letting the user know that their IT admin can't reset their screen lock if they forget it, and they can choose to set another lock that would be specifically for their work apps. The place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring the user to enroll a work profile screen lock instead. [CHAR LIMIT=100] -->
-    <string name="lock_settings_picker_admin_restricted_personal_message">This lock can\u2019t be reset by your IT admin. <xliff:g id="link_begin" example="">LINK_BEGIN</xliff:g>Set a separate work lock instead<xliff:g id="link_end" example="">LINK_END</xliff:g></string>
+    <string name="lock_settings_picker_admin_restricted_personal_message">If you forget your screen lock, your IT admin can\u2019t reset it. <annotation id="link">Set a separate work lock</annotation></string>
 
     <!-- Message shown in screen lock picker for setting up a work profile screen lock. [CHAR LIMIT=80] -->
     <string name="lock_settings_picker_profile_message">If you forget this lock, ask your IT admin to reset it</string>
@@ -6627,10 +6639,14 @@
     <!-- Menu label for refreshing with latest usage numbers -->
     <string name="menu_stats_refresh">Refresh</string>
 
-    <!-- Label for mediaserver process in battery usage -->
+    <!-- Label for mediaserver process in battery usage [CHAR_LIMIT=NONE] -->
     <string name="process_mediaserver_label">Mediaserver</string>
     <!-- Label for dex2oat process in battery usage used for the optimization of one or more apps -->
     <string name="process_dex2oat_label">App optimization</string>
+    <!-- Label for network tethering UID label in battery usage [CHAR_LIMIT=NONE] -->
+    <string name="process_network_tethering">Tethering</string>
+    <!-- Label for removed apps UID lablel in battery usage [CHAR_LIMIT=NONE] -->
+    <string name="process_removed_apps">Removed apps</string>
 
     <!-- Battery saver: Label for feature, title + menu item [CHAR_LIMIT=40] -->
     <string name="battery_saver">Battery Saver</string>
@@ -7613,15 +7629,15 @@
         <item quantity="other">Trust or remove certificates</item>
     </plurals>
     <!-- Text of message to show to device owner user whose administrator has installed a SSL CA Cert.  [CHAR LIMIT=NONE] -->
-    <plurals name="ssl_ca_cert_info_message_device_owner">
-        <item quantity="one"><xliff:g id="managing_domain">%s</xliff:g> has installed a certificate authority on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.</item>
-        <item quantity="other"><xliff:g id="managing_domain">%s</xliff:g> has installed certificate authorities on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.</item>
-    </plurals>
+    <string name="ssl_ca_cert_info_message_device_owner"> {numberOfCertificates, plural,
+        =1 {{orgName} has installed a certificate authority on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.}
+        other {{orgName} has installed certificate authorities on your device, which may allow them to monitor your device network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.}
+        }</string>
     <!-- Text of message to show to work profile users whose administrator has installed a SSL CA Cert.  [CHAR LIMIT=NONE] -->
-    <plurals name="ssl_ca_cert_info_message">
-        <item quantity="one"><xliff:g id="managing_domain">%s</xliff:g> has installed a certificate authority for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.</item>
-        <item quantity="other"><xliff:g id="managing_domain">%s</xliff:g> has installed certificate authorities for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.</item>
-    </plurals>
+    <string name="ssl_ca_cert_info_message">{numberOfCertificates, plural,
+        =1 {{orgName} has installed a certificate authority for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about this certificate, contact your admin.}
+        other {{orgName} has installed certificate authorities for your work profile, which may allow them to monitor work network activity, including emails, apps, and secure websites.\n\nFor more information about these certificates, contact your admin.}
+        }</string>
     <!-- Text of warning to show to users that have a SSL CA Cert installed.  [CHAR LIMIT=NONE] -->
     <string name="ssl_ca_cert_warning_message">A third party is capable of monitoring your network activity, including emails, apps, and secure websites.\n\nA trusted credential installed on your device is making this possible.</string>
     <!-- Label on button that will take the user to the Trusted Credentials settings page.  [CHAR LIMIT=NONE]-->
@@ -14139,4 +14155,10 @@
     <string name="bluetooth_find_broadcast_button_leave">Leave broadcast</string>
     <!-- The Button of the action to scan QR code [CHAR LIMIT=none] -->
     <string name="bluetooth_find_broadcast_button_scan">Scan QR code</string>
+    <!-- The title of enter password dialog in bluetooth find broadcast page. [CHAR LIMIT=none] -->
+    <string name="find_broadcast_password_dialog_title">Enter password</string>
+    <!-- The error message of enter password dialog in bluetooth find broadcast page [CHAR LIMIT=none] -->
+    <string name="find_broadcast_password_dialog_connection_error">Can\u2019t connect. Try again.</string>
+    <!-- The error message of enter password dialog in bluetooth find broadcast page [CHAR LIMIT=none] -->
+    <string name="find_broadcast_password_dialog_password_error">Wrong password</string>
 </resources>
diff --git a/res/xml/app_list_disclosure_settings.xml b/res/xml/app_list_disclosure_settings.xml
index 0874407..3224974 100644
--- a/res/xml/app_list_disclosure_settings.xml
+++ b/res/xml/app_list_disclosure_settings.xml
@@ -23,5 +23,6 @@
 
     <com.android.settingslib.widget.FooterPreference
             android:title="@string/enterprise_privacy_apps_count_estimation_info"
+            android:key="enterprise_privacy_apps_footer"
             android:selectable="false"/>
 </PreferenceScreen>
diff --git a/res/xml/app_locale_details.xml b/res/xml/app_locale_details.xml
index 8b1b370..e01db2f 100644
--- a/res/xml/app_locale_details.xml
+++ b/res/xml/app_locale_details.xml
@@ -20,6 +20,7 @@
     android:title="@string/app_locale_picker_title">
 
     <com.android.settingslib.widget.TopIntroPreference
+        android:key="app_locale_disclaimer"
         android:title="@string/desc_app_locale_disclaimer"
         android:order="1"/>
 
diff --git a/res/xml/wifi_network_details_fragment2.xml b/res/xml/wifi_network_details_fragment2.xml
index 1c4fe91..eb9add1 100644
--- a/res/xml/wifi_network_details_fragment2.xml
+++ b/res/xml/wifi_network_details_fragment2.xml
@@ -58,14 +58,14 @@
         android:title="@string/wifi_security"
         android:selectable="false"/>
 
-    <DropDownPreference
+    <ListPreference
         android:key="metered"
         android:icon="@drawable/ic_attach_money_black_24dp"
         android:title="@string/wifi_metered_title"
         android:entries="@array/wifi_metered_entries"
         android:entryValues="@array/wifi_metered_values"/>
 
-    <DropDownPreference
+    <ListPreference
         android:key="privacy"
         android:icon="@drawable/ic_wifi_privacy_24dp"
         android:title="@string/wifi_privacy_settings"
diff --git a/src/com/android/settings/DefaultRingtonePreference.java b/src/com/android/settings/DefaultRingtonePreference.java
index 9f9f832..914c4b2 100644
--- a/src/com/android/settings/DefaultRingtonePreference.java
+++ b/src/com/android/settings/DefaultRingtonePreference.java
@@ -22,6 +22,9 @@
 import android.media.RingtoneManager;
 import android.net.Uri;
 import android.util.AttributeSet;
+import android.util.Log;
+
+import androidx.annotation.VisibleForTesting;
 
 public class DefaultRingtonePreference extends RingtonePreference {
     private static final String TAG = "DefaultRingtonePreference";
@@ -43,6 +46,24 @@
 
     @Override
     protected void onSaveRingtone(Uri ringtoneUri) {
+        String mimeType = getContext().getContentResolver().getType(ringtoneUri);
+        if (mimeType == null) {
+            Log.e(TAG, "onSaveRingtone for URI:" + ringtoneUri
+                    + " ignored: failure to find mimeType (no access from this context?)");
+            return;
+        }
+
+        if (!(mimeType.startsWith("audio/") || mimeType.equals("application/ogg"))) {
+            Log.e(TAG, "onSaveRingtone for URI:" + ringtoneUri
+                    + " ignored: associated mimeType:" + mimeType + " is not an audio type");
+            return;
+        }
+
+        setActualDefaultRingtoneUri(ringtoneUri);
+    }
+
+    @VisibleForTesting
+    void setActualDefaultRingtoneUri(Uri ringtoneUri) {
         RingtoneManager.setActualDefaultRingtoneUri(mUserContext, getRingtoneType(), ringtoneUri);
     }
 
diff --git a/src/com/android/settings/MonitoringCertInfoActivity.java b/src/com/android/settings/MonitoringCertInfoActivity.java
index eadebc1..5c15eb3 100644
--- a/src/com/android/settings/MonitoringCertInfoActivity.java
+++ b/src/com/android/settings/MonitoringCertInfoActivity.java
@@ -16,12 +16,16 @@
 
 package com.android.settings;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.DEVICE_OWNER_INSTALLED_CERTIFICATE_AUTHORITY_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_INSTALLED_CERTIFICATE_AUTHORITY_WARNING;
+
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
 import android.content.DialogInterface;
 import android.content.DialogInterface.OnClickListener;
 import android.content.DialogInterface.OnDismissListener;
 import android.content.Intent;
+import android.icu.text.MessageFormat;
 import android.os.Bundle;
 import android.os.UserHandle;
 import android.provider.Settings;
@@ -30,6 +34,10 @@
 
 import com.android.settingslib.RestrictedLockUtils;
 
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
 /**
  * Activity that shows a dialog explaining that a CA cert is allowing someone to monitor network
  * traffic. This activity should be launched for the user into which the CA cert is installed
@@ -71,12 +79,30 @@
         builder.setOnDismissListener(this);
 
         if (dpm.getProfileOwnerAsUser(mUserId) != null) {
-            builder.setMessage(getResources().getQuantityString(R.plurals.ssl_ca_cert_info_message,
-                    numberOfCertificates, dpm.getProfileOwnerNameAsUser(mUserId)));
+            MessageFormat msgFormat = new MessageFormat(
+                    dpm.getResources().getString(
+                            WORK_PROFILE_INSTALLED_CERTIFICATE_AUTHORITY_WARNING,
+                            () -> getString(R.string.ssl_ca_cert_info_message)),
+                    Locale.getDefault());
+
+            Map<String, Object> arguments = new HashMap<>();
+            arguments.put("numberOfCertificates", numberOfCertificates);
+            arguments.put("orgName", dpm.getProfileOwnerNameAsUser(mUserId));
+
+            builder.setMessage(msgFormat.format(arguments));
         } else if (dpm.getDeviceOwnerComponentOnCallingUser() != null) {
-            builder.setMessage(getResources().getQuantityString(
-                    R.plurals.ssl_ca_cert_info_message_device_owner, numberOfCertificates,
-                    dpm.getDeviceOwnerNameOnAnyUser()));
+            MessageFormat msgFormat = new MessageFormat(
+                    dpm.getResources()
+                            .getString(DEVICE_OWNER_INSTALLED_CERTIFICATE_AUTHORITY_WARNING,
+                                    () -> getResources().getString(
+                                            R.string.ssl_ca_cert_info_message_device_owner)),
+                    Locale.getDefault());
+
+            Map<String, Object> arguments = new HashMap<>();
+            arguments.put("numberOfCertificates", numberOfCertificates);
+            arguments.put("orgName", dpm.getDeviceOwnerNameOnAnyUser());
+
+            builder.setMessage(msgFormat.format(arguments));
         } else  {
             // Consumer case.  Show scary warning.
             builder.setIcon(android.R.drawable.stat_notify_error);
diff --git a/src/com/android/settings/SettingsPreferenceFragment.java b/src/com/android/settings/SettingsPreferenceFragment.java
index d3e1c49..8c97f02 100644
--- a/src/com/android/settings/SettingsPreferenceFragment.java
+++ b/src/com/android/settings/SettingsPreferenceFragment.java
@@ -18,6 +18,7 @@
 
 import android.app.Activity;
 import android.app.Dialog;
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -70,6 +71,7 @@
 
     private static final int ORDER_FIRST = -1;
 
+    protected DevicePolicyManager mDevicePolicyManager;
     private SettingsDialogFragment mDialogFragment;
     // Cache the content resolver for async callbacks
     private ContentResolver mContentResolver;
@@ -135,6 +137,7 @@
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        mDevicePolicyManager = getContext().getSystemService(DevicePolicyManager.class);
         if (icicle != null) {
             mPreferenceHighlighted = icicle.getBoolean(SAVE_HIGHLIGHTED_KEY);
         }
@@ -728,4 +731,35 @@
         final Activity activity = getActivity();
         return activity == null || activity.isFinishing() || activity.isDestroyed();
     }
+
+    protected void replaceEnterprisePreferenceScreenTitle(String overrideKey, int resource) {
+        getActivity().setTitle(mDevicePolicyManager.getResources().getString(
+                overrideKey, () -> getString(resource)));
+    }
+
+    protected void replaceEnterpriseStringSummary(
+            String preferenceKey, String overrideKey, int resource) {
+        Preference preference = findPreference(preferenceKey);
+        if (preference == null) {
+            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
+            return;
+        }
+
+        preference.setSummary(
+                mDevicePolicyManager.getResources().getString(overrideKey,
+                        () -> getString(resource)));
+    }
+
+    protected void replaceEnterpriseStringTitle(
+            String preferenceKey, String overrideKey, int resource) {
+        Preference preference = findPreference(preferenceKey);
+        if (preference == null) {
+            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
+            return;
+        }
+
+        preference.setTitle(
+                mDevicePolicyManager.getResources().getString(overrideKey,
+                        () -> getString(resource)));
+    }
 }
diff --git a/src/com/android/settings/accounts/ManagedProfileSettings.java b/src/com/android/settings/accounts/ManagedProfileSettings.java
index 001a2cd..9c4d855 100644
--- a/src/com/android/settings/accounts/ManagedProfileSettings.java
+++ b/src/com/android/settings/accounts/ManagedProfileSettings.java
@@ -18,6 +18,7 @@
 
 import static android.app.admin.DevicePolicyResources.Strings.Settings.CROSS_PROFILE_CALENDAR_SUMMARY;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.CROSS_PROFILE_CALENDAR_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_PROFILE_SETTINGS_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONTACT_SEARCH_SUMMARY;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_CONTACT_SEARCH_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SETTING;
@@ -84,6 +85,8 @@
         super.onCreate(icicle);
         mManagedProfileBroadcastReceiver = new ManagedProfileBroadcastReceiver();
         mManagedProfileBroadcastReceiver.register(getActivity());
+        replaceEnterprisePreferenceScreenTitle(
+                MANAGED_PROFILE_SETTINGS_TITLE, R.string.managed_profile_settings_title);
         replaceEnterpriseStringTitle("work_mode",
                 WORK_PROFILE_SETTING, R.string.work_mode_label);
         replaceEnterpriseStringTitle("contacts_search",
diff --git a/src/com/android/settings/applications/AppLocaleUtil.java b/src/com/android/settings/applications/AppLocaleUtil.java
index 7004377..77fba89 100644
--- a/src/com/android/settings/applications/AppLocaleUtil.java
+++ b/src/com/android/settings/applications/AppLocaleUtil.java
@@ -18,11 +18,14 @@
 
 import android.annotation.NonNull;
 import android.app.ActivityManager;
+import android.app.LocaleConfig;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.ResolveInfo;
+import android.os.LocaleList;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 
 import com.android.settings.R;
@@ -35,6 +38,7 @@
 
     public static final Intent LAUNCHER_ENTRY_INTENT =
             new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
+
     /**
      * Decides the UI display of per app locale.
      */
@@ -42,9 +46,20 @@
             @NonNull Context context,
             @NonNull String packageName,
             @NonNull List<ResolveInfo> infos) {
-        return !isDisallowedPackage(context, packageName)
-                && !isSignedWithPlatformKey(context, packageName)
-                && hasLauncherEntry(packageName, infos);
+        boolean isDisallowedPackage = isDisallowedPackage(context, packageName);
+        boolean hasLauncherEntry = hasLauncherEntry(packageName, infos);
+        boolean isSignedWithPlatformKey = isSignedWithPlatformKey(context, packageName);
+        boolean isAppLocaleSupported = isAppLocaleSupported(context, packageName);
+        Log.i(TAG, "Can display preference - [" + packageName + "] :"
+                + " isDisallowedPackage : " + isDisallowedPackage
+                + " / isSignedWithPlatformKey : " + isSignedWithPlatformKey
+                + " / hasLauncherEntry : " + hasLauncherEntry
+                + " / isAppLocaleSupported : " + isAppLocaleSupported);
+
+        return !isDisallowedPackage
+                && !isSignedWithPlatformKey
+                && hasLauncherEntry
+                && isAppLocaleSupported;
     }
 
     private static boolean isDisallowedPackage(Context context, String packageName) {
@@ -79,4 +94,61 @@
         return infos.stream()
                 .anyMatch(info -> info.activityInfo.packageName.equals(packageName));
     }
+
+    /**
+     * Check the function of per app language is supported by current application.
+     */
+    public static boolean isAppLocaleSupported(Context context, String packageName) {
+        if (getPackageLocales(context, packageName) != null) {
+            return true;
+        }
+
+        if (FeatureFlagUtils.isEnabled(
+                context, FeatureFlagUtils.SETTINGS_APP_LOCALE_OPT_IN_ENABLED)) {
+            return false;
+        }
+
+        return getAssetLocales(context, packageName).length > 0;
+    }
+
+    /**
+     * Get locales fron AssetManager.
+     */
+    public static String[] getAssetLocales(Context context, String packageName) {
+        try {
+            PackageManager packageManager = context.getPackageManager();
+            String[] locales = packageManager.getResourcesForApplication(
+                    packageManager.getPackageInfo(packageName, PackageManager.MATCH_ALL)
+                            .applicationInfo).getAssets().getNonSystemLocales();
+            if (locales == null) {
+                Log.i(TAG, "[" + packageName + "] locales are null.");
+            }
+            if (locales.length <= 0) {
+                Log.i(TAG, "[" + packageName + "] locales length is 0.");
+                return new String[0];
+            }
+            String locale = locales[0];
+            Log.i(TAG, "First asset locale - [" + packageName + "] " + locale);
+            return locales;
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "Can not found the package name : " + packageName + " / " + e);
+        }
+        return new String[0];
+    }
+
+    /**
+     * Get locales from LocaleConfig.
+     */
+    public static LocaleList getPackageLocales(Context context, String packageName) {
+        try {
+            LocaleConfig localeConfig =
+                    new LocaleConfig(context.createPackageContext(packageName, 0));
+            if (localeConfig.getStatus() == LocaleConfig.STATUS_SUCCESS) {
+                return localeConfig.getSupportedLocales();
+            }
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "Can not found the package name : " + packageName + " / " + e);
+        }
+        return null;
+    }
 }
diff --git a/src/com/android/settings/applications/AppStateBaseBridge.java b/src/com/android/settings/applications/AppStateBaseBridge.java
index 1a39483..d7f253b 100644
--- a/src/com/android/settings/applications/AppStateBaseBridge.java
+++ b/src/com/android/settings/applications/AppStateBaseBridge.java
@@ -36,6 +36,8 @@
     protected final BackgroundHandler mHandler;
     protected final MainHandler mMainHandler;
 
+    private boolean mForceLoadAllApps;
+
     public AppStateBaseBridge(ApplicationsState appState, Callback callback) {
         mAppState = appState;
         mAppSession = mAppState != null ? mAppState.newSession(this) : null;
@@ -48,13 +50,22 @@
         mMainHandler = new MainHandler(Looper.getMainLooper());
     }
 
-    public void resume() {
+    public void resume(boolean forceLoadAllApps) {
+        mForceLoadAllApps = forceLoadAllApps;
         mHandler.sendEmptyMessage(BackgroundHandler.MSG_LOAD_ALL);
-        mAppSession.onResume();
+        if (mForceLoadAllApps) {
+            mAppSession.onResume();
+        } else {
+            mAppSession.activateSession();
+        }
     }
 
     public void pause() {
-        mAppSession.onPause();
+        if (mForceLoadAllApps) {
+            mAppSession.onPause();
+        } else {
+            mAppSession.deactivateSession();
+        }
     }
 
     public void release() {
diff --git a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
index 19b8f50..42f5930 100644
--- a/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
+++ b/src/com/android/settings/applications/SpecialAppAccessPreferenceController.java
@@ -74,7 +74,7 @@
 
     @Override
     public void onStart() {
-        mDataUsageBridge.resume();
+        mDataUsageBridge.resume(true /* forceLoadAllApps */);
     }
 
     @Override
diff --git a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
index e6caafc..20cddec 100644
--- a/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
+++ b/src/com/android/settings/applications/appinfo/AppLocaleDetails.java
@@ -18,7 +18,6 @@
 import static com.android.settings.widget.EntityHeaderController.ActionType;
 
 import android.app.Activity;
-import android.app.LocaleConfig;
 import android.app.LocaleManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
@@ -31,6 +30,7 @@
 import android.os.Bundle;
 import android.os.LocaleList;
 import android.os.UserHandle;
+import android.util.FeatureFlagUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -44,6 +44,7 @@
 import com.android.settings.SettingsPreferenceFragment;
 import com.android.settings.Utils;
 import com.android.settings.applications.AppInfoBase;
+import com.android.settings.applications.AppLocaleUtil;
 import com.android.settings.widget.EntityHeaderController;
 import com.android.settingslib.applications.AppUtils;
 import com.android.settingslib.applications.ApplicationsState.AppEntry;
@@ -62,10 +63,12 @@
 
     private static final String KEY_APP_DESCRIPTION = "app_locale_description";
     private static final String KEY_WARNINGS = "key_warnings";
+    private static final String KEY_APP_DISCLAIMER = "app_locale_disclaimer";
 
     private boolean mCreated = false;
     private String mPackageName;
     private LayoutPreference mPrefOfDescription;
+    private Preference mPrefOfDisclaimer;
     private ApplicationInfo mApplicationInfo;
 
     /**
@@ -91,8 +94,10 @@
         }
         addPreferencesFromResource(R.xml.app_locale_details);
         mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
+        mPrefOfDisclaimer = getPreferenceScreen().findPreference(KEY_APP_DISCLAIMER);
         mApplicationInfo = getApplicationInfo(mPackageName, getContext().getUserId());
         setWarningMessage();
+        setDisclaimerPreference();
     }
 
     // Override here so we don't have an empty screen
@@ -171,6 +176,13 @@
         }
     }
 
+    private void setDisclaimerPreference() {
+        if (FeatureFlagUtils.isEnabled(
+                getContext(), FeatureFlagUtils.SETTINGS_APP_LOCALE_OPT_IN_ENABLED)) {
+            mPrefOfDisclaimer.setVisible(false);
+        }
+    }
+
     private void setDescription() {
         int res = getAppDescription();
         if (res != -1) {
@@ -206,8 +218,8 @@
     }
 
     private int getAppDescription() {
-        LocaleList packageLocaleList = getPackageLocales();
-        String[] assetLocaleList = getAssetLocales();
+        LocaleList packageLocaleList = AppLocaleUtil.getPackageLocales(getContext(), mPackageName);
+        String[] assetLocaleList = AppLocaleUtil.getAssetLocales(getContext(), mPackageName);
         // TODO add apended url string, "Learn more", to these both sentenses.
         if ((packageLocaleList != null && packageLocaleList.isEmpty())
                 || (packageLocaleList == null && assetLocaleList.length == 0)) {
@@ -216,41 +228,6 @@
         return -1;
     }
 
-    private String[] getAssetLocales() {
-        try {
-            PackageManager packageManager = getContext().getPackageManager();
-            String[] locales = packageManager.getResourcesForApplication(
-                    packageManager.getPackageInfo(mPackageName, PackageManager.MATCH_ALL)
-                            .applicationInfo).getAssets().getNonSystemLocales();
-            if (locales == null) {
-                Log.i(TAG, "[" + mPackageName + "] locales are null.");
-            }
-            if (locales.length <= 0) {
-                Log.i(TAG, "[" + mPackageName + "] locales length is 0.");
-                return new String[0];
-            }
-            String locale = locales[0];
-            Log.i(TAG, "First asset locale - [" + mPackageName + "] " + locale);
-            return locales;
-        } catch (PackageManager.NameNotFoundException e) {
-            Log.w(TAG, "Can not found the package name : " + mPackageName + " / " + e);
-        }
-        return new String[0];
-    }
-
-    private LocaleList getPackageLocales() {
-        try {
-            LocaleConfig localeConfig =
-                    new LocaleConfig(getContext().createPackageContext(mPackageName, 0));
-            if (localeConfig.getStatus() == LocaleConfig.STATUS_SUCCESS) {
-                return localeConfig.getSupportedLocales();
-            }
-        } catch (PackageManager.NameNotFoundException e) {
-            Log.w(TAG, "Can not found the package name : " + mPackageName + " / " + e);
-        }
-        return null;
-    }
-
     /** Gets per app's default locale */
     public static Locale getAppDefaultLocale(Context context, String packageName) {
         LocaleManager localeManager = context.getSystemService(LocaleManager.class);
diff --git a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
index cb8b73d..a130bb2 100644
--- a/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
+++ b/src/com/android/settings/applications/autofill/PasswordsPreferenceController.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.applications.autofill;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.AUTO_SYNC_PERSONAL_DATA;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.AUTO_SYNC_WORK_DATA;
 import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
 import static android.service.autofill.AutofillService.EXTRA_RESULT;
 
@@ -114,6 +116,11 @@
         super.displayPreference(screen);
         final PreferenceGroup group = screen.findPreference(getPreferenceKey());
         addPasswordPreferences(screen.getContext(), getUser(), group);
+
+        replaceEnterpriseStringTitle(screen, "auto_sync_personal_account_data",
+                AUTO_SYNC_PERSONAL_DATA, R.string.account_settings_menu_auto_sync_personal);
+        replaceEnterpriseStringTitle(screen, "auto_sync_work_account_data",
+                AUTO_SYNC_WORK_DATA, R.string.account_settings_menu_auto_sync_work);
     }
 
     private void addPasswordPreferences(
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index 062bfc5..a6abd10 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -173,6 +173,8 @@
     private static final String EXTRA_HAS_BRIDGE = "hasBridge";
     private static final String EXTRA_FILTER_TYPE = "filterType";
     @VisibleForTesting
+    static final String EXTRA_SEARCH_QUERY = "search_query";
+    @VisibleForTesting
     static final String EXTRA_EXPAND_SEARCH_VIEW = "expand_search_view";
 
     // attributes used as keys when passing values to AppInfoDashboardFragment activity
@@ -253,6 +255,8 @@
     // Whether or not search view is expanded.
     @VisibleForTesting
     boolean mExpandSearch;
+    @VisibleForTesting
+    CharSequence mPreQuery;
 
     private View mRootView;
     private Spinner mFilterSpinner;
@@ -358,6 +362,7 @@
             mFilterType =
                     savedInstanceState.getInt(EXTRA_FILTER_TYPE, AppFilterRegistry.FILTER_APPS_ALL);
             mExpandSearch = savedInstanceState.getBoolean(EXTRA_EXPAND_SEARCH_VIEW);
+            mPreQuery = savedInstanceState.getCharSequence(EXTRA_SEARCH_QUERY);
         }
 
         mInvalidSizeStr = activity.getText(R.string.invalid_size_value);
@@ -544,6 +549,7 @@
         outState.putBoolean(EXTRA_SHOW_SYSTEM, mShowSystem);
         if (mSearchView != null) {
             outState.putBoolean(EXTRA_EXPAND_SEARCH_VIEW, !mSearchView.isIconified());
+            outState.putCharSequence(EXTRA_SEARCH_QUERY, mSearchView.getQuery());
         }
         if (mApplications != null) {
             outState.putBoolean(EXTRA_HAS_ENTRIES, mApplications.mHasReceivedLoadEntries);
@@ -683,6 +689,9 @@
             if (mExpandSearch) {
                 searchMenuItem.expandActionView();
             }
+            if (!TextUtils.isEmpty(mPreQuery)) {
+                mSearchView.setQuery(mPreQuery, true);
+            }
         }
 
         updateOptionsMenu();
@@ -1176,7 +1185,7 @@
                 mSession.onResume();
                 mLastSortMode = sort;
                 if (mExtraInfoBridge != null) {
-                    mExtraInfoBridge.resume();
+                    mExtraInfoBridge.resume(false /* forceLoadAllApps */);
                 }
                 rebuild();
             } else {
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index dd16006..9403316 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -92,6 +92,7 @@
 
     private PreferenceGroup mPreferenceGroup;
     private FooterPreference mFooterPreference;
+    private boolean mFirstLaunch = true;
 
     static {
         FILTER.addAction(ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
@@ -121,6 +122,17 @@
     }
 
     @Override
+    public void updateState(Preference preference) {
+        super.updateState(preference);
+        if (mFirstLaunch) {
+            mFirstLaunch = false;
+            // When first launch, updateList() is already be called in displayPreference().
+        } else {
+            updateList();
+        }
+    }
+
+    @Override
     public void onStart() {
         mContext.registerReceiverAsUser(
                 mBroadcastReceiver, UserHandle.ALL, FILTER,
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
index 3819124..2258bf1 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminSettings.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.applications.specialaccess.deviceadmin;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGE_DEVICE_ADMIN_APPS;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.NO_DEVICE_ADMINS;
 
 import android.app.settings.SettingsEnums;
@@ -37,7 +38,8 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
-        // TODO: Replace PreferenceScreen title manage_device_admin/MANAGE_DEVICE_ADMIN_APPS
+        replaceEnterprisePreferenceScreenTitle(
+                MANAGE_DEVICE_ADMIN_APPS, R.string.manage_device_admin);
         replaceEnterpriseStringTitle("device_admin_footer",
                 NO_DEVICE_ADMINS, R.string.no_device_admins);
     }
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index e316125..b59928f 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -18,6 +18,7 @@
 import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_DATA;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.APP_CAN_ACCESS_PERSONAL_PERMISSIONS;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_APPS_SHARE_PERMISSIONS_AND_DATA;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECTED_WORK_AND_PERSONAL_APPS_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECT_APPS_DIALOG_SUMMARY;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.CONNECT_APPS_DIALOG_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.HOW_TO_DISCONNECT_APPS;
@@ -81,7 +82,6 @@
 
     private Context mContext;
     private CrossProfileApps mCrossProfileApps;
-    private DevicePolicyManager mDevicePolicyManager;
     private UserManager mUserManager;
     private RestrictedSwitchPreference mSwitchPref;
     private LayoutPreference mHeader;
@@ -101,7 +101,6 @@
 
         mContext = getContext();
         mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
-        mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
         mUserManager = mContext.getSystemService(UserManager.class);
         mPackageManager = mContext.getPackageManager();
 
@@ -115,6 +114,8 @@
 
         addPreferencesFromResource(R.xml.interact_across_profiles_permissions_details);
 
+        replaceEnterprisePreferenceScreenTitle(CONNECTED_WORK_AND_PERSONAL_APPS_TITLE,
+                R.string.interact_across_profiles_title);
         replaceEnterpriseStringSummary("interact_across_profiles_summary_1",
                 CONNECTED_APPS_SHARE_PERMISSIONS_AND_DATA,
                 R.string.interact_across_profiles_summary_1);
@@ -147,19 +148,6 @@
         logPageLaunchMetrics();
     }
 
-    private void replaceEnterpriseStringSummary(
-            String preferenceKey, String overrideKey, int resource) {
-        Preference preference = findPreference(preferenceKey);
-        if (preference == null) {
-            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
-            return;
-        }
-
-        preference.setSummary(
-                mDevicePolicyManager.getResources().getString(overrideKey,
-                        () -> getString(resource)));
-    }
-
     private void maybeShowExtraSummary() {
         Preference extraSummary = findPreference(INTERACT_ACROSS_PROFILE_EXTRA_SUMMARY_KEY);
         if (extraSummary == null) {
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
index 6ce0869..ba0d9af 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesSettings.java
@@ -53,7 +53,6 @@
     private Context mContext;
     private PackageManager mPackageManager;
     private UserManager mUserManager;
-    private DevicePolicyManager mDevicePolicyManager;
     private CrossProfileApps mCrossProfileApps;
     private IconDrawableFactory mIconDrawableFactory;
 
@@ -66,7 +65,6 @@
         mUserManager = mContext.getSystemService(UserManager.class);
         mIconDrawableFactory = IconDrawableFactory.newInstance(mContext);
         mCrossProfileApps = mContext.getSystemService(CrossProfileApps.class);
-        mDevicePolicyManager = mContext.getSystemService(DevicePolicyManager.class);
     }
 
     @Override
@@ -76,6 +74,9 @@
         final PreferenceScreen screen = getPreferenceScreen();
         screen.removeAll();
 
+        replaceEnterprisePreferenceScreenTitle(CONNECTED_WORK_AND_PERSONAL_APPS_TITLE,
+                R.string.interact_across_profiles_title);
+
         final ArrayList<Pair<ApplicationInfo, UserHandle>> crossProfileApps =
                 collectConfigurableApps(mPackageManager, mUserManager, mCrossProfileApps);
 
diff --git a/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsAccess.java b/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsAccess.java
index 3df19be..54ac63e 100644
--- a/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsAccess.java
+++ b/src/com/android/settings/applications/specialaccess/premiumsms/PremiumSmsAccess.java
@@ -74,7 +74,7 @@
     @Override
     public void onResume() {
         super.onResume();
-        mSmsBackend.resume();
+        mSmsBackend.resume(true /* forceLoadAllApps */);
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 74e844a..7bfe615 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -57,7 +57,7 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.fingerprint_enroll_finish);
         setHeaderText(R.string.security_settings_fingerprint_enroll_finish_title);
-        setDescriptionText(R.string.security_settings_fingerprint_enroll_finish_message);
+        setDescriptionText(R.string.security_settings_fingerprint_enroll_finish_v2_message);
 
         mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
         mFooterBarMixin.setSecondaryButton(
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index 2282192..408f859 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -145,6 +145,7 @@
         private Drawable mHighlightDrawable;
         private int mUserId;
         private CharSequence mFooterTitle;
+        private View.OnClickListener mLearnMoreListener = null;
         private boolean mEnrollClicked;
 
         private long mChallenge;
@@ -372,9 +373,8 @@
 
                 mFooterTitle = AnnotationSpan.linkify(footerText, linkInfo, adminLinkInfo);
             } else {
-                mFooterTitle = AnnotationSpan.linkify(
-                        getText(R.string.security_settings_fingerprint_v2_home_screen),
-                        linkInfo, adminLinkInfo);
+                mFooterTitle = getText(R.string.security_settings_fingerprint_v2_home_screen_text);
+                mLearnMoreListener = (v) -> activity.startActivityForResult(helpIntent, 0);
             }
 
 
@@ -474,8 +474,12 @@
             if (context == null) {
                 return;
             }
-            root.addPreference(new FooterPreference.Builder(context).setTitle(
-                    mFooterTitle).build());
+            final FooterPreference footer = new FooterPreference.Builder(context)
+                    .setTitle(mFooterTitle).build();
+            if (mLearnMoreListener != null) {
+                footer.setLearnMoreAction(mLearnMoreListener);
+            }
+            root.addPreference(footer);
         }
 
         private static String genKey(int id) {
diff --git a/src/com/android/settings/bluetooth/BluetoothBroadcastSourcePreference.java b/src/com/android/settings/bluetooth/BluetoothBroadcastSourcePreference.java
new file mode 100644
index 0000000..17b604c
--- /dev/null
+++ b/src/com/android/settings/bluetooth/BluetoothBroadcastSourcePreference.java
@@ -0,0 +1,141 @@
+/*
+ * 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.bluetooth;
+
+import android.bluetooth.BluetoothLeBroadcastMetadata;
+import android.bluetooth.BluetoothLeBroadcastSubgroup;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settingslib.Utils;
+
+import java.util.List;
+
+/**
+ * Preference to display a broadcast source in the Broadcast Source List.
+ */
+class BluetoothBroadcastSourcePreference extends Preference {
+
+    private static final int RESOURCE_ID_UNKNOWN_PROGRAM_INFO = R.string.device_info_default;
+    private static final int RESOURCE_ID_ICON = R.drawable.settings_input_antenna;
+
+    private BluetoothLeBroadcastMetadata mBluetoothLeBroadcastMetadata;
+    private ImageView mFrictionImageView;
+    private String mTitle;
+    private boolean mStatus;
+    private boolean mIsEncrypted;
+
+    BluetoothBroadcastSourcePreference(@NonNull Context context,
+            @NonNull BluetoothLeBroadcastMetadata source) {
+        super(context);
+        initUi();
+        updateMetadataAndRefreshUi(source, false);
+    }
+
+    @Override
+    public void onBindViewHolder(final PreferenceViewHolder view) {
+        super.onBindViewHolder(view);
+        view.findViewById(R.id.two_target_divider).setVisibility(View.INVISIBLE);
+        final ImageButton imageButton = (ImageButton) view.findViewById(R.id.icon_button);
+        imageButton.setVisibility(View.GONE);
+        mFrictionImageView = (ImageView) view.findViewById(R.id.friction_icon);
+        updateStatusButton();
+    }
+
+    private void initUi() {
+        setLayoutResource(R.layout.preference_access_point);
+        setWidgetLayoutResource(R.layout.access_point_friction_widget);
+
+        mStatus = false;
+        final Drawable drawable = getContext().getDrawable(RESOURCE_ID_ICON);
+        if (drawable != null) {
+            drawable.setTint(Utils.getColorAttrDefaultColor(getContext(),
+                    android.R.attr.colorControlNormal));
+            setIcon(drawable);
+        }
+    }
+
+    private void updateStatusButton() {
+        if (mFrictionImageView == null) {
+            return;
+        }
+        if (mStatus || mIsEncrypted) {
+            Drawable drawable;
+            if (mStatus) {
+                drawable = getContext().getDrawable(R.drawable.bluetooth_broadcast_dialog_done);
+            } else {
+                drawable = getContext().getDrawable(R.drawable.ic_friction_lock_closed);
+            }
+            if (drawable != null) {
+                drawable.setTint(Utils.getColorAttrDefaultColor(getContext(),
+                        android.R.attr.colorControlNormal));
+                mFrictionImageView.setImageDrawable(drawable);
+            }
+            mFrictionImageView.setVisibility(View.VISIBLE);
+        } else {
+            mFrictionImageView.setVisibility(View.GONE);
+        }
+    }
+
+    /**
+     * Updates the title and status from BluetoothLeBroadcastMetadata.
+     */
+    public void updateMetadataAndRefreshUi(BluetoothLeBroadcastMetadata source, boolean status) {
+        mBluetoothLeBroadcastMetadata = source;
+        mTitle = getBroadcastMetadataProgramInfo();
+        mIsEncrypted = mBluetoothLeBroadcastMetadata.isEncrypted();
+        mStatus = status;
+
+        refresh();
+    }
+
+    /**
+     * Gets the BluetoothLeBroadcastMetadata.
+     */
+    public BluetoothLeBroadcastMetadata getBluetoothLeBroadcastMetadata() {
+        return mBluetoothLeBroadcastMetadata;
+    }
+
+    private void refresh() {
+        setTitle(mTitle);
+        updateStatusButton();
+    }
+
+    private String getBroadcastMetadataProgramInfo() {
+        if (mBluetoothLeBroadcastMetadata == null) {
+            return getContext().getString(RESOURCE_ID_UNKNOWN_PROGRAM_INFO);
+        }
+        final List<BluetoothLeBroadcastSubgroup> subgroups =
+                mBluetoothLeBroadcastMetadata.getSubgroups();
+        if (subgroups.isEmpty()) {
+            return getContext().getString(RESOURCE_ID_UNKNOWN_PROGRAM_INFO);
+        }
+        return subgroups.stream()
+                .map(i -> i.getContentMetadata().getProgramInfo())
+                .filter(i -> !TextUtils.isEmpty(i))
+                .findFirst().orElse(getContext().getString(RESOURCE_ID_UNKNOWN_PROGRAM_INFO));
+    }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java
index f251db5..07a3156 100644
--- a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java
+++ b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsFragment.java
@@ -19,33 +19,53 @@
 import static android.bluetooth.BluetoothDevice.BOND_NONE;
 import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
 
+import android.app.AlertDialog;
 import android.app.settings.SettingsEnums;
 import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothLeBroadcastAssistant;
+import android.bluetooth.BluetoothLeBroadcastMetadata;
+import android.bluetooth.BluetoothLeBroadcastReceiveState;
+import android.bluetooth.le.ScanFilter;
 import android.content.Context;
+import android.os.Bundle;
 import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.EditText;
+import android.widget.TextView;
 
+import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
 
 import com.android.settings.R;
 import com.android.settings.dashboard.RestrictedDashboardFragment;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
+import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
 import com.android.settingslib.core.AbstractPreferenceController;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
 
 /**
  * This fragment allowed users to find the nearby broadcast sources.
  */
 public class BluetoothFindBroadcastsFragment extends RestrictedDashboardFragment {
 
-    private static final String TAG = "BTFindBroadcastsFrg";
+    private static final String TAG = "BtFindBroadcastsFrg";
 
     public static final String KEY_DEVICE_ADDRESS = "device_address";
-
-    public static final String PREF_KEY_BROADCAST_SOURCE = "broadcast_source";
+    public static final String PREF_KEY_BROADCAST_SOURCE_LIST = "broadcast_source_list";
 
     @VisibleForTesting
     String mDeviceAddress;
@@ -53,6 +73,91 @@
     LocalBluetoothManager mManager;
     @VisibleForTesting
     CachedBluetoothDevice mCachedDevice;
+    @VisibleForTesting
+    PreferenceCategory mBroadcastSourceListCategory;
+    BluetoothFindBroadcastsHeaderController mBluetoothFindBroadcastsHeaderController;
+    private LocalBluetoothLeBroadcastAssistant mLeBroadcastAssistant;
+    private BluetoothBroadcastSourcePreference mSelectedPreference;
+    private Executor mExecutor;
+    private int mSourceId;
+
+    private BluetoothLeBroadcastAssistant.Callback mBroadcastAssistantCallback =
+            new BluetoothLeBroadcastAssistant.Callback() {
+                @Override
+                public void onSearchStarted(int reason) {
+                    Log.d(TAG, "onSearchStarted: " + reason);
+
+                    getActivity().runOnUiThread(
+                            () -> cacheRemoveAllPrefs(mBroadcastSourceListCategory));
+                }
+
+                @Override
+                public void onSearchStartFailed(int reason) {
+                    Log.d(TAG, "onSearchStartFailed: " + reason);
+                }
+
+                @Override
+                public void onSearchStopped(int reason) {
+                    Log.d(TAG, "onSearchStopped: " + reason);
+                }
+
+                @Override
+                public void onSearchStopFailed(int reason) {
+                    Log.d(TAG, "onSearchStopFailed: " + reason);
+                }
+
+                @Override
+                public void onSourceFound(@NonNull BluetoothLeBroadcastMetadata source) {
+                    Log.d(TAG, "onSourceFound:");
+                    getActivity().runOnUiThread(() -> updateListCategory(source, false));
+                }
+
+                @Override
+                public void onSourceAdded(@NonNull BluetoothDevice sink, int sourceId, int reason) {
+                    setSourceId(sourceId);
+                    if (mSelectedPreference == null) {
+                        Log.w(TAG, "onSourceAdded: mSelectedPreference == null!");
+                        return;
+                    }
+                    getActivity().runOnUiThread(() -> updateListCategory(
+                            mSelectedPreference.getBluetoothLeBroadcastMetadata(), true));
+                }
+
+                @Override
+                public void onSourceAddFailed(@NonNull BluetoothDevice sink,
+                        @NonNull BluetoothLeBroadcastMetadata source, int reason) {
+                    mSelectedPreference = null;
+                    Log.d(TAG, "onSourceAddFailed: clear the mSelectedPreference.");
+                }
+
+                @Override
+                public void onSourceModified(@NonNull BluetoothDevice sink, int sourceId,
+                        int reason) {
+                }
+
+                @Override
+                public void onSourceModifyFailed(@NonNull BluetoothDevice sink, int sourceId,
+                        int reason) {
+                }
+
+                @Override
+                public void onSourceRemoved(@NonNull BluetoothDevice sink, int sourceId,
+                        int reason) {
+                    Log.d(TAG, "onSourceRemoved:");
+                }
+
+                @Override
+                public void onSourceRemoveFailed(@NonNull BluetoothDevice sink, int sourceId,
+                        int reason) {
+                    Log.d(TAG, "onSourceRemoveFailed:");
+                }
+
+                @Override
+                public void onReceiveStateChanged(@NonNull BluetoothDevice sink, int sourceId,
+                        @NonNull BluetoothLeBroadcastReceiveState state) {
+                    Log.d(TAG, "onReceiveStateChanged:");
+                }
+            };
 
     public BluetoothFindBroadcastsFragment() {
         super(DISALLOW_CONFIG_BLUETOOTH);
@@ -75,19 +180,50 @@
         mDeviceAddress = getArguments().getString(KEY_DEVICE_ADDRESS);
         mManager = getLocalBluetoothManager(context);
         mCachedDevice = getCachedDevice(mDeviceAddress);
+        mLeBroadcastAssistant = getLeBroadcastAssistant();
+        mExecutor = Executors.newSingleThreadExecutor();
+
         super.onAttach(context);
-        if (mCachedDevice == null) {
+        if (mCachedDevice == null || mLeBroadcastAssistant == null) {
             //Close this page if device is null with invalid device mac address
-            Log.w(TAG, "onAttach() CachedDevice is null!");
+            //or if the device does not have LeBroadcastAssistant profile
+            Log.w(TAG, "onAttach() CachedDevice or LeBroadcastAssistant is null!");
             finish();
             return;
         }
     }
 
     @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        mBroadcastSourceListCategory = findPreference(PREF_KEY_BROADCAST_SOURCE_LIST);
+    }
+
+    @Override
+    public void onStart() {
+        super.onStart();
+        if (mLeBroadcastAssistant != null) {
+            mLeBroadcastAssistant.registerServiceCallBack(mExecutor, mBroadcastAssistantCallback);
+        }
+    }
+
+    @Override
     public void onResume() {
         super.onResume();
         finishFragmentIfNecessary();
+        //check assistant status. Start searching...
+        if (mLeBroadcastAssistant != null && !mLeBroadcastAssistant.isSearchInProgress()) {
+            mLeBroadcastAssistant.startSearchingForSources(getScanFilter());
+        }
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+        if (mLeBroadcastAssistant != null) {
+            mLeBroadcastAssistant.unregisterServiceCallBack(mBroadcastAssistantCallback);
+        }
     }
 
     @VisibleForTesting
@@ -104,6 +240,28 @@
         return SettingsEnums.PAGE_UNKNOWN;
     }
 
+    /**
+     * Starts to scan broadcast source by the BluetoothLeBroadcastAssistant.
+     */
+    public void scanBroadcastSource() {
+        if (mLeBroadcastAssistant == null) {
+            Log.w(TAG, "scanBroadcastSource: LeBroadcastAssistant is null!");
+            return;
+        }
+        mLeBroadcastAssistant.startSearchingForSources(getScanFilter());
+    }
+
+    /**
+     * Leaves the broadcast source by the BluetoothLeBroadcastAssistant.
+     */
+    public void leaveBroadcastSession() {
+        if (mLeBroadcastAssistant == null || mCachedDevice == null) {
+            Log.w(TAG, "leaveBroadcastSession: LeBroadcastAssistant or CachedDevice is null!");
+            return;
+        }
+        mLeBroadcastAssistant.removeSource(mCachedDevice.getDevice(), getSourceId());
+    }
+
     @Override
     protected String getLogTag() {
         return TAG;
@@ -120,9 +278,125 @@
 
         if (mCachedDevice != null) {
             Lifecycle lifecycle = getSettingsLifecycle();
-            controllers.add(new BluetoothFindBroadcastsHeaderController(context, this,
-                    mCachedDevice, lifecycle, mManager));
+            mBluetoothFindBroadcastsHeaderController = new BluetoothFindBroadcastsHeaderController(
+                    context, this, mCachedDevice, lifecycle, mManager);
+            controllers.add(mBluetoothFindBroadcastsHeaderController);
         }
         return controllers;
     }
+
+    /**
+     * Gets the LocalBluetoothLeBroadcastAssistant
+     * @return the LocalBluetoothLeBroadcastAssistant
+     */
+    public LocalBluetoothLeBroadcastAssistant getLeBroadcastAssistant() {
+        if (mManager == null) {
+            Log.w(TAG, "getLeBroadcastAssistant: LocalBluetoothManager is null!");
+            return null;
+        }
+
+        LocalBluetoothProfileManager profileManager = mManager.getProfileManager();
+        if (profileManager == null) {
+            Log.w(TAG, "getLeBroadcastAssistant: LocalBluetoothProfileManager is null!");
+            return null;
+        }
+
+        return profileManager.getLeAudioBroadcastAssistantProfile();
+    }
+
+    private List<ScanFilter> getScanFilter() {
+        // Currently there is no function for setting the ScanFilter. It may have this function
+        // in the further.
+        return Collections.emptyList();
+    }
+
+    private void updateListCategory(BluetoothLeBroadcastMetadata source, boolean isConnected) {
+        BluetoothBroadcastSourcePreference item = mBroadcastSourceListCategory.findPreference(
+                Integer.toString(source.getBroadcastId()));
+        if (item == null) {
+            item = createBluetoothBroadcastSourcePreference(source);
+            mBroadcastSourceListCategory.addPreference(item);
+        }
+        item.updateMetadataAndRefreshUi(source, isConnected);
+        item.setOrder(isConnected ? 0 : 1);
+
+        //refresh the header
+        if (mBluetoothFindBroadcastsHeaderController != null) {
+            mBluetoothFindBroadcastsHeaderController.refreshUi();
+        }
+    }
+
+    private BluetoothBroadcastSourcePreference createBluetoothBroadcastSourcePreference(
+            BluetoothLeBroadcastMetadata source) {
+        BluetoothBroadcastSourcePreference pref = new BluetoothBroadcastSourcePreference(
+                getContext(), source);
+        pref.setKey(Integer.toString(source.getBroadcastId()));
+        pref.setOnPreferenceClickListener(preference -> {
+            if (source.isEncrypted()) {
+                launchBroadcastCodeDialog(pref);
+            } else {
+                addSource(pref);
+            }
+            return true;
+        });
+        return pref;
+    }
+
+    private void addSource(BluetoothBroadcastSourcePreference pref) {
+        if (mLeBroadcastAssistant == null || mCachedDevice == null) {
+            Log.w(TAG, "addSource: LeBroadcastAssistant or CachedDevice is null!");
+            return;
+        }
+        if (mSelectedPreference != null) {
+            // The previous preference status set false after user selects the new Preference.
+            getActivity().runOnUiThread(
+                    () -> {
+                        mSelectedPreference.updateMetadataAndRefreshUi(
+                                mSelectedPreference.getBluetoothLeBroadcastMetadata(), false);
+                        mSelectedPreference.setOrder(1);
+                    });
+        }
+        mSelectedPreference = pref;
+        mLeBroadcastAssistant.addSource(mCachedDevice.getDevice(),
+                pref.getBluetoothLeBroadcastMetadata(), true);
+    }
+
+    private void addBroadcastCodeIntoPreference(BluetoothBroadcastSourcePreference pref,
+            String broadcastCode) {
+        BluetoothLeBroadcastMetadata metadata =
+                new BluetoothLeBroadcastMetadata.Builder(pref.getBluetoothLeBroadcastMetadata())
+                        .setBroadcastCode(broadcastCode.getBytes(StandardCharsets.UTF_8))
+                        .build();
+        pref.updateMetadataAndRefreshUi(metadata, false);
+    }
+
+    private void launchBroadcastCodeDialog(BluetoothBroadcastSourcePreference pref) {
+        final View layout = LayoutInflater.from(getContext()).inflate(
+                R.layout.bluetooth_find_broadcast_password_dialog, null);
+        final TextView broadcastName = layout.requireViewById(R.id.broadcast_name_text);
+        final EditText editText = layout.requireViewById(R.id.broadcast_edit_text);
+        broadcastName.setText(pref.getTitle());
+        AlertDialog alertDialog = new AlertDialog.Builder(getContext())
+                .setTitle(R.string.find_broadcast_password_dialog_title)
+                .setView(layout)
+                .setNeutralButton(android.R.string.cancel, null)
+                .setPositiveButton(R.string.bluetooth_connect_access_dialog_positive,
+                        (d, w) -> {
+                            Log.d(TAG, "setPositiveButton: clicked");
+                            addBroadcastCodeIntoPreference(pref, editText.getText().toString());
+                            addSource(pref);
+                        })
+                .create();
+
+        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
+        alertDialog.show();
+    }
+
+    public int getSourceId() {
+        return mSourceId;
+    }
+
+    public void setSourceId(int sourceId) {
+        mSourceId = sourceId;
+    }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java
index dfdcae0..1527f21 100644
--- a/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothFindBroadcastsHeaderController.java
@@ -16,22 +16,24 @@
 
 package com.android.settings.bluetooth;
 
+import android.bluetooth.BluetoothProfile;
 import android.content.Context;
-import android.util.Log;
+import android.content.Intent;
 import android.view.View;
 import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import androidx.preference.PreferenceCategory;
-import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
+import com.android.settingslib.bluetooth.BluetoothBroadcastUtils;
 import com.android.settingslib.bluetooth.CachedBluetoothDevice;
+import com.android.settingslib.bluetooth.LocalBluetoothLeBroadcastAssistant;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
 import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.qrcode.QrCodeScanModeActivity;
 import com.android.settingslib.widget.LayoutPreference;
 
 /**
@@ -52,11 +54,12 @@
     LinearLayout mBtnBroadcastLayout;
     Button mBtnLeaveBroadcast;
     Button mBtnScanQrCode;
-
+    BluetoothFindBroadcastsFragment mBluetoothFindBroadcastsFragment;
     public BluetoothFindBroadcastsHeaderController(Context context,
-            PreferenceFragmentCompat fragment, CachedBluetoothDevice device, Lifecycle lifecycle,
-            LocalBluetoothManager bluetoothManager) {
+            BluetoothFindBroadcastsFragment fragment, CachedBluetoothDevice device,
+            Lifecycle lifecycle, LocalBluetoothManager bluetoothManager) {
         super(context, fragment, device, lifecycle);
+        mBluetoothFindBroadcastsFragment = fragment;
     }
 
     @Override
@@ -101,20 +104,41 @@
             mBtnFindBroadcast.setVisibility(View.VISIBLE);
             mBtnBroadcastLayout.setVisibility(View.GONE);
         }
+
+        mBtnLeaveBroadcast.setEnabled(false);
+        if (mBluetoothFindBroadcastsFragment != null && mCachedDevice != null) {
+            LocalBluetoothLeBroadcastAssistant broadcastAssistant =
+                    mBluetoothFindBroadcastsFragment.getLeBroadcastAssistant();
+            if (broadcastAssistant != null
+                    && broadcastAssistant.getConnectionStatus(mCachedDevice.getDevice())
+                    == BluetoothProfile.STATE_CONNECTED) {
+                mBtnLeaveBroadcast.setEnabled(true);
+            }
+        }
     }
 
     private void scanBroadcastSource() {
-        // TODO(b/228258236) : Call the LocalBluetoothLeBroadcastAssistant
-        //  to start searching for source
+        // TODO(b/231543455) : Using the BluetoothDeviceUpdater to refactor it.
+        if (mBluetoothFindBroadcastsFragment == null) {
+            return;
+        }
+        mBluetoothFindBroadcastsFragment.scanBroadcastSource();
     }
 
     private void leaveBroadcastSession() {
-        // TODO(b/228258236) : Call the LocalBluetoothLeBroadcastAssistant
-        //  to leave the broadcast session
+        if (mBluetoothFindBroadcastsFragment == null) {
+            return;
+        }
+        mBluetoothFindBroadcastsFragment.leaveBroadcastSession();
     }
 
     private void launchQrCodeScanner() {
-        // TODO(b/228259065) : Launch the QR code scanner page by intent
+        final Intent intent = new Intent(mContext, QrCodeScanModeActivity.class);
+        intent.setAction(BluetoothBroadcastUtils.ACTION_BLUETOOTH_LE_AUDIO_QR_CODE_SCANNER)
+                .putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_SINK_IS_GROUP, false)
+                .putExtra(BluetoothBroadcastUtils.EXTRA_BLUETOOTH_DEVICE_SINK,
+                        mCachedDevice.getDevice());
+        mContext.startActivity(intent);
     }
 
     @Override
@@ -128,4 +152,11 @@
     public String getPreferenceKey() {
         return KEY_BROADCAST_HEADER;
     }
+
+    /**
+     * Updates the UI
+     */
+    public void refreshUi() {
+        updateHeaderLayout();
+    }
 }
diff --git a/src/com/android/settings/core/CategoryMixin.java b/src/com/android/settings/core/CategoryMixin.java
index 8d0a412..151ed7b 100644
--- a/src/com/android/settings/core/CategoryMixin.java
+++ b/src/com/android/settings/core/CategoryMixin.java
@@ -58,6 +58,7 @@
     private final PackageReceiver mPackageReceiver = new PackageReceiver();
     private final List<CategoryListener> mCategoryListeners = new ArrayList<>();
     private int mCategoriesUpdateTaskCount;
+    private boolean mFirstOnResume = true;
 
     public CategoryMixin(Context context) {
         mContext = context;
@@ -75,6 +76,12 @@
         filter.addDataScheme(DATA_SCHEME_PKG);
         mContext.registerReceiver(mPackageReceiver, filter);
 
+        if (mFirstOnResume) {
+            // Skip since all tiles have been refreshed in DashboardFragment.onCreatePreferences().
+            Log.d(TAG, "Skip categories update");
+            mFirstOnResume = false;
+            return;
+        }
         updateCategories();
     }
 
diff --git a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
index 8ad66d2..2ae2057 100644
--- a/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
+++ b/src/com/android/settings/dashboard/DashboardFeatureProviderImpl.java
@@ -235,13 +235,13 @@
             public void onDataChanged() {
                 switch (method) {
                     case METHOD_GET_DYNAMIC_TITLE:
-                        refreshTitle(uri, pref);
+                        refreshTitle(uri, pref, this);
                         break;
                     case METHOD_GET_DYNAMIC_SUMMARY:
-                        refreshSummary(uri, pref);
+                        refreshSummary(uri, pref, this);
                         break;
                     case METHOD_IS_CHECKED:
-                        refreshSwitch(uri, pref);
+                        refreshSwitch(uri, pref, this);
                         break;
                 }
             }
@@ -262,19 +262,18 @@
 
             final Uri uri = TileUtils.getCompleteUri(tile, META_DATA_PREFERENCE_TITLE_URI,
                     METHOD_GET_DYNAMIC_TITLE);
-            refreshTitle(uri, preference);
             return createDynamicDataObserver(METHOD_GET_DYNAMIC_TITLE, uri, preference);
         }
         return null;
     }
 
-    private void refreshTitle(Uri uri, Preference preference) {
+    private void refreshTitle(Uri uri, Preference preference, DynamicDataObserver observer) {
         ThreadUtils.postOnBackgroundThread(() -> {
             final Map<String, IContentProvider> providerMap = new ArrayMap<>();
             final String titleFromUri = TileUtils.getTextFromUri(
                     mContext, uri, providerMap, META_DATA_PREFERENCE_TITLE);
             if (!TextUtils.equals(titleFromUri, preference.getTitle())) {
-                ThreadUtils.postOnMainThread(() -> preference.setTitle(titleFromUri));
+                observer.post(() -> preference.setTitle(titleFromUri));
             }
         });
     }
@@ -291,19 +290,18 @@
 
             final Uri uri = TileUtils.getCompleteUri(tile, META_DATA_PREFERENCE_SUMMARY_URI,
                     METHOD_GET_DYNAMIC_SUMMARY);
-            refreshSummary(uri, preference);
             return createDynamicDataObserver(METHOD_GET_DYNAMIC_SUMMARY, uri, preference);
         }
         return null;
     }
 
-    private void refreshSummary(Uri uri, Preference preference) {
+    private void refreshSummary(Uri uri, Preference preference, DynamicDataObserver observer) {
         ThreadUtils.postOnBackgroundThread(() -> {
             final Map<String, IContentProvider> providerMap = new ArrayMap<>();
             final String summaryFromUri = TileUtils.getTextFromUri(
                     mContext, uri, providerMap, META_DATA_PREFERENCE_SUMMARY);
             if (!TextUtils.equals(summaryFromUri, preference.getSummary())) {
-                ThreadUtils.postOnMainThread(() -> preference.setSummary(summaryFromUri));
+                observer.post(() -> preference.setSummary(summaryFromUri));
             }
         });
     }
@@ -323,7 +321,6 @@
         final Uri isCheckedUri = TileUtils.getCompleteUri(tile, META_DATA_PREFERENCE_SWITCH_URI,
                 METHOD_IS_CHECKED);
         setSwitchEnabled(preference, false);
-        refreshSwitch(isCheckedUri, preference);
         return createDynamicDataObserver(METHOD_IS_CHECKED, isCheckedUri, preference);
     }
 
@@ -350,12 +347,12 @@
         });
     }
 
-    private void refreshSwitch(Uri uri, Preference preference) {
+    private void refreshSwitch(Uri uri, Preference preference, DynamicDataObserver observer) {
         ThreadUtils.postOnBackgroundThread(() -> {
             final Map<String, IContentProvider> providerMap = new ArrayMap<>();
             final boolean checked = TileUtils.getBooleanFromUri(mContext, uri, providerMap,
                     EXTRA_SWITCH_CHECKED_STATE);
-            ThreadUtils.postOnMainThread(() -> {
+            observer.post(() -> {
                 setSwitchChecked(preference, checked);
                 setSwitchEnabled(preference, true);
             });
diff --git a/src/com/android/settings/dashboard/DashboardFragment.java b/src/com/android/settings/dashboard/DashboardFragment.java
index aaa9b3d..fb0a09d 100644
--- a/src/com/android/settings/dashboard/DashboardFragment.java
+++ b/src/com/android/settings/dashboard/DashboardFragment.java
@@ -16,7 +16,6 @@
 package com.android.settings.dashboard;
 
 import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -57,6 +56,8 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Base fragment for dashboard style UI containing a list of static and dynamic setting items.
@@ -66,6 +67,7 @@
         BasePreferenceController.UiBlockListener {
     public static final String CATEGORY = "category";
     private static final String TAG = "DashboardFragment";
+    private static final long TIMEOUT_MILLIS = 50L;
 
     @VisibleForTesting
     final ArrayMap<String, List<DynamicDataObserver>> mDashboardTilePrefKeys = new ArrayMap<>();
@@ -79,7 +81,6 @@
     private DashboardTilePlaceholderPreferenceController mPlaceholderPreferenceController;
     private boolean mListeningToCategoryChange;
     private List<String> mSuppressInjectedTileKeys;
-    private DevicePolicyManager mDevicePolicyManager;
 
     @Override
     public void onAttach(Context context) {
@@ -154,7 +155,6 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
-        mDevicePolicyManager = getSystemService(DevicePolicyManager.class);
         // Set ComparisonCallback so we get better animation when list changes.
         getPreferenceManager().setPreferenceComparisonCallback(
                 new PreferenceManager.SimplePreferenceComparisonCallback());
@@ -463,8 +463,9 @@
         // Create a list to track which tiles are to be removed.
         final Map<String, List<DynamicDataObserver>> remove = new ArrayMap(mDashboardTilePrefKeys);
 
-        // Install dashboard tiles.
+        // Install dashboard tiles and collect pending observers.
         final boolean forceRoundedIcons = shouldForceRoundedIcon();
+        final List<DynamicDataObserver> pendingObservers = new ArrayList<>();
         for (Tile tile : tiles) {
             final String key = mDashboardFeatureProvider.getDashboardKeyForTile(tile);
             if (TextUtils.isEmpty(key)) {
@@ -474,26 +475,30 @@
             if (!displayTile(tile)) {
                 continue;
             }
+            final List<DynamicDataObserver> observers;
             if (mDashboardTilePrefKeys.containsKey(key)) {
                 // Have the key already, will rebind.
                 final Preference preference = screen.findPreference(key);
-                mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(getActivity(), this,
-                        forceRoundedIcons, preference, tile, key,
+                observers = mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(
+                        getActivity(), this, forceRoundedIcons, preference, tile, key,
                         mPlaceholderPreferenceController.getOrder());
             } else {
                 // Don't have this key, add it.
                 final Preference pref = createPreference(tile);
-                final List<DynamicDataObserver> observers =
-                        mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(getActivity(),
-                                this, forceRoundedIcons, pref, tile, key,
-                                mPlaceholderPreferenceController.getOrder());
+                observers = mDashboardFeatureProvider.bindPreferenceToTileAndGetObservers(
+                        getActivity(), this, forceRoundedIcons, pref, tile, key,
+                        mPlaceholderPreferenceController.getOrder());
                 screen.addPreference(pref);
                 registerDynamicDataObservers(observers);
                 mDashboardTilePrefKeys.put(key, observers);
             }
+            if (observers != null) {
+                pendingObservers.addAll(observers);
+            }
             remove.remove(key);
         }
-        // Finally remove tiles that are gone.
+
+        // Remove tiles that are gone.
         for (Map.Entry<String, List<DynamicDataObserver>> entry : remove.entrySet()) {
             final String key = entry.getKey();
             mDashboardTilePrefKeys.remove(key);
@@ -503,6 +508,20 @@
             }
             unregisterDynamicDataObservers(entry.getValue());
         }
+
+        // Wait for pending observers to update UI.
+        if (!pendingObservers.isEmpty()) {
+            final CountDownLatch mainLatch = new CountDownLatch(1);
+            new Thread(() -> {
+                pendingObservers.forEach(observer ->
+                        awaitObserverLatch(observer.getCountDownLatch()));
+                mainLatch.countDown();
+            }).start();
+            Log.d(tag, "Start waiting observers");
+            awaitObserverLatch(mainLatch);
+            Log.d(tag, "Stop waiting observers");
+            pendingObservers.forEach(DynamicDataObserver::updateUi);
+        }
     }
 
     @Override
@@ -549,29 +568,11 @@
         });
     }
 
-    protected void replaceEnterpriseStringTitle(
-            String preferenceKey, String overrideKey, int resource) {
-        Preference preference = findPreference(preferenceKey);
-        if (preference == null) {
-            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
-            return;
+    private void awaitObserverLatch(CountDownLatch latch) {
+        try {
+            latch.await(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
+        } catch (InterruptedException e) {
+            // Do nothing
         }
-
-        preference.setTitle(
-                mDevicePolicyManager.getResources().getString(overrideKey,
-                        () -> getString(resource)));
-    }
-
-    protected void replaceEnterpriseStringSummary(
-            String preferenceKey, String overrideKey, int resource) {
-        Preference preference = findPreference(preferenceKey);
-        if (preference == null) {
-            Log.d(TAG, "Could not find enterprise preference " + preferenceKey);
-            return;
-        }
-
-        preference.setSummary(
-                mDevicePolicyManager.getResources().getString(overrideKey,
-                        () -> getString(resource)));
     }
 }
diff --git a/src/com/android/settings/dashboard/DynamicDataObserver.java b/src/com/android/settings/dashboard/DynamicDataObserver.java
index f5299be..41bc563 100644
--- a/src/com/android/settings/dashboard/DynamicDataObserver.java
+++ b/src/com/android/settings/dashboard/DynamicDataObserver.java
@@ -20,13 +20,24 @@
 import android.os.Handler;
 import android.os.Looper;
 
+import com.android.settingslib.utils.ThreadUtils;
+
+import java.util.concurrent.CountDownLatch;
+
 /**
  * Observer for updating injected dynamic data.
  */
 public abstract class DynamicDataObserver extends ContentObserver {
 
+    private Runnable mUpdateRunnable;
+    private CountDownLatch mCountDownLatch;
+    private boolean mUpdateDelegated;
+
     protected DynamicDataObserver() {
         super(new Handler(Looper.getMainLooper()));
+        mCountDownLatch = new CountDownLatch(1);
+        // Load data for the first time
+        onDataChanged();
     }
 
     /** Returns the uri of the callback. */
@@ -35,8 +46,30 @@
     /** Called when data changes. */
     public abstract void onDataChanged();
 
+    /** Calls the runnable to update UI */
+    public synchronized void updateUi() {
+        mUpdateDelegated = true;
+        if (mUpdateRunnable != null) {
+            mUpdateRunnable.run();
+        }
+    }
+
+    /** Returns the count-down latch */
+    public CountDownLatch getCountDownLatch() {
+        return mCountDownLatch;
+    }
+
     @Override
     public void onChange(boolean selfChange) {
         onDataChanged();
     }
+
+    protected synchronized void post(Runnable runnable) {
+        if (mUpdateDelegated) {
+            ThreadUtils.postOnMainThread(runnable);
+        } else {
+            mUpdateRunnable = runnable;
+            mCountDownLatch.countDown();
+        }
+    }
 }
diff --git a/src/com/android/settings/dashboard/profileselector/UserAdapter.java b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
index 2573d11..e88b9cb 100644
--- a/src/com/android/settings/dashboard/profileselector/UserAdapter.java
+++ b/src/com/android/settings/dashboard/profileselector/UserAdapter.java
@@ -120,7 +120,7 @@
     private void bindViewHolder(ViewHolder holder, int position) {
         UserDetails userDetails = getItem(position);
         holder.getIconView().setImageDrawable(userDetails.mIcon);
-        holder.getTitleView().setText(userDetails.mTitle);
+        holder.setTitle(userDetails.mTitle);
     }
 
     @Override
@@ -206,18 +206,19 @@
     static class ViewHolder extends RecyclerView.ViewHolder {
         private final ImageView mIconView;
         private final TextView mTitleView;
+        private final View mButtonView;
 
         private ViewHolder(View view) {
             super(view);
             mIconView = view.findViewById(android.R.id.icon);
             mTitleView = view.findViewById(android.R.id.title);
+            mButtonView = view.findViewById(R.id.button);
         }
 
         private ViewHolder(View view, OnClickListener onClickListener) {
             this(view);
-            View button = view.findViewById(R.id.button);
-            if (button != null) {
-                button.setOnClickListener(v -> onClickListener.onClick(getAdapterPosition()));
+            if (mButtonView != null) {
+                mButtonView.setOnClickListener(v -> onClickListener.onClick(getAdapterPosition()));
             }
         }
 
@@ -225,8 +226,11 @@
             return mIconView;
         }
 
-        private TextView getTitleView() {
-            return mTitleView;
+        private void setTitle(CharSequence title) {
+            mTitleView.setText(title);
+            if (mButtonView != null) {
+                mButtonView.setContentDescription(title);
+            }
         }
     }
 
diff --git a/src/com/android/settings/datausage/DataSaverSummary.java b/src/com/android/settings/datausage/DataSaverSummary.java
index 2e52e38..744f692 100644
--- a/src/com/android/settings/datausage/DataSaverSummary.java
+++ b/src/com/android/settings/datausage/DataSaverSummary.java
@@ -83,7 +83,7 @@
         mDataSaverBackend.refreshAllowlist();
         mDataSaverBackend.refreshDenylist();
         mDataSaverBackend.addListener(this);
-        mDataUsageBridge.resume();
+        mDataUsageBridge.resume(true /* forceLoadAllApps */);
     }
 
     @Override
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccessPreferenceController.java b/src/com/android/settings/datausage/UnrestrictedDataAccessPreferenceController.java
index ac088c0..06cf8ed 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccessPreferenceController.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccessPreferenceController.java
@@ -91,7 +91,7 @@
 
     @Override
     public void onStart() {
-        mDataUsageBridge.resume();
+        mDataUsageBridge.resume(true /* forceLoadAllApps */);
     }
 
     @Override
diff --git a/src/com/android/settings/display/TimeoutListPreference.java b/src/com/android/settings/display/TimeoutListPreference.java
index 0b2d18f..5079cca 100644
--- a/src/com/android/settings/display/TimeoutListPreference.java
+++ b/src/com/android/settings/display/TimeoutListPreference.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.display;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.OTHER_OPTIONS_DISABLED_BY_ADMIN;
+
 import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
 import android.app.Dialog;
@@ -24,7 +26,9 @@
 import android.content.DialogInterface;
 import android.util.AttributeSet;
 import android.util.Log;
+import android.view.LayoutInflater;
 import android.view.View;
+import android.widget.TextView;
 
 import androidx.appcompat.app.AlertDialog.Builder;
 
@@ -52,13 +56,26 @@
             DialogInterface.OnClickListener listener) {
         super.onPrepareDialogBuilder(builder, listener);
         if (mAdmin != null) {
-            builder.setView(R.layout.admin_disabled_other_options_footer);
-            // TODO: replace Text on textview with admin_disabled_other_options
+            updateTextOnDialog(builder);
         } else {
             builder.setView(null);
         }
     }
 
+    private void updateTextOnDialog(Builder builder) {
+        LayoutInflater inflater = getContext().getSystemService(LayoutInflater.class);
+        DevicePolicyManager devicePolicyManager = getContext()
+                .getSystemService(DevicePolicyManager.class);
+        View v = inflater.inflate(R.layout.admin_disabled_other_options_footer, null);
+        builder.setView(v);
+        TextView textView = v.findViewById(R.id.admin_disabled_other_options_text);
+        String replacementText = devicePolicyManager.getResources().getString(
+                OTHER_OPTIONS_DISABLED_BY_ADMIN, () -> null);
+        if (replacementText != null) {
+            textView.setText(replacementText);
+        }
+    }
+
     @Override
     protected void onDialogCreated(Dialog dialog) {
         super.onDialogCreated(dialog);
diff --git a/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java b/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
index e5484db..cf1b8a3 100644
--- a/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
+++ b/src/com/android/settings/enterprise/AdminActionPreferenceControllerBase.java
@@ -52,7 +52,8 @@
     }
 
     private String getEnterprisePrivacyNone() {
-        return mContext.getSystemService(DevicePolicyManager.class).getResources()
+        return ((DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE))
+                .getResources()
                 .getString(ADMIN_ACTION_NONE,
                         () -> mContext.getString(R.string.enterprise_privacy_none));
     }
diff --git a/src/com/android/settings/enterprise/ApplicationListFragment.java b/src/com/android/settings/enterprise/ApplicationListFragment.java
index a82789b..38a5c6f 100644
--- a/src/com/android/settings/enterprise/ApplicationListFragment.java
+++ b/src/com/android/settings/enterprise/ApplicationListFragment.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.enterprise;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_APPS_COUNT_ESTIMATED;
+
 import android.Manifest;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
@@ -47,6 +49,10 @@
     @Override
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+
+        replaceEnterpriseStringTitle("enterprise_privacy_apps_footer",
+                ADMIN_ACTION_APPS_COUNT_ESTIMATED,
+                R.string.enterprise_privacy_apps_count_estimation_info);
     }
 
     @Override
diff --git a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
index 1aad544..92e4f4a 100644
--- a/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
+++ b/src/com/android/settings/enterprise/EnterprisePrivacySettings.java
@@ -16,11 +16,39 @@
 
 package com.android.settings.enterprise;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_ACCESS_CAMERA;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_ACCESS_LOCATION;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_ACCESS_MICROPHONE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_APPS_INSTALLED;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_SET_CURRENT_INPUT_METHOD;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_SET_DEFAULT_APPS;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_ACTION_SET_HTTP_PROXY;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_LOCK_DEVICE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_APPS_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_BUG_REPORT_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_NETWORK_LOGS_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_SECURITY_LOGS_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_USAGE_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_SEE_WORK_DATA_WARNING;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CAN_WIPE_DEVICE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CONFIGURED_FAILED_PASSWORD_WIPE_DEVICE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ADMIN_CONFIGURED_FAILED_PASSWORD_WIPE_WORK_PROFILE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ALWAYS_ON_VPN_WORK_PROFILE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CA_CERTS_PERSONAL_PROFILE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CA_CERTS_WORK_PROFILE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.CHANGES_BY_ORGANIZATION_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.ENTERPRISE_PRIVACY_FOOTER;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.INFORMATION_SEEN_BY_ORGANIZATION_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MANAGED_DEVICE_INFO;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.YOUR_ACCESS_TO_THIS_DEVICE_TITLE;
+
 import android.app.settings.SettingsEnums;
 import android.content.Context;
+import android.os.Bundle;
 import android.provider.SearchIndexableResource;
 
 import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settings.search.BaseSearchIndexProvider;
@@ -46,6 +74,70 @@
     }
 
     @Override
+    public void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+
+        replaceEnterprisePreferenceScreenTitle(
+                MANAGED_DEVICE_INFO, R.string.enterprise_privacy_settings);
+
+        replaceEnterpriseStringTitle("exposure_category",
+                INFORMATION_SEEN_BY_ORGANIZATION_TITLE,
+                R.string.enterprise_privacy_exposure_category);
+        replaceEnterpriseStringTitle("enterprise_privacy_enterprise_data",
+                ADMIN_CAN_SEE_WORK_DATA_WARNING, R.string.enterprise_privacy_enterprise_data);
+        replaceEnterpriseStringTitle("enterprise_privacy_installed_packages",
+                ADMIN_CAN_SEE_APPS_WARNING, R.string.enterprise_privacy_installed_packages);
+        replaceEnterpriseStringTitle("enterprise_privacy_usage_stats",
+                ADMIN_CAN_SEE_USAGE_WARNING, R.string.enterprise_privacy_usage_stats);
+        replaceEnterpriseStringTitle("network_logs",
+                ADMIN_CAN_SEE_NETWORK_LOGS_WARNING, R.string.enterprise_privacy_network_logs);
+        replaceEnterpriseStringTitle("bug_reports",
+                ADMIN_CAN_SEE_BUG_REPORT_WARNING, R.string.enterprise_privacy_bug_reports);
+        replaceEnterpriseStringTitle("security_logs",
+                ADMIN_CAN_SEE_SECURITY_LOGS_WARNING, R.string.enterprise_privacy_security_logs);
+        replaceEnterpriseStringTitle("exposure_changes_category",
+                CHANGES_BY_ORGANIZATION_TITLE,
+                R.string.enterprise_privacy_exposure_changes_category);
+        replaceEnterpriseStringTitle("number_enterprise_installed_packages",
+                ADMIN_ACTION_APPS_INSTALLED,
+                R.string.enterprise_privacy_enterprise_installed_packages);
+        replaceEnterpriseStringTitle("enterprise_privacy_number_location_access_packages",
+                ADMIN_ACTION_ACCESS_LOCATION, R.string.enterprise_privacy_location_access);
+        replaceEnterpriseStringTitle("enterprise_privacy_number_microphone_access_packages",
+                ADMIN_ACTION_ACCESS_MICROPHONE, R.string.enterprise_privacy_microphone_access);
+        replaceEnterpriseStringTitle("enterprise_privacy_number_camera_access_packages",
+                ADMIN_ACTION_ACCESS_CAMERA, R.string.enterprise_privacy_camera_access);
+        replaceEnterpriseStringTitle("number_enterprise_set_default_apps",
+                ADMIN_ACTION_SET_DEFAULT_APPS,
+                R.string.enterprise_privacy_enterprise_set_default_apps);
+        replaceEnterpriseStringTitle("always_on_vpn_managed_profile",
+                ALWAYS_ON_VPN_WORK_PROFILE, R.string.enterprise_privacy_always_on_vpn_work);
+        replaceEnterpriseStringTitle("input_method",
+                ADMIN_ACTION_SET_CURRENT_INPUT_METHOD, R.string.enterprise_privacy_input_method);
+        replaceEnterpriseStringTitle("global_http_proxy",
+                ADMIN_ACTION_SET_HTTP_PROXY, R.string.enterprise_privacy_global_http_proxy);
+        replaceEnterpriseStringTitle("ca_certs_current_user",
+                CA_CERTS_PERSONAL_PROFILE, R.string.enterprise_privacy_ca_certs_personal);
+        replaceEnterpriseStringTitle("ca_certs_managed_profile",
+                CA_CERTS_WORK_PROFILE, R.string.enterprise_privacy_ca_certs_work);
+        replaceEnterpriseStringTitle("device_access_category",
+                YOUR_ACCESS_TO_THIS_DEVICE_TITLE,
+                R.string.enterprise_privacy_device_access_category);
+        replaceEnterpriseStringTitle("enterprise_privacy_lock_device",
+                ADMIN_CAN_LOCK_DEVICE, R.string.enterprise_privacy_lock_device);
+        replaceEnterpriseStringTitle("enterprise_privacy_wipe_device",
+                ADMIN_CAN_WIPE_DEVICE, R.string.enterprise_privacy_wipe_device);
+        replaceEnterpriseStringTitle("failed_password_wipe_current_user",
+                ADMIN_CONFIGURED_FAILED_PASSWORD_WIPE_DEVICE,
+                R.string.enterprise_privacy_failed_password_wipe_device);
+        replaceEnterpriseStringTitle("failed_password_wipe_managed_profile",
+                ADMIN_CONFIGURED_FAILED_PASSWORD_WIPE_WORK_PROFILE,
+                R.string.enterprise_privacy_failed_password_wipe_work);
+        replaceEnterpriseStringTitle("enterprise_privacy_footer",
+                ENTERPRISE_PRIVACY_FOOTER, R.string.enterprise_privacy_header);
+    }
+
+    @Override
     public void onDetach() {
         mPrivacySettingsPreference = null;
         super.onDetach();
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index 1ecde44..9e1bbb3 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -243,7 +243,8 @@
                     continue;
                 }
 
-                final UserHandle userHandle = new UserHandle(UserHandle.getUserId(entry.getUid()));
+                final int uid = entry.getUid();
+                final UserHandle userHandle = new UserHandle(UserHandle.getUserId(uid));
                 final Drawable badgedIcon = mUserManager.getBadgedIconForUser(entry.getIcon(),
                         userHandle);
                 final CharSequence contentDescription = mUserManager.getBadgedLabelForUser(
@@ -261,6 +262,8 @@
                 pref.setOrder(i + 1);
                 pref.setPercent(percentOfTotal);
                 pref.shouldShowAnomalyIcon(false);
+                pref.setEnabled(uid != BatteryUtils.UID_TETHERING
+                        && uid != BatteryUtils.UID_REMOVED_APPS);
                 setUsageSummary(pref, entry);
                 addedSome = true;
                 mAppListGroup.addPreference(pref);
diff --git a/src/com/android/settings/fuelgauge/BatteryDiffEntry.java b/src/com/android/settings/fuelgauge/BatteryDiffEntry.java
index 5ef1110..403f79c 100644
--- a/src/com/android/settings/fuelgauge/BatteryDiffEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryDiffEntry.java
@@ -153,13 +153,16 @@
             case ConvertUtils.CONSUMER_TYPE_SYSTEM_BATTERY:
                 return true;
             case ConvertUtils.CONSUMER_TYPE_UID_BATTERY:
-                if (mBatteryHistEntry.mIsHidden) {
+                final int uid = (int) mBatteryHistEntry.mUid;
+                if (mBatteryHistEntry.mIsHidden
+                        || uid == BatteryUtils.UID_REMOVED_APPS
+                        || uid == BatteryUtils.UID_TETHERING) {
                     return true;
                 }
                 final boolean combineSystemComponents =
                         mContext.getResources().getBoolean(
                                 R.bool.config_battery_combine_system_components);
-                return combineSystemComponents && isSystemUid((int) mBatteryHistEntry.mUid);
+                return combineSystemComponents && isSystemUid(uid);
         }
         return false;
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryEntry.java b/src/com/android/settings/fuelgauge/BatteryEntry.java
index c9acc4c..ef200a4 100644
--- a/src/com/android/settings/fuelgauge/BatteryEntry.java
+++ b/src/com/android/settings/fuelgauge/BatteryEntry.java
@@ -209,7 +209,8 @@
                 if (packages != null && packages.length == 1) {
                     mDefaultPackageName = packages[0];
                 } else {
-                    mDefaultPackageName = uidBatteryConsumer.getPackageWithHighestDrain();
+                    mDefaultPackageName = isSystemUid(uid)
+                            ? PACKAGE_SYSTEM : uidBatteryConsumer.getPackageWithHighestDrain();
                 }
             }
             if (mDefaultPackageName != null) {
@@ -352,13 +353,8 @@
         }
 
         final PackageManager pm = context.getPackageManager();
-        final String[] packages;
-        if (uid == Process.SYSTEM_UID) {
-            packages = new String[] {PACKAGE_SYSTEM};
-        } else {
-            packages = pm.getPackagesForUid(uid);
-        }
-
+        final String[] packages = isSystemUid(uid)
+                ? new String[] {PACKAGE_SYSTEM} : pm.getPackagesForUid(uid);
         if (packages != null) {
             final String[] packageLabels = new String[packages.length];
             System.arraycopy(packages, 0, packageLabels, 0, packages.length);
@@ -550,6 +546,10 @@
         Drawable icon = context.getDrawable(R.drawable.ic_power_system);
         if (uid == 0) {
             name = context.getResources().getString(R.string.process_kernel_label);
+        } else if (uid == BatteryUtils.UID_REMOVED_APPS) {
+            name = context.getResources().getString(R.string.process_removed_apps);
+        } else if (uid == BatteryUtils.UID_TETHERING) {
+            name = context.getResources().getString(R.string.process_network_tethering);
         } else if ("mediaserver".equals(name)) {
             name = context.getResources().getString(R.string.process_mediaserver_label);
         } else if ("dex2oat".equals(name) || "dex2oat32".equals(name) ||
@@ -611,4 +611,8 @@
         }
         return new NameAndIcon(name, null /* icon */, iconId);
     }
+
+    private static boolean isSystemUid(int uid) {
+        return uid == Process.SYSTEM_UID;
+    }
 }
diff --git a/src/com/android/settings/fuelgauge/BatteryUtils.java b/src/com/android/settings/fuelgauge/BatteryUtils.java
index 67ffa7d..29c2fc9 100644
--- a/src/com/android/settings/fuelgauge/BatteryUtils.java
+++ b/src/com/android/settings/fuelgauge/BatteryUtils.java
@@ -65,6 +65,10 @@
 public class BatteryUtils {
     public static final int UID_NULL = -1;
     public static final int SDK_NULL = -1;
+    /** Special UID value for data usage by removed apps. */
+    public static final int UID_REMOVED_APPS = -4;
+    /** Special UID value for data usage by tethering. */
+    public static final int UID_TETHERING = -5;
 
     @Retention(RetentionPolicy.SOURCE)
     @IntDef({StatusType.SCREEN_USAGE,
@@ -188,7 +192,10 @@
      */
     boolean shouldHideUidBatteryConsumerUnconditionally(UidBatteryConsumer consumer,
             String[] packages) {
-        return consumer.getUid() < 0 || isHiddenSystemModule(packages);
+        final int uid = consumer.getUid();
+        return uid == UID_TETHERING
+                ? false
+                : uid < 0 || isHiddenSystemModule(packages);
     }
 
     /**
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 7e4730c..4e276c1 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -176,7 +176,7 @@
     List<CachedBluetoothDevice> getPairedBluetoothDevices() {
         final List<CachedBluetoothDevice> bluetoothDeviceList = new ArrayList<>();
 
-        // If Bluetooth is disable, skip getting the Bluetooth devices.
+        // If Bluetooth is disabled, skip getting the Bluetooth devices.
         if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
             Log.i(TAG, "Cannot get Bluetooth devices, Bluetooth is disabled.");
             return bluetoothDeviceList;
diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java
index 23e37ba..71b48f9 100644
--- a/src/com/android/settings/language/LanguageAndInputSettings.java
+++ b/src/com/android/settings/language/LanguageAndInputSettings.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.language;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.PERSONAL_DICTIONARY_FOR_WORK;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.SPELL_CHECKER_FOR_WORK;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_KEYBOARDS_AND_TOOLS;
 
 import android.app.Activity;
@@ -80,6 +82,12 @@
         replaceEnterpriseStringTitle("language_and_input_for_work_category",
                 WORK_PROFILE_KEYBOARDS_AND_TOOLS,
                 R.string.language_and_input_for_work_category_title);
+        replaceEnterpriseStringTitle("spellcheckers_settings_for_work_pref",
+                SPELL_CHECKER_FOR_WORK,
+                R.string.spellcheckers_settings_for_work_title);
+        replaceEnterpriseStringTitle("user_dictionary_settings_for_work_pref",
+                PERSONAL_DICTIONARY_FOR_WORK,
+                R.string.user_dict_settings_for_work_title);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index 1c024e3..1ede911 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -18,6 +18,8 @@
 
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT;
 
 import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
@@ -158,8 +160,13 @@
         ArrayList<CharSequence> entries = new ArrayList<>();
         ArrayList<CharSequence> values = new ArrayList<>();
 
-        String summaryShowEntry = mContext.getString(
-                R.string.lock_screen_notifications_summary_show_profile);
+        DevicePolicyManager devicePolicyManager =
+                mContext.getSystemService(DevicePolicyManager.class);
+
+        String summaryShowEntry = devicePolicyManager
+                .getResources().getString(LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT,
+                        () -> mContext.getString(
+                                R.string.lock_screen_notifications_summary_show_profile));
         String summaryShowEntryValue = Integer.toString(
                 R.string.lock_screen_notifications_summary_show_profile);
         entries.add(summaryShowEntry);
@@ -168,8 +175,10 @@
                 KEYGUARD_DISABLE_SECURE_NOTIFICATIONS | KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS);
 
         if (mSecureProfile) {
-            String summaryHideEntry = mContext.getString(
-                    R.string.lock_screen_notifications_summary_hide_profile);
+            String summaryHideEntry = devicePolicyManager
+                    .getResources().getString(LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT,
+                            () -> mContext.getString(
+                                    R.string.lock_screen_notifications_summary_hide_profile));
             String summaryHideEntryValue = Integer.toString(
                     R.string.lock_screen_notifications_summary_hide_profile);
             entries.add(summaryHideEntry);
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index d6cf0c6..f243250 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -18,11 +18,14 @@
 
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_SECURE_NOTIFICATIONS;
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_UNREDACTED_NOTIFICATIONS;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT;
 import static android.provider.Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS;
 import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS;
 
 import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 
+import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
@@ -115,6 +118,7 @@
         @Override
         public void onViewCreated(View view, Bundle savedInstanceState) {
             super.onViewCreated(view, savedInstanceState);
+            DevicePolicyManager devicePolicyManager = getSystemService(DevicePolicyManager.class);
             mRadioGroup = (RadioGroup) view.findViewById(R.id.radio_group);
             mShowAllButton = (RestrictedRadioButton) view.findViewById(R.id.show_all);
             mRedactSensitiveButton =
@@ -126,9 +130,15 @@
             if (UserManager.get(getContext()).isManagedProfile(mUserId)) {
                 ((TextView) view.findViewById(R.id.sud_layout_description))
                         .setText(R.string.lock_screen_notifications_interstitial_message_profile);
-                mShowAllButton.setText(R.string.lock_screen_notifications_summary_show_profile);
+                mShowAllButton.setText(devicePolicyManager
+                        .getResources().getString(LOCK_SCREEN_SHOW_WORK_NOTIFICATION_CONTENT,
+                                () -> getString(
+                                        R.string.lock_screen_notifications_summary_show_profile)));
                 mRedactSensitiveButton
-                        .setText(R.string.lock_screen_notifications_summary_hide_profile);
+                        .setText(devicePolicyManager.getResources().getString(
+                                LOCK_SCREEN_HIDE_WORK_NOTIFICATION_CONTENT,
+                                () -> getString(
+                                        R.string.lock_screen_notifications_summary_hide_profile)));
 
                 ((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
             }
diff --git a/src/com/android/settings/notification/SoundWorkSettings.java b/src/com/android/settings/notification/SoundWorkSettings.java
index eb7f05e..2cb4215 100644
--- a/src/com/android/settings/notification/SoundWorkSettings.java
+++ b/src/com/android/settings/notification/SoundWorkSettings.java
@@ -19,6 +19,7 @@
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_ALARM_RINGTONE_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_NOTIFICATION_RINGTONE_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_RINGTONE_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SOUND_SETTINGS_SECTION_HEADER;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_USE_PERSONAL_SOUNDS_SUMMARY;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_USE_PERSONAL_SOUNDS_TITLE;
 
@@ -70,6 +71,8 @@
                 mRequestPreference = findPreference(selectedPreference);
             }
         }
+        replaceEnterprisePreferenceScreenTitle(
+                WORK_PROFILE_SOUND_SETTINGS_SECTION_HEADER, R.string.sound_work_settings);
         replaceEnterpriseStringTitle("work_use_personal_sounds",
                 WORK_PROFILE_USE_PERSONAL_SOUNDS_TITLE, R.string.work_use_personal_sounds_title);
         replaceEnterpriseStringSummary("work_use_personal_sounds",
@@ -79,7 +82,7 @@
                 WORK_PROFILE_RINGTONE_TITLE, R.string.work_ringtone_title);
         replaceEnterpriseStringTitle("work_alarm_ringtone",
                 WORK_PROFILE_ALARM_RINGTONE_TITLE, R.string.work_alarm_ringtone_title);
-        replaceEnterpriseStringTitle("work_notification",
+        replaceEnterpriseStringTitle("work_notification_ringtone",
                 WORK_PROFILE_NOTIFICATION_RINGTONE_TITLE,
                 R.string.work_notification_ringtone_title);
     }
diff --git a/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java b/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java
index c9eaa65..8ae0493 100644
--- a/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java
+++ b/src/com/android/settings/notification/SpatialAudioParentPreferenceController.java
@@ -57,7 +57,7 @@
     @Override
     public CharSequence getSummary() {
         boolean speakerOn = mSpatialAudioPreferenceController.isAvailable()
-                && mSpatialAudioWiredHeadphonesController.isChecked();
+                && mSpatialAudioPreferenceController.isChecked();
         boolean wiredHeadphonesOn = mSpatialAudioWiredHeadphonesController.isAvailable()
                 && mSpatialAudioWiredHeadphonesController.isChecked();
         if (speakerOn && wiredHeadphonesOn) {
diff --git a/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceController.java b/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceController.java
index c6d735c..ee6e828 100644
--- a/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceController.java
+++ b/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceController.java
@@ -18,6 +18,7 @@
 
 import android.app.AutomaticZenRule;
 import android.content.Context;
+import android.util.ArrayMap;
 
 import androidx.annotation.VisibleForTesting;
 import androidx.fragment.app.Fragment;
@@ -28,7 +29,6 @@
 import com.android.settingslib.core.lifecycle.Lifecycle;
 
 import java.util.Map;
-import java.util.Objects;
 
 public class ZenModeAutomaticRulesPreferenceController extends
         AbstractZenModeAutomaticRulePreferenceController {
@@ -38,6 +38,10 @@
     @VisibleForTesting
     protected PreferenceCategory mPreferenceCategory;
 
+    // Map of rule key -> preference so that we can update each preference as needed
+    @VisibleForTesting
+    protected Map<String, ZenRulePreference> mZenRulePreferences = new ArrayMap<>();
+
     public ZenModeAutomaticRulesPreferenceController(Context context, Fragment parent, Lifecycle
             lifecycle) {
         super(context, KEY, parent, lifecycle);
@@ -58,38 +62,73 @@
         super.displayPreference(screen);
         mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mPreferenceCategory.setPersistent(false);
+
+        // if mPreferenceCategory was un-set, make sure to clear out mZenRulePreferences too, just
+        // in case
+        if (mPreferenceCategory.getPreferenceCount() == 0) {
+            mZenRulePreferences.clear();
+        }
     }
 
     @Override
     public void updateState(Preference preference) {
         super.updateState(preference);
         Map.Entry<String, AutomaticZenRule>[] sortedRules = getRules();
-        final int currNumPreferences = mPreferenceCategory.getPreferenceCount();
-        if (currNumPreferences == sortedRules.length) {
+
+        // refresh the whole preference category list if the total number of rules has changed, or
+        // if any individual rules have changed, so we can rebuild the list & keep things in sync
+        boolean refreshPrefs = false;
+        if (mPreferenceCategory.getPreferenceCount() != sortedRules.length) {
+            refreshPrefs = true;
+        } else {
+            // check whether any rules in sortedRules are not in mZenRulePreferences; that should
+            // be enough to see whether something has changed
             for (int i = 0; i < sortedRules.length; i++) {
-                ZenRulePreference pref = (ZenRulePreference) mPreferenceCategory.getPreference(i);
-                // we are either:
-                // 1. updating everything about the rule
-                // 2. rule was added or deleted, so reload the entire list
-                if (Objects.equals(pref.mId, sortedRules[i].getKey())) {
-                    AutomaticZenRule rule = sortedRules[i].getValue();
-                    pref.updatePreference(rule);
-                } else {
-                    reloadAllRules(sortedRules);
+                if (!mZenRulePreferences.containsKey(sortedRules[i].getKey())) {
+                    refreshPrefs = true;
                     break;
                 }
             }
-        } else {
-            reloadAllRules(sortedRules);
         }
-    }
 
-    @VisibleForTesting
-    void reloadAllRules(Map.Entry<String, AutomaticZenRule>[] rules) {
-        mPreferenceCategory.removeAll();
-        for (Map.Entry<String, AutomaticZenRule> rule : rules) {
-            ZenRulePreference pref = createZenRulePreference(rule);
-            mPreferenceCategory.addPreference(pref);
+        // if we need to refresh the whole list, clear the preference category and also start a
+        // new map of preferences according to the preference category contents
+        // we need to not update the existing one yet, as we'll need to know what preferences
+        // previously existed in order to update and re-attach them to the preference category
+        Map<String, ZenRulePreference> newPrefs = new ArrayMap<>();
+        if (refreshPrefs) {
+            mPreferenceCategory.removeAll();
+        }
+
+        // Loop through each rule, either updating the existing rule or creating the rule's
+        // preference if needed (and, in the case where we need to rebuild the preference category
+        // list, do so as well)
+        for (int i = 0; i < sortedRules.length; i++) {
+            String key = sortedRules[i].getKey();
+            if (mZenRulePreferences.containsKey(key)) {
+                // existing rule; update its info if it's changed since the last display
+                AutomaticZenRule rule = sortedRules[i].getValue();
+                ZenRulePreference pref = mZenRulePreferences.get(key);
+                pref.updatePreference(rule);
+
+                // only add to preference category if the overall set of rules has changed so this
+                // needs to be rearranged
+                if (refreshPrefs) {
+                    mPreferenceCategory.addPreference(pref);
+                    newPrefs.put(key, pref);
+                }
+            } else {
+                // new rule; create a new ZenRulePreference & add it to the preference category
+                // and the map so we'll know about it later
+                ZenRulePreference pref = createZenRulePreference(sortedRules[i]);
+                mPreferenceCategory.addPreference(pref);
+                newPrefs.put(key, pref);
+            }
+        }
+
+        // If anything was new, then make sure we overwrite mZenRulePreferences with our new data
+        if (refreshPrefs) {
+            mZenRulePreferences = newPrefs;
         }
     }
 
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index 841d1f9..d3988fa 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -22,6 +22,8 @@
 import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_LOW;
 import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_MEDIUM;
 import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK;
 import static android.app.admin.DevicePolicyResources.Strings.Settings.WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE;
 
@@ -66,7 +68,6 @@
 import com.android.internal.widget.LockscreenCredential;
 import com.android.settings.EncryptionInterstitial;
 import com.android.settings.EventLogTags;
-import com.android.settings.LinkifyUtils;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
 import com.android.settings.SettingsPreferenceFragment;
@@ -77,7 +78,9 @@
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
 import com.android.settings.safetycenter.LockScreenSafetySource;
 import com.android.settings.search.SearchFeatureProvider;
+import com.android.settings.utils.AnnotationSpan;
 import com.android.settingslib.RestrictedPreference;
+import com.android.settingslib.widget.FooterPreference;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 
@@ -345,9 +348,14 @@
                 // it's an update.
                 updateExistingLock = mLockPatternUtils.isSeparateProfileChallengeEnabled(mUserId);
                 if (updateExistingLock) {
-                    getActivity().setTitle(R.string.lock_settings_picker_update_profile_lock_title);
+                    getActivity().setTitle(mDpm.getResources().getString(
+                            LOCK_SETTINGS_UPDATE_PROFILE_LOCK_TITLE,
+                            () -> getString(
+                                    R.string.lock_settings_picker_update_profile_lock_title)));
                 } else {
-                    getActivity().setTitle(R.string.lock_settings_picker_new_profile_lock_title);
+                    getActivity().setTitle(mDpm.getResources().getString(
+                            LOCK_SETTINGS_NEW_PROFILE_LOCK_TITLE,
+                            () -> getString(R.string.lock_settings_picker_new_profile_lock_title)));
                 }
             } else {
                 updateExistingLock = mLockPatternUtils.isSecure(mUserId);
@@ -400,32 +408,7 @@
                             WORK_PROFILE_SCREEN_LOCK_SETUP_MESSAGE,
                             () -> getString(R.string.lock_settings_picker_profile_message)));
                 } else {
-                    int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId);
-                    if (mController.isScreenLockRestrictedByAdmin()
-                            && profileUserId != UserHandle.USER_NULL) {
-                        final StringBuilder description = new StringBuilder(
-                                mDpm.getResources().getString(
-                                        WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
-                                        () -> getString(
-                                                R.string.lock_settings_picker_admin_restricted_personal_message)));
-                        final LinkifyUtils.OnClickListener clickListener = () -> {
-                            final Bundle extras = new Bundle();
-                            extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
-                            if (mUserPassword != null) {
-                                extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
-                                        mUserPassword);
-                            }
-                            new SubSettingLauncher(getActivity())
-                                    .setDestination(ChooseLockGenericFragment.class.getName())
-                                    .setSourceMetricsCategory(getMetricsCategory())
-                                    .setArguments(extras)
-                                    .launch();
-                            finish();
-                        };
-                        LinkifyUtils.linkify(textView, description, clickListener);
-                    } else {
-                        textView.setText("");
-                    }
+                    textView.setText("");
                 }
             }
         }
@@ -630,10 +613,39 @@
         protected void addPreferences() {
             addPreferencesFromResource(R.xml.security_settings_picker);
 
-            final Preference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
+            int profileUserId = Utils.getManagedProfileId(mUserManager, mUserId);
+            final FooterPreference footer = findPreference(KEY_LOCK_SETTINGS_FOOTER);
             if (!TextUtils.isEmpty(mCallerAppName) && !mIsCallingAppAdmin) {
                 footer.setVisible(true);
                 footer.setTitle(getFooterString());
+            } else if (!mForFace && !mForBiometrics && !mForFingerprint && !mIsManagedProfile
+                    && mController.isScreenLockRestrictedByAdmin()
+                    && profileUserId != UserHandle.USER_NULL) {
+                CharSequence description =
+                        mDpm.getResources().getString(WORK_PROFILE_IT_ADMIN_CANT_RESET_SCREEN_LOCK,
+                                () -> null);
+                if (description == null) {
+                    description = getText(
+                            R.string.lock_settings_picker_admin_restricted_personal_message);
+                }
+                final AnnotationSpan.LinkInfo linkInfo = new AnnotationSpan.LinkInfo(
+                        AnnotationSpan.LinkInfo.DEFAULT_ANNOTATION, (view) -> {
+                    final Bundle extras = new Bundle();
+                    extras.putInt(Intent.EXTRA_USER_ID, profileUserId);
+                    if (mUserPassword != null) {
+                        extras.putParcelable(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD,
+                                mUserPassword);
+                    }
+                    new SubSettingLauncher(getActivity())
+                            .setDestination(ChooseLockGenericFragment.class.getName())
+                            .setSourceMetricsCategory(getMetricsCategory())
+                            .setArguments(extras)
+                            .launch();
+                    finish();
+                });
+                CharSequence footerText = AnnotationSpan.linkify(description, linkInfo);
+                footer.setVisible(true);
+                footer.setTitle(footerText);
             } else {
                 footer.setVisible(false);
             }
diff --git a/src/com/android/settings/password/ForgotPasswordActivity.java b/src/com/android/settings/password/ForgotPasswordActivity.java
index 657139e..d9db335 100644
--- a/src/com/android/settings/password/ForgotPasswordActivity.java
+++ b/src/com/android/settings/password/ForgotPasswordActivity.java
@@ -17,6 +17,7 @@
 package com.android.settings.password;
 
 import static android.app.admin.DevicePolicyResources.Strings.Settings.FORGOT_PASSWORD_TEXT;
+import static android.app.admin.DevicePolicyResources.Strings.Settings.FORGOT_PASSWORD_TITLE;
 
 import android.app.Activity;
 import android.app.admin.DevicePolicyManager;
@@ -64,6 +65,9 @@
                         .build()
         );
 
+        layout.setHeaderText(devicePolicyManager.getResources().getString(
+                FORGOT_PASSWORD_TITLE, () -> getString(R.string.forgot_password_title)));
+
         UserManager.get(this).requestQuietModeEnabled(
                 false, UserHandle.of(userId), UserManager.QUIET_MODE_DISABLE_DONT_ASK_CREDENTIAL);
     }
diff --git a/src/com/android/settings/security/SecurityAdvancedSettingsController.java b/src/com/android/settings/security/SecurityAdvancedSettingsController.java
index 904141d..22a482d 100644
--- a/src/com/android/settings/security/SecurityAdvancedSettingsController.java
+++ b/src/com/android/settings/security/SecurityAdvancedSettingsController.java
@@ -16,6 +16,9 @@
 
 package com.android.settings.security;
 
+import static android.app.admin.DevicePolicyResources.Strings.Settings.MORE_SECURITY_SETTINGS_WORK_PROFILE_SUMMARY;
+
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.pm.CrossProfileApps;
 
@@ -29,11 +32,13 @@
 public class SecurityAdvancedSettingsController extends BasePreferenceController {
 
     private final CrossProfileApps mCrossProfileApps;
+    private final DevicePolicyManager mDevicePolicyManager;
 
     public SecurityAdvancedSettingsController(Context context, String preferenceKey) {
         super(context, preferenceKey);
 
         mCrossProfileApps = context.getSystemService(CrossProfileApps.class);
+        mDevicePolicyManager = context.getSystemService(DevicePolicyManager.class);
     }
 
     @Override
@@ -44,8 +49,10 @@
     @Override
     public CharSequence getSummary() {
         return isWorkProfilePresent()
-                ? mContext.getResources().getString(
-                        R.string.security_advanced_settings_work_profile_settings_summary)
+                ? mDevicePolicyManager.getResources().getString(
+                        MORE_SECURITY_SETTINGS_WORK_PROFILE_SUMMARY,
+                    () -> mContext.getResources().getString(
+                            R.string.security_advanced_settings_work_profile_settings_summary))
                 : mContext.getResources().getString(
                         R.string.security_advanced_settings_no_work_profile_settings_summary);
     }
diff --git a/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
index 52645aa..85dc2e4 100644
--- a/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiMeteredPreferenceController2.java
@@ -21,7 +21,7 @@
 import android.net.wifi.WifiConfiguration;
 
 import androidx.annotation.VisibleForTesting;
-import androidx.preference.DropDownPreference;
+import androidx.preference.ListPreference;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
@@ -30,13 +30,13 @@
 import com.android.wifitrackerlib.WifiEntry;
 
 /**
- * {@link AbstractPreferenceController} that controls whether the wifi network is metered or not
+ * A controller that controls whether the Wi-Fi network is metered or not.
  */
 public class WifiMeteredPreferenceController2 extends BasePreferenceController implements
         Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
 
     private static final String KEY_WIFI_METERED = "metered";
-    private WifiEntry mWifiEntry;
+    private final WifiEntry mWifiEntry;
     private Preference mPreference;
 
     public WifiMeteredPreferenceController2(Context context, WifiEntry wifiEntry) {
@@ -46,11 +46,11 @@
 
     @Override
     public void updateState(Preference preference) {
-        final DropDownPreference dropDownPreference = (DropDownPreference) preference;
+        final ListPreference listPreference = (ListPreference) preference;
         final int meteredOverride = getMeteredOverride();
         preference.setSelectable(mWifiEntry.canSetMeteredChoice());
-        dropDownPreference.setValue(Integer.toString(meteredOverride));
-        updateSummary(dropDownPreference, meteredOverride);
+        listPreference.setValue(Integer.toString(meteredOverride));
+        updateSummary(listPreference, meteredOverride);
     }
 
     @Override
@@ -66,7 +66,7 @@
 
         // Stage the backup of the SettingsProvider package which backs this up
         BackupManager.dataChanged("com.android.providers.settings");
-        updateSummary((DropDownPreference) preference, getMeteredOverride());
+        updateSummary((ListPreference) preference, getMeteredOverride());
         return true;
     }
 
@@ -79,7 +79,7 @@
         return WifiEntry.METERED_CHOICE_AUTO;
     }
 
-    private void updateSummary(DropDownPreference preference, int meteredOverride) {
+    private void updateSummary(ListPreference preference, int meteredOverride) {
         preference.setSummary(preference.getEntries()[meteredOverride]);
     }
 
diff --git a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
index c484922..632a562 100644
--- a/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiPrivacyPreferenceController2.java
@@ -21,7 +21,7 @@
 import android.net.wifi.WifiManager;
 
 import androidx.annotation.VisibleForTesting;
-import androidx.preference.DropDownPreference;
+import androidx.preference.ListPreference;
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
@@ -31,14 +31,13 @@
 import com.android.wifitrackerlib.WifiEntry;
 
 /**
- * {@link AbstractPreferenceController} that controls whether the wifi network is mac randomized
- * or not
+ * A controller that controls whether the Wi-Fi network is mac randomized or not.
  */
 public class WifiPrivacyPreferenceController2 extends BasePreferenceController implements
         Preference.OnPreferenceChangeListener, WifiDialog2.WifiDialog2Listener {
 
     private static final String KEY_WIFI_PRIVACY = "privacy";
-    private WifiManager mWifiManager;
+    private final WifiManager mWifiManager;
     private WifiEntry mWifiEntry;
     private Preference mPreference;
 
@@ -66,16 +65,16 @@
 
     @Override
     public void updateState(Preference preference) {
-        final DropDownPreference dropDownPreference = (DropDownPreference) preference;
+        final ListPreference listPreference = (ListPreference) preference;
         final int randomizationLevel = getRandomizationValue();
         final boolean isSelectable = mWifiEntry.canSetPrivacy();
         preference.setSelectable(isSelectable);
-        dropDownPreference.setValue(Integer.toString(randomizationLevel));
-        updateSummary(dropDownPreference, randomizationLevel);
+        listPreference.setValue(Integer.toString(randomizationLevel));
+        updateSummary(listPreference, randomizationLevel);
 
         // If the preference cannot be selectable, display a temporary network in the summary.
         if (!isSelectable) {
-            dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
+            listPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
         }
     }
 
@@ -90,7 +89,7 @@
             mWifiEntry.disconnect(null /* callback */);
             mWifiEntry.connect(null /* callback */);
         }
-        updateSummary((DropDownPreference) preference, privacy);
+        updateSummary((ListPreference) preference, privacy);
         return true;
     }
 
@@ -124,7 +123,7 @@
             ? WifiEntry.PRIVACY_RANDOMIZED_MAC : WifiEntry.PRIVACY_DEVICE_MAC;
     }
 
-    private void updateSummary(DropDownPreference preference, int macRandomized) {
+    private void updateSummary(ListPreference preference, int macRandomized) {
         // Translates value here to set RANDOMIZATION_PERSISTENT as first item in UI for better UX.
         final int prefMacRandomized = translateMacRandomizedValueToPrefValue(macRandomized);
         preference.setSummary(preference.getEntries()[prefMacRandomized]);
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 7b2eae9..76dfab8 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -97,14 +97,13 @@
     @Override
     public Slice getSlice() {
         // If external calling package doesn't have Wi-Fi permission.
-        if (!Utils.isSettingsIntelligence(mContext) && !isPermissionGranted(mContext)) {
-            Log.i(TAG, "No wifi permissions to control wifi slice.");
-            return null;
-        }
-
+        final boolean isPermissionGranted =
+                Utils.isSettingsIntelligence(mContext) || isPermissionGranted(mContext);
         final boolean isWifiEnabled = isWifiEnabled();
-        ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* wifiSliceItem */);
-        if (!isWifiEnabled) {
+        ListBuilder listBuilder = getListBuilder(isWifiEnabled, null /* wifiSliceItem */,
+                isPermissionGranted);
+        // If the caller doesn't have the permission granted, just return a slice without a toggle.
+        if (!isWifiEnabled || !isPermissionGranted) {
             return listBuilder.build();
         }
 
@@ -116,7 +115,8 @@
 
         if (isFirstApActive) {
             // refresh header subtext
-            listBuilder = getListBuilder(true /* isWifiEnabled */, apList.get(0));
+            listBuilder = getListBuilder(
+                    true /* isWifiEnabled */, apList.get(0), true /* isWiFiPermissionGranted */);
         }
 
         if (isApRowCollapsed()) {
@@ -186,16 +186,21 @@
         return builder;
     }
 
-    private ListBuilder getListBuilder(boolean isWifiEnabled, WifiSliceItem wifiSliceItem) {
+    private ListBuilder getListBuilder(boolean isWifiEnabled, WifiSliceItem wifiSliceItem,
+            boolean isWiFiPermissionGranted) {
         final ListBuilder builder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY)
                 .setAccentColor(COLOR_NOT_TINTED)
                 .setKeywords(getKeywords())
                 .addRow(getHeaderRow(isWifiEnabled, wifiSliceItem));
-
-        if (mWifiRestriction.isChangeWifiStateAllowed(mContext)) {
-            builder.addAction(SliceAction.createToggle(
-                    getBroadcastIntent(mContext), null /* actionTitle */, isWifiEnabled));
+        if (!isWiFiPermissionGranted || !mWifiRestriction.isChangeWifiStateAllowed(mContext)) {
+            return builder;
         }
+
+        final PendingIntent toggleAction = getBroadcastIntent(mContext);
+        final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction,
+                null /* actionTitle */, isWifiEnabled);
+        builder.addAction(toggleSliceAction);
+
         return builder;
     }
 
diff --git a/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
index 67ec836..ece7ea9 100644
--- a/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/EmergencyInfoPreferenceControllerTest.java
@@ -20,12 +20,14 @@
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ResolveInfo;
@@ -70,6 +72,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new EmergencyInfoPreferenceController(mContext, "test_key");
         mPreference = new Preference(Robolectric.setupActivity(Activity.class));
         mPreference.setKey(mController.getPreferenceKey());
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
index e78a394..e4d3ca5 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPreferenceControllerTest.java
@@ -18,10 +18,12 @@
 
 import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIUM;
 
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.os.UserManager;
 
@@ -57,6 +59,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index da17f11..ec4f8f2 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -189,6 +189,24 @@
     }
 
     @Test
+    public void onCreateOptionsMenu_hasPreQuery_shouldSetQuery() {
+        final SearchView searchView = mock(SearchView.class);
+        final MenuItem searchMenu = mock(MenuItem.class);
+        final MenuItem helpMenu = mock(MenuItem.class);
+        when(searchMenu.getActionView()).thenReturn(searchView);
+        when(mMenu.findItem(R.id.search_app_list_menu)).thenReturn(searchMenu);
+        when(mMenu.add(anyInt() /* groupId */, anyInt() /* itemId */, anyInt() /* order */,
+                anyInt() /* titleRes */)).thenReturn(helpMenu);
+        doReturn("Test").when(mFragment).getText(anyInt() /* resId */);
+        doNothing().when(mFragment).updateOptionsMenu();
+
+        mFragment.mPreQuery = "test";
+        mFragment.onCreateOptionsMenu(mMenu, mock(MenuInflater.class));
+
+        verify(searchView).setQuery("test", true);
+    }
+
+    @Test
     public void onQueryTextChange_shouldFilterSearchInApplicationsAdapter() {
         final ManageApplications.ApplicationsAdapter adapter =
                 mock(ManageApplications.ApplicationsAdapter.class);
@@ -519,6 +537,38 @@
     }
 
     @Test
+    public void onSaveInstanceState_noSearchView_shouldNotSaveQuery() {
+        final Bundle bundle = new Bundle();
+        ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
+        ReflectionHelpers.setField(mFragment, "mFilter", mock(AppFilterItem.class));
+        ReflectionHelpers.setField(mFragment, "mApplications",
+                mock(ManageApplications.ApplicationsAdapter.class));
+
+        mFragment.onSaveInstanceState(bundle);
+
+        assertThat(bundle.containsKey(ManageApplications.EXTRA_SEARCH_QUERY)).isFalse();
+    }
+
+    @Test
+    public void onSaveInstanceState_searchViewSet_shouldSaveQuery() {
+        final SearchView searchView = mock(SearchView.class);
+        final Bundle bundle = new Bundle();
+        ReflectionHelpers.setField(mFragment, "mResetAppsHelper", mock(ResetAppsHelper.class));
+        ReflectionHelpers.setField(mFragment, "mFilter", mock(AppFilterItem.class));
+        ReflectionHelpers.setField(mFragment, "mApplications",
+                mock(ManageApplications.ApplicationsAdapter.class));
+        ReflectionHelpers.setField(mFragment, "mSearchView", searchView);
+        when(searchView.isIconified()).thenReturn(true);
+        when(searchView.getQuery()).thenReturn("test");
+
+        mFragment.onSaveInstanceState(bundle);
+
+        assertThat(bundle.containsKey(ManageApplications.EXTRA_SEARCH_QUERY)).isTrue();
+        assertThat(bundle.getCharSequence(ManageApplications.EXTRA_SEARCH_QUERY))
+                .isEqualTo("test");
+    }
+
+    @Test
     public void createHeader_batteryListType_hasCorrectItems() {
         ReflectionHelpers.setField(mFragment, "mListType", ManageApplications.LIST_TYPE_HIGH_POWER);
         ReflectionHelpers.setField(mFragment, "mRootView",
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
index e7c99c8..f2b0acd 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardFeatureProviderImplTest.java
@@ -308,8 +308,12 @@
                 mActivity, mFragment, mForceRoundedIcon, preference, tile, null /* key */,
                 Preference.DEFAULT_ORDER);
 
-        assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
         assertThat(observers.get(0).getUri().toString()).isEqualTo(uriString);
+        assertThat(preference.getSummary()).isNotEqualTo(ShadowTileUtils.MOCK_TEXT);
+
+        observers.get(0).updateUi();
+
+        assertThat(preference.getSummary()).isEqualTo(ShadowTileUtils.MOCK_TEXT);
     }
 
     @Test
@@ -324,8 +328,12 @@
                 mActivity, mFragment, mForceRoundedIcon, preference, tile, null /* key */,
                 Preference.DEFAULT_ORDER);
 
-        assertThat(preference.getTitle()).isEqualTo(ShadowTileUtils.MOCK_SUMMARY);
         assertThat(observers.get(0).getUri().toString()).isEqualTo(uriString);
+        assertThat(preference.getTitle()).isNotEqualTo(ShadowTileUtils.MOCK_TEXT);
+
+        observers.get(0).updateUi();
+
+        assertThat(preference.getTitle()).isEqualTo(ShadowTileUtils.MOCK_TEXT);
     }
 
     @Test
@@ -379,6 +387,7 @@
         final List<DynamicDataObserver> observers = mImpl.bindPreferenceToTileAndGetObservers(
                 mActivity, mFragment, mForceRoundedIcon, preference, tile, null /* key */,
                 Preference.DEFAULT_ORDER);
+        observers.get(0).updateUi();
 
         ShadowTileUtils.setProviderChecked(false);
         observers.get(0).onDataChanged();
diff --git a/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
index 8b4686b..9696776 100644
--- a/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dashboard/DashboardTilePlaceholderPreferenceControllerTest.java
@@ -20,8 +20,11 @@
 
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -47,6 +50,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new DashboardTilePlaceholderPreferenceController(mContext);
     }
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
index 1e3b112..f6bda32 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FccEquipmentIdPreferenceControllerTest.java
@@ -17,8 +17,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.os.SystemProperties;
 
@@ -47,6 +50,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new FccEquipmentIdPreferenceController(mContext);
         when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
             .thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
index eef262c..38140c5 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/FeedbackPreferenceControllerTest.java
@@ -18,8 +18,11 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.fragment.app.Fragment;
@@ -51,6 +54,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new FeedbackPreferenceController(mFragment, mContext);
         final String prefKey = mController.getPreferenceKey();
         when(mScreen.findPreference(prefKey)).thenReturn(mPreference);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
index 1da1f21..1155025 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/ManualPreferenceControllerTest.java
@@ -19,8 +19,11 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import org.junit.Before;
@@ -41,6 +44,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new ManualPreferenceController(mContext);
     }
 
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
index 464d9a2..6a85ab9 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/RegulatoryInfoPreferenceControllerTest.java
@@ -19,8 +19,11 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -56,6 +59,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
 
         mController = new RegulatoryInfoPreferenceController(mContext);
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
index a0f188d..3552e16 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceControllerTest.java
@@ -20,6 +20,7 @@
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
@@ -27,6 +28,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.res.Resources;
@@ -77,6 +79,10 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application.getApplicationContext());
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
+        doReturn(mock(DevicePolicyManager.class)).when(mMockContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         FeatureFactory.getFactory(mContext);
         mResources = spy(mContext.getResources());
         when(mContext.getResources()).thenReturn(mResources);
diff --git a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
index 54e6b99..5611e93 100644
--- a/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AutoRotatePreferenceControllerTest.java
@@ -20,8 +20,11 @@
 
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.pm.PackageManager;
@@ -60,6 +63,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         FakeFeatureFactory.setupForTest();
         mContentResolver = RuntimeEnvironment.application.getContentResolver();
         mPreference = new SwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java
index dfc13de..25d5241 100644
--- a/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java
@@ -1,13 +1,15 @@
 package com.android.settings.display;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
-import static com.google.common.truth.Truth.assertThat;
 
-
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.hardware.display.ColorDisplayManager;
@@ -17,6 +19,7 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -56,6 +59,8 @@
   @Before
   public void setUp() {
     MockitoAnnotations.initMocks(this);
+    doReturn(mock(DevicePolicyManager.class)).when(mContext)
+            .getSystemService(Context.DEVICE_POLICY_SERVICE);
 
     mContentResolver = RuntimeEnvironment.application.getContentResolver();
     when(mContext.getContentResolver()).thenReturn(mContentResolver);
diff --git a/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
index 6a46110..c6f8a1f 100644
--- a/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ShowOperatorNamePreferenceControllerTest.java
@@ -20,8 +20,11 @@
 
 import static org.mockito.Mockito.anyInt;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.os.PersistableBundle;
 import android.provider.Settings;
@@ -60,6 +63,8 @@
         when(mConfigManager.getConfigForSubId(anyInt())).thenReturn(mConfig);
         when(mContext.getSystemService(CarrierConfigManager.class)).thenReturn(mConfigManager);
 
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new ShowOperatorNamePreferenceController(mContext);
     }
 
diff --git a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
index 5133ae6..af46663 100644
--- a/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/ThemePreferenceControllerTest.java
@@ -22,10 +22,12 @@
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.om.IOverlayManager;
 import android.content.om.OverlayInfo;
@@ -70,6 +72,8 @@
     public void setUp() throws NameNotFoundException {
         MockitoAnnotations.initMocks(this);
         FakeFeatureFactory.setupForTest();
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mPackageManager.getApplicationInfo(any(), anyInt())).thenReturn(mApplicationInfo);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         when(mContext.getString(R.string.default_theme))
diff --git a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
index 6c136f1..09d1c84 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AdminGrantedPermissionsPreferenceControllerTestBase.java
@@ -21,8 +21,11 @@
 import static org.mockito.ArgumentMatchers.anyObject;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -61,6 +64,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = createController(true /* async */);
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
index 5a4f38b..2b122ab 100644
--- a/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/AlwaysOnVpnManagedProfilePreferenceControllerTest.java
@@ -18,8 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -48,6 +51,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = new AlwaysOnVpnManagedProfilePreferenceController(mContext);
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
index 47db2c7..e26915b 100644
--- a/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/CaCertsPreferenceControllerTestBase.java
@@ -18,8 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -46,6 +49,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = createController();
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
index 232d3e7..f39b4b8 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseInstalledPackagesPreferenceControllerTest.java
@@ -20,9 +20,12 @@
 
 import static org.mockito.Mockito.anyObject;
 import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -56,6 +59,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = new EnterpriseInstalledPackagesPreferenceController(mContext,
                 true /* async */);
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
index afb1971..62133d9 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterprisePrivacyPreferenceControllerTest.java
@@ -18,9 +18,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -47,6 +50,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new EnterprisePrivacyPreferenceController(
                 mContext, mPrivacyPreferenceControllerHelper, KEY_ENTERPRISE_PRIVACY);
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
index b91582b..7a38feb 100644
--- a/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/EnterpriseSetDefaultAppsPreferenceControllerTest.java
@@ -22,8 +22,11 @@
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.argThat;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ApplicationInfo;
@@ -64,6 +67,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = new EnterpriseSetDefaultAppsPreferenceController(mContext);
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
index 9dd02de..03854bf 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FailedPasswordWipePreferenceControllerTestBase.java
@@ -18,8 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -53,6 +56,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
     }
 
diff --git a/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
index 61da68e..8d82284 100644
--- a/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/FinancedPrivacyPreferenceControllerTest.java
@@ -18,9 +18,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -47,6 +50,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new FinancedPrivacyPreferenceController(
                 mContext, mPrivacyPreferenceControllerHelper, PREF_KEY_FINANCED_PRIVACY);
     }
diff --git a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
index dc9fb0c..c9ce060 100644
--- a/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/enterprise/ImePreferenceControllerTest.java
@@ -18,8 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -52,6 +55,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFeatureFactory = FakeFeatureFactory.setupForTest();
         mController = new ImePreferenceController(mContext);
         when(mContext.getResources().getString(R.string.enterprise_privacy_input_method_name,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
index 5e69b8f..46773c9 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java
@@ -26,6 +26,7 @@
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
+import android.os.Process;
 import android.os.UserManager;
 import android.text.format.DateUtils;
 
@@ -101,7 +102,7 @@
     }
 
     @Test
-    public void testSetUsageSummary_timeLessThanOneMinute_DoNotSetSummary() {
+    public void testSetUsageSummary_timeLessThanOneMinute_doNotSetSummary() {
         when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(59 * DateUtils.SECOND_IN_MILLIS);
 
         mPreferenceController.setUsageSummary(mPreference, mBatteryEntry);
@@ -109,6 +110,15 @@
     }
 
     @Test
+    public void testSetUsageSummary_systemProcessUid_doNotSetSummary() {
+        when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(DateUtils.MINUTE_IN_MILLIS);
+        when(mBatteryEntry.getUid()).thenReturn(Process.SYSTEM_UID);
+
+        mPreferenceController.setUsageSummary(mPreference, mBatteryEntry);
+        assertThat(mPreference.getSummary()).isNull();
+    }
+
+    @Test
     public void testSetUsageSummary_timeMoreThanOneMinute_normalApp_setScreenSummary() {
         when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(2 * DateUtils.MINUTE_IN_MILLIS);
         doReturn(mContext.getText(R.string.battery_used_for)).when(mFragment).getText(
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDiffEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDiffEntryTest.java
index 710d065..6ea1390 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryDiffEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryDiffEntryTest.java
@@ -358,6 +358,24 @@
     }
 
     @Test
+    public void testIsSystemEntry_uidBatteryWithTetheringProcess_returnTrue() {
+        final BatteryDiffEntry entry =
+            createBatteryDiffEntry(
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
+                /*uid=*/ BatteryUtils.UID_TETHERING, /*isHidden=*/ false);
+        assertThat(entry.isSystemEntry()).isTrue();
+    }
+
+    @Test
+    public void testIsSystemEntry_uidBatteryWithRemovedAppsProcess_returnTrue() {
+        final BatteryDiffEntry entry =
+            createBatteryDiffEntry(
+                ConvertUtils.CONSUMER_TYPE_UID_BATTERY,
+                /*uid=*/ BatteryUtils.UID_REMOVED_APPS, /*isHidden=*/ false);
+        assertThat(entry.isSystemEntry()).isTrue();
+    }
+
+    @Test
     public void testUpdateRestrictionFlagState_updateFlagAsExpected() throws Exception {
         final String expectedAppLabel = "fake app label";
         final String fakePackageName = "com.fake.google.com";
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
index 966bc70..707a658 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryEntryTest.java
@@ -279,6 +279,22 @@
     }
 
     @Test
+    public void getNameAndIconFromUid_tetheringUid_rerturnExpectedName() {
+        final NameAndIcon nameAndIcon = BatteryEntry.getNameAndIconFromUid(
+                mContext, /* name */ null, /* uid */ BatteryUtils.UID_TETHERING);
+
+        assertThat(nameAndIcon.mName).isEqualTo(getString(R.string.process_network_tethering));
+    }
+
+    @Test
+    public void getNameAndIconFromUid_removedAppsUid_rerturnExpectedName() {
+        final NameAndIcon nameAndIcon = BatteryEntry.getNameAndIconFromUid(
+                mContext, /* name */ null, /* uid */ BatteryUtils.UID_REMOVED_APPS);
+
+        assertThat(nameAndIcon.mName).isEqualTo(getString(R.string.process_removed_apps));
+    }
+
+    @Test
     public void getNameAndIconFromPowerComponent_rerturnExpectedNameAndIcon() {
         assertNameAndIcon(BatteryConsumer.POWER_COMPONENT_AMBIENT_DISPLAY,
                 R.string.ambient_display_screen_title,
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
index b132a97..6691bd5 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/SmartBatteryPreferenceControllerTest.java
@@ -19,15 +19,18 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
+import android.content.Context;
 import android.provider.Settings;
 
 import androidx.preference.SwitchPreference;
 
 import com.android.settings.core.BasePreferenceController;
 import com.android.settings.testutils.FakeFeatureFactory;
-import com.android.settingslib.widget.MainSwitchPreference;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -42,6 +45,7 @@
     private static final int ON = 1;
     private static final int OFF = 0;
 
+    private Context mContext = spy(RuntimeEnvironment.application);
     private SmartBatteryPreferenceController mController;
     private SwitchPreference mPreference;
     private ContentResolver mContentResolver;
@@ -50,11 +54,13 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
 
         mFeatureFactory = FakeFeatureFactory.setupForTest();
-        mContentResolver = RuntimeEnvironment.application.getContentResolver();
-        mController = new SmartBatteryPreferenceController(RuntimeEnvironment.application);
-        mPreference = new SwitchPreference(RuntimeEnvironment.application);
+        mContentResolver = mContext.getContentResolver();
+        mController = new SmartBatteryPreferenceController(mContext);
+        mPreference = new SwitchPreference(mContext);
     }
 
     @Test
@@ -118,7 +124,7 @@
     @Test
     public void isSliceableCorrectKey_returnsTrue() {
         final SmartBatteryPreferenceController controller =
-                new SmartBatteryPreferenceController(null);
+                new SmartBatteryPreferenceController(mContext);
         assertThat(controller.isSliceable()).isTrue();
     }
 
diff --git a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
index e77521d..4984946 100644
--- a/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/AssistGestureSettingsPreferenceControllerTest.java
@@ -18,8 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import com.android.settings.testutils.FakeFeatureFactory;
@@ -48,6 +51,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mFactory = FakeFeatureFactory.setupForTest();
         mController = new AssistGestureSettingsPreferenceController(mContext, KEY_ASSIST);
         mController.setAssistOnly(false);
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
index edcbd76..6069253 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTapScreenPreferenceControllerTest.java
@@ -22,8 +22,11 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.hardware.display.AmbientDisplayConfiguration;
@@ -53,6 +56,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new DoubleTapScreenPreferenceController(mContext, KEY_DOUBLE_TAP_SCREEN);
         mController.setConfig(mAmbientDisplayConfiguration);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
index 630d480..f04505b 100644
--- a/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/DoubleTwistPreferenceControllerTest.java
@@ -19,10 +19,12 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.hardware.Sensor;
 import android.hardware.SensorManager;
@@ -61,6 +63,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
         mController = new DoubleTwistPreferenceController(mContext, KEY_DOUBLE_TWIST);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
index 1707c9d..6339546 100644
--- a/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GesturePreferenceControllerTest.java
@@ -19,10 +19,12 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -55,6 +57,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new TestPrefController(mContext, "testKey");
         mPreference = new Preference(RuntimeEnvironment.application);
         mPreference.setKey(mController.getPreferenceKey());
diff --git a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
index c185810..fc0f45c 100644
--- a/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/GesturesSettingsPreferenceControllerTest.java
@@ -20,7 +20,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
 import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
 
 import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settingslib.core.AbstractPreferenceController;
@@ -49,6 +54,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mActivity)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         FakeFeatureFactory.setupForTest();
         mController = new GesturesSettingPreferenceController(mActivity);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
index b694db3..3fd6877 100644
--- a/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PickupGesturePreferenceControllerTest.java
@@ -22,8 +22,11 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.hardware.display.AmbientDisplayConfiguration;
@@ -54,6 +57,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new PickupGesturePreferenceController(mContext, KEY_PICK_UP);
         mController.setConfig(mAmbientDisplayConfiguration);
     }
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
index 519232e..13856d0 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeToNotificationPreferenceControllerTest.java
@@ -20,8 +20,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
@@ -55,6 +58,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new SwipeToNotificationPreferenceController(mContext, KEY_SWIPE_DOWN);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         when(mContext.getSystemService(Context.FINGERPRINT_SERVICE))
diff --git a/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
index ead12cf..b050970 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/SpellCheckerPreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.res.Resources;
 import android.view.textservice.SpellCheckerInfo;
@@ -59,6 +61,8 @@
         mAppContext = RuntimeEnvironment.application;
         when(mContext.getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE))
                 .thenReturn(mTextServicesManager);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mContext.getResources()).thenReturn(mResources);
         when(mResources.getBoolean(R.bool.config_show_spellcheckers_settings)).thenReturn(true);
         mPreference = new Preference(mAppContext);
diff --git a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
index 29492b6..ed48fd1 100644
--- a/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/language/UserDictionaryPreferenceControllerTest.java
@@ -18,6 +18,10 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 
 import androidx.preference.Preference;
@@ -48,6 +52,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         FakeFeatureFactory.setupForTest();
         mController = new TestController(mContext);
         mPreference = new Preference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/localepicker/AppLocalePickerActivityTest.java b/tests/robotests/src/com/android/settings/localepicker/AppLocalePickerActivityTest.java
index 4d5e0b9..332a39b 100644
--- a/tests/robotests/src/com/android/settings/localepicker/AppLocalePickerActivityTest.java
+++ b/tests/robotests/src/com/android/settings/localepicker/AppLocalePickerActivityTest.java
@@ -18,6 +18,10 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
 import android.app.Activity;
 import android.app.ApplicationPackageManager;
 import android.content.Context;
@@ -28,14 +32,15 @@
 import android.os.UserHandle;
 import android.telephony.TelephonyManager;
 
-import androidx.fragment.app.Fragment;
-
-import com.android.settings.R;
+import com.android.internal.app.LocaleStore;
 import com.android.settings.applications.AppInfoBase;
 
+import java.util.Locale;
+
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 import org.robolectric.Robolectric;
@@ -56,6 +61,9 @@
     private static final String TEST_PACKAGE_NAME = "com.android.settings";
     private static final Uri TEST_PACKAGE_URI = Uri.parse("package:" + TEST_PACKAGE_NAME);
 
+    @Mock
+    LocaleStore.LocaleInfo mLocaleInfo;
+
     @Rule
     public MockitoRule rule = MockitoJUnit.rule();
 
@@ -79,6 +87,38 @@
         assertThat(controller.get().isFinishing()).isTrue();
     }
 
+    @Test
+    public void onLocaleSelected_getLocaleNotNull_getLanguageTag() {
+        ActivityController<TestAppLocalePickerActivity> controller =
+                initActivityController(true);
+        Locale locale = new Locale("en", "US");
+        when(mLocaleInfo.getLocale()).thenReturn(locale);
+        when(mLocaleInfo.isSystemLocale()).thenReturn(false);
+
+        controller.create();
+        AppLocalePickerActivity mActivity = controller.get();
+        mActivity.onLocaleSelected(mLocaleInfo);
+
+        verify(mLocaleInfo, times(2)).getLocale();
+        assertThat(mLocaleInfo.getLocale().toLanguageTag()).isEqualTo("en-US");
+        assertThat(controller.get().isFinishing()).isTrue();
+    }
+
+    @Test
+    public void onLocaleSelected_getLocaleNull_getEmptyLanguageTag() {
+        ActivityController<TestAppLocalePickerActivity> controller =
+                initActivityController(true);
+        when(mLocaleInfo.getLocale()).thenReturn(null);
+        when(mLocaleInfo.isSystemLocale()).thenReturn(false);
+
+        controller.create();
+        AppLocalePickerActivity mActivity = controller.get();
+        mActivity.onLocaleSelected(mLocaleInfo);
+
+        verify(mLocaleInfo, times(1)).getLocale();
+        assertThat(controller.get().isFinishing()).isTrue();
+    }
+
     private ActivityController<TestAppLocalePickerActivity> initActivityController(
             boolean hasPackageName) {
         Intent data = new Intent();
diff --git a/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java
index c216671..15e24e1 100644
--- a/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/AllInOneTetherPreferenceControllerTest.java
@@ -131,9 +131,11 @@
 
     @Before
     public void setUp() {
-        mContext = ApplicationProvider.getApplicationContext();
+        mContext = spy(ApplicationProvider.getApplicationContext());
         MockitoAnnotations.initMocks(this);
-        mController = spy(AllInOneTetherPreferenceController.class);
+        doReturn(null).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
+        mController = spy(new AllInOneTetherPreferenceController(mContext, /* key= */ "test"));
         ReflectionHelpers.setField(mController, "mContext", mContext);
         ReflectionHelpers.setField(mController, "mBluetoothAdapter", mBluetoothAdapter);
         ReflectionHelpers.setField(mController, "mPreferenceKey", PREF_KEY);
diff --git a/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
index b80bc11..bafc021 100644
--- a/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/TetherPreferenceControllerTest.java
@@ -17,6 +17,7 @@
 package com.android.settings.network;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -24,6 +25,7 @@
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothPan;
 import android.bluetooth.BluetoothProfile;
@@ -67,7 +69,9 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        mController = spy(TetherPreferenceController.class);
+        doReturn(null).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
+        mController = spy(new TetherPreferenceController(mContext, /* lifecycle= */ null));
         ReflectionHelpers.setField(mController, "mContext", mContext);
         ReflectionHelpers.setField(mController, "mTetheringManager", mTetheringManager);
         ReflectionHelpers.setField(mController, "mBluetoothAdapter", mBluetoothAdapter);
diff --git a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
index 89cf2f7..e2226d9 100644
--- a/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BadgingNotificationPreferenceControllerTest.java
@@ -23,10 +23,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.provider.Settings;
 
@@ -59,6 +61,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new BadgingNotificationPreferenceController(mContext,
                 KEY_NOTIFICATION_BADGING);
         mPreference = new Preference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
index 9a2ab9b..76a64d3 100644
--- a/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BootSoundPreferenceControllerTest.java
@@ -18,9 +18,12 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.os.SystemProperties;
 
@@ -52,6 +55,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mContext.getResources().getBoolean(R.bool.has_boot_sounds))
                 .thenReturn(true);
         mController = new BootSoundPreferenceController(mContext);
diff --git a/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
index db50214..d237b27 100644
--- a/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DockAudioMediaPreferenceControllerTest.java
@@ -21,8 +21,10 @@
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.provider.Settings.Global;
@@ -59,6 +61,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mSetting.getActivity()).thenReturn(mActivity);
         when(mActivity.getContentResolver()).thenReturn(mContentResolver);
         when(mActivity.getResources().getBoolean(com.android.settings.R.bool.has_dock_settings))
diff --git a/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
index b694268..0cfc6b7 100644
--- a/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/DockingSoundPreferenceControllerTest.java
@@ -20,8 +20,10 @@
 
 import static org.mockito.Answers.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.provider.Settings.Global;
@@ -58,6 +60,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mSetting.getActivity()).thenReturn(mActivity);
         when(mActivity.getContentResolver()).thenReturn(mContentResolver);
         mPreference = new SwitchPreference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
index 822ca5f..ec9bfc5 100644
--- a/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/EmergencyBroadcastPreferenceControllerTest.java
@@ -20,10 +20,13 @@
 
 import static org.mockito.Mockito.anyInt;
 import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.UserManager;
@@ -60,6 +63,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
         when(mContext.getPackageManager()).thenReturn(mPackageManager);
         mController =
diff --git a/tests/robotests/src/com/android/settings/notification/SnoozeNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SnoozeNotificationPreferenceControllerTest.java
index 6779ff1..1426ccc 100644
--- a/tests/robotests/src/com/android/settings/notification/SnoozeNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SnoozeNotificationPreferenceControllerTest.java
@@ -16,7 +16,6 @@
 
 package com.android.settings.notification;
 
-import static android.provider.Settings.Secure.NOTIFICATION_BADGING;
 import static android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE;
 
 import static com.android.settings.notification.BadgingNotificationPreferenceController.OFF;
@@ -24,13 +23,17 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.provider.Settings;
 
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -40,10 +43,6 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
-
 @RunWith(RobolectricTestRunner.class)
 public class SnoozeNotificationPreferenceControllerTest {
 
@@ -58,6 +57,8 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         mController = new SnoozeNotificationPreferenceController(mContext,
                 "key");
         mPreference = new Preference(RuntimeEnvironment.application);
diff --git a/tests/robotests/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceControllerTest.java
index b2a54ca..1660955 100644
--- a/tests/robotests/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/zen/ZenModeAutomaticRulesPreferenceControllerTest.java
@@ -16,6 +16,8 @@
 
 package com.android.settings.notification.zen;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.doReturn;
@@ -33,10 +35,7 @@
 import androidx.fragment.app.Fragment;
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceScreen;
-
-import com.android.settings.notification.zen.ZenModeAutomaticRulesPreferenceController;
-import com.android.settings.notification.zen.ZenModeBackend;
-import com.android.settings.notification.zen.ZenRulePreference;
+import androidx.test.core.app.ApplicationProvider;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -45,7 +44,6 @@
 import org.mockito.MockitoAnnotations;
 import org.mockito.internal.util.reflection.FieldSetter;
 import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
 import org.robolectric.util.ReflectionHelpers;
 
 import java.util.HashMap;
@@ -68,7 +66,7 @@
     @Before
     public void setup() {
         MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
+        mContext = ApplicationProvider.getApplicationContext();
         mController = spy(new ZenModeAutomaticRulesPreferenceController(mContext, mock(Fragment.class),
             null));
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
@@ -79,6 +77,16 @@
     }
 
     @Test
+    public void testDisplayPreference_resetsPreferencesWhenCategoryEmpty() {
+        // when the PreferenceCategory is empty (no preferences), make sure we clear out any
+        // stale state in the cached set of zen rule preferences
+        mController.mZenRulePreferences.put("test1_id", mZenRulePreference);
+        when(mockPref.getPreferenceCount()).thenReturn(0);
+        mController.displayPreference(mPreferenceScreen);
+        assertTrue(mController.mZenRulePreferences.isEmpty());
+    }
+
+    @Test
     public void testUpdateState_clearsPreferencesWhenAddingNewPreferences() {
         final int NUM_RULES = 3;
         Map<String, AutomaticZenRule> rMap = new HashMap<>();
@@ -103,6 +111,7 @@
         mController.updateState(mockPref);
         verify(mockPref, times(1)).removeAll();
         verify(mockPref, times(NUM_RULES)).addPreference(any());
+        assertEquals(NUM_RULES, mController.mZenRulePreferences.size());
     }
 
     @Test
@@ -121,12 +130,49 @@
         rMap.put(ruleId1, autoRule1);
         rMap.put(ruleId2, autoRule2);
 
+        // Add three preferences to the set of previously-known-about ZenRulePreferences; in this
+        // case, test3_id is "deleted"
+        mController.mZenRulePreferences.put("test1_id", mZenRulePreference);
+        mController.mZenRulePreferences.put("test2_id", mZenRulePreference);
+        mController.mZenRulePreferences.put("test3_id", mZenRulePreference);
+
         // update state should re-add all preferences since a preference was deleted
-        when(mockPref.getPreferenceCount()).thenReturn(NUM_RULES + 2);
+        when(mockPref.getPreferenceCount()).thenReturn(NUM_RULES + 1);
         mockGetAutomaticZenRules(NUM_RULES, rMap);
         mController.updateState(mockPref);
         verify(mockPref, times(1)).removeAll();
         verify(mockPref, times(NUM_RULES)).addPreference(any());
+        assertEquals(NUM_RULES, mController.mZenRulePreferences.size());
+    }
+
+    @Test
+    public void testUpdateState_clearsPreferencesWhenSameNumberButDifferentPrefs() {
+        final int NUM_RULES = 2;
+        Map<String, AutomaticZenRule> rMap = new HashMap<>();
+
+        String ruleId1 = "test1_id";
+        String ruleId2 = "test2_id";
+
+        AutomaticZenRule autoRule1 = new AutomaticZenRule("test_rule_1", null, null,
+                null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 10);
+        AutomaticZenRule autoRule2 = new AutomaticZenRule("test_rule_2", null, null,
+                null, null, Settings.Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS, true, 20);
+
+        rMap.put(ruleId1, autoRule1);
+        rMap.put(ruleId2, autoRule2);
+
+        // Add two preferences to the set of previously-known-about ZenRulePreferences; in this
+        // case, test3_id is "deleted" but test2_id is "added"
+        mController.mZenRulePreferences.put("test1_id", mZenRulePreference);
+        mController.mZenRulePreferences.put("test3_id", mZenRulePreference);
+
+        // update state should re-add all preferences since a preference was deleted
+        when(mockPref.getPreferenceCount()).thenReturn(NUM_RULES);
+        mockGetAutomaticZenRules(NUM_RULES, rMap);
+        mController.updateState(mockPref);
+        verify(mockPref, times(1)).removeAll();
+        verify(mockPref, times(NUM_RULES)).addPreference(any());
+        assertEquals(NUM_RULES, mController.mZenRulePreferences.size());
     }
 
     @Test
@@ -140,6 +186,7 @@
 
         when(mockPref.getPreferenceCount()).thenReturn(NUM_RULES);
         when(mockPref.getPreference(anyInt())).thenReturn(mZenRulePreference);
+        mController.mZenRulePreferences.put("test1_id", mZenRulePreference);
 
         // update state should NOT re-add all the preferences, should only update enable state
         rule.setEnabled(false);
@@ -148,7 +195,8 @@
         FieldSetter.setField(mZenRulePreference, ZenRulePreference.class.getDeclaredField("mId"), testId);
         mController.updateState(mockPref);
         verify(mZenRulePreference, times(1)).updatePreference(any());
-        verify(mController, never()).reloadAllRules(any());
+        verify(mockPref, never()).removeAll();
+        assertEquals(NUM_RULES, mController.mZenRulePreferences.size());
     }
 
     private void mockGetAutomaticZenRules(int numRules, Map<String, AutomaticZenRule> rules) {
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
index 45a9dd6..d164cb9 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowTileUtils.java
@@ -34,7 +34,7 @@
 @Implements(TileUtils.class)
 public class ShadowTileUtils {
 
-    public static final String MOCK_SUMMARY = "summary";
+    public static final String MOCK_TEXT = "text";
 
     private static boolean sChecked;
     private static Bundle sResult;
@@ -42,13 +42,14 @@
     @Implementation
     protected static String getTextFromUri(Context context, Uri uri,
             Map<String, IContentProvider> providerMap, String key) {
-        return MOCK_SUMMARY;
+        return MOCK_TEXT;
     }
 
     @Implementation
     protected static Pair<String, Integer> getIconFromUri(Context context, String packageName,
             Uri uri, Map<String, IContentProvider> providerMap) {
-        return Pair.create(RuntimeEnvironment.application.getPackageName(), R.drawable.ic_settings_accent);
+        return Pair.create(RuntimeEnvironment.application.getPackageName(),
+                R.drawable.ic_settings_accent);
     }
 
     @Implementation
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 d8151d0..8e42fcd 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -38,6 +38,7 @@
 import androidx.slice.SliceItem;
 import androidx.slice.SliceMetadata;
 import androidx.slice.SliceProvider;
+import androidx.slice.core.SliceAction;
 import androidx.slice.core.SliceQuery;
 import androidx.slice.widget.ListContent;
 import androidx.slice.widget.SliceLiveData;
@@ -120,6 +121,11 @@
         final Slice wifiSlice = mWifiSlice.getSlice();
 
         assertThat(wifiSlice).isNotNull();
+
+        final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+        final List<SliceAction> toggles = metadata.getToggles();
+
+        assertThat(toggles).hasSize(1);
     }
 
     @Test
@@ -128,18 +134,29 @@
         ShadowWifiSlice.setWifiPermissible(true);
 
         final Slice wifiSlice = mWifiSlice.getSlice();
-
         assertThat(wifiSlice).isNotNull();
+
+        final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+        final List<SliceAction> toggles = metadata.getToggles();
+
+        assertThat(toggles).hasSize(1);
     }
 
     @Test
-    public void getWifiSlice_notFromSIPackageAndWithoutWifiPermission_shouldNoSlice() {
+    public void getWifiSlice_notFromSIPackageAndWithoutWifiPermission_shouldReturnNoToggle() {
         when(mPackageManager.getPackagesForUid(USER_ID)).thenReturn(new String[]{"com.test"});
         ShadowWifiSlice.setWifiPermissible(false);
 
         final Slice wifiSlice = mWifiSlice.getSlice();
+        final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+        final List<SliceAction> toggles = metadata.getToggles();
 
-        assertThat(wifiSlice).isNull();
+        assertThat(toggles).hasSize(0);
+
+        final int rows = SliceQuery.findAll(wifiSlice, FORMAT_SLICE, HINT_LIST_ITEM,
+                null /* nonHints */).size();
+        // Title row
+        assertThat(rows).isEqualTo(1);
     }
 
     @Test
@@ -150,7 +167,6 @@
 
         final int rows = SliceQuery.findAll(wifiSlice, FORMAT_SLICE, HINT_LIST_ITEM,
                 null /* nonHints */).size();
-
         // Title row
         assertThat(rows).isEqualTo(1);
     }
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
index c1d6c16..432c7e2 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherFooterPreferenceControllerTest.java
@@ -18,10 +18,12 @@
 
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.net.TetheringManager;
 import android.net.wifi.WifiManager;
@@ -58,6 +60,8 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
         doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
         when(mContext.getSystemService(Context.TETHERING_SERVICE)).thenReturn(mTetheringManager);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
index bb61eb9..081a078 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherPasswordPreferenceControllerTest.java
@@ -20,11 +20,13 @@
 
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.net.TetheringManager;
@@ -76,6 +78,8 @@
                 .setPassphrase(INITIAL_PASSWORD, SoftApConfiguration.SECURITY_TYPE_WPA2_PSK)
                 .build();
 
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
         when(mWifiManager.getSoftApConfiguration()).thenReturn(mConfig);
         doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
index 2d88722..07d5762 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceControllerTest.java
@@ -20,11 +20,13 @@
 
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.net.TetheringManager;
@@ -68,6 +70,8 @@
         MockitoAnnotations.initMocks(this);
         mPreference = new WifiTetherSsidPreference(RuntimeEnvironment.application);
 
+        doReturn(mock(DevicePolicyManager.class)).when(mContext)
+                .getSystemService(Context.DEVICE_POLICY_SERVICE);
         doReturn(mWifiManager).when(mContext).getSystemService(WifiManager.class);
         doReturn(mTetheringManager).when(mContext).getSystemService(TetheringManager.class);
         when(mTetheringManager.getTetherableWifiRegexs()).thenReturn(new String[]{"1", "2"});
diff --git a/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java b/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java
new file mode 100644
index 0000000..b9dea01
--- /dev/null
+++ b/tests/unit/src/com/android/settings/DefaultRingtonePreferenceTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.media.RingtoneManager;
+import android.net.Uri;
+
+import androidx.test.core.app.ApplicationProvider;
+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;
+
+/** Unittest for DefaultRingtonePreference. */
+@RunWith(AndroidJUnit4.class)
+public class DefaultRingtonePreferenceTest {
+
+    private DefaultRingtonePreference mDefaultRingtonePreference;
+
+    @Mock
+    private ContentResolver mContentResolver;
+    @Mock
+    private Uri mRingtoneUri;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        Context context = spy(ApplicationProvider.getApplicationContext());
+        doReturn(mContentResolver).when(context).getContentResolver();
+
+        mDefaultRingtonePreference = spy(new DefaultRingtonePreference(context, null /* attrs */));
+        doReturn(context).when(mDefaultRingtonePreference).getContext();
+        when(mDefaultRingtonePreference.getRingtoneType())
+                .thenReturn(RingtoneManager.TYPE_RINGTONE);
+        mDefaultRingtonePreference.setUserId(1);
+    }
+
+    @Test
+    public void onSaveRingtone_nullMimeType_shouldNotSetRingtone() {
+        when(mContentResolver.getType(mRingtoneUri)).thenReturn(null);
+
+        mDefaultRingtonePreference.onSaveRingtone(mRingtoneUri);
+
+        verify(mDefaultRingtonePreference, never()).setActualDefaultRingtoneUri(mRingtoneUri);
+    }
+
+    @Test
+    public void onSaveRingtone_notAudioMimeType_shouldNotSetRingtone() {
+        when(mContentResolver.getType(mRingtoneUri)).thenReturn("text/plain");
+
+        mDefaultRingtonePreference.onSaveRingtone(mRingtoneUri);
+
+        verify(mDefaultRingtonePreference, never()).setActualDefaultRingtoneUri(mRingtoneUri);
+    }
+}
diff --git a/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java b/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java
index 9bc3ef5..8350bc7 100644
--- a/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java
+++ b/tests/unit/src/com/android/settings/applications/AppLocaleUtilTest.java
@@ -37,6 +37,7 @@
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -71,6 +72,7 @@
     }
 
     @Test
+    @Ignore("b/231904717")
     public void canDisplayLocaleUi_showUI() throws PackageManager.NameNotFoundException {
         setApplicationInfo(/*no platform key*/ false);
         setActivityInfo(mAllowedPackage);
@@ -79,6 +81,7 @@
     }
 
     @Test
+    @Ignore("b/231904717")
     public void canDisplayLocaleUi_notShowUI_hasPlatformKey()
             throws PackageManager.NameNotFoundException {
         setApplicationInfo(/*has platform key*/ true);
@@ -88,6 +91,7 @@
     }
 
     @Test
+    @Ignore("b/231904717")
     public void canDisplayLocaleUi_notShowUI_noLauncherEntry()
             throws PackageManager.NameNotFoundException {
         setApplicationInfo(/*no platform key*/false);
@@ -97,6 +101,7 @@
     }
 
     @Test
+    @Ignore("b/231904717")
     public void canDisplayLocaleUi_notShowUI_matchDisallowedPackageList()
             throws PackageManager.NameNotFoundException {
         setApplicationInfo(/*no platform key*/false);
diff --git a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
index 066cf6b..b5020db 100644
--- a/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/NetworkProviderSimListControllerTest.java
@@ -46,6 +46,7 @@
 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.Mock;
@@ -230,6 +231,7 @@
         assertTrue(TextUtils.equals(mController.getSummary(SUB_ID_1, DISPLAY_NAME_1), summary));
     }
 
+    @Ignore
     @Test
     @UiThreadTest
     public void getAvailablePhysicalSubscription_withTwoPhysicalSims_returnTwo() {
diff --git a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
index 8687e5a..436d37f 100644
--- a/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
+++ b/tests/unit/src/com/android/settings/network/ProviderModelSliceHelperTest.java
@@ -56,6 +56,7 @@
 import com.android.wifitrackerlib.WifiEntry;
 
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -165,6 +166,7 @@
         assertThat(testItem).isNull();
     }
 
+    @Ignore
     @Test
     public void createCarrierRow_hasDdsAndActiveNetworkIsNotCellular_verifyTitleAndSummary() {
         String expectDisplayName = "Name1";
@@ -181,6 +183,7 @@
         assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
     }
 
+    @Ignore
     @Test
     public void createCarrierRow_wifiOnhasDdsAndActiveNetworkIsCellular_verifyTitleAndSummary() {
         String expectDisplayName = "Name1";
@@ -201,6 +204,7 @@
         assertThat(testRowBuild.getSubtitle()).isEqualTo(expectedSubtitle);
     }
 
+    @Ignore
     @Test
     public void createCarrierRow_noNetworkAvailable_verifyTitleAndSummary() {
         String expectDisplayName = "Name1";
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
index b0d6365..43a32b5 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -69,6 +69,7 @@
         when(mTelMgr.getUiccSlotsInfo()).thenReturn(null);
     }
 
+    @Ignore
     @Test
     public void getAvailableSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
         when(mSubMgr.getAvailableSubscriptionInfoList()).thenReturn(null);
@@ -90,6 +91,7 @@
         assertThat(subs).hasSize(1);
     }
 
+    @Ignore
     @Test
     public void getAvailableSubscriptions_twoSubscriptions_twoResults() {
         final SubscriptionInfo info1 = mock(SubscriptionInfo.class);
@@ -138,6 +140,7 @@
         assertThat(subs).hasSize(2);
     }
 
+    @Ignore
     @Test
     public void getUniqueDisplayNames_uniqueCarriers_originalUsed() {
         // Each subscription's default display name is unique.
@@ -228,6 +231,7 @@
         assertEquals(CARRIER_1 + " 4444", idNames.get(SUBID_2));
     }
 
+    @Ignore
     @Test
     public void getUniqueDisplayNames_phoneNumberBlocked_subscriptoinIdFallback() {
         // Both subscriptoins have the same display name.
@@ -295,6 +299,7 @@
         assertEquals(CARRIER_1 + " 3", idNames.get(SUBID_3));
     }
 
+    @Ignore
     @Test
     public void getUniqueDisplayName_onlyOneSubscription_correctNameReturned() {
         // Each subscription's default display name is unique.
@@ -394,6 +399,7 @@
         assertTrue(TextUtils.isEmpty(name));
     }
 
+    @Ignore
     @Test
     public void getUniqueDisplayName_fullSubscriptionInfo_correctNameReturned() {
         // Each subscription's default display name is unique.
diff --git a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
index ac07fae..3bcfcb4 100644
--- a/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/SubscriptionsPreferenceControllerTest.java
@@ -200,7 +200,7 @@
     }
 
     @Test
-    public void isAvailable_airplaneModeOnWifiOffWithCarrierNetwork_availableTrue() {
+    public void isAvailable_airplaneModeOnWifiOffWithCarrierNetwork_availableFalse() {
         setupMockSubscriptions(1);
 
         when(mWifiManager.isWifiEnabled()).thenReturn(false);
@@ -212,7 +212,7 @@
     }
 
     @Test
-    public void isAvailable_airplaneModeOff_availableFalse() {
+    public void isAvailable_airplaneModeOff_availableTrue() {
         setupMockSubscriptions(2);
 
         assertThat(mController.isAvailable()).isTrue();
@@ -235,12 +235,11 @@
         mController.displayPreference(mPreferenceScreen);
 
         assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
     }
 
     @Test
     @UiThreadTest
-    public void displayPreference_providerAndHasMultiSim_showDataSubPreference() {
+    public void displayPreference_providerAndHasMultiSim_showOnePreference() {
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
         doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
@@ -249,7 +248,6 @@
         mController.displayPreference(mPreferenceScreen);
 
         assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
     }
 
     @Test
@@ -437,7 +435,7 @@
 
     @Test
     @UiThreadTest
-    public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId1Preference() {
+    public void dataSubscriptionChanged_providerAndHasMultiSim_showOnePreference() {
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
         doReturn(sub).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
@@ -449,12 +447,11 @@
 
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
     }
 
     @Test
     @UiThreadTest
-    public void dataSubscriptionChanged_providerAndHasMultiSim_showSubId2Preference() {
+    public void dataSubscriptionChanged_providerAndHasMultiSim_showOnlyOnePreference() {
         final List<SubscriptionInfo> sub = setupMockSubscriptions(2);
         final int subId = sub.get(0).getSubscriptionId();
         doReturn(sub.get(0)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
@@ -464,17 +461,12 @@
         mController.onResume();
         mController.displayPreference(mPreferenceScreen);
 
-        assertThat(mController.isAvailable()).isTrue();
-        assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub1");
-
         doReturn(sub.get(1)).when(mSubscriptionManager).getDefaultDataSubscriptionInfo();
 
         mController.mConnectionChangeReceiver.onReceive(mContext, intent);
 
         assertThat(mController.isAvailable()).isTrue();
         assertThat(mPreferenceCategory.getPreferenceCount()).isEqualTo(1);
-        assertThat(mPreferenceCategory.getPreference(0).getTitle()).isEqualTo("sub2");
     }
 
     @Test
diff --git a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
index c48941f..57e38d3 100644
--- a/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
+++ b/tests/unit/src/com/android/settings/network/telephony/DefaultSubscriptionControllerTest.java
@@ -44,6 +44,7 @@
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -111,6 +112,7 @@
         assertThat(mController.getLabelFromCallingAccount(null)).isEqualTo("");
     }
 
+    @Ignore
     @Test
     public void displayPreference_twoSubscriptionsSub1Default_correctListPreferenceValues() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
@@ -141,6 +143,7 @@
                 Integer.toString(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
     }
 
+    @Ignore
     @Test
     public void displayPreference_twoSubscriptionsSub2Default_correctListPreferenceValues() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
@@ -171,6 +174,7 @@
                 Integer.toString(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
     }
 
+    @Ignore
     @Test
     public void displayPreference_threeSubsOneIsOpportunistic_correctListPreferenceValues() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
@@ -254,6 +258,7 @@
         assertThat(mController.getDefaultSubscriptionId()).isEqualTo(222);
     }
 
+    @Ignore
     @Test
     public void onSubscriptionsChanged_twoSubscriptionsDefaultChanges_selectedEntryGetsUpdated() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");
@@ -314,6 +319,7 @@
         assertThat(mListPreference.isEnabled()).isTrue();
     }
 
+    @Ignore
     @Test
     public void onSubscriptionsChanged_goFromTwoToThreeSubscriptions_listGetsUpdated() {
         final SubscriptionInfo sub1 = createMockSub(111, "sub1");