Merge "Fix the battery usage screen left alignment issue" into sc-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9b11fe8..35b086b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -141,7 +141,7 @@
 
         <activity android:name=".network.telephony.MobileNetworkActivity"
                   android:label="@string/network_settings_title"
-                  android:theme="@style/Theme.Settings.Home"
+                  android:theme="@style/Theme.SubSettings"
                   android:exported="true"
                   android:launchMode="singleTask">
             <intent-filter android:priority="1">
@@ -418,6 +418,7 @@
                 android:label="@string/apn_settings"
                 android:launchMode="singleTask"
                 android:exported="true"
+                android:theme="@style/Theme.SubSettings"
                 android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.APN_SETTINGS" />
@@ -1135,6 +1136,7 @@
         <activity
             android:name="Settings$ManageDomainUrlsActivity"
             android:exported="true"
+            android:theme="@style/Theme.SubSettings"
             android:label="@string/domain_urls_title">
             <intent-filter>
                 <action android:name="android.settings.MANAGE_DOMAIN_URLS" />
@@ -1312,7 +1314,7 @@
         <activity
             android:name=".notification.history.NotificationHistoryActivity"
             android:exported="true"
-            android:theme="@style/Theme.NotificationHistory"
+            android:theme="@style/Theme.SubSettings"
             android:label="@string/notification_history_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.NOTIFICATION_HISTORY" />
@@ -2059,6 +2061,7 @@
         <activity android:name="Settings$ApnEditorActivity"
                 android:configChanges="orientation|keyboardHidden|screenSize"
                 android:exported="true"
+                android:theme="@style/Theme.SubSettings"
                 android:label="@string/apn_edit">
             <intent-filter>
                 <action android:name="android.intent.action.VIEW" />
@@ -2999,6 +3002,7 @@
         <activity
             android:name="Settings$WifiCallingSettingsActivity"
             android:exported="true"
+            android:theme="@style/Theme.SubSettings"
             android:label="@string/wifi_calling_settings_title">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -3267,8 +3271,6 @@
             <!-- Tell Settings app which category it belongs to -->
             <meta-data android:name="com.android.settings.category"
                        android:value="com.android.settings.category.ia.system" />
-            <meta-data android:name="com.android.settings.summary_uri"
-                       android:value="content://com.android.settings.dashboard.SummaryProvider/backup" />
             <meta-data android:name="com.android.settings.order" android:value="-60"/>
         </activity>
 
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 800d95b..0c61a47 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -4205,4 +4205,20 @@
             column="5"/>
     </issue>
 
+    <issue
+        id="HardCodedColor"
+        severity="Error"
+        message="Avoid using hardcoded color"
+        category="Correctness"
+        priority="4"
+        summary="Using hardcoded color"
+        explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.&#xA;This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+        errorLine1="    &lt;color name=&quot;battery_info_error_color_red&quot;>#fce8e6&lt;/color> &lt;!-- Material Red 50 -->"
+        errorLine2="    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+        <location
+            file="res/values/colors.xml"
+            line="202"
+            column="5"/>
+    </issue>
+
 </issues>
diff --git a/res/drawable/ic_headset_24dp.xml b/res/drawable/ic_headset_24dp.xml
deleted file mode 100644
index 23210d0..0000000
--- a/res/drawable/ic_headset_24dp.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<!--
-    Copyright (C) 2017 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.0"
-        android:viewportHeight="24.0"
-        android:tint="?android:attr/colorControlNormal">
-    <path
-        android:fillColor="#FF000000"
-        android:pathData="M19,15v3c0,0.55 -0.45,1 -1,1h-1v-4H19M7,15v4H6c-0.55,0 -1,-0.45 -1,-1v-3H7M12,2c-4.97,0 -9,4.03 -9,9v7c0,1.66 1.34,3 3,3h3v-8H5v-2c0,-3.87 3.13,-7 7,-7s7,3.13 7,7v2h-4v8h3c1.66,0 3,-1.34 3,-3v-7C21,6.03 16.97,2 12,2L12,2z"/>
-</vector>
diff --git a/res/layout/dream_start_button.xml b/res/layout/dream_start_button.xml
deleted file mode 100644
index a45e56f..0000000
--- a/res/layout/dream_start_button.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2017 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:orientation="horizontal"
-    android:gravity="bottom"
-    android:paddingTop="4dp"
-    android:paddingStart="72dp"
-    android:paddingEnd="72dp"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <Button
-        android:id="@+id/dream_start_now_button"
-        style="@style/ActionSecondaryButton"
-        android:layout_width="0dp"
-        android:layout_weight="1"
-        android:layout_height="wrap_content"
-        android:layout_gravity="center"
-        android:text="@string/screensaver_settings_dream_start"
-        android:paddingEnd="8dp" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/face_remove_button.xml b/res/layout/face_remove_button.xml
index 98459f0..a05fb85 100644
--- a/res/layout/face_remove_button.xml
+++ b/res/layout/face_remove_button.xml
@@ -26,6 +26,6 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="start"
-        android:text="@string/security_settings_face_settings_remove_face_data"/>
+        android:text="@string/security_settings_face_settings_remove_face_model"/>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/res/layout/loading_container.xml b/res/layout/loading_container.xml
index eb67044..80cbbf9 100644
--- a/res/layout/loading_container.xml
+++ b/res/layout/loading_container.xml
@@ -18,7 +18,7 @@
     android:id="@+id/loading_container"
     android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="450dp"
     android:visibility="gone"
     android:gravity="center">
 
diff --git a/res/layout/main_clear.xml b/res/layout/main_clear.xml
index 1cf1909..cbccb0a 100644
--- a/res/layout/main_clear.xml
+++ b/res/layout/main_clear.xml
@@ -21,7 +21,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:theme="@style/GlifV3Theme.Footer"
     android:icon="@drawable/ic_delete_accent"
     app:sucHeaderText="@string/main_clear_title">
 
diff --git a/res/layout/main_clear_confirm.xml b/res/layout/main_clear_confirm.xml
index 95262a0..914a998 100644
--- a/res/layout/main_clear_confirm.xml
+++ b/res/layout/main_clear_confirm.xml
@@ -19,7 +19,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
-    android:theme="@style/SudThemeGlifV3.DayNight"
     android:id="@+id/setup_wizard_layout"
     android:icon="@drawable/ic_delete_accent"
     app:sucHeaderText="@string/main_clear_confirm_title">
diff --git a/res/layout/palette_listview_item.xml b/res/layout/palette_listview_item.xml
index e67b7cb..012e740 100644
--- a/res/layout/palette_listview_item.xml
+++ b/res/layout/palette_listview_item.xml
@@ -23,7 +23,7 @@
         android:id="@+id/item_textview"
         android:layout_width="match_parent"
         android:layout_height="42dp"
-        android:fontFamily="roboto-bold"
+        android:fontFamily="@*android:string/config_headlineFontFamilyMedium"
         android:gravity="center_vertical"
         android:maxLength="20"
         android:paddingLeft="@dimen/accessibility_layout_margin_start_end"
diff --git a/res/layout/preference_battery_error.xml b/res/layout/preference_battery_error.xml
index 66ff96a..4efd13a 100644
--- a/res/layout/preference_battery_error.xml
+++ b/res/layout/preference_battery_error.xml
@@ -1,20 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!--
-  ~ Copyright (C) 2021 The Android Open Source Project
-  ~
-  ~ Licensed under the Apache License, Version 2.0 (the "License");
-  ~ you may not use this file except in compliance with the License.
-  ~ You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
+  Copyright (C) 2021 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
   -->
-<!-- TODO(b/179237551): Refine the layout once the design been lock down. -->
+
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
@@ -23,26 +23,28 @@
         android:id="@+id/container"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:layout_marginStart="24dp"
-        android:layout_marginEnd="24dp"
+        android:layout_margin="8dp"
         style="@style/ContextualCardStyle">
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:gravity="top|start"
             android:orientation="vertical"
-            android:padding="16dp"
-            android:background="@color/homepage_emergency_background">
+            android:padding="20dp"
+            android:background="@color/battery_info_error_color_red">
 
             <ImageView
                 android:id="@+id/battery_icon"
-                android:src="@drawable/ic_battery_alert_24dp"
+                android:src="@drawable/ic_warning_24dp"
+                android:tint="@*android:color/material_red_A700"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content" />
 
             <TextView android:id="@+id/summary_text"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
+                      android:layout_marginTop="12dp"
+                      android:layout_marginBottom="16dp"
                       android:text="@string/battery_missing_message"
                       android:textAppearance="?android:attr/textAppearanceSmall"
                       android:textColor="?android:attr/textColorSecondary" />
@@ -53,7 +55,7 @@
                       android:layout_gravity="end"
                       android:text="@string/battery_missing_link_message"
                       android:textAppearance="?android:attr/textAppearanceSmall"
-                      android:textColor="?android:attr/colorError" />
+                      android:textColor="@*android:color/material_red_A700" />
         </LinearLayout>
     </com.google.android.material.card.MaterialCardView>
 </FrameLayout>
diff --git a/res/layout/wifi_add_network_view.xml b/res/layout/wifi_add_network_view.xml
index 6af46cf..8c23020 100644
--- a/res/layout/wifi_add_network_view.xml
+++ b/res/layout/wifi_add_network_view.xml
@@ -22,19 +22,29 @@
     android:layout_height="wrap_content"
     android:clipToPadding="true"
     android:clipChildren="true">
-
-        <include
-            android:id="@+id/wifi_dialog_frame"
+        <ScrollView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_above="@id/add_network_button_bar"
-            app:layout_constraintTop_toTopOf="parent"
-            layout="@layout/wifi_dialog"/>
+            android:scrollIndicators="top|bottom">
+                <LinearLayout
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:orientation="vertical">
+                        <include
+                            android:id="@+id/wifi_dialog_frame"
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            android:layout_above="@id/add_network_button_bar"
+                            app:layout_constraintTop_toTopOf="parent"
+                            layout="@layout/wifi_dialog"/>
 
-        <include
-            android:id="@+id/add_network_button_bar"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            app:layout_constraintTop_toBottomOf="@id/wifi_dialog_frame"
-            layout="@*android:layout/alert_dialog_button_bar_material"/>
+                        <include
+                            android:id="@+id/add_network_button_bar"
+                            android:layout_width="match_parent"
+                            android:layout_height="wrap_content"
+                            app:layout_constraintTop_toBottomOf="@id/wifi_dialog_frame"
+                            layout="@*android:layout/alert_dialog_button_bar_material"/>
+                </LinearLayout>
+        </ScrollView>
+
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 0aa309f..be32412 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -198,4 +198,6 @@
     <color name="accessibility_magnification_background">#F50D60</color>
     <color name="accessibility_daltonizer_background">#00BCD4</color>
     <color name="accessibility_color_inversion_background">#546E7A</color>
+
+    <color name="battery_info_error_color_red">#fce8e6</color> <!-- Material Red 50 -->
 </resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8368b46..df41b70d 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -853,8 +853,6 @@
     <string name="security_settings_face_settings_require_confirmation">Always require confirmation</string>
     <!-- When authenticating in apps, always require confirmation (e.g. confirm button) after a face is authenticated. [CHAR LIMIT=70] -->
     <string name="security_settings_face_settings_require_confirmation_details">When using face unlock in apps, always require confirmation step</string>
-    <!-- Button text in face settings which removes the user's faces from the device [CHAR LIMIT=20] -->
-    <string name="security_settings_face_settings_remove_face_data">Delete face data</string>
     <!-- Button text in face settings which removes the user's face model from the device [CHAR LIMIT=40] -->
     <string name="security_settings_face_settings_remove_face_model">Delete face model</string>
     <!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
@@ -866,9 +864,9 @@
     <!-- Text shown in face settings explaining what your face can be used for. Used when attention checking is not supported. [CHAR LIMIT=NONE] -->
     <string name="security_settings_face_settings_footer_attention_not_supported">Keep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face, even if your eyes are closed.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
     <!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
-    <string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
+    <string name="security_settings_face_settings_remove_dialog_title">Delete face model?</string>
     <!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
-    <string name="security_settings_face_settings_remove_dialog_details">The face data used by face unlock will be permanently and securely deleted. After removal, you will need your PIN, pattern, or password to unlock your phone, sign in to apps, and confirm payments.</string>
+    <string name="security_settings_face_settings_remove_dialog_details">Your face model will be permanently and securely deleted. After deletion, you will need your PIN, pattern, or password to unlock your phone or for authentication in apps.</string>
     <!-- Dialog title shown when the user chooses to delete an existing enrolled face model. [CHAR LIMIT=35] -->
     <string name="security_settings_face_settings_remove_model_dialog_title">Delete face model?</string>
     <!-- Dialog contents shown when the user chooses to delete an existing enrolled face model. [CHAR LIMIT=NONE] -->
@@ -889,8 +887,8 @@
     <string name="fingerprint_enable_keyguard_toggle_title">screen lock</string>
     <!-- Message showing the current number of fingerprints set up. Shown for a menu item that launches fingerprint settings or enrollment. -->
     <plurals name="security_settings_fingerprint_preference_summary">
-        <item quantity="one"><xliff:g id="count">%1$d</xliff:g> fingerprint set up</item>
-        <item quantity="other"><xliff:g id="count">%1$d</xliff:g> fingerprints set up</item>
+        <item quantity="one">Fingerprint added</item>
+        <item quantity="other"><xliff:g id="count">%1$d</xliff:g> fingerprints added</item>
     </plurals>
     <!-- message shown in summary field when no fingerprints are registered -->
     <string name="security_settings_fingerprint_preference_summary_none"></string>
@@ -971,9 +969,13 @@
 
     <!-- Biometric settings --><skip />
     <!-- Title shown for menu item that launches biometric settings. [CHAR LIMIT=66] -->
-    <string name="security_settings_biometric_preference_title">Face &amp; fingerprint unlock</string>
+    <string name="security_settings_biometric_preference_title">Face &amp; Fingerprint Unlock</string>
     <!-- Message shown in summary field of biometric settings. [CHAR LIMIT=66] -->
-    <string name="security_settings_biometric_preference_summary">Face and fingerprint</string>
+    <string name="security_settings_biometric_preference_summary_none_enrolled">Tap to set up</string>
+    <!-- Message shown in summary field of biometric settings when face is enrolled, and multiple fingerprints are enrolled. [CHAR LIMIT=66]-->
+    <string name="security_settings_biometric_preference_summary_both_fp_multiple">Face and fingerprints added</string>
+    <!-- Message shown in summary field of biometric settings when face is enrolled, and a single fingerprintis enrolled. [CHAR LIMIT=66]-->
+    <string name="security_settings_biometric_preference_summary_both_fp_single">Face and fingerprint added</string>
     <!-- Introduction shown in face and fingerprint page to introduce the biometric feature. [CHAR LIMIT=NONE]-->
     <string name="biometric_settings_intro">When you set up face unlock and fingerprint, your phone will ask for your fingerprint when you wear a mask or are in a dark area.</string>
     <!-- Biometric category title - biometric options for unlocking the device. [CHAR LIMIT=50] -->
@@ -1309,16 +1311,16 @@
     <!--  Title for security picker to choose the unlock method: None/Pattern/PIN/Password [CHAR LIMIT=22] -->
     <string name="lock_settings_picker_title">Choose screen lock</string>
 
-    <!--  Screen title. This title is asking the user to choose a type of screen lock for their device, such as a pattern, PIN, or password. [CHAR LIMIT=27] -->
+    <!--  Screen title. This title is asking the user to choose a type of screen lock for their device, such as a pattern, PIN, or password. [CHAR LIMIT=55] -->
     <string name="lock_settings_picker_new_lock_title">Choose a screen lock</string>
 
-    <!--  Screen title. This title is asking the user to choose a new screen lock for their device, such as a pattern, PIN, or password. [CHAR LIMIT=27] -->
+    <!--  Screen title. This title is asking the user to choose a new screen lock for their device, such as a pattern, PIN, or password. [CHAR LIMIT=55] -->
     <string name="lock_settings_picker_update_lock_title">Choose a new screen lock</string>
 
-    <!--  Screen title. This title is asking the user to choose a type of screen lock (such as a pattern, PIN, or password) that they need to enter to use their work apps. [CHAR LIMIT=27] -->
+    <!--  Screen title. This title is asking the user to choose a type of screen lock (such as a pattern, PIN, or password) that they need to enter to use their work apps. [CHAR LIMIT=56] -->
     <string name="lock_settings_picker_new_profile_lock_title">Choose a lock for work apps</string>
 
-    <!--  Screen title. This title is asking the user to choose a new screen lock (such as a pattern, PIN, or password) that they need to enter to use their work apps. [CHAR LIMIT=27] -->
+    <!--  Screen title. This title is asking the user to choose a new screen lock (such as a pattern, PIN, or password) that they need to enter to use their work apps. [CHAR LIMIT=55] -->
     <string name="lock_settings_picker_update_profile_lock_title">Choose a new work lock</string>
 
     <!--  Title for security picker in setup wizard to choose the unlock method: None/Pattern/PIN/Password (tablet) [CHAR LIMIT=22] -->
@@ -1464,43 +1466,42 @@
     <string name="unlock_disable_lock_title">Turn off screen lock</string>
 
     <!-- Title of the dialog shown when the user removes the device lock [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_title">Remove device protection?</string>
+    <string name="unlock_disable_frp_warning_title">Delete screen lock?</string>
     <!-- Title of the dialog shown when the user removes the profile lock [CHAR LIMIT=NONE] -->
     <string name="unlock_disable_frp_warning_title_profile">Remove profile protection?</string>
 
     <!-- Content of the dialog shown when the user removes the device lock pattern [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pattern">"Device protection features will not work without your pattern."</string>
+    <string name="unlock_disable_frp_warning_content_pattern">"A pattern protects your phone if it\u2019s lost or stolen"</string>
     <!-- Content of the dialog shown when the user removes the device lock pattern and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pattern_fingerprint">"Device protection features will not work without your pattern.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this device and you won\'t be able to unlock your phone, authorize purchases, or sign in to apps with them."</string>
+    <string name="unlock_disable_frp_warning_content_pattern_fingerprint">"A pattern protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This also deletes the fingerprint model stored on your device. You won\u2019t be able to use your fingerprint for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock pattern and the user has face authentication enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_pattern_face">"A pattern protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock pattern and the user has face authentication and fingerprint enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_pattern_face_fingerprint">"A pattern protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This deletes the fingerprint model stored on your device. Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face or fingerprint for authentication in apps."</string>
     <!-- Content of the dialog shown when the user removes the device lock PIN [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pin">"Device protection features will not work without your PIN."</string>
+    <string name="unlock_disable_frp_warning_content_pin">"A PIN protects your phone if it\u2019s lost or stolen"</string>
     <!-- Content of the dialog shown when the user removes the device lock PIN and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pin_fingerprint">"Device protection features will not work without your PIN.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this device and you won\'t be able to unlock your phone, authorize purchases, or sign in to apps with them."</string>
+    <string name="unlock_disable_frp_warning_content_pin_fingerprint">"A PIN protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This also deletes the fingerprint model stored on your device. You won\u2019t be able to use your fingerprint for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock PIN and the user has face enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_pin_face">"A PIN protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock PIN and the user has face authentication and fingerprint enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_pin_face_fingerprint">"A PIN protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This deletes the fingerprint model stored on your device. Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face or fingerprint for authentication in apps."</string>
     <!-- Content of the dialog shown when the user removes the device lock password [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_password">"Device protection features will not work without your password."</string>
+    <string name="unlock_disable_frp_warning_content_password">"A password protects your phone if it\u2019s lost or stolen"</string>
     <!-- Content of the dialog shown when the user removes the device lock password and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_password_fingerprint">"Device protection features will not work without your password.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this device and you won\'t be able to unlock your phone, authorize purchases, or sign in to apps with them."</string>
+    <string name="unlock_disable_frp_warning_content_password_fingerprint">"A password protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This also deletes the fingerprint model stored on your device. You won\u2019t be able to use your fingerprint for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock password and the user has face enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_password_face">"A password protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock password and the user has face authentication and fingerprint enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_password_face_fingerprint">"A password protects your phone if it\u2019s lost or stolen.<xliff:g id="empty_line">\n\n</xliff:g>This deletes the fingerprint model stored on your device. Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face or fingerprint for authentication in apps."</string>
     <!-- Content of the dialog shown when the user removes the device lock of unknown type [CHAR LIMIT=NONE] -->
     <string name="unlock_disable_frp_warning_content_unknown">"Device protection features will not work without your screen lock."</string>
     <!-- Content of the dialog shown when the user removes the device lock of unknown type and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_unknown_fingerprint">"Device protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this device and you won\'t be able to unlock your phone, authorize purchases, or sign in to apps with them."</string>
-
-    <!-- Content of the dialog shown when the user removes the profile lock pattern [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pattern_profile">"Profile protection features will not work without your pattern."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock pattern and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pattern_fingerprint_profile">"Profile protection features will not work without your pattern.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this profile and you won\'t be able to unlock your profile, authorize purchases, or sign in to apps with them."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock PIN [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pin_profile">"Profile protection features will not work without your PIN."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock PIN and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_pin_fingerprint_profile">"Profile protection features will not work without your PIN.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this profile and you won\'t be able to unlock your profile, authorize purchases, or sign in to apps with them."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock password [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_password_profile">"Profile protection features will not work without your password."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock password and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_password_fingerprint_profile">"Profile protection features will not work without your password.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this profile and you won\'t be able to unlock your profile, authorize purchases, or sign in to apps with them."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock of unknown type [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_unknown_profile">"Profile protection features will not work without your screen lock."</string>
-    <!-- Content of the dialog shown when the user removes the profile lock of unknown type and the user has fingerprints enrolled [CHAR LIMIT=NONE] -->
-    <string name="unlock_disable_frp_warning_content_unknown_fingerprint_profile">"Profile protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>Your saved fingerprints will also be removed from this profile and you won\'t be able to unlock your profile, authorize purchases, or sign in to apps with them."</string>
+    <string name="unlock_disable_frp_warning_content_unknown_fingerprint">"Device protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>This also deletes the fingerprint model stored on your device. You won\u2019t be able to use your fingerprint for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock of unknown type and the user has face enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_unknown_face">"Device protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face for authentication in apps."</string>
+    <!-- Content of the dialog shown when the user removes the device lock of unknown type and the user has face authentication and fingerprint enrolled [CHAR LIMIT=NONE] -->
+    <string name="unlock_disable_frp_warning_content_unknown_face_fingerprint">"Device protection features will not work without your screen lock.<xliff:g id="empty_line">\n\n</xliff:g>This deletes the fingerprint model stored on your device. Your face model will also be permanently and securely deleted. You won\u2019t be able to use your face or fingerprint for authentication in apps."</string>
 
     <!-- Affirmative action of the dialog shown when the user removes the device lock [CHAR LIMIT=25] -->
     <string name="unlock_disable_frp_warning_ok">Yes, remove</string>
@@ -2425,7 +2426,7 @@
     <!-- Wifi details preference title to display router IP subnet mask -->
     <string name="wifi_details_subnet_mask">Subnet mask</string>
     <!-- Wifi details preference title to display wifi type info [CHAR LIMIT=50]-->
-    <string name="wifi_type_title">TYPE</string>
+    <string name="wifi_type_title">Type</string>
     <!-- Wifi details preference title to display router DNS info -->
     <string name="wifi_details_dns">DNS</string>
     <!-- Wifi details preference category title for IPv6 information -->
@@ -3121,8 +3122,6 @@
     <string name="screensaver_settings_when_to_dream">When to start</string>
     <!-- Dream settings screen, action label, current selected screen saver -->
     <string name="screensaver_settings_current">Current screen saver</string>
-    <!-- Dream settings screen, button label to start dreaming -->
-    <string name="screensaver_settings_dream_start">Start now</string>
     <!-- Dream settings screen, button label for settings for a specific screensaver -->
     <string name="screensaver_settings_button">Settings</string>
     <!-- Sound & display settings screen, setting option name to change whether the screen adjusts automatically based on lighting conditions -->
@@ -3573,8 +3572,6 @@
     <!-- Body of dialog confirming that user wants to forget an internal storage device [CHAR LIMIT=NONE]-->
     <string name="storage_internal_forget_confirm">All the apps, photos, and data stored on this <xliff:g id="name" example="SD card">^1</xliff:g> will be lost forever.</string>
 
-    <!-- Item title describing storage used by images [CHAR LIMIT=48]-->
-    <string name="storage_detail_images">Images</string>
     <!-- Body of dialog informing user about the storage used by the Android System [CHAR LIMIT=NONE]-->
     <string name="storage_detail_dialog_system">System includes files used to run Android version <xliff:g id="version" example="8.0">%s</xliff:g></string>
 
@@ -5124,7 +5121,7 @@
     <!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
     <string name="interaction_control_category_title">Interaction controls</string>
     <!-- Title for the accessibility tap assistance page. [CHAR LIMIT=50] -->
-    <string name="accessibility_tap_assistance_title">Tap assistance</string>
+    <string name="accessibility_tap_assistance_title">Timing controls</string>
     <!-- Title for the accessibility system controls page. [CHAR LIMIT=50] -->
     <string name="accessibility_system_controls_title">System controls</string>
     <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
@@ -5913,6 +5910,10 @@
     <string name="manager_battery_usage_footer">Changing how an app uses your battery can affect its performance.</string>
     <!-- Footer for the manage battery usage page when app is limited to specific option (e.g This app requires restricted battery usage) [CHAR_LIMIT=NONE] -->
     <string name="manager_battery_usage_footer_limited">This app requires <xliff:g id="state" example="restricted">%1$s</xliff:g> battery usage.</string>
+    <!-- The state when app is limited to unrestricted option only (e.g This app requires unrestricted battery usage) [CHAR_LIMIT=40] -->
+    <string name="manager_battery_usage_unrestricted_only">unrestricted</string>
+    <!-- The state when app is limited to optimized option only (e.g This app requires optimized battery usage) [CHAR_LIMIT=40] -->
+    <string name="manager_battery_usage_optimized_only">optimized</string>
 
     <!-- Title for the screen usage in power use UI [CHAR_LIMIT=60] -->
     <string name="device_screen_usage">Screen usage since full charge</string>
@@ -6087,7 +6088,7 @@
     <string name="restricted_app_time_summary">Restricted <xliff:g id="time" example="5 days ago">%1$s</xliff:g></string>
 
     <!-- Footer message for restrict app details page -->
-    <string name="restricted_app_detail_footer">These apps have been using battery in the background. Restricted apps may not work properly and notifications may be delayed.</string>
+    <string name="restricted_app_detail_footer">These apps are restricted from background battery usage. They may not work as expected, and notifications may be delayed.</string>
 
     <!-- Title for auto restriction toggle -->
     <string name="battery_auto_restriction_title">Use Battery Manager</string>
@@ -6311,7 +6312,7 @@
     <!-- Title for usage time that full charge lasts. [CHAR LIMIT=60] -->
     <string name="battery_full_charge_last">Full charge lasts about</string>
     <!-- Description for text in battery footer. [CHAR LIMIT=NONE] -->
-    <string name="battery_footer_summary">Battery usage data is approximate and can change based on usage</string>
+    <string name="battery_footer_summary">Battery usage data is approximate and can change based on usage.</string>
     <!-- Title for text that shows the amount of time an app has been running while in the foreground. [CHAR LIMIT=80] -->
     <string name="battery_detail_foreground">While in active use</string>
     <!-- Title for text that shows the amount of time an app has been running while in the background. [CHAR LIMIT=80] -->
@@ -6416,11 +6417,11 @@
     <string name="battery_saver_sticky_title_new">Turn off when charged</string>
 
     <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
-    <string name="battery_saver_sticky_description_new" product="default">Battery Saver turns off when your phone charges above <xliff:g id="percent" example="90%">%1$s</xliff:g></string>
+    <string name="battery_saver_sticky_description_new" product="default">Battery Saver turns off when your phone charges above <xliff:g id="number" example="88">^1</xliff:g><xliff:g id="unit" example="%">%</xliff:g></string>
     <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
-    <string name="battery_saver_sticky_description_new" product="tablet">Battery Saver turns off when your tablet charges above <xliff:g id="percent" example="90%">%1$s</xliff:g></string>
+    <string name="battery_saver_sticky_description_new" product="tablet">Battery Saver turns off when your tablet charges above <xliff:g id="number" example="88">^1</xliff:g><xliff:g id="unit" example="%">%</xliff:g></string>
     <!-- Battery Saver: Description for sticky battery saver preference [CHAR_LIMIT=NONE] -->
-    <string name="battery_saver_sticky_description_new" product="device">Battery Saver turns off when your device charges above <xliff:g id="percent" example="90%">%1$s</xliff:g></string>
+    <string name="battery_saver_sticky_description_new" product="device">Battery Saver turns off when your device charges above <xliff:g id="number" example="88">^1</xliff:g><xliff:g id="unit" example="%">%</xliff:g></string>
 
     <!-- Battery saver: Label for seekbar to change battery saver threshold [CHAR_LIMIT=40] -->
     <string name="battery_saver_seekbar_title"><xliff:g id="percent">%1$s</xliff:g></string>
@@ -7599,10 +7600,6 @@
     <string name="help_uri_apps_manage_sources" translatable="false"></string>
     <!-- Help URI, manage apps games [DO NOT TRANSLATE] -->
     <string name="help_uri_apps_games" translatable="false"></string>
-    <!-- Help URI, manage apps movies [DO NOT TRANSLATE] -->
-    <string name="help_uri_apps_movies" translatable="false"></string>
-    <!-- Help URI, manage apps photography [DO NOT TRANSLATE] -->
-    <string name="help_uri_apps_photography" translatable="false"></string>
     <!-- Help URI, manage apps wifi access [DO NOT TRANSLATE] -->
     <string name="help_uri_apps_wifi_access" translatable="false"></string>
     <!-- Help URI, manage apps that have access to all files [DO NOT TRANSLATE] -->
@@ -8747,10 +8744,6 @@
 
     <!-- Bubble feature settings: Description for toggle when bubbles are turned on in notification settings [CHAR LIMIT=100] -->
     <string name="notifications_bubble_setting_on_summary">On / Conversations can appear as floating icons</string>
-    <!-- Bubble feature settings: Title of the toggle to turn bubbles on and off [CHAR LIMIT=100] -->
-    <string name="notifications_bubble_setting_title">Allow apps to show bubbles</string>
-    <!-- Bubble feature settings: Description shown with the toggle to turn bubbles on and off [CHAR LIMIT=NONE]-->
-    <string name="notifications_bubble_setting_description">Some conversations will appear as floating icons on top of other apps</string>
 
     <!-- Bubble app settings: option allowing all conversations from an app to bubble if the app sends bubbles [CHAR LIMIT=60]-->
     <string name="bubble_app_setting_all">All conversations can bubble</string>
@@ -11921,9 +11914,6 @@
     <!-- Title of games app storage screen [CHAR LIMIT=30] -->
     <string name="game_storage_settings">Games</string>
 
-    <!-- Title for audio files preference. [CHAR LIMIT=50] -->
-    <string name="audio_files_title">Audio files</string>
-
     <!-- Title for the installed app info storage page. The total storage space taken up by this app. [CHAR LIMIT=40]-->
     <string name="app_info_storage_title">Space used</string>
 
@@ -13236,6 +13226,10 @@
     <string name="adaptive_brightness_main_switch_title">Use adaptive brightness</string>
     <!-- Title for wifi calling main switch preferences. [CHAR LIMIT=50] -->
     <string name="wifi_calling_main_switch_title">Use Wi‑Fi calling</string>
+    <!-- Title for Bubbles main switch preferences. [CHAR LIMIT=50] -->
+    <string name="bubbles_main_switch_title">Use Bubbles</string>
+    <!-- Title for Screen saver main switch preferences. [CHAR LIMIT=50] -->
+    <string name="screen_saver_main_switch_title">Use screen saver</string>
 
     <!-- Default preference title for showing all apps on device [CHAR_LIMIT=50]-->
     <string name="default_see_all_apps_title">See all apps</string>
@@ -13272,6 +13266,8 @@
 
     <!-- Label for extra app info settings for a specific app [CHAR LIMIT=40] -->
     <string name="extra_app_info_label" translatable="false"></string>
+    <!-- Summary for extra app info settings for a specific app [CHAR LIMIT=40] -->
+    <string name="extra_app_info_summary" translatable="false"></string>
 
     <!-- Title for toggle controlling whether notifications are shown when an app pastes from clipboard. [CHAR LIMIT=50] -->
     <string name="show_clip_access_notification">Show clipboard access</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 783a148..2619398 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -665,7 +665,7 @@
         <item name="android:gravity">center</item>
         <item name="android:textSize">20sp</item>
         <item name="android:textColor">?android:attr/textColorPrimary</item>
-        <item name="android:fontFamily">google-sans-medium</item>
+        <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
     </style>
 
     <style name="AccessibilityDialogDescription"
@@ -676,7 +676,6 @@
         <item name="android:layout_marginBottom">32dp</item>
         <item name="android:textSize">16sp</item>
         <item name="android:textColor">?android:attr/textColorPrimary</item>
-        <item name="android:fontFamily">sans-serif</item>
     </style>
 
     <style name="AccessibilityDialogPermissionTitle"
@@ -685,7 +684,7 @@
         <item name="android:layout_height">wrap_content</item>
         <item name="android:textSize">16sp</item>
         <item name="android:textColor">?android:attr/textColorPrimary</item>
-        <item name="android:fontFamily">sans-serif</item>
+        <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
     </style>
 
     <style name="AccessibilityDialogPermissionDescription"
@@ -694,7 +693,6 @@
         <item name="android:layout_height">wrap_content</item>
         <item name="android:textSize">14sp</item>
         <item name="android:textColor">?android:attr/textColorSecondary</item>
-        <item name="android:fontFamily">sans-serif</item>
     </style>
 
     <style name="AccessibilityDialogButtonBarSpace">
diff --git a/res/values/themes.xml b/res/values/themes.xml
index b5f71fa..af44276 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -254,11 +254,4 @@
         <item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
         <item name="colorAccent">@*android:color/accent_device_default_light</item>
     </style>
-
-    <style name="Theme.NotificationHistory" parent="@android:style/Theme.DeviceDefault.DayNight">
-        <item name="android:windowActionBar">false</item>
-        <item name="android:windowNoTitle">true</item>
-        <item name="android:navigationBarColor">@android:color/transparent</item>
-        <item name="android:statusBarColor">@android:color/transparent</item>
-    </style>
 </resources>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 357d658..14879a8 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -53,11 +53,13 @@
             settings:keywords="@string/keywords_reduce_bright_colors"
             settings:controller="com.android.settings.accessibility.ReduceBrightColorsPreferenceController"/>
 
-        <SwitchPreference
+        <com.android.settings.display.darkmode.DarkModePreference
             android:key="dark_ui_mode_accessibility"
             android:icon="@drawable/ic_dark_ui"
-            android:persistent="false"
             android:title="@string/dark_ui_mode"
+            android:fragment="com.android.settings.display.darkmode.DarkModeSettingsFragment"
+            android:widgetLayout="@null"
+            settings:widgetLayout="@null"
             settings:controller="com.android.settings.display.DarkUIPreferenceController"
             settings:searchable="false"/>
 
diff --git a/res/xml/app_info_settings_v2.xml b/res/xml/app_info_settings_v2.xml
index 80c449a..8b9cf4f 100644
--- a/res/xml/app_info_settings_v2.xml
+++ b/res/xml/app_info_settings_v2.xml
@@ -83,6 +83,7 @@
     <Preference
         android:key="extra_app_info_settings"
         android:title="@string/extra_app_info_label"
+        android:summary="@string/extra_app_info_summary"
         settings:controller="com.android.settings.applications.appinfo.ExtraAppInfoPreferenceController" />
 
     <Preference
diff --git a/res/xml/bubble_notification_settings.xml b/res/xml/bubble_notification_settings.xml
index 4827cb6..70492b4 100644
--- a/res/xml/bubble_notification_settings.xml
+++ b/res/xml/bubble_notification_settings.xml
@@ -18,6 +18,11 @@
                   xmlns:settings="http://schemas.android.com/apk/res-auto"
                   android:title="@string/bubbles_app_toggle_title">
 
+        <com.android.settingslib.widget.MainSwitchPreference
+            android:key="global_notification_bubbles"
+            android:title="@string/bubbles_main_switch_title"
+            settings:controller="com.android.settings.notification.BubbleNotificationPreferenceController"/>
+
         <com.android.settings.widget.VideoPreference
             android:key="bubbles_illustration"
             android:title="@string/summary_placeholder"
@@ -25,13 +30,4 @@
             settings:controller="com.android.settings.widget.VideoPreferenceController"
             android:persistent="false" />
 
-        <!-- Notification bubbles -->
-        <SwitchPreference
-            android:key="global_notification_bubbles"
-            android:icon="@drawable/ic_create_bubble"
-            settings:allowDividerAbove="true"
-            android:title="@string/notifications_bubble_setting_title"
-            android:summary="@string/notifications_bubble_setting_description"
-            settings:controller="com.android.settings.notification.BubbleNotificationPreferenceController"/>
-
-</PreferenceScreen>
\ No newline at end of file
+</PreferenceScreen>
diff --git a/res/xml/connected_devices.xml b/res/xml/connected_devices.xml
index e7e3c2c..75878f9 100644
--- a/res/xml/connected_devices.xml
+++ b/res/xml/connected_devices.xml
@@ -40,7 +40,6 @@
         android:key="add_bt_devices"
         android:title="@string/bluetooth_pairing_pref_title"
         android:icon="@drawable/ic_add_24dp"
-        android:summary="@string/connected_device_add_device_summary"
         android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
         settings:allowDividerAbove="true"
         settings:keywords="@string/keywords_add_bt_device"
@@ -48,6 +47,18 @@
         settings:useAdminDisabledSummary="true"
         settings:controller="com.android.settings.connecteddevice.AddDevicePreferenceController"/>
 
+    <com.android.settingslib.RestrictedPreference
+        android:key="add_bt_devices_summary"
+        android:title="@string/bluetooth_pairing_pref_title"
+        android:icon="@drawable/ic_add_24dp"
+        android:summary="@string/connected_device_add_device_summary"
+        android:fragment="com.android.settings.bluetooth.BluetoothPairingDetail"
+        settings:allowDividerAbove="true"
+        settings:keywords="@string/keywords_add_bt_device"
+        settings:userRestriction="no_config_bluetooth"
+        settings:useAdminDisabledSummary="true"
+        settings:controller="com.android.settings.connecteddevice.AddDeviceSummaryPreferenceController"/>
+
     <PreferenceCategory
         android:key="previously_connected_devices"
         android:title="@string/connected_device_previously_connected_title"
diff --git a/res/xml/dream_fragment_overview.xml b/res/xml/dream_fragment_overview.xml
index 3cb49f9..6e18a97 100644
--- a/res/xml/dream_fragment_overview.xml
+++ b/res/xml/dream_fragment_overview.xml
@@ -19,6 +19,11 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:title="@string/screensaver_settings_title">
 
+    <com.android.settingslib.widget.MainSwitchPreference
+        android:key="dream_start_now_button_container"
+        android:title="@string/screen_saver_main_switch_title"
+        settings:controller="com.android.settings.dream.StartNowPreferenceController"/>
+
     <com.android.settings.widget.GearPreference
         android:key="current_screensaver"
         android:title="@string/screensaver_settings_current"
@@ -30,14 +35,4 @@
         android:title="@string/screensaver_settings_when_to_dream"
         android:fragment="com.android.settings.dream.WhenToDreamPicker" />
 
-
-    <!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
-    <PreferenceCategory
-        android:key="dream_start_now_category">
-        <com.android.settingslib.widget.LayoutPreference
-            android:key="dream_start_now_button_container"
-            android:selectable="false"
-            android:layout="@layout/dream_start_button" />
-    </PreferenceCategory>
-
 </PreferenceScreen>
diff --git a/res/xml/one_handed_settings.xml b/res/xml/one_handed_settings.xml
index 5a71d48..b2c7de9 100644
--- a/res/xml/one_handed_settings.xml
+++ b/res/xml/one_handed_settings.xml
@@ -21,6 +21,12 @@
     android:persistent="false"
     android:title="@string/one_handed_title">
 
+    <com.android.settingslib.widget.MainSwitchPreference
+        android:key="gesture_one_handed_mode_enabled"
+        android:title="@string/one_handed_mode_enabled"
+        settings:keywords="@string/keywords_one_handed"
+        settings:controller="com.android.settings.gestures.OneHandedEnablePreferenceController"/>
+
     <com.android.settingslib.widget.LayoutPreference
         android:key="one_handed_header"
         android:layout="@layout/one_handed_header"
@@ -30,12 +36,6 @@
         settings:searchable="false"/>
 
     <SwitchPreference
-        android:key="gesture_one_handed_mode_enabled"
-        android:title="@string/one_handed_mode_enabled"
-        settings:keywords="@string/keywords_one_handed"
-        settings:controller="com.android.settings.gestures.OneHandedEnablePreferenceController"/>
-
-    <SwitchPreference
         android:key="gesture_app_taps_to_exit"
         android:title="@string/one_handed_app_taps_to_exit"
         settings:controller="com.android.settings.gestures.OneHandedAppTapsExitPreferenceController"/>
diff --git a/res/xml/security_settings_face.xml b/res/xml/security_settings_face.xml
index 131f222..e1ac9b3 100644
--- a/res/xml/security_settings_face.xml
+++ b/res/xml/security_settings_face.xml
@@ -81,7 +81,7 @@
         android:title="@string/security_settings_face_preference_title">
         <com.android.settingslib.widget.LayoutPreference
             android:key="security_settings_face_delete_faces_container"
-            android:title="@string/security_settings_face_settings_remove_face_data"
+            android:title="@string/security_settings_face_settings_remove_face_model"
             android:selectable="false"
             android:layout="@layout/face_remove_button"
             settings:allowDividerBelow="true"/>
diff --git a/res/xml/zen_mode_settings.xml b/res/xml/zen_mode_settings.xml
index 10b3e41..886790a 100644
--- a/res/xml/zen_mode_settings.xml
+++ b/res/xml/zen_mode_settings.xml
@@ -38,6 +38,7 @@
         <Preference
             android:key="zen_mode_behavior_apps"
             android:title="@string/zen_category_apps"
+            android:summary=" "
             android:fragment="com.android.settings.notification.zen.ZenModeBypassingAppsSettings" />
 
         <!-- All sounds -->
diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java
index c89402c..705ac36 100644
--- a/src/com/android/settings/Settings.java
+++ b/src/com/android/settings/Settings.java
@@ -19,11 +19,16 @@
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.util.FeatureFlagUtils;
 
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.core.FeatureFlags;
 import com.android.settings.enterprise.EnterprisePrivacySettings;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.security.SecuritySettingsFeatureProvider;
+
+import com.google.android.setupdesign.util.ThemeHelper;
 
 /**
  * Top-level Settings activity
@@ -118,7 +123,39 @@
      * Activity for Reduce Bright Colors.
      */
     public static class ReduceBrightColorsSettingsActivity extends SettingsActivity { /* empty */ }
-    public static class SecurityDashboardActivity extends SettingsActivity { /* empty */ }
+    /** Activity for the security dashboard. */
+    public static class SecurityDashboardActivity extends SettingsActivity {
+
+        /** Whether the given fragment is allowed. */
+        @VisibleForTesting
+        @Override
+        public boolean isValidFragment(String fragmentName) {
+            return super.isValidFragment(fragmentName)
+                    || (fragmentName != null
+                            && TextUtils.equals(fragmentName, getAlternativeFragmentName()));
+        }
+
+        @Override
+        public String getInitialFragmentName(Intent intent) {
+            final String alternativeFragmentName = getAlternativeFragmentName();
+            if (alternativeFragmentName != null) {
+                return alternativeFragmentName;
+            }
+
+            return super.getInitialFragmentName(intent);
+        }
+
+        private String getAlternativeFragmentName() {
+            String alternativeFragmentClassname = null;
+            final SecuritySettingsFeatureProvider securitySettingsFeatureProvider =
+                    FeatureFactory.getFactory(this).getSecuritySettingsFeatureProvider();
+            if (securitySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment()) {
+                alternativeFragmentClassname = securitySettingsFeatureProvider
+                        .getAlternativeSecuritySettingsFragmentClassname();
+            }
+            return alternativeFragmentClassname;
+        }
+    }
     public static class UsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
     public static class AppUsageAccessSettingsActivity extends SettingsActivity { /* empty */ }
     public static class LocationSettingsActivity extends SettingsActivity { /* empty */ }
@@ -129,6 +166,7 @@
         @Override
         protected void onCreate(Bundle savedState) {
             setTheme(SetupWizardUtils.getTheme(this, getIntent()));
+            ThemeHelper.trySetDynamicColor(this);
             super.onCreate(savedState);
         }
 
@@ -141,6 +179,7 @@
         @Override
         protected void onCreate(Bundle savedState) {
             setTheme(SetupWizardUtils.getTheme(this, getIntent()));
+            ThemeHelper.trySetDynamicColor(this);
             super.onCreate(savedState);
         }
 
@@ -199,10 +238,6 @@
     public static class ManageDomainUrlsActivity extends SettingsActivity { /* empty */ }
     public static class AutomaticStorageManagerSettingsActivity extends SettingsActivity { /* empty */ }
     public static class GamesStorageActivity extends SettingsActivity { /* empty */ }
-    public static class MoviesStorageActivity extends SettingsActivity { /* empty */ }
-    public static class PhotosStorageActivity extends SettingsActivity {
-        /* empty */
-    }
     public static class GestureNavigationSettingsActivity extends SettingsActivity { /* empty */ }
     public static class InteractAcrossProfilesSettingsActivity extends SettingsActivity {
         /* empty */
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index b672917..923c2bd 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -219,7 +219,7 @@
     private String getMetricsTag() {
         String tag = null;
         if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
-            tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
+            tag = getInitialFragmentName(getIntent());
         }
         if (TextUtils.isEmpty(tag)) {
             Log.w(LOG_TAG, "MetricsTag is invalid " + tag);
@@ -262,7 +262,7 @@
         }
 
         // Getting Intent properties can only be done after the super.onCreate(...)
-        final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
+        final String initialFragmentName = getInitialFragmentName(intent);
 
         // This is a "Sub Settings" when:
         // - this is a real SubSettings
@@ -363,6 +363,12 @@
         }
     }
 
+    /** Returns the initial fragment name that the activity will launch. */
+    @VisibleForTesting
+    public String getInitialFragmentName(Intent intent) {
+        return intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
+    }
+
     @Override
     protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
         theme.applyStyle(R.style.SetupWizardPartnerResource, true);
diff --git a/src/com/android/settings/SettingsDumpService.java b/src/com/android/settings/SettingsDumpService.java
index 5e6ee93..a935c18 100644
--- a/src/com/android/settings/SettingsDumpService.java
+++ b/src/com/android/settings/SettingsDumpService.java
@@ -120,7 +120,9 @@
             obj.put("cell", array);
         }
         if (packageManager.hasSystemFeature(FEATURE_WIFI)) {
-            obj.put("wifi", dumpDataUsage(NetworkTemplate.buildTemplateWifiWildcard(), controller));
+            obj.put("wifi", dumpDataUsage(
+                    NetworkTemplate.buildTemplateWifi(
+                    NetworkTemplate.WIFI_NETWORKID_ALL, null /* subscriberId */), controller));
         }
 
         if (packageManager.hasSystemFeature(FEATURE_ETHERNET)) {
diff --git a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
index 4db7857..fe08d6b 100644
--- a/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/LaunchAccessibilityActivityPreferenceFragment.java
@@ -30,34 +30,41 @@
 import android.os.UserHandle;
 import android.text.TextUtils;
 import android.util.Log;
+import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.accessibility.AccessibilityManager;
 
 import androidx.annotation.Nullable;
+import androidx.preference.Preference;
 
 import com.android.settings.R;
-import com.android.settings.widget.SettingsMainSwitchPreference;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /** Fragment for providing open activity button. */
 public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeaturePreferenceFragment {
     private static final String TAG = "LaunchA11yActivity";
     private static final String EMPTY_STRING = "";
+    protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";
 
     @Override
-    public void onViewCreated(View view, Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        final View view = super.onCreateView(inflater, container, savedInstanceState);
 
-        mToggleServiceSwitchPreference.hide();
-    }
+        // Init new preference to replace the switch preference instead.
+        initLaunchPreference();
+        removePreference(KEY_USE_SERVICE_PREFERENCE);
+        return view;
+    };
 
     @Override
     protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
-        logAccessibilityServiceEnabled(mComponentName, enabled);
-        launchShortcutTargetActivity(getPrefContext().getDisplayId(), mComponentName);
+        // Do nothing.
     }
 
     @Override
@@ -99,16 +106,6 @@
         // accessibility service from this page.
     }
 
-    @Override
-    protected void updateToggleServiceTitle(SettingsMainSwitchPreference switchPreference) {
-        final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo();
-        final String switchBarText = (info == null) ? EMPTY_STRING : getString(
-                R.string.accessibility_service_primary_open_title,
-                info.getActivityInfo().loadLabel(getPackageManager()));
-
-        switchPreference.setTitle(switchBarText);
-    }
-
     // IMPORTANT: Refresh the info since there are dynamically changing capabilities.
     private AccessibilityShortcutInfo getAccessibilityShortcutInfo() {
         final List<AccessibilityShortcutInfo> infos = AccessibilityManager.getInstance(
@@ -126,6 +123,34 @@
         return null;
     }
 
+    /** Customizes the order by preference key. */
+    protected List<String> getPreferenceOrderList() {
+        final List<String> lists = new ArrayList<>();
+        lists.add(KEY_ANIMATED_IMAGE);
+        lists.add(KEY_LAUNCH_PREFERENCE);
+        lists.add(KEY_GENERAL_CATEGORY);
+        lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
+        return lists;
+    }
+
+    private void initLaunchPreference() {
+        final Preference launchPreference = new Preference(getPrefContext());
+        launchPreference.setKey(KEY_LAUNCH_PREFERENCE);
+
+        final AccessibilityShortcutInfo info = getAccessibilityShortcutInfo();
+        final String switchBarText = (info == null) ? EMPTY_STRING : getString(
+                R.string.accessibility_service_primary_open_title,
+                info.getActivityInfo().loadLabel(getPackageManager()));
+        launchPreference.setTitle(switchBarText);
+
+        launchPreference.setOnPreferenceClickListener(preference -> {
+            logAccessibilityServiceEnabled(mComponentName, /* enabled= */ true);
+            launchShortcutTargetActivity(getPrefContext().getDisplayId(), mComponentName);
+            return true;
+        });
+        getPreferenceScreen().addPreference(launchPreference);
+    }
+
     private void launchShortcutTargetActivity(int displayId, ComponentName name) {
         final Intent intent = new Intent();
         final Bundle bundle = ActivityOptions.makeBasic().setLaunchDisplayId(displayId).toBundle();
diff --git a/src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java b/src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java
index a29567e..62051c1 100644
--- a/src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java
+++ b/src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java
@@ -20,6 +20,8 @@
 import android.hardware.display.ColorDisplayManager;
 import android.provider.Settings;
 
+import androidx.preference.Preference;
+
 import com.android.settings.core.TogglePreferenceController;
 
 /** PreferenceController for persisting feature activation state after a restart. */
@@ -54,4 +56,10 @@
         return Settings.Secure.putInt(mContext.getContentResolver(),
                 Settings.Secure.REDUCE_BRIGHT_COLORS_PERSIST_ACROSS_REBOOTS, (isChecked ? 1 : 0));
     }
+
+    @Override
+    public final void updateState(Preference preference) {
+        super.updateState(preference);
+        preference.setEnabled(mColorDisplayManager.isReduceBrightColorsActivated());
+    }
 }
diff --git a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
index a3ea478..f321d72 100644
--- a/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppDataUsagePreferenceController.java
@@ -139,7 +139,8 @@
             return NetworkTemplate.buildTemplateMobileWildcard();
         }
         if (DataUsageUtils.hasWifiRadio(context)) {
-            return NetworkTemplate.buildTemplateWifiWildcard();
+            return NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                    null /* subscriberId */);
         }
         return NetworkTemplate.buildTemplateEthernet();
     }
diff --git a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
index c9f0e31..285493a 100644
--- a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
@@ -29,11 +29,10 @@
 import com.android.settingslib.applications.ApplicationsState.AppEntry;
 import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
-import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.widget.LayoutPreference;
 
 public class AppHeaderViewPreferenceController extends BasePreferenceController
-        implements AppInfoDashboardFragment.Callback, LifecycleObserver, OnStart {
+        implements AppInfoDashboardFragment.Callback, LifecycleObserver {
 
     private static final String KEY_HEADER = "header_view";
 
@@ -67,6 +66,7 @@
         final Activity activity = mParent.getActivity();
         mEntityHeaderController = EntityHeaderController
                 .newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
+                .setRecyclerView(mParent.getListView(), mLifecycle)
                 .setPackageName(mPackageName)
                 .setButtonActions(EntityHeaderController.ActionType.ACTION_NONE,
                         EntityHeaderController.ActionType.ACTION_NONE)
@@ -74,13 +74,6 @@
     }
 
     @Override
-    public void onStart() {
-        mEntityHeaderController
-                .setRecyclerView(mParent.getListView(), mLifecycle)
-                .styleActionBar(mParent.getActivity());
-    }
-
-    @Override
     public void refreshUi() {
         setAppLabelAndIcon(mParent.getPackageInfo(), mParent.getAppEntry());
     }
diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java
index 20938d1..4de1c2c 100644
--- a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java
+++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProvider.java
@@ -34,4 +34,9 @@
      * Sets the package name
      */
     void setPackageName(String packageName);
+
+    /**
+     * gets the summary name
+     */
+    String getSummary(Context context);
 }
diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java
index 3e5ef78..55b9bf0 100644
--- a/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java
+++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoFeatureProviderImpl.java
@@ -37,4 +37,9 @@
     public void setPackageName(String packageName) {
         return;
     }
+
+    @Override
+    public String getSummary(Context context) {
+        return "";
+    }
 }
diff --git a/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java b/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java
index 0c1b3e3..0d72b74 100644
--- a/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/ExtraAppInfoPreferenceController.java
@@ -50,6 +50,11 @@
         return super.handlePreferenceTreeClick(preference);
     }
 
+    @Override
+    public CharSequence getSummary() {
+        return mExtraAppInfoFeatureProvider.getSummary(mContext);
+    }
+
     /**
      * Set the local package name
      */
diff --git a/src/com/android/settings/applications/manageapplications/FileViewHolderController.java b/src/com/android/settings/applications/manageapplications/FileViewHolderController.java
deleted file mode 100644
index ded0286..0000000
--- a/src/com/android/settings/applications/manageapplications/FileViewHolderController.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.manageapplications;
-
-import androidx.fragment.app.Fragment;
-
-/**
- * FileViewHolderController handles adapting the AppViewHolder to work as a general purpose
- * storage categorization preference in the ManageApplications view.
- */
-public interface FileViewHolderController {
-    /**
-     * Begins a synchronous query for statistics for the files.
-     */
-    void queryStats();
-
-    /**
-     * Returns if the preference should be shown.
-     */
-    boolean shouldShow();
-
-    /**
-     * Initializes the view within an AppViewHolder.
-     *
-     * @param holder The holder to use to initialize.
-     */
-    void setupView(ApplicationViewHolder holder);
-
-    /**
-     * Handles the behavior when the view is clicked.
-     *
-     * @param fragment Fragment where the click originated.
-     */
-    void onClick(Fragment fragment);
-}
diff --git a/src/com/android/settings/applications/manageapplications/ManageApplications.java b/src/com/android/settings/applications/manageapplications/ManageApplications.java
index a08c540..7469b71 100644
--- a/src/com/android/settings/applications/manageapplications/ManageApplications.java
+++ b/src/com/android/settings/applications/manageapplications/ManageApplications.java
@@ -83,7 +83,6 @@
 import com.android.settings.Settings.GamesStorageActivity;
 import com.android.settings.Settings.HighPowerApplicationsActivity;
 import com.android.settings.Settings.ManageExternalSourcesActivity;
-import com.android.settings.Settings.MoviesStorageActivity;
 import com.android.settings.Settings.OverlaySettingsActivity;
 import com.android.settings.Settings.StorageUseActivity;
 import com.android.settings.Settings.UsageAccessSettingsActivity;
@@ -130,7 +129,6 @@
 import com.android.settingslib.applications.ApplicationsState.AppFilter;
 import com.android.settingslib.applications.ApplicationsState.CompoundFilter;
 import com.android.settingslib.applications.ApplicationsState.VolumeFilter;
-import com.android.settingslib.applications.StorageStatsSource;
 import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
 import com.android.settingslib.utils.ThreadUtils;
 import com.android.settingslib.widget.settingsspinner.SettingsSpinnerAdapter;
@@ -182,9 +180,7 @@
 
     // Storage types. Used to determine what the extra item in the list of preferences is.
     public static final int STORAGE_TYPE_DEFAULT = 0; // Show all apps that are not categorized.
-    public static final int STORAGE_TYPE_MUSIC = 1;
-    public static final int STORAGE_TYPE_LEGACY = 2; // Show apps even if they can be categorized.
-    public static final int STORAGE_TYPE_PHOTOS_VIDEOS = 3;
+    public static final int STORAGE_TYPE_LEGACY = 1;  // Show apps even if they can be categorized.
 
     /**
      * Intents with action {@code android.settings.MANAGE_APP_OVERLAY_PERMISSION}
@@ -230,12 +226,10 @@
     public static final int LIST_TYPE_WRITE_SETTINGS = 7;
     public static final int LIST_TYPE_MANAGE_SOURCES = 8;
     public static final int LIST_TYPE_GAMES = 9;
-    public static final int LIST_TYPE_MOVIES = 10;
-    public static final int LIST_TYPE_PHOTOGRAPHY = 11;
-    public static final int LIST_TYPE_WIFI_ACCESS = 13;
-    public static final int LIST_MANAGE_EXTERNAL_STORAGE = 14;
-    public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 15;
-    public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 16;
+    public static final int LIST_TYPE_WIFI_ACCESS = 10;
+    public static final int LIST_MANAGE_EXTERNAL_STORAGE = 11;
+    public static final int LIST_TYPE_ALARMS_AND_REMINDERS = 12;
+    public static final int LIST_TYPE_MEDIA_MANAGEMENT_APPS = 13;
 
     // List types that should show instant apps.
     public static final Set<Integer> LIST_TYPES_WITH_INSTANT = new ArraySet<>(Arrays.asList(
@@ -314,13 +308,6 @@
         } else if (className.equals(GamesStorageActivity.class.getName())) {
             mListType = LIST_TYPE_GAMES;
             mSortOrder = R.id.sort_order_size;
-        } else if (className.equals(MoviesStorageActivity.class.getName())) {
-            mListType = LIST_TYPE_MOVIES;
-            mSortOrder = R.id.sort_order_size;
-        } else if (className.equals(Settings.PhotosStorageActivity.class.getName())) {
-            mListType = LIST_TYPE_PHOTOGRAPHY;
-            mSortOrder = R.id.sort_order_size;
-            mStorageType = args.getInt(EXTRA_STORAGE_TYPE, STORAGE_TYPE_DEFAULT);
         } else if (className.equals(Settings.ChangeWifiStateActivity.class.getName())) {
             mListType = LIST_TYPE_WIFI_ACCESS;
             screenTitle = R.string.change_wifi_state_title;
@@ -429,24 +416,6 @@
                 mApplications.mHasReceivedBridgeCallback =
                         savedInstanceState.getBoolean(EXTRA_HAS_BRIDGE, false);
             }
-            int userId = mIsWorkOnly ? mWorkUserId : UserHandle.myUserId();
-            if (mStorageType == STORAGE_TYPE_MUSIC) {
-                Context context = getContext();
-                mApplications.setExtraViewController(
-                        new MusicViewHolderController(
-                                context,
-                                new StorageStatsSource(context),
-                                mVolumeUuid,
-                                UserHandle.of(userId)));
-            } else if (mStorageType == STORAGE_TYPE_PHOTOS_VIDEOS) {
-                Context context = getContext();
-                mApplications.setExtraViewController(
-                        new PhotosViewHolderController(
-                                context,
-                                new StorageStatsSource(context),
-                                mVolumeUuid,
-                                UserHandle.of(userId)));
-            }
             mRecyclerView = mListContainer.findViewById(R.id.apps_list);
             mRecyclerView.setItemAnimator(null);
             mRecyclerView.setLayoutManager(new LinearLayoutManager(
@@ -508,19 +477,13 @@
     static AppFilter getCompositeFilter(int listType, int storageType, String volumeUuid) {
         AppFilter filter = new VolumeFilter(volumeUuid);
         if (listType == LIST_TYPE_STORAGE) {
-            if (storageType == STORAGE_TYPE_MUSIC) {
-                filter = new CompoundFilter(ApplicationsState.FILTER_AUDIO, filter);
-            } else if (storageType == STORAGE_TYPE_DEFAULT) {
+            if (storageType == STORAGE_TYPE_DEFAULT) {
                 filter = new CompoundFilter(ApplicationsState.FILTER_APPS_EXCEPT_GAMES, filter);
             }
             return filter;
         }
         if (listType == LIST_TYPE_GAMES) {
             return new CompoundFilter(ApplicationsState.FILTER_GAMES, filter);
-        } else if (listType == LIST_TYPE_MOVIES) {
-            return new CompoundFilter(ApplicationsState.FILTER_MOVIES, filter);
-        } else if (listType == LIST_TYPE_PHOTOGRAPHY) {
-            return new CompoundFilter(ApplicationsState.FILTER_PHOTOS, filter);
         }
         return null;
     }
@@ -533,16 +496,9 @@
             case LIST_TYPE_NOTIFICATION:
                 return SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS;
             case LIST_TYPE_STORAGE:
-                if (mStorageType == STORAGE_TYPE_MUSIC) {
-                    return SettingsEnums.APPLICATIONS_STORAGE_MUSIC;
-                }
                 return SettingsEnums.APPLICATIONS_STORAGE_APPS;
             case LIST_TYPE_GAMES:
                 return SettingsEnums.APPLICATIONS_STORAGE_GAMES;
-            case LIST_TYPE_MOVIES:
-                return SettingsEnums.APPLICATIONS_STORAGE_MOVIES;
-            case LIST_TYPE_PHOTOGRAPHY:
-                return SettingsEnums.APPLICATIONS_STORAGE_PHOTOS;
             case LIST_TYPE_USAGE_ACCESS:
                 return SettingsEnums.USAGE_ACCESS;
             case LIST_TYPE_HIGH_POWER:
@@ -668,12 +624,6 @@
             case LIST_TYPE_GAMES:
                 startAppInfoFragment(AppStorageSettings.class, R.string.game_storage_settings);
                 break;
-            case LIST_TYPE_MOVIES:
-                startAppInfoFragment(AppStorageSettings.class, R.string.storage_movies_tv);
-                break;
-            case LIST_TYPE_PHOTOGRAPHY:
-                startAppInfoFragment(AppStorageSettings.class, R.string.storage_photos_videos);
-                break;
             case LIST_TYPE_WIFI_ACCESS:
                 startAppInfoFragment(ChangeWifiStateDetails.class,
                         R.string.change_wifi_state_title);
@@ -760,10 +710,6 @@
                 return R.string.help_uri_apps_manage_sources;
             case LIST_TYPE_GAMES:
                 return R.string.help_uri_apps_overlay;
-            case LIST_TYPE_MOVIES:
-                return R.string.help_uri_apps_movies;
-            case LIST_TYPE_PHOTOGRAPHY:
-                return R.string.help_uri_apps_photography;
             case LIST_TYPE_WIFI_ACCESS:
                 return R.string.help_uri_apps_wifi_access;
             case LIST_MANAGE_EXTERNAL_STORAGE:
@@ -856,8 +802,6 @@
             mCurrentPkgName = entry.info.packageName;
             mCurrentUid = entry.info.uid;
             startApplicationDetailsActivity();
-        } else {
-            mApplications.mExtraViewController.onClick(this);
         }
     }
 
@@ -1046,7 +990,6 @@
         private AppFilter mCompositeFilter;
         private boolean mHasReceivedLoadEntries;
         private boolean mHasReceivedBridgeCallback;
-        private FileViewHolderController mExtraViewController;
         private SearchFilter mSearchFilter;
         private PowerAllowlistBackend mBackend;
 
@@ -1146,18 +1089,6 @@
             }
         }
 
-        public void setExtraViewController(FileViewHolderController extraViewController) {
-            mExtraViewController = extraViewController;
-            // Start to query extra view's stats on background, and once done post result to main
-            // thread.
-            ThreadUtils.postOnBackgroundThread(() -> {
-                mExtraViewController.queryStats();
-                ThreadUtils.postOnMainThread(() -> {
-                    onExtraViewCompleted();
-                });
-            });
-        }
-
         public void resume(int sort) {
             if (DEBUG) Log.i(TAG, "Resume!  mResumed=" + mResumed);
             if (!mResumed) {
@@ -1219,10 +1150,7 @@
 
         @Override
         public int getItemViewType(int position) {
-            boolean isLastItem = (getItemCount() - 1) == position;
-            return hasExtraView() && isLastItem
-                    ? VIEW_TYPE_EXTRA_VIEW
-                    : VIEW_TYPE_APP;
+            return VIEW_TYPE_APP;
         }
 
         public void rebuild() {
@@ -1454,20 +1382,12 @@
             }
         }
 
-        public void onExtraViewCompleted() {
-            if (!hasExtraView()) {
-                return;
-            }
-            // Update last item - this is assumed to be the extra view.
-            notifyItemChanged(getItemCount() - 1);
-        }
-
         @Override
         public int getItemCount() {
             if (mEntries == null) {
                 return 0;
             }
-            return mEntries.size() + (hasExtraView() ? 1 : 0);
+            return mEntries.size();
         }
 
         public int getApplicationCount() {
@@ -1499,24 +1419,20 @@
 
         @Override
         public void onBindViewHolder(ApplicationViewHolder holder, int position) {
-            if (mEntries != null && mExtraViewController != null && position == mEntries.size()) {
-                // set up view for extra view controller
-                mExtraViewController.setupView(holder);
-            } else {
-                // Bind the data efficiently with the holder
-                ApplicationsState.AppEntry entry = mEntries.get(position);
-                synchronized (entry) {
-                    holder.setTitle(entry.label);
-                    mState.ensureLabelDescription(entry);
-                    holder.itemView.setContentDescription(entry.labelDescription);
-                    mState.ensureIcon(entry);
-                    holder.setIcon(entry.icon);
-                    updateSummary(holder, entry);
-                    updateSwitch(holder, entry);
-                    holder.updateDisableView(entry.info);
-                }
-                holder.setEnabled(isEnabled(position));
+            // Bind the data efficiently with the holder
+            final ApplicationsState.AppEntry entry = mEntries.get(position);
+            synchronized (entry) {
+                holder.setTitle(entry.label);
+                mState.ensureLabelDescription(entry);
+                holder.itemView.setContentDescription(entry.labelDescription);
+                mState.ensureIcon(entry);
+                holder.setIcon(entry.icon);
+                updateSummary(holder, entry);
+                updateSwitch(holder, entry);
+                holder.updateDisableView(entry.info);
             }
+            holder.setEnabled(isEnabled(position));
+
             holder.itemView.setOnClickListener(mManageApplications);
         }
 
@@ -1589,11 +1505,6 @@
             }
         }
 
-        private boolean hasExtraView() {
-            return mExtraViewController != null
-                    && mExtraViewController.shouldShow();
-        }
-
         public static class OnScrollListener extends RecyclerView.OnScrollListener {
             private int mScrollState = SCROLL_STATE_IDLE;
             private boolean mDelayNotifyDataChange;
diff --git a/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java b/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java
deleted file mode 100644
index 184fd1d..0000000
--- a/src/com/android/settings/applications/manageapplications/MusicViewHolderController.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.manageapplications;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.provider.DocumentsContract;
-import android.text.format.Formatter;
-import android.util.Log;
-
-import androidx.annotation.WorkerThread;
-import androidx.fragment.app.Fragment;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settingslib.applications.StorageStatsSource;
-
-import java.io.IOException;
-
-/**
- * MusicViewHolderController controls an Audio/Music file view in the ManageApplications view.
- */
-public class MusicViewHolderController implements FileViewHolderController {
-    private static final String TAG = "MusicViewHolderCtrl";
-
-    private static final String AUTHORITY_MEDIA = "com.android.providers.media.documents";
-
-    private Context mContext;
-    private StorageStatsSource mSource;
-    private String mVolumeUuid;
-    private long mMusicSize;
-    private UserHandle mUser;
-
-    public MusicViewHolderController(
-            Context context, StorageStatsSource source, String volumeUuid, UserHandle user) {
-        mContext = context;
-        mSource = source;
-        mVolumeUuid = volumeUuid;
-        mUser = user;
-    }
-
-    @Override
-    @WorkerThread
-    public void queryStats() {
-        try {
-            mMusicSize = mSource.getExternalStorageStats(mVolumeUuid, mUser).audioBytes;
-        } catch (IOException e) {
-            mMusicSize = 0;
-            Log.w(TAG, e);
-        }
-    }
-
-    @Override
-    public boolean shouldShow() {
-        return true;
-    }
-
-    @Override
-    public void setupView(ApplicationViewHolder holder) {
-        holder.setIcon(R.drawable.ic_headset_24dp);
-        holder.setTitle(mContext.getText(R.string.audio_files_title));
-        holder.setSummary(Formatter.formatFileSize(mContext, mMusicSize));
-    }
-
-    @Override
-    public void onClick(Fragment fragment) {
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setDataAndType(
-                DocumentsContract.buildRootUri(AUTHORITY_MEDIA, "audio_root"),
-                DocumentsContract.Root.MIME_TYPE_ITEM);
-        intent.addCategory(Intent.CATEGORY_DEFAULT);
-        intent.putExtra(Intent.EXTRA_USER_ID, mUser.getIdentifier());
-        Utils.launchIntent(fragment, intent);
-    }
-}
diff --git a/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java b/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java
deleted file mode 100644
index 30166c9..0000000
--- a/src/com/android/settings/applications/manageapplications/PhotosViewHolderController.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.manageapplications;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.text.format.Formatter;
-import android.util.Log;
-
-import androidx.annotation.WorkerThread;
-import androidx.fragment.app.Fragment;
-
-import com.android.settings.R;
-import com.android.settings.Utils;
-import com.android.settingslib.applications.StorageStatsSource;
-
-import java.io.IOException;
-
-/** PhotosViewHolderController controls an Audio/Music file view in the ManageApplications view. */
-public class PhotosViewHolderController implements FileViewHolderController {
-    private static final String TAG = "PhotosViewHolderCtrl";
-
-    private static final String IMAGE_MIME_TYPE = "image/*";
-
-    private Context mContext;
-    private StorageStatsSource mSource;
-    private String mVolumeUuid;
-    private long mFilesSize;
-    private UserHandle mUser;
-
-    public PhotosViewHolderController(
-            Context context, StorageStatsSource source, String volumeUuid, UserHandle user) {
-        mContext = context;
-        mSource = source;
-        mVolumeUuid = volumeUuid;
-        mUser = user;
-    }
-
-    @Override
-    @WorkerThread
-    public void queryStats() {
-        try {
-            StorageStatsSource.ExternalStorageStats stats =
-                    mSource.getExternalStorageStats(mVolumeUuid, mUser);
-            mFilesSize = stats.imageBytes + stats.videoBytes;
-        } catch (IOException e) {
-            mFilesSize = 0;
-            Log.w(TAG, e);
-        }
-    }
-
-    @Override
-    public boolean shouldShow() {
-        return true;
-    }
-
-    @Override
-    public void setupView(ApplicationViewHolder holder) {
-        holder.setIcon(R.drawable.ic_photo_library);
-        holder.setTitle(mContext.getText(R.string.storage_detail_images));
-        holder.setSummary(Formatter.formatFileSize(mContext, mFilesSize));
-    }
-
-    @Override
-    public void onClick(Fragment fragment) {
-        Intent intent = new Intent();
-        intent.setAction(android.content.Intent.ACTION_VIEW);
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
-        intent.setType(IMAGE_MIME_TYPE);
-        intent.putExtra(Intent.EXTRA_FROM_STORAGE, true);
-        intent.putExtra(Intent.EXTRA_USER_ID, mUser.getIdentifier());
-        Utils.launchIntent(fragment, intent);
-    }
-}
diff --git a/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java b/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
index 1144f12..8ccf7ed 100644
--- a/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/notificationaccess/HeaderPreferenceController.java
@@ -25,7 +25,6 @@
 import android.view.View;
 
 import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
@@ -36,7 +35,6 @@
 import com.android.settings.widget.EntityHeaderController;
 import com.android.settingslib.applications.AppUtils;
 import com.android.settingslib.bluetooth.LocalBluetoothManager;
-import com.android.settingslib.core.lifecycle.Lifecycle;
 import com.android.settingslib.widget.LayoutPreference;
 
 public class HeaderPreferenceController extends BasePreferenceController
@@ -127,11 +125,4 @@
                 .done(mFragment.getActivity(), mContext);
         pref.findViewById(R.id.entity_header).setVisibility(View.VISIBLE);
     }
-
-    @OnLifecycleEvent(Lifecycle.Event.ON_START)
-    public void onStart() {
-        if (mHeaderController != null) {
-            mHeaderController.styleActionBar(mFragment.getActivity());
-        }
-    }
 }
diff --git a/src/com/android/settings/backup/BackupSettingsHelper.java b/src/com/android/settings/backup/BackupSettingsHelper.java
index cc010f0..1483714 100644
--- a/src/com/android/settings/backup/BackupSettingsHelper.java
+++ b/src/com/android/settings/backup/BackupSettingsHelper.java
@@ -26,14 +26,12 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.text.TextUtils;
-import android.util.FeatureFlagUtils;
 import android.util.Log;
 
 import androidx.annotation.VisibleForTesting;
 
 import com.android.settings.R;
 import com.android.settings.Settings.PrivacySettingsActivity;
-import com.android.settings.core.FeatureFlags;
 
 import java.net.URISyntaxException;
 
@@ -57,9 +55,6 @@
      * Otherwise, show nothing.
      */
     public String getSummary() {
-        if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) {
-            return null;
-        }
         UserManager userManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
         if (userManager.getUserProfiles().size() == 1) {
             try {
diff --git a/src/com/android/settings/biometrics/BiometricEnrollActivity.java b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
index 0a2e5fe..97cda4b 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollActivity.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollActivity.java
@@ -211,8 +211,7 @@
                 case REQUEST_CHOOSE_LOCK:
                     mConfirmingCredentials = false;
                     if (resultCode == ChooseLockPattern.RESULT_FINISHED) {
-                        mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(data);
-                        startMultiBiometricEnroll();
+                        startMultiBiometricEnroll(data);
                     } else {
                         Log.d(TAG, "Unknown result for chooseLock: " + resultCode);
                         setResult(resultCode);
@@ -222,8 +221,7 @@
                 case REQUEST_CONFIRM_LOCK:
                     mConfirmingCredentials = false;
                     if (resultCode == RESULT_OK) {
-                        mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(data);
-                        startMultiBiometricEnroll();
+                        startMultiBiometricEnroll(data);
                     } else {
                         Log.d(TAG, "Unknown result for confirmLock: " + resultCode);
                         finish();
@@ -283,7 +281,8 @@
         }
     }
 
-    private void startMultiBiometricEnroll() {
+    private void startMultiBiometricEnroll(Intent data) {
+        mGkPwHandle = BiometricUtils.getGatekeeperPasswordHandle(data);
         mMultiBiometricEnrollHelper = new MultiBiometricEnrollHelper(this, mUserId,
                 mIsFaceEnrollable, mIsFingerprintEnrollable, mGkPwHandle);
         mMultiBiometricEnrollHelper.startNextStep();
@@ -299,9 +298,7 @@
     private void launchChooseLock() {
         Log.d(TAG, "launchChooseLock");
         Intent intent = BiometricUtils.getChooseLockIntent(this, getIntent());
-        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
-        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
 
@@ -351,8 +348,7 @@
         final Intent intent;
         // If only device credential was specified, ask the user to only set that up.
         intent = new Intent(this, ChooseLockGeneric.class);
-        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         launchEnrollActivity(intent);
     }
 
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index b44c2c9..c34b284 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -222,9 +222,7 @@
 
     private void launchChooseLock() {
         Intent intent = BiometricUtils.getChooseLockIntent(this, getIntent());
-        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
-        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+        intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
         intent.putExtra(getExtraKeyForBiometric(), true);
         if (mUserId != UserHandle.USER_NULL) {
diff --git a/src/com/android/settings/biometrics/BiometricUtils.java b/src/com/android/settings/biometrics/BiometricUtils.java
index e12badf..9de8105 100644
--- a/src/com/android/settings/biometrics/BiometricUtils.java
+++ b/src/com/android/settings/biometrics/BiometricUtils.java
@@ -33,6 +33,7 @@
 import androidx.fragment.app.FragmentActivity;
 
 import com.android.internal.widget.LockPatternUtils;
+import com.android.internal.widget.VerifyCredentialResponse;
 import com.android.settings.R;
 import com.android.settings.SetupWizardUtils;
 import com.android.settings.biometrics.fingerprint.FingerprintEnrollFindSensor;
@@ -72,8 +73,12 @@
     public static byte[] requestGatekeeperHat(@NonNull Context context, long gkPwHandle, int userId,
             long challenge) {
         final LockPatternUtils utils = new LockPatternUtils(context);
-        return utils.verifyGatekeeperPasswordHandle(gkPwHandle, challenge, userId)
-                .getGatekeeperHAT();
+        final VerifyCredentialResponse response = utils.verifyGatekeeperPasswordHandle(gkPwHandle,
+                challenge, userId);
+        if (!response.isMatched()) {
+            throw new IllegalStateException("Unable to request Gatekeeper HAT");
+        }
+        return response.getGatekeeperHAT();
     }
 
     public static boolean containsGatekeeperPasswordHandle(@Nullable Intent data) {
@@ -190,7 +195,7 @@
                     hardwareAuthToken);
         }
         if (gkPwHandle != null) {
-            intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, gkPwHandle);
+            intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, (long) gkPwHandle);
         }
 
         if (activity instanceof BiometricEnrollActivity.InternalActivity) {
diff --git a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
index 7d3be87..018c815 100644
--- a/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
+++ b/src/com/android/settings/biometrics/MultiBiometricEnrollHelper.java
@@ -77,12 +77,14 @@
 
             if (mRequestEnrollFingerprint) {
                 // Give FaceEnroll a pendingIntent pointing to fingerprint enrollment, so that it
-                // can be started when user skips or finishes face enrollment.
+                // can be started when user skips or finishes face enrollment. FLAG_UPDATE_CURRENT
+                // ensures it is launched with the most recent values.
                 final Intent fpIntent = BiometricUtils.getFingerprintIntroIntent(mActivity,
                         mActivity.getIntent());
                 fpIntent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_GK_PW_HANDLE, mGkPwHandle);
                 final PendingIntent fpAfterFaceIntent = PendingIntent.getActivity(mActivity,
-                        0 /* requestCode */, fpIntent, PendingIntent.FLAG_IMMUTABLE);
+                        0 /* requestCode */, fpIntent,
+                        PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
                 faceIntent.putExtra(EXTRA_ENROLL_AFTER_FACE, fpAfterFaceIntent);
             }
 
diff --git a/src/com/android/settings/biometrics/combination/BiometricFaceStatusPreferenceController.java b/src/com/android/settings/biometrics/combination/BiometricFaceStatusPreferenceController.java
index e4b210e..047a2df 100644
--- a/src/com/android/settings/biometrics/combination/BiometricFaceStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/BiometricFaceStatusPreferenceController.java
@@ -32,6 +32,6 @@
 
     @Override
     protected boolean isDeviceSupported() {
-        return Utils.hasFaceHardware(mContext);
+        return Utils.isMultipleBiometricsSupported(mContext) && Utils.hasFaceHardware(mContext);
     }
 }
diff --git a/src/com/android/settings/biometrics/combination/BiometricFingerprintStatusPreferenceController.java b/src/com/android/settings/biometrics/combination/BiometricFingerprintStatusPreferenceController.java
index fd742ff..72a19c7 100644
--- a/src/com/android/settings/biometrics/combination/BiometricFingerprintStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/BiometricFingerprintStatusPreferenceController.java
@@ -33,6 +33,7 @@
 
     @Override
     protected boolean isDeviceSupported() {
-        return Utils.hasFingerprintHardware(mContext);
+        return Utils.isMultipleBiometricsSupported(mContext)
+                && Utils.hasFingerprintHardware(mContext);
     }
 }
diff --git a/src/com/android/settings/biometrics/combination/BiometricSettingsAppPreferenceController.java b/src/com/android/settings/biometrics/combination/BiometricSettingsAppPreferenceController.java
index 9107e1b..861ff27 100644
--- a/src/com/android/settings/biometrics/combination/BiometricSettingsAppPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/BiometricSettingsAppPreferenceController.java
@@ -69,6 +69,9 @@
 
     @Override
     public int getAvailabilityStatus() {
+        if (!Utils.isMultipleBiometricsSupported(mContext)) {
+            return UNSUPPORTED_ON_DEVICE;
+        }
         if (mFaceManager == null || mFingerprintManager == null) {
             return AVAILABLE_UNSEARCHABLE;
         }
diff --git a/src/com/android/settings/biometrics/combination/BiometricSettingsKeyguardPreferenceController.java b/src/com/android/settings/biometrics/combination/BiometricSettingsKeyguardPreferenceController.java
index 263134a..6fe651f 100644
--- a/src/com/android/settings/biometrics/combination/BiometricSettingsKeyguardPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/BiometricSettingsKeyguardPreferenceController.java
@@ -21,6 +21,7 @@
 import android.content.Context;
 import android.provider.Settings;
 
+import com.android.settings.Utils;
 import com.android.settings.core.TogglePreferenceController;
 import com.android.settingslib.RestrictedLockUtils;
 import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -62,6 +63,9 @@
 
     @Override
     public int getAvailabilityStatus() {
+        if (!Utils.isMultipleBiometricsSupported(mContext)) {
+            return UNSUPPORTED_ON_DEVICE;
+        }
         return getRestrictingAdmin() != null ? DISABLED_FOR_USER : AVAILABLE;
     }
 }
diff --git a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
index c449ff4..b5f6ef3 100644
--- a/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
+++ b/src/com/android/settings/biometrics/combination/BiometricsSettingsBase.java
@@ -19,7 +19,6 @@
 
 import static com.android.settings.password.ChooseLockPattern.RESULT_FINISHED;
 
-import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.hardware.face.FaceManager;
@@ -193,9 +192,8 @@
 
         if (!launched) {
             Intent intent = BiometricUtils.getChooseLockIntent(getActivity(), getIntent());
-            intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                    DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
-            intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+            intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS,
+                    true);
             intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
             intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
 
diff --git a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
index c3db174..6e989d8 100644
--- a/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
+++ b/src/com/android/settings/biometrics/combination/CombinedBiometricStatusPreferenceController.java
@@ -16,6 +16,10 @@
 package com.android.settings.biometrics.combination;
 
 import android.content.Context;
+import android.hardware.face.FaceManager;
+import android.hardware.fingerprint.FingerprintManager;
+
+import androidx.annotation.Nullable;
 
 import com.android.settings.R;
 import com.android.settings.Settings;
@@ -30,6 +34,10 @@
         BiometricStatusPreferenceController {
     private static final String KEY_BIOMETRIC_SETTINGS = "biometric_settings";
 
+    @Nullable
+    FingerprintManager mFingerprintManager;
+    @Nullable
+    FaceManager mFaceManager;
 
     public CombinedBiometricStatusPreferenceController(Context context) {
         this(context, KEY_BIOMETRIC_SETTINGS);
@@ -37,6 +45,8 @@
 
     public CombinedBiometricStatusPreferenceController(Context context, String key) {
         super(context, key);
+        mFingerprintManager = Utils.getFingerprintManagerOrNull(context);
+        mFaceManager = Utils.getFaceManagerOrNull(context);
     }
 
     @Override
@@ -51,12 +61,34 @@
 
     @Override
     protected String getSummaryTextEnrolled() {
-        return mContext.getString(R.string.security_settings_biometric_preference_summary);
+        // Note that this is currently never called (see the super class)
+        return mContext.getString(
+                R.string.security_settings_biometric_preference_summary_none_enrolled);
     }
 
     @Override
     protected String getSummaryTextNoneEnrolled() {
-        return mContext.getString(R.string.security_settings_biometric_preference_summary);
+        final int numFingerprintsEnrolled = mFingerprintManager != null ?
+                mFingerprintManager.getEnrolledFingerprints(getUserId()).size() : 0;
+        final boolean faceEnrolled = mFaceManager != null
+                && mFaceManager.hasEnrolledTemplates(getUserId());
+
+        if (faceEnrolled && numFingerprintsEnrolled > 1) {
+            return mContext.getString(
+                    R.string.security_settings_biometric_preference_summary_both_fp_multiple);
+        } else if (faceEnrolled && numFingerprintsEnrolled == 1) {
+            return mContext.getString(
+                    R.string.security_settings_biometric_preference_summary_both_fp_single);
+        } else if (faceEnrolled) {
+            return mContext.getString(R.string.security_settings_face_preference_summary);
+        } else if (numFingerprintsEnrolled > 0) {
+            return mContext.getResources().getQuantityString(
+                    R.plurals.security_settings_fingerprint_preference_summary,
+                    numFingerprintsEnrolled, numFingerprintsEnrolled);
+        } else {
+            return mContext.getString(
+                    R.string.security_settings_biometric_preference_summary_none_enrolled);
+        }
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index 9110292..4129fa5 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -114,9 +114,6 @@
                 mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
                 mSensorId = sensorId;
                 mChallenge = challenge;
-                if (BiometricUtils.isMultiBiometricEnrollmentFlow(this)) {
-                    BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
-                }
                 mFooterBarMixin.getPrimaryButton().setEnabled(true);
             });
         }
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index 69624ab..db03a3d 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -85,7 +85,6 @@
                 mChallenge = challenge;
                 mSensorId = sensorId;
                 mToken = BiometricUtils.requestGatekeeperHat(this, getIntent(), mUserId, challenge);
-                BiometricUtils.removeGatekeeperPasswordHandle(this, getIntent());
 
                 // Put this into the intent. This is really just to work around the fact that the
                 // enrollment sidecar gets the HAT from the activity's intent, rather than having
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 0996a58..1622086 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -37,6 +37,7 @@
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupdesign.span.LinkSpan;
+import com.google.android.setupdesign.template.RequireScrollMixin;
 
 import java.util.List;
 
@@ -69,14 +70,18 @@
                         .build()
         );
 
-        mFooterBarMixin.setPrimaryButton(
-                new FooterButton.Builder(this)
-                        .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
-                        .setListener(this::onNextButtonClick)
-                        .setButtonType(FooterButton.ButtonType.NEXT)
-                        .setTheme(R.style.SudGlifButton_Primary)
-                        .build()
-        );
+        final FooterButton nextButton = new FooterButton.Builder(this)
+                .setText(R.string.security_settings_fingerprint_enroll_introduction_agree)
+                .setListener(this::onNextButtonClick)
+                .setButtonType(FooterButton.ButtonType.NEXT)
+                .setTheme(R.style.SudGlifButton_Primary)
+                .build();
+
+        mFooterBarMixin.setPrimaryButton(nextButton);
+        final RequireScrollMixin requireScrollMixin =
+                getLayout().getMixin(RequireScrollMixin.class);
+        requireScrollMixin.requireScrollWithButton(this, nextButton,
+                R.string.security_settings_face_enroll_introduction_more, this::onNextButtonClick);
     }
 
     int getNegativeButtonTextId() {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
index a328f21..dbac415 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintSettings.java
@@ -685,9 +685,7 @@
                 // TODO: This should be cleaned up. ChooseLockGeneric should provide a way of
                 //  specifying arguments/requests, instead of relying on callers setting extras.
                 intent.setClassName(SETTINGS_PACKAGE_NAME, ChooseLockGeneric.class.getName());
-                intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                        DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
-                intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS,
+                intent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS,
                         true);
                 intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
                 intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
diff --git a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
index 9706c17..6fdc7e5 100644
--- a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
@@ -33,7 +33,8 @@
 
 /**
  * Controller to maintain the {@link androidx.preference.Preference} for add
- * device. It monitor Bluetooth's status(on/off) and decide if need to show summary or not.
+ * device without summary at beginning. It monitor Bluetooth's status(on/off) and decide if need
+ * to show summary or not.
  */
 public class AddDevicePreferenceController extends BasePreferenceController
         implements LifecycleObserver, OnStart, OnStop {
@@ -46,7 +47,8 @@
         }
     };
     private IntentFilter mIntentFilter;
-    private BluetoothAdapter mBluetoothAdapter;
+
+    protected BluetoothAdapter mBluetoothAdapter;
 
     public AddDevicePreferenceController(Context context, String key) {
         super(context, key);
@@ -57,6 +59,7 @@
     @Override
     public void onStart() {
         mContext.registerReceiver(mReceiver, mIntentFilter);
+        updateState(mPreference);
     }
 
     @Override
@@ -75,17 +78,22 @@
     @Override
     public int getAvailabilityStatus() {
         return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
+                && isBluetoothEnabled()
                 ? AVAILABLE
                 : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
     public CharSequence getSummary() {
-        return mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()
+        return isBluetoothEnabled()
                 ? ""
                 : mContext.getString(R.string.connected_device_add_device_summary);
     }
 
+    protected boolean isBluetoothEnabled() {
+        return mBluetoothAdapter != null && mBluetoothAdapter.isEnabled();
+    }
+
     void updateState() {
         updateState(mPreference);
     }
diff --git a/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceController.java b/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceController.java
new file mode 100644
index 0000000..4513473
--- /dev/null
+++ b/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceController.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.connecteddevice;
+
+import android.content.Context;
+import android.content.pm.PackageManager;
+
+/**
+ * Controller to maintain the {@link androidx.preference.Preference} for add
+ * device with summary at beginning. It monitor Bluetooth's status(on/off) and decide if need
+ * to show summary or not.
+ */
+public class AddDeviceSummaryPreferenceController extends AddDevicePreferenceController {
+
+    public AddDeviceSummaryPreferenceController(Context context, String key) {
+        super(context, key);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)
+                && !isBluetoothEnabled()
+                ? AVAILABLE
+                : UNSUPPORTED_ON_DEVICE;
+    }
+}
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
index 390faa4..502c7d2 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDefaultFragment.java
@@ -61,9 +61,10 @@
     long mCurrentFunctions;
     @VisibleForTesting
     boolean mIsStartTethering = false;
+    @VisibleForTesting
+    Handler mHandler;
 
     private UsbConnectionBroadcastReceiver mUsbReceiver;
-    private Handler mHandler;
     private boolean mIsConnected = false;
 
     @VisibleForTesting
diff --git a/src/com/android/settings/datausage/DataUsageSummary.java b/src/com/android/settings/datausage/DataUsageSummary.java
index b11935f..a4396a2 100644
--- a/src/com/android/settings/datausage/DataUsageSummary.java
+++ b/src/com/android/settings/datausage/DataUsageSummary.java
@@ -183,7 +183,9 @@
     void addWifiSection() {
         TemplatePreferenceCategory category = (TemplatePreferenceCategory)
                 inflatePreferences(R.xml.data_usage_wifi);
-        category.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(), 0, services);
+        category.setTemplate(
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */), 0, services);
     }
 
     private void addEthernetSection() {
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreference.java b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
index f1728b6..260a6da 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreference.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreference.java
@@ -225,7 +225,8 @@
     static void launchWifiDataUsage(Context context) {
         final Bundle args = new Bundle(1);
         args.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE,
-                NetworkTemplate.buildTemplateWifiWildcard());
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
         args.putInt(DataUsageList.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_WIFI);
         final SubSettingLauncher launcher = new SubSettingLauncher(context)
                 .setArguments(args)
@@ -367,7 +368,9 @@
     @VisibleForTesting
     protected long getHistoricalUsageLevel() {
         final DataUsageController controller = new DataUsageController(getContext());
-        return controller.getHistoricalUsageLevel(NetworkTemplate.buildTemplateWifiWildcard());
+        return controller.getHistoricalUsageLevel(
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
index 73f8f45..ac1e1ad 100644
--- a/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
+++ b/src/com/android/settings/datausage/DataUsageSummaryPreferenceController.java
@@ -138,7 +138,8 @@
             mDefaultTemplate = DataUsageLib.getMobileTemplate(context, subscriptionId);
         } else if (DataUsageUtils.hasWifiRadio(context)) {
             mDataUsageTemplate = R.string.wifi_data_template;
-            mDefaultTemplate = NetworkTemplate.buildTemplateWifiWildcard();
+            mDefaultTemplate = NetworkTemplate.buildTemplateWifi(
+                    NetworkTemplate.WIFI_NETWORKID_ALL, null /* subscriberId */);
         } else {
             mDataUsageTemplate = R.string.ethernet_data_template;
             mDefaultTemplate = DataUsageUtils.getDefaultTemplate(context, subscriptionId);
@@ -178,7 +179,6 @@
         }
         RecyclerView view = mFragment.getListView();
         mEntityHeaderController.setRecyclerView(view, mLifecycle);
-        mEntityHeaderController.styleActionBar((Activity) mContext);
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/datausage/DataUsageUtils.java b/src/com/android/settings/datausage/DataUsageUtils.java
index 7da69cb..fae53ec 100644
--- a/src/com/android/settings/datausage/DataUsageUtils.java
+++ b/src/com/android/settings/datausage/DataUsageUtils.java
@@ -184,7 +184,8 @@
         if (SubscriptionManager.isValidSubscriptionId(defaultSubId) && hasMobileData(context)) {
             return DataUsageLib.getMobileTemplate(context, defaultSubId);
         } else if (hasWifiRadio(context)) {
-            return NetworkTemplate.buildTemplateWifiWildcard();
+            return NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                    null /* subscriberId */);
         } else {
             return NetworkTemplate.buildTemplateEthernet();
         }
diff --git a/src/com/android/settings/datausage/lib/DataUsageLib.java b/src/com/android/settings/datausage/lib/DataUsageLib.java
index cf2ce1f..786f0ec 100644
--- a/src/com/android/settings/datausage/lib/DataUsageLib.java
+++ b/src/com/android/settings/datausage/lib/DataUsageLib.java
@@ -73,6 +73,7 @@
 
     private static NetworkTemplate getMobileTemplateForSubId(
             TelephonyManager telephonyManager, int subId) {
-        return NetworkTemplate.buildTemplateMobileAll(telephonyManager.getSubscriberId(subId));
+        return NetworkTemplate.buildTemplateMobileAll(
+                telephonyManager.getSubscriberId(subId));
     }
 }
diff --git a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
index dcc581c..89d349f 100644
--- a/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
+++ b/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceController.java
@@ -21,6 +21,7 @@
 import android.text.format.Formatter;
 import android.util.FeatureFlagUtils;
 
+import androidx.annotation.VisibleForTesting;
 import androidx.preference.Preference;
 
 import com.android.settings.R;
@@ -31,6 +32,7 @@
 import com.android.settingslib.utils.ThreadUtils;
 
 import java.text.NumberFormat;
+import java.util.concurrent.Future;
 
 public class TopLevelStoragePreferenceController extends BasePreferenceController {
 
@@ -59,10 +61,15 @@
             return;
         }
 
-        ThreadUtils.postOnBackgroundThread(() -> {
+        refreshSummaryThread(preference);
+    }
+
+    @VisibleForTesting
+    protected Future refreshSummaryThread(Preference preference) {
+        return ThreadUtils.postOnBackgroundThread(() -> {
             final NumberFormat percentageFormat = NumberFormat.getPercentInstance();
             final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(
-                    mStorageManagerVolumeProvider);
+                    getStorageManagerVolumeProvider());
             final double privateUsedBytes = info.totalBytes - info.freeBytes;
 
             ThreadUtils.postOnMainThread(() -> {
@@ -72,4 +79,10 @@
             });
         });
     }
+
+
+    @VisibleForTesting
+    protected StorageManagerVolumeProvider getStorageManagerVolumeProvider() {
+        return mStorageManagerVolumeProvider;
+    }
 }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 4817485..bc46110 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -88,10 +88,14 @@
     @VisibleForTesting
     static final String TRASH_KEY = "pref_trash";
 
-    private final Uri mImagesUri;
-    private final Uri mVideosUri;
-    private final Uri mAudiosUri;
-    private final Uri mDocumentsAndOtherUri;
+    @VisibleForTesting
+    final Uri mImagesUri;
+    @VisibleForTesting
+    final Uri mVideosUri;
+    @VisibleForTesting
+    final Uri mAudiosUri;
+    @VisibleForTesting
+    final Uri mDocumentsAndOtherUri;
 
     // This value should align with the design of storage_dashboard_fragment.xml
     private static final int LAST_STORAGE_CATEGORY_PREFERENCE_ORDER = 200;
@@ -175,13 +179,13 @@
                 launchPublicStorageIntent();
                 return true;
             case IMAGES_KEY:
-                launchImagesIntent();
+                launchActivityWithUri(mImagesUri);
                 return true;
             case VIDEOS_KEY:
-                launchVideosIntent();
+                launchActivityWithUri(mVideosUri);
                 return true;
             case AUDIOS_KEY:
-                launchAudiosIntent();
+                launchActivityWithUri(mAudiosUri);
                 return true;
             case APPS_KEY:
                 launchAppsIntent();
@@ -190,7 +194,7 @@
                 launchGamesIntent();
                 return true;
             case DOCUMENTS_AND_OTHER_KEY:
-                launchDocumentsAndOtherIntent();
+                launchActivityWithUri(mDocumentsAndOtherUri);
                 return true;
             case SYSTEM_KEY:
                 final SystemInfoFragment dialog = new SystemInfoFragment();
@@ -405,29 +409,10 @@
         }
     }
 
-    // TODO(b/183078080): To simplify StorageItemPreferenceController, move launchxxxIntent to a
-    //                    utility object.
-    private void launchImagesIntent() {
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setData(mImagesUri);
-
-        if (intent.resolveActivity(mPackageManager) == null) {
-            final Bundle args = getWorkAnnotatedBundle(2);
-            args.putString(ManageApplications.EXTRA_CLASSNAME,
-                    Settings.PhotosStorageActivity.class.getName());
-            args.putInt(ManageApplications.EXTRA_STORAGE_TYPE,
-                    ManageApplications.STORAGE_TYPE_PHOTOS_VIDEOS);
-            intent = new SubSettingLauncher(mContext)
-                    .setDestination(ManageApplications.class.getName())
-                    .setTitleRes(R.string.storage_photos_videos)
-                    .setArguments(args)
-                    .setSourceMetricsCategory(mMetricsFeatureProvider.getMetricsCategory(mFragment))
-                    .toIntent();
-            intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
-            Utils.launchIntent(mFragment, intent);
-        } else {
-            mContext.startActivity(intent);
-        }
+    private void launchActivityWithUri(Uri dataUri) {
+        final Intent intent = new Intent(Intent.ACTION_VIEW);
+        intent.setData(dataUri);
+        mContext.startActivity(intent);
     }
 
     private long getImagesSize(StorageAsyncLoader.AppsStorageResult data,
@@ -443,27 +428,6 @@
         }
     }
 
-    private void launchVideosIntent() {
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setData(mVideosUri);
-
-        if (intent.resolveActivity(mPackageManager) == null) {
-            final Bundle args = getWorkAnnotatedBundle(1);
-            args.putString(ManageApplications.EXTRA_CLASSNAME,
-                    Settings.MoviesStorageActivity.class.getName());
-            intent = new SubSettingLauncher(mContext)
-                    .setDestination(ManageApplications.class.getName())
-                    .setTitleRes(R.string.storage_movies_tv)
-                    .setArguments(args)
-                    .setSourceMetricsCategory(mMetricsFeatureProvider.getMetricsCategory(mFragment))
-                    .toIntent();
-            intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
-            Utils.launchIntent(mFragment, intent);
-        } else {
-            mContext.startActivity(intent);
-        }
-    }
-
     private long getVideosSize(StorageAsyncLoader.AppsStorageResult data,
             StorageAsyncLoader.AppsStorageResult profileData) {
         if (profileData != null) {
@@ -473,31 +437,6 @@
         }
     }
 
-    private void launchAudiosIntent() {
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setData(mAudiosUri);
-
-        if (intent.resolveActivity(mPackageManager) == null) {
-            final Bundle args = getWorkAnnotatedBundle(4);
-            args.putString(ManageApplications.EXTRA_CLASSNAME,
-                    Settings.StorageUseActivity.class.getName());
-            args.putString(ManageApplications.EXTRA_VOLUME_UUID, mVolume.getFsUuid());
-            args.putString(ManageApplications.EXTRA_VOLUME_NAME, mVolume.getDescription());
-            args.putInt(ManageApplications.EXTRA_STORAGE_TYPE,
-                    ManageApplications.STORAGE_TYPE_MUSIC);
-            intent = new SubSettingLauncher(mContext)
-                    .setDestination(ManageApplications.class.getName())
-                    .setTitleRes(R.string.storage_music_audio)
-                    .setArguments(args)
-                    .setSourceMetricsCategory(mMetricsFeatureProvider.getMetricsCategory(mFragment))
-                    .toIntent();
-            intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
-            Utils.launchIntent(mFragment, intent);
-        } else {
-            mContext.startActivity(intent);
-        }
-    }
-
     private long getAudiosSize(StorageAsyncLoader.AppsStorageResult data,
             StorageAsyncLoader.AppsStorageResult profileData) {
         if (profileData != null) {
@@ -563,19 +502,6 @@
         return args;
     }
 
-    private void launchDocumentsAndOtherIntent() {
-        Intent intent = new Intent(Intent.ACTION_VIEW);
-        intent.setData(mDocumentsAndOtherUri);
-
-        if (intent.resolveActivity(mPackageManager) == null) {
-            intent = mSvp.findEmulatedForPrivate(mVolume).buildBrowseIntent();
-            intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
-            Utils.launchIntent(mFragment, intent);
-        } else {
-            mContext.startActivity(intent);
-        }
-    }
-
     private long getDocumentsAndOtherSize(StorageAsyncLoader.AppsStorageResult data,
             StorageAsyncLoader.AppsStorageResult profileData) {
         if (profileData != null) {
diff --git a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
index 0d21e9c..c3db6f7 100644
--- a/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPermissionPreferenceController.java
@@ -37,26 +37,18 @@
     @VisibleForTesting
     BannerMessagePreference mPreference;
     private final PackageManager mPackageManager;
+    private final Context mContext;
 
     public AdaptiveSleepPermissionPreferenceController(Context context) {
-        final String packageName = context.getPackageManager().getAttentionServicePackageName();
         mPackageManager = context.getPackageManager();
-        final Intent intent = new Intent(
-                android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
-        intent.setData(Uri.parse("package:" + packageName));
-        mPreference = new BannerMessagePreference(context);
-        mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
-        mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
-        mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
-        mPreference.setPositiveButtonOnClickListener(p -> {
-            context.startActivity(intent);
-        });
+        mContext = context;
     }
 
     /**
      * Adds the controlled preference to the provided preference screen.
      */
     public void addToScreen(PreferenceScreen screen) {
+        initializePreference();
         if (!hasSufficientPermission(mPackageManager)) {
             screen.addPreference(mPreference);
         }
@@ -66,6 +58,25 @@
      * Refreshes the visibility of the preference.
      */
     public void updateVisibility() {
+        initializePreference();
         mPreference.setVisible(!hasSufficientPermission(mPackageManager));
     }
+
+    private void initializePreference() {
+        if (mPreference == null) {
+            final String packageName =
+                    mContext.getPackageManager().getAttentionServicePackageName();
+            final Intent intent = new Intent(
+                    android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+            intent.setData(Uri.parse("package:" + packageName));
+            mPreference = new BannerMessagePreference(mContext);
+            mPreference.setTitle(R.string.adaptive_sleep_title_no_permission);
+            mPreference.setSummary(R.string.adaptive_sleep_summary_no_permission);
+            mPreference.setPositiveButtonText(R.string.adaptive_sleep_manage_permission_button);
+            mPreference.setPositiveButtonOnClickListener(p -> {
+                mContext.startActivity(intent);
+            });
+        }
+    }
+
 }
diff --git a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
index 70d8a79..8f61683 100644
--- a/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
+++ b/src/com/android/settings/display/AdaptiveSleepPreferenceController.java
@@ -49,10 +49,10 @@
     public static final String PREFERENCE_KEY = "adaptive_sleep";
     private static final int DEFAULT_VALUE = 0;
     private final SensorPrivacyManager mPrivacyManager;
-    private RestrictionUtils mRestrictionUtils;
-    private PackageManager mPackageManager;
-    private Context mContext;
-    private MetricsFeatureProvider mMetricsFeatureProvider;
+    private final RestrictionUtils mRestrictionUtils;
+    private final PackageManager mPackageManager;
+    private final Context mContext;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
 
     @VisibleForTesting
     RestrictedSwitchPreference mPreference;
@@ -62,19 +62,6 @@
         mRestrictionUtils = restrictionUtils;
         mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
         mPrivacyManager = SensorPrivacyManager.getInstance(context);
-        mPreference = new RestrictedSwitchPreference(context);
-        mPreference.setTitle(R.string.adaptive_sleep_title);
-        mPreference.setSummary(R.string.adaptive_sleep_description);
-        mPreference.setChecked(isChecked());
-        mPreference.setKey(PREFERENCE_KEY);
-        mPreference.setOnPreferenceClickListener(preference -> {
-            final boolean isChecked = ((RestrictedSwitchPreference) preference).isChecked();
-            mMetricsFeatureProvider.action(context, SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
-                    isChecked);
-            Settings.Secure.putInt(context.getContentResolver(),
-                    Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
-            return true;
-        });
         mPackageManager = context.getPackageManager();
     }
 
@@ -91,9 +78,10 @@
     }
 
     /**
-     *  Updates the appearance of the preference.
+     * Updates the appearance of the preference.
      */
     public void updatePreference() {
+        initializePreference();
         final EnforcedAdmin enforcedAdmin = mRestrictionUtils.checkIfRestrictionEnforced(mContext,
                 UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT);
         if (enforcedAdmin != null) {
@@ -104,6 +92,26 @@
     }
 
     @VisibleForTesting
+    void initializePreference() {
+        if (mPreference == null) {
+            mPreference = new RestrictedSwitchPreference(mContext);
+            mPreference.setTitle(R.string.adaptive_sleep_title);
+            mPreference.setSummary(R.string.adaptive_sleep_description);
+            mPreference.setChecked(isChecked());
+            mPreference.setKey(PREFERENCE_KEY);
+            mPreference.setOnPreferenceChangeListener((preference, value) -> {
+                final boolean isChecked = (Boolean) value;
+                mMetricsFeatureProvider.action(mContext,
+                        SettingsEnums.ACTION_SCREEN_ATTENTION_CHANGED,
+                        isChecked);
+                Settings.Secure.putInt(mContext.getContentResolver(),
+                        Settings.Secure.ADAPTIVE_SLEEP, isChecked ? 1 : DEFAULT_VALUE);
+                return true;
+            });
+        }
+    }
+
+    @VisibleForTesting
     boolean isChecked() {
         return hasSufficientPermission(mContext.getPackageManager()) && !isCameraLocked()
                 && Settings.Secure.getInt(mContext.getContentResolver(),
@@ -146,4 +154,4 @@
         return attentionPackage != null && packageManager.checkPermission(
                 Manifest.permission.CAMERA, attentionPackage) == PackageManager.PERMISSION_GRANTED;
     }
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/display/ScreenTimeoutSettings.java b/src/com/android/settings/display/ScreenTimeoutSettings.java
index 27e1e1b..6dfb225 100644
--- a/src/com/android/settings/display/ScreenTimeoutSettings.java
+++ b/src/com/android/settings/display/ScreenTimeoutSettings.java
@@ -71,11 +71,15 @@
     private CharSequence[] mInitialEntries;
     private CharSequence[] mInitialValues;
     private FooterPreference mPrivacyPreference;
-    private MetricsFeatureProvider mMetricsFeatureProvider;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
     private SensorPrivacyManager mPrivacyManager;
 
     @VisibleForTesting
+    Context mContext;
+
+    @VisibleForTesting
     RestrictedLockUtils.EnforcedAdmin mAdmin;
+
     @VisibleForTesting
     Preference mDisableOptionsPreference;
 
@@ -97,6 +101,7 @@
     @Override
     public void onAttach(Context context) {
         super.onAttach(context);
+        mContext = context;
         mInitialEntries = getResources().getStringArray(R.array.screen_timeout_entries);
         mInitialValues = getResources().getStringArray(R.array.screen_timeout_values);
         mAdaptiveSleepController = new AdaptiveSleepPreferenceController(context);
@@ -104,11 +109,6 @@
                 context);
         mAdaptiveSleepCameraStatePreferenceController =
                 new AdaptiveSleepCameraStatePreferenceController(context);
-        mPrivacyPreference = new FooterPreference(context);
-        mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
-        mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
-        mPrivacyPreference.setSelectable(false);
-        mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
         mPrivacyManager = SensorPrivacyManager.getInstance(context);
         mPrivacyManager.addSensorPrivacyListener(CAMERA,
                 (sensor, enabled) -> mAdaptiveSleepController.updatePreference());
@@ -167,6 +167,12 @@
             preferenceWithLargestTimeout.setChecked(true);
         }
 
+        mPrivacyPreference = new FooterPreference(mContext);
+        mPrivacyPreference.setIcon(R.drawable.ic_privacy_shield_24dp);
+        mPrivacyPreference.setTitle(R.string.adaptive_sleep_privacy);
+        mPrivacyPreference.setSelectable(false);
+        mPrivacyPreference.setLayoutResource(R.layout.preference_footer);
+
         if (isScreenAttentionAvailable(getContext())) {
             mAdaptiveSleepPermissionController.addToScreen(screen);
             mAdaptiveSleepCameraStatePreferenceController.addToScreen(screen);
diff --git a/src/com/android/settings/display/SmartAutoRotateCameraStateController.java b/src/com/android/settings/display/SmartAutoRotateCameraStateController.java
index 9e2a784..a17a903 100644
--- a/src/com/android/settings/display/SmartAutoRotateCameraStateController.java
+++ b/src/com/android/settings/display/SmartAutoRotateCameraStateController.java
@@ -44,7 +44,9 @@
         super(context, key);
         mPrivacyManager = SensorPrivacyManager.getInstance(context);
         mPrivacyManager.addSensorPrivacyListener(CAMERA, (sensor, enabled) -> {
-            mPreference.setVisible(enabled);
+            if (mPreference != null) {
+                mPreference.setVisible(enabled);
+            }
             updateState(mPreference);
         });
     }
diff --git a/src/com/android/settings/dream/DreamSettings.java b/src/com/android/settings/dream/DreamSettings.java
index a40cf88..83979e5 100644
--- a/src/com/android/settings/dream/DreamSettings.java
+++ b/src/com/android/settings/dream/DreamSettings.java
@@ -129,9 +129,8 @@
     }
 
     private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
-        List<AbstractPreferenceController> controllers = new ArrayList<>();
+        final List<AbstractPreferenceController> controllers = new ArrayList<>();
         controllers.add(new WhenToDreamPreferenceController(context));
-        controllers.add(new StartNowPreferenceController(context));
         return controllers;
     }
 
diff --git a/src/com/android/settings/dream/StartNowPreferenceController.java b/src/com/android/settings/dream/StartNowPreferenceController.java
index fb0581f..ed0a4db 100644
--- a/src/com/android/settings/dream/StartNowPreferenceController.java
+++ b/src/com/android/settings/dream/StartNowPreferenceController.java
@@ -17,63 +17,52 @@
 package com.android.settings.dream;
 
 import android.content.Context;
-import android.widget.Button;
 
 import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
 
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
 import com.android.settings.dashboard.DashboardFragment;
 import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settings.widget.SettingsMainSwitchPreferenceController;
 import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 import com.android.settingslib.dream.DreamBackend;
-import com.android.settingslib.widget.LayoutPreference;
 
-public class StartNowPreferenceController extends AbstractPreferenceController implements
-        PreferenceControllerMixin {
+/**
+ * Controller that used to enable screen saver
+ */
+public class StartNowPreferenceController extends SettingsMainSwitchPreferenceController {
 
-    private static final String PREF_KEY = "dream_start_now_button_container";
     private final DreamBackend mBackend;
     private final MetricsFeatureProvider mMetricsFeatureProvider;
 
-    public StartNowPreferenceController(Context context) {
-        super(context);
-
+    public StartNowPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
         mBackend = DreamBackend.getInstance(context);
         mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
     @Override
-    public boolean isAvailable() {
-        return true;
-    }
-
-    @Override
-    public String getPreferenceKey() {
-        return PREF_KEY;
-    }
-
-    @Override
-    public void displayPreference(PreferenceScreen screen) {
-        super.displayPreference(screen);
-
-        LayoutPreference pref = screen.findPreference(getPreferenceKey());
-        Button startButton = pref.findViewById(R.id.dream_start_now_button);
-        startButton.setOnClickListener(v -> {
-            mMetricsFeatureProvider.logClickedPreference(pref,
-                    pref.getExtras().getInt(DashboardFragment.CATEGORY));
-            mBackend.startDreaming();
-        });
+    public int getAvailabilityStatus() {
+        return AVAILABLE;
     }
 
     @Override
     public void updateState(Preference preference) {
-        super.updateState(preference);
+        mSwitchPreference.setChecked(false);
+        mSwitchPreference.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
+    }
 
-        Button startButton = ((LayoutPreference) preference)
-                .findViewById(R.id.dream_start_now_button);
-        startButton.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
+    @Override
+    public boolean isChecked() {
+        return false;
+    }
+
+    @Override
+    public boolean setChecked(boolean isChecked) {
+        if (isChecked) {
+            mMetricsFeatureProvider.logClickedPreference(mSwitchPreference,
+                    mSwitchPreference.getExtras().getInt(DashboardFragment.CATEGORY));
+            mBackend.startDreaming();
+        }
+        return true;
     }
 }
diff --git a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
index 21160d7..7c2f052 100644
--- a/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
+++ b/src/com/android/settings/fuelgauge/AdvancedPowerUsageDetail.java
@@ -297,7 +297,6 @@
             final long foregroundTimeMs = bundle.getLong(EXTRA_FOREGROUND_TIME);
             final long backgroundTimeMs = bundle.getLong(EXTRA_BACKGROUND_TIME);
             final String slotTime = bundle.getString(EXTRA_SLOT_TIME, null);
-            //TODO(b/178197718) Update layout to support multiple lines
             controller.setSummary(getAppActiveTime(foregroundTimeMs, backgroundTimeMs, slotTime));
         }
 
@@ -329,15 +328,15 @@
     void initPreferenceForTriState(Context context) {
         final String stateString;
         final String footerString;
-        //TODO(b/178197718) Update strings
+
         if (!mBatteryOptimizeUtils.isValidPackageName()) {
             //Present optimized only string when the package name is invalid.
-            stateString = context.getString(R.string.manager_battery_usage_optimized_title);
+            stateString = context.getString(R.string.manager_battery_usage_optimized_only);
             footerString = context.getString(
                     R.string.manager_battery_usage_footer_limited, stateString);
         } else if (mBatteryOptimizeUtils.isSystemOrDefaultApp()) {
             //Present unrestricted only string when the package is system or default active app.
-            stateString = context.getString(R.string.manager_battery_usage_unrestricted_title);
+            stateString = context.getString(R.string.manager_battery_usage_unrestricted_only);
             footerString = context.getString(
                     R.string.manager_battery_usage_footer_limited, stateString);
         } else {
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
index 7d4bdac..6754245 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverStickyPreferenceController.java
@@ -4,6 +4,8 @@
 import android.icu.text.NumberFormat;
 import android.provider.Settings;
 import android.provider.Settings.Global;
+import android.text.TextUtils;
+
 import androidx.preference.Preference;
 import androidx.preference.SwitchPreference;
 import com.android.settings.R;
@@ -37,13 +39,11 @@
     @Override
     protected void refreshSummary(Preference preference) {
         super.refreshSummary(preference);
-        final double stickyShutoffLevel = Settings.Global.getInt(
+        final int stickyShutoffLevel = Settings.Global.getInt(
             mContext.getContentResolver(), Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL, 90);
-        final String percentage = NumberFormat
-            .getPercentInstance()
-            .format(stickyShutoffLevel / 100.0);
-        preference.setSummary(
-            mContext.getString(R.string.battery_saver_sticky_description_new, percentage));
+        preference.setSummary(TextUtils.expandTemplate(
+                mContext.getString(R.string.battery_saver_sticky_description_new),
+                NumberFormat.getIntegerInstance().format(stickyShutoffLevel)));
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
index adfa137..7501897 100644
--- a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
+++ b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
@@ -20,12 +20,12 @@
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
-import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.widget.SettingsMainSwitchPreferenceController;
 
 /**
  * The controller to handle one-handed mode enable or disable state.
  **/
-public class OneHandedEnablePreferenceController extends TogglePreferenceController {
+public class OneHandedEnablePreferenceController extends SettingsMainSwitchPreferenceController {
 
     public OneHandedEnablePreferenceController(Context context, String key) {
         super(context, key);
diff --git a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
index ca1f1c7..b679438 100644
--- a/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingParentPreferenceController.java
@@ -92,8 +92,9 @@
             case VOLUME_HUSH_MUTE:
                 summary = mContext.getText(R.string.prevent_ringing_option_mute_summary);
                 break;
+            // VOLUME_HUSH_OFF
             default:
-                summary = null;
+                summary = mContext.getText(R.string.switch_off_text);
         }
         preference.setSummary(summary);
     }
diff --git a/src/com/android/settings/network/InternetUpdater.java b/src/com/android/settings/network/InternetUpdater.java
index dd70cef..cb8d32c 100644
--- a/src/com/android/settings/network/InternetUpdater.java
+++ b/src/com/android/settings/network/InternetUpdater.java
@@ -20,6 +20,7 @@
 import static android.net.NetworkCapabilities.TRANSPORT_ETHERNET;
 import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
 
+import static androidx.lifecycle.Lifecycle.Event.ON_DESTROY;
 import static androidx.lifecycle.Lifecycle.Event.ON_PAUSE;
 import static androidx.lifecycle.Lifecycle.Event.ON_RESUME;
 
@@ -191,6 +192,12 @@
         mContext.unregisterReceiver(mWifiStateReceiver);
     }
 
+    /** @OnLifecycleEvent(ON_DESTROY) */
+    @OnLifecycleEvent(ON_DESTROY)
+    public void onDestroy() {
+        mAirplaneModeEnabler.close();
+    }
+
     @Override
     public void onAirplaneModeChanged(boolean isAirplaneModeOn) {
         fetchActiveNetwork();
diff --git a/src/com/android/settings/network/NetworkProviderSettings.java b/src/com/android/settings/network/NetworkProviderSettings.java
index c368fa3..3b65221 100644
--- a/src/com/android/settings/network/NetworkProviderSettings.java
+++ b/src/com/android/settings/network/NetworkProviderSettings.java
@@ -279,9 +279,9 @@
         mAddWifiNetworkPreference = new AddWifiNetworkPreference(getPrefContext());
         mDataUsagePreference = findPreference(PREF_KEY_DATA_USAGE);
         mDataUsagePreference.setVisible(DataUsageUtils.hasWifiRadio(getContext()));
-        mDataUsagePreference.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(),
-                0 /*subId*/,
-                null /*service*/);
+        mDataUsagePreference.setTemplate(
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */), 0 /*subId*/, null /*service*/);
         mResetInternetPreference = findPreference(PREF_KEY_RESET_INTERNET);
         if (mResetInternetPreference != null) {
             mResetInternetPreference.setVisible(false);
diff --git a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
index c4bf6b4..d1c9f7b 100644
--- a/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/BackupCallingPreferenceController.java
@@ -42,7 +42,6 @@
 
     private static final String LOG_TAG = "BackupCallingPrefCtrl";
 
-    private int mSubId;
     private Preference mPreference;
 
     /**
diff --git a/src/com/android/settings/network/telephony/Enable2gPreferenceController.java b/src/com/android/settings/network/telephony/Enable2gPreferenceController.java
index d336cb4..5c7d224 100644
--- a/src/com/android/settings/network/telephony/Enable2gPreferenceController.java
+++ b/src/com/android/settings/network/telephony/Enable2gPreferenceController.java
@@ -71,6 +71,10 @@
     @Override
     public int getAvailabilityStatus(int subId) {
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        if (mTelephonyManager == null) {
+            Log.w(LOG_TAG, "Telephony manager not yet initialized");
+            mTelephonyManager = mContext.getSystemService(TelephonyManager.class);
+        }
         boolean visible =
                 SubscriptionManager.isUsableSubscriptionId(subId)
                 && carrierConfig != null
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 6952e72..d39f6a4 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -63,6 +63,7 @@
     public EnabledNetworkModePreferenceController(Context context, String key) {
         super(context, key);
         mSubscriptionsListener = new SubscriptionsChangeListener(context, this);
+        mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
     }
 
     @Override
@@ -145,7 +146,6 @@
         mSubId = subId;
         mTelephonyManager = mContext.getSystemService(TelephonyManager.class)
                 .createForSubscriptionId(mSubId);
-        mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
         mBuilder = new PreferenceEntriesBuilder(mContext, mSubId);
 
         if (mAllowedNetworkTypesListener == null) {
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index b3421f4..46e1385 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -19,7 +19,6 @@
 import android.content.Context;
 import android.os.PersistableBundle;
 import android.telephony.CarrierConfigManager;
-import android.telephony.PhoneStateListener;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyCallback;
 import android.telephony.TelephonyManager;
@@ -143,6 +142,16 @@
             return false;
         }
 
+        // When called within Settings Search, this variable may still be null.
+        if (mCarrierConfigManager == null) {
+            Log.e(TAG, "CarrierConfigManager set to null.");
+            mCarrierConfigManager = mContext.getSystemService(CarrierConfigManager.class);
+            if (mCarrierConfigManager == null) {
+                Log.e(TAG, "Unable to reinitialize CarrierConfigManager.");
+                return false;
+            }
+        }
+
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
         if (carrierConfig == null) {
             return false;
diff --git a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java b/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
index 67f0c7b..37723b1 100644
--- a/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/BubbleNotificationPreferenceController.java
@@ -30,8 +30,7 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.TogglePreferenceController;
+import com.android.settings.widget.SettingsMainSwitchPreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnPause;
 import com.android.settingslib.core.lifecycle.events.OnResume;
@@ -40,9 +39,8 @@
  * Feature level screen for bubbles, available through notification menu.
  * Allows user to turn bubbles on or off for the device.
  */
-public class BubbleNotificationPreferenceController extends TogglePreferenceController
-        implements PreferenceControllerMixin, Preference.OnPreferenceChangeListener,
-        LifecycleObserver, OnResume, OnPause {
+public class BubbleNotificationPreferenceController extends
+        SettingsMainSwitchPreferenceController implements LifecycleObserver, OnResume, OnPause {
 
     private static final String TAG = "BubbleNotifPrefContr";
 
@@ -60,9 +58,8 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        Preference preference = screen.findPreference(getPreferenceKey());
-        if (preference != null) {
-            mSettingObserver = new SettingObserver(preference);
+        if (mSwitchPreference != null) {
+            mSettingObserver = new SettingObserver(mSwitchPreference);
         }
     }
 
@@ -87,20 +84,21 @@
     }
 
     @Override
+    public boolean isSliceable() {
+        return false;
+    }
+
+    @Override
     public boolean isChecked() {
-        return Settings.Secure.getInt(mContext.getContentResolver(),
+        return Settings.Global.getInt(mContext.getContentResolver(),
                 NOTIFICATION_BUBBLES, ON) == ON;
     }
 
     @Override
     public boolean setChecked(boolean isChecked) {
-        return Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES,
-                isChecked ? ON : OFF);
-    }
-
-    @Override
-    public boolean isSliceable() {
-        return false;
+        Settings.Global.putInt(mContext.getContentResolver(),
+                NOTIFICATION_BUBBLES, isChecked ? ON : OFF);
+        return true;
     }
 
     class SettingObserver extends ContentObserver {
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 87d25dd..bd45884 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -236,7 +236,7 @@
             final String pkgName = app.getPackage();
             final ApplicationsState.AppEntry appEntry =
                     mApplicationsState.getEntry(app.getPackage(), app.getUserId());
-            if (appEntry == null) {
+            if (appEntry == null || appEntry.label == null) {
                 continue;
             }
 
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index 73659b8..f99a56a 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -122,9 +122,6 @@
     @OnLifecycleEvent(Lifecycle.Event.ON_START)
     public void onStart() {
         mStarted = true;
-        if (mHeaderController != null) {
-            mHeaderController.styleActionBar(mFragment.getActivity());
-        }
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/notification/app/HeaderPreferenceController.java b/src/com/android/settings/notification/app/HeaderPreferenceController.java
index 4e9c039..974ac79 100644
--- a/src/com/android/settings/notification/app/HeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/HeaderPreferenceController.java
@@ -121,9 +121,6 @@
     @OnLifecycleEvent(Lifecycle.Event.ON_START)
     public void onStart() {
         mStarted = true;
-        if (mHeaderController != null) {
-            mHeaderController.styleActionBar(mFragment.getActivity());
-        }
     }
 
     @VisibleForTesting
diff --git a/src/com/android/settings/password/ChooseLockGeneric.java b/src/com/android/settings/password/ChooseLockGeneric.java
index b8e1165..a1826ba 100644
--- a/src/com/android/settings/password/ChooseLockGeneric.java
+++ b/src/com/android/settings/password/ChooseLockGeneric.java
@@ -75,8 +75,6 @@
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
 import com.android.settings.search.SearchFeatureProvider;
-import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
-import com.android.settingslib.RestrictedLockUtilsInternal;
 import com.android.settingslib.RestrictedPreference;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
@@ -112,8 +110,7 @@
         private static final String KEY_SKIP_BIOMETRICS = "unlock_skip_biometrics";
         private static final String PASSWORD_CONFIRMED = "password_confirmed";
         private static final String WAITING_FOR_CONFIRMATION = "waiting_for_confirmation";
-        public static final String MINIMUM_QUALITY_KEY = "minimum_quality";
-        public static final String HIDE_DISABLED_PREFS = "hide_disabled_prefs";
+        public static final String HIDE_INSECURE_OPTIONS = "hide_insecure_options";
         public static final String TAG_FRP_WARNING_DIALOG = "frp_warning_dialog";
         public static final String KEY_LOCK_SETTINGS_FOOTER ="lock_settings_footer";
 
@@ -277,21 +274,20 @@
                     arguments,
                     intent.getExtras()).getIdentifier();
             mIsManagedProfile = UserManager.get(getActivity()).isManagedProfile(mUserId);
-            mController = new ChooseLockGenericController(
-                    getContext(), mUserId, mRequestedMinComplexity,
-                    mOnlyEnforceDevicePasswordRequirement,
-                    mLockPatternUtils);
-
-            final int aggregatedComplexity = mController.getAggregatedPasswordComplexity();
-            final boolean isComplexityProvidedByAdmin =
-                    aggregatedComplexity > mRequestedMinComplexity
-                    && aggregatedComplexity > PASSWORD_COMPLEXITY_NONE;
+            mController = new ChooseLockGenericController.Builder(
+                    getContext(), mUserId, mLockPatternUtils)
+                    .setAppRequestedMinComplexity(mRequestedMinComplexity)
+                    .setEnforceDevicePasswordRequirementOnly(mOnlyEnforceDevicePasswordRequirement)
+                    .setProfileToUnify(mUnificationProfileId)
+                    .setHideInsecureScreenLockTypes(alwaysHideInsecureScreenLockTypes()
+                            || intent.getBooleanExtra(HIDE_INSECURE_OPTIONS, false))
+                    .build();
 
             // If the complexity is provided by the admin, do not get the caller app's name.
             // If the app requires, for example, low complexity, and the admin requires high
             // complexity, it does not make sense to show a footer telling the user it's the app
             // requesting a particular complexity because the admin-set complexity will override it.
-            mCallerAppName = isComplexityProvidedByAdmin ? null :
+            mCallerAppName = mController.isComplexityProvidedByAdmin() ? null :
                     intent.getStringExtra(EXTRA_KEY_CALLER_APP_NAME);
 
             mManagedPasswordProvider = ManagedLockPasswordProvider.get(activity, mUserId);
@@ -330,6 +326,10 @@
             return super.onCreateView(inflater, container, savedInstanceState);
         }
 
+        protected boolean alwaysHideInsecureScreenLockTypes() {
+            return false;
+        }
+
         private void updateActivityTitle() {
             if (mLockPatternUtils == null) {
                 // mLockPatternUtils will be uninitialized if ChooseLockGenericFragment.onCreate()
@@ -606,16 +606,12 @@
             }
             if (quality == -1) {
                 // If caller didn't specify password quality, show UI and allow the user to choose.
-                quality = intent.getIntExtra(MINIMUM_QUALITY_KEY, -1);
-                quality = mController.upgradeQuality(quality);
-                final boolean hideDisabledPrefs = intent.getBooleanExtra(
-                        HIDE_DISABLED_PREFS, false);
                 final PreferenceScreen prefScreen = getPreferenceScreen();
                 if (prefScreen != null) {
                     prefScreen.removeAll();
                 }
                 addPreferences();
-                disableUnusablePreferences(quality, hideDisabledPrefs);
+                disableUnusablePreferences();
                 updatePreferenceText();
                 updateCurrentPreference();
                 updatePreferenceSummaryIfNeeded();
@@ -747,70 +743,22 @@
         }
 
         /***
-         * Disables preferences that are less secure than required quality. The actual
-         * implementation is in disableUnusablePreferenceImpl.
-         *
-         * @param quality the requested quality.
-         * @param hideDisabledPrefs if false preferences show why they were disabled; otherwise
-         * they're not shown at all.
-         */
-        protected void disableUnusablePreferences(final int quality, boolean hideDisabledPrefs) {
-            disableUnusablePreferencesImpl(quality, hideDisabledPrefs);
-        }
-
-        /***
          * Disables preferences that are less secure than required quality.
          *
-         * @param quality the requested quality.
-         * @param hideDisabled whether to hide disable screen lock options.
          */
-        protected void disableUnusablePreferencesImpl(final int quality,
-                boolean hideDisabled) {
+        private void disableUnusablePreferences() {
             final PreferenceScreen entries = getPreferenceScreen();
 
-            int adminEnforcedQuality = LockPatternUtils.credentialTypeToPasswordQuality(
-                    mLockPatternUtils.getRequestedPasswordMetrics(
-                            mUserId, mOnlyEnforceDevicePasswordRequirement).credType);
-            EnforcedAdmin enforcedAdmin =
-                    RestrictedLockUtilsInternal.checkIfPasswordQualityIsSet(getActivity(),
-                            mUserId);
-            // If we are to unify a work challenge at the end of the credential enrollment, manually
-            // merge any password policy from that profile here, so we are enrolling a compliant
-            // password. This is because once unified, the profile's password policy will
-            // be enforced on the new credential.
-            if (mUnificationProfileId != UserHandle.USER_NULL) {
-                int profileEnforceQuality = mDpm.getPasswordQuality(null, mUnificationProfileId);
-                if (profileEnforceQuality > adminEnforcedQuality) {
-                    adminEnforcedQuality = profileEnforceQuality;
-                    enforcedAdmin = EnforcedAdmin.combine(enforcedAdmin,
-                            RestrictedLockUtilsInternal.checkIfPasswordQualityIsSet(
-                                    getActivity(), mUnificationProfileId));
-                }
-            }
-
             for (ScreenLockType lock : ScreenLockType.values()) {
                 String key = lock.preferenceKey;
                 Preference pref = findPreference(key);
                 if (pref instanceof RestrictedPreference) {
                     boolean visible = mController.isScreenLockVisible(lock);
-                    boolean enabled = mController.isScreenLockEnabled(lock, quality);
-                    boolean disabledByAdmin =
-                            mController.isScreenLockDisabledByAdmin(lock, adminEnforcedQuality);
-                    if (hideDisabled) {
-                        visible = visible && enabled;
-                    }
+                    boolean enabled = mController.isScreenLockEnabled(lock);
                     if (!visible) {
                         entries.removePreference(pref);
-                    } else if (disabledByAdmin && enforcedAdmin != null) {
-                        ((RestrictedPreference) pref).setDisabledByAdmin(enforcedAdmin);
                     } else if (!enabled) {
-                        // we need to setDisabledByAdmin to null first to disable the padlock
-                        // in case it was set earlier.
-                        ((RestrictedPreference) pref).setDisabledByAdmin(null);
-                        pref.setSummary(R.string.unlock_set_unlock_disabled_summary);
                         pref.setEnabled(false);
-                    } else {
-                        ((RestrictedPreference) pref).setDisabledByAdmin(null);
                     }
                 }
             }
@@ -975,31 +923,38 @@
 
         private int getResIdForFactoryResetProtectionWarningMessage() {
             final boolean hasFingerprints;
+            final boolean hasFace;
             if (mFingerprintManager != null && mFingerprintManager.isHardwareDetected()) {
                 hasFingerprints = mFingerprintManager.hasEnrolledFingerprints(mUserId);
             } else {
                 hasFingerprints = false;
             }
+
+            if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
+                hasFace = mFaceManager.hasEnrolledTemplates(mUserId);
+            } else {
+                hasFace = false;
+            }
+
             switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(mUserId)) {
                 case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
-                    if (hasFingerprints && mIsManagedProfile) {
-                        return R.string
-                                .unlock_disable_frp_warning_content_pattern_fingerprint_profile;
-                    } else if (hasFingerprints && !mIsManagedProfile) {
+                    if (hasFingerprints && hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_pattern_face_fingerprint;
+                    } else if (hasFingerprints) {
                         return R.string.unlock_disable_frp_warning_content_pattern_fingerprint;
-                    } else if (mIsManagedProfile) {
-                        return R.string.unlock_disable_frp_warning_content_pattern_profile;
+                    } else if (hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_pattern_face;
                     } else {
                         return R.string.unlock_disable_frp_warning_content_pattern;
                     }
                 case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
                 case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
-                    if (hasFingerprints && mIsManagedProfile) {
-                        return R.string.unlock_disable_frp_warning_content_pin_fingerprint_profile;
-                    } else if (hasFingerprints && !mIsManagedProfile) {
+                    if (hasFingerprints && hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_pin_face_fingerprint;
+                    } else if (hasFingerprints) {
                         return R.string.unlock_disable_frp_warning_content_pin_fingerprint;
-                    } else if (mIsManagedProfile) {
-                        return R.string.unlock_disable_frp_warning_content_pin_profile;
+                    } else if (hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_pin_face;
                     } else {
                         return R.string.unlock_disable_frp_warning_content_pin;
                     }
@@ -1007,24 +962,23 @@
                 case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
                 case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
                 case DevicePolicyManager.PASSWORD_QUALITY_MANAGED:
-                    if (hasFingerprints && mIsManagedProfile) {
+                    if (hasFingerprints && hasFace) {
                         return R.string
-                                .unlock_disable_frp_warning_content_password_fingerprint_profile;
-                    } else if (hasFingerprints && !mIsManagedProfile) {
+                                .unlock_disable_frp_warning_content_password_face_fingerprint;
+                    } else if (hasFingerprints) {
                         return R.string.unlock_disable_frp_warning_content_password_fingerprint;
-                    } else if (mIsManagedProfile) {
-                        return R.string.unlock_disable_frp_warning_content_password_profile;
+                    } else if (hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_password_face;
                     } else {
                         return R.string.unlock_disable_frp_warning_content_password;
                     }
                 default:
-                    if (hasFingerprints && mIsManagedProfile) {
-                        return R.string
-                                .unlock_disable_frp_warning_content_unknown_fingerprint_profile;
-                    } else if (hasFingerprints && !mIsManagedProfile) {
+                    if (hasFingerprints && hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_unknown_face_fingerprint;
+                    } else if (hasFingerprints) {
                         return R.string.unlock_disable_frp_warning_content_unknown_fingerprint;
-                    } else if (mIsManagedProfile) {
-                        return R.string.unlock_disable_frp_warning_content_unknown_profile;
+                    } else if (hasFace) {
+                        return R.string.unlock_disable_frp_warning_content_unknown_face;
                     } else {
                         return R.string.unlock_disable_frp_warning_content_unknown;
                     }
diff --git a/src/com/android/settings/password/ChooseLockGenericController.java b/src/com/android/settings/password/ChooseLockGenericController.java
index 6900e3d..1b951d4 100644
--- a/src/com/android/settings/password/ChooseLockGenericController.java
+++ b/src/com/android/settings/password/ChooseLockGenericController.java
@@ -17,6 +17,7 @@
 package com.android.settings.password;
 
 import static android.app.admin.DevicePolicyManager.PASSWORD_COMPLEXITY_NONE;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
 
 import static com.android.internal.widget.LockPatternUtils.CREDENTIAL_TYPE_NONE;
 
@@ -24,6 +25,7 @@
 import android.app.admin.PasswordMetrics;
 import android.content.Context;
 import android.os.UserHandle;
+import android.os.UserManager;
 
 import androidx.annotation.NonNull;
 import androidx.annotation.VisibleForTesting;
@@ -36,84 +38,140 @@
 
 /**
  * A controller for ChooseLockGeneric, and other similar classes which shows a list of possible
- * screen locks for the user to choose from.
+ * screen lock types for the user to choose from. This is the main place where different
+ * restrictions on allowed screen lock types are aggregated in Settings.
+ *
+ * Each screen lock type has two states: whether it is visible and whether it is enabled.
+ * Visibility is affected by things like resource configs, whether it's for a managed profile,
+ * or whether the caller allows it or not. This is determined by
+ * {@link #isScreenLockVisible(ScreenLockType)}. For visible screen lock types, they can be disabled
+ * by a combination of admin policies and request from the calling app, which is determined by
+ * {@link #isScreenLockEnabled(ScreenLockType}.
  */
+
 public class ChooseLockGenericController {
 
     private final Context mContext;
     private final int mUserId;
-    @PasswordComplexity private final int mRequestedMinComplexity;
+    private final boolean mHideInsecureScreenLockTypes;
+    @PasswordComplexity private final int mAppRequestedMinComplexity;
     private final boolean mDevicePasswordRequirementOnly;
-    private ManagedLockPasswordProvider mManagedPasswordProvider;
+    private final int mUnificationProfileId;
+    private final ManagedLockPasswordProvider mManagedPasswordProvider;
     private final LockPatternUtils mLockPatternUtils;
 
-    public ChooseLockGenericController(Context context, int userId) {
-        this(
-                context,
-                userId,
-                PASSWORD_COMPLEXITY_NONE,
-                /* mOnlyEnforceDevicePasswordRequirement */ false,
-                new LockPatternUtils(context));
-    }
-
-    /**
-     * @param requestedMinComplexity specifies the min password complexity to be taken into account
-     *                               when determining the available screen lock types
-     */
     public ChooseLockGenericController(Context context, int userId,
-            @PasswordComplexity int requestedMinComplexity,
-            boolean devicePasswordRequirementOnly,
-            LockPatternUtils lockPatternUtils) {
-        this(
-                context,
-                userId,
-                requestedMinComplexity,
-                devicePasswordRequirementOnly,
-                ManagedLockPasswordProvider.get(context, userId),
-                lockPatternUtils);
-    }
-
-    @VisibleForTesting
-    ChooseLockGenericController(
-            Context context,
-            int userId,
-            @PasswordComplexity int requestedMinComplexity,
-            boolean devicePasswordRequirementOnly,
-            ManagedLockPasswordProvider managedLockPasswordProvider,
-            LockPatternUtils lockPatternUtils) {
+            ManagedLockPasswordProvider managedPasswordProvider, LockPatternUtils lockPatternUtils,
+            boolean hideInsecureScreenLockTypes, int appRequestedMinComplexity,
+            boolean devicePasswordRequirementOnly, int unificationProfileId) {
         mContext = context;
         mUserId = userId;
-        mRequestedMinComplexity = requestedMinComplexity;
-        mDevicePasswordRequirementOnly = devicePasswordRequirementOnly;
-        mManagedPasswordProvider = managedLockPasswordProvider;
+        mManagedPasswordProvider = managedPasswordProvider;
         mLockPatternUtils = lockPatternUtils;
+        mHideInsecureScreenLockTypes = hideInsecureScreenLockTypes;
+        mAppRequestedMinComplexity = appRequestedMinComplexity;
+        mDevicePasswordRequirementOnly = devicePasswordRequirementOnly;
+        mUnificationProfileId = unificationProfileId;
+    }
+
+    /** Builder class for {@link ChooseLockGenericController} */
+    public static class Builder {
+        private final Context mContext;
+        private final int mUserId;
+        private final ManagedLockPasswordProvider mManagedPasswordProvider;
+        private final LockPatternUtils mLockPatternUtils;
+
+        private boolean mHideInsecureScreenLockTypes = false;
+        @PasswordComplexity private int mAppRequestedMinComplexity = PASSWORD_COMPLEXITY_NONE;
+        private boolean mDevicePasswordRequirementOnly = false;
+        private int mUnificationProfileId = UserHandle.USER_NULL;
+
+        public Builder(Context context, int userId) {
+            this(context, userId, new LockPatternUtils(context));
+        }
+
+        public Builder(Context context, int userId,
+                LockPatternUtils lockPatternUtils) {
+            this(
+                    context,
+                    userId,
+                    ManagedLockPasswordProvider.get(context, userId),
+                    lockPatternUtils);
+        }
+
+        @VisibleForTesting
+        Builder(
+                Context context,
+                int userId,
+                ManagedLockPasswordProvider managedLockPasswordProvider,
+                LockPatternUtils lockPatternUtils) {
+            mContext = context;
+            mUserId = userId;
+            mManagedPasswordProvider = managedLockPasswordProvider;
+            mLockPatternUtils = lockPatternUtils;
+        }
+        /**
+         * Sets the password complexity requested by the calling app via
+         * {@link android.app.admin.DevicePolicyManager#EXTRA_PASSWORD_COMPLEXITY}.
+         */
+        public Builder setAppRequestedMinComplexity(int complexity) {
+            mAppRequestedMinComplexity = complexity;
+            return this;
+        }
+
+        /**
+         * Sets whether the enrolment flow should discard any password policies originating from the
+         * work profile, even if the work profile currently has unified challenge. This can be
+         * requested by the calling app via
+         * {@link android.app.admin.DevicePolicyManager#EXTRA_DEVICE_PASSWORD_REQUIREMENT_ONLY}.
+         */
+        public Builder setEnforceDevicePasswordRequirementOnly(boolean deviceOnly) {
+            mDevicePasswordRequirementOnly = deviceOnly;
+            return this;
+        }
+
+        /**
+         * Sets the user ID of any profile whose work challenge should be unified at the end of this
+         * enrolment flow. This will lead to all password policies from that profile to be taken
+         * into consideration by this class, so that we are enrolling a compliant password. This is
+         * because once unified, the profile's password policy will be enforced on the new
+         * credential.
+         */
+        public Builder setProfileToUnify(int profileId) {
+            mUnificationProfileId = profileId;
+            return this;
+        }
+
+        /**
+         * Sets whether insecure screen lock types (NONE and SWIPE) should be hidden in the UI.
+         */
+        public Builder setHideInsecureScreenLockTypes(boolean hide) {
+            mHideInsecureScreenLockTypes = hide;
+            return this;
+        }
+
+        /** Creates {@link ChooseLockGenericController} instance. */
+        public ChooseLockGenericController build() {
+            return new ChooseLockGenericController(mContext, mUserId, mManagedPasswordProvider,
+                    mLockPatternUtils, mHideInsecureScreenLockTypes, mAppRequestedMinComplexity,
+                    mDevicePasswordRequirementOnly, mUnificationProfileId);
+        }
     }
 
     /**
-     * Returns the highest quality among the specified {@code quality}, the password requirement
-     * set by device admins (legacy password quality metrics and password complexity), and the
-     * min password complexity requested by the calling app.
-     */
-    public int upgradeQuality(int quality) {
-        // Compare specified quality and dpm quality
-        // TODO(b/142781408): convert from quality to credential type once PIN is supported.
-        int dpmUpgradedQuality = Math.max(quality, LockPatternUtils.credentialTypeToPasswordQuality(
-                getAggregatedPasswordMetrics().credType));
-        return Math.max(dpmUpgradedQuality,
-                PasswordMetrics.complexityLevelToMinQuality(getAggregatedPasswordComplexity()));
-    }
-
-    /**
-     * Whether the given screen lock type should be visible in the given context.
+     * Returns whether the given screen lock type should be visible in the given context.
      */
     public boolean isScreenLockVisible(ScreenLockType type) {
-        final boolean managedProfile = mUserId != UserHandle.myUserId();
+        final boolean managedProfile = mContext.getSystemService(UserManager.class)
+                .isManagedProfile(mUserId);
         switch (type) {
             case NONE:
-                return !mContext.getResources().getBoolean(R.bool.config_hide_none_security_option)
+                return !mHideInsecureScreenLockTypes
+                    && !mContext.getResources().getBoolean(R.bool.config_hide_none_security_option)
                     && !managedProfile; // Profiles should use unified challenge instead.
             case SWIPE:
-                return !mContext.getResources().getBoolean(R.bool.config_hide_swipe_security_option)
+                return !mHideInsecureScreenLockTypes
+                    && !mContext.getResources().getBoolean(R.bool.config_hide_swipe_security_option)
                     && !managedProfile; // Swipe doesn't make sense for profiles.
             case MANAGED:
                 return mManagedPasswordProvider.isManagedPasswordChoosable();
@@ -128,29 +186,27 @@
     }
 
     /**
-     * Whether screen lock with {@code type} should be enabled.
-     *
-     * @param type The screen lock type.
-     * @param quality The minimum required quality. This can either be requirement by device policy
-     *                manager or because some flow only makes sense with secure lock screens.
+     * Whether screen lock with {@code type} should be enabled assuming all relevant password
+     * requirements. The lock's visibility ({@link #isScreenLockVisible}) is not considered here.
      */
-    public boolean isScreenLockEnabled(ScreenLockType type, int quality) {
-        return type.maxQuality >= quality;
+    public boolean isScreenLockEnabled(ScreenLockType type) {
+        return type.maxQuality >= upgradeQuality(PASSWORD_QUALITY_UNSPECIFIED);
     }
 
     /**
-     * Whether screen lock with {@code type} is disabled by device policy admin.
-     *
-     * @param type The screen lock type.
-     * @param adminEnforcedQuality The minimum quality that the admin enforces.
+     * Increases the given quality to be as high as the combined quality from all relevant
+     * password requirements.
      */
-    public boolean isScreenLockDisabledByAdmin(ScreenLockType type, int adminEnforcedQuality) {
-        boolean disabledByAdmin = type.maxQuality < adminEnforcedQuality;
-        if (type == ScreenLockType.MANAGED) {
-            disabledByAdmin = disabledByAdmin
-                    || !mManagedPasswordProvider.isManagedPasswordChoosable();
-        }
-        return disabledByAdmin;
+    // TODO(b/142781408): convert from quality to credential type once PIN is supported.
+    public int upgradeQuality(int quality) {
+        return Math.max(quality,
+                Math.max(
+                        LockPatternUtils.credentialTypeToPasswordQuality(
+                                getAggregatedPasswordMetrics().credType),
+                        PasswordMetrics.complexityLevelToMinQuality(
+                                getAggregatedPasswordComplexity())
+                )
+        );
     }
 
     /**
@@ -175,43 +231,72 @@
     }
 
     /**
-     * Gets a list of screen locks that should be visible for the given quality. The returned list
-     * is ordered in the natural order of the enum (the order those enums were defined).
-     *
-     * @param quality The minimum quality required in the context of the current flow. This should
-     *                be one of the constants defined in
-     *                {@code DevicePolicyManager#PASSWORD_QUALITY_*}.
-     * @param includeDisabled Whether to include screen locks disabled by {@code quality}
-     *                        requirements in the returned list.
+     * Gets a list of screen lock types that should be visible for the given quality. The returned
+     * list is ordered in the natural order of the enum (the order those enums were defined). Screen
+     * locks disabled by password policy will not be returned.
      */
     @NonNull
-    public List<ScreenLockType> getVisibleScreenLockTypes(int quality, boolean includeDisabled) {
-        int upgradedQuality = upgradeQuality(quality);
+    public List<ScreenLockType> getVisibleAndEnabledScreenLockTypes() {
         List<ScreenLockType> locks = new ArrayList<>();
         // EnumSet's iterator guarantees the natural order of the enums
         for (ScreenLockType lock : ScreenLockType.values()) {
-            if (isScreenLockVisible(lock)) {
-                if (includeDisabled || isScreenLockEnabled(lock, upgradedQuality)) {
-                    locks.add(lock);
-                }
+            if (isScreenLockVisible(lock) && isScreenLockEnabled(lock)) {
+                locks.add(lock);
             }
         }
         return locks;
     }
 
+    /**
+     * Returns the combined password metrics from all relevant policies which affects the current
+     * user. Normally password policies set on the current user's work profile instance will be
+     * taken into consideration here iff the work profile doesn't have its own work challenge.
+     * By setting {@link #mUnificationProfileId}, the work profile's password policy will always
+     * be combined here. Alternatively, by setting {@link #mDevicePasswordRequirementOnly}, its
+     * password policy will always be disregarded here.
+     */
     public PasswordMetrics getAggregatedPasswordMetrics() {
-        return mLockPatternUtils.getRequestedPasswordMetrics(mUserId,
+        PasswordMetrics metrics = mLockPatternUtils.getRequestedPasswordMetrics(mUserId,
                 mDevicePasswordRequirementOnly);
+        if (mUnificationProfileId != UserHandle.USER_NULL) {
+            metrics.maxWith(mLockPatternUtils.getRequestedPasswordMetrics(mUnificationProfileId));
+        }
+        return metrics;
     }
 
+    /**
+     * Returns the combined password complexity from all relevant policies which affects the current
+     * user. The same logic of handling work profile password policies as
+     * {@link #getAggregatedPasswordMetrics} applies here.
+     */
     public int getAggregatedPasswordComplexity() {
-        return Math.max(mRequestedMinComplexity,
+        int complexity = Math.max(mAppRequestedMinComplexity,
                 mLockPatternUtils.getRequestedPasswordComplexity(
                         mUserId, mDevicePasswordRequirementOnly));
+        if (mUnificationProfileId != UserHandle.USER_NULL) {
+            complexity = Math.max(complexity,
+                    mLockPatternUtils.getRequestedPasswordComplexity(mUnificationProfileId));
+        }
+        return complexity;
     }
 
+    /**
+     * Returns whether any screen lock type has been disabled only due to password policy
+     * from the admin. Will return {@code false} if the restriction is purely due to calling
+     * app's request.
+     */
     public boolean isScreenLockRestrictedByAdmin() {
         return getAggregatedPasswordMetrics().credType != CREDENTIAL_TYPE_NONE
-                || getAggregatedPasswordComplexity() != PASSWORD_COMPLEXITY_NONE;
+                || isComplexityProvidedByAdmin();
+    }
+
+    /**
+     * Returns whether the aggregated password complexity is non-zero and comes from
+     * admin policy.
+     */
+    public boolean isComplexityProvidedByAdmin() {
+        final int aggregatedComplexity = getAggregatedPasswordComplexity();
+        return aggregatedComplexity > mAppRequestedMinComplexity
+                && aggregatedComplexity > PASSWORD_COMPLEXITY_NONE;
     }
 }
diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java
index de377a7..6382abf 100644
--- a/src/com/android/settings/password/ChooseLockPassword.java
+++ b/src/com/android/settings/password/ChooseLockPassword.java
@@ -416,19 +416,6 @@
             mMinComplexity = intent.getIntExtra(EXTRA_KEY_MIN_COMPLEXITY, PASSWORD_COMPLEXITY_NONE);
             mMinMetrics = intent.getParcelableExtra(EXTRA_KEY_MIN_METRICS);
             if (mMinMetrics == null) mMinMetrics = new PasswordMetrics(CREDENTIAL_TYPE_NONE);
-            // If we are to unify a work challenge at the end of the credential enrollment, manually
-            // merge any password policy from that profile here, so we are enrolling a compliant
-            // password. This is because once unified, the profile's password policy will
-            // be enforced on the new credential.
-            //TODO: Move this logic to ChooseLockGeneric; let ChooseLockGeneric be the only place
-            //where password requirement mixing happens. ChooseLockPassword simply enforces what's
-            //set via IntentBuilder.setPasswordRequirement()
-            if (mUnificationProfileId != UserHandle.USER_NULL) {
-                mMinMetrics.maxWith(
-                        mLockPatternUtils.getRequestedPasswordMetrics(mUnificationProfileId));
-                mMinComplexity = Math.max(mMinComplexity,
-                        mLockPatternUtils.getRequestedPasswordComplexity(mUnificationProfileId));
-            }
 
             if (intent.getBooleanExtra(
                     ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
diff --git a/src/com/android/settings/password/ChooseLockTypeDialogFragment.java b/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
index 8bc2976..6ec7057 100644
--- a/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
+++ b/src/com/android/settings/password/ChooseLockTypeDialogFragment.java
@@ -18,7 +18,6 @@
 
 import android.app.Activity;
 import android.app.Dialog;
-import android.app.admin.DevicePolicyManager;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -100,7 +99,9 @@
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         final int userId = getArguments().getInt(ARG_USER_ID);
-        mController = new ChooseLockGenericController(getContext(), userId);
+        mController = new ChooseLockGenericController.Builder(getContext(), userId)
+                .setHideInsecureScreenLockTypes(true)
+                .build();
     }
 
     @Override
@@ -124,10 +125,7 @@
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         Context context = getContext();
         Builder builder = new Builder(context);
-        List<ScreenLockType> locks =
-                mController.getVisibleScreenLockTypes(
-                        DevicePolicyManager.PASSWORD_QUALITY_SOMETHING,
-                        false /* includeDisabled */);
+        List<ScreenLockType> locks = mController.getVisibleAndEnabledScreenLockTypes();
         mAdapter = new ScreenLockAdapter(context, locks, mController);
         builder.setAdapter(mAdapter, this);
         builder.setTitle(R.string.setup_lock_settings_options_dialog_title);
diff --git a/src/com/android/settings/password/SetNewPasswordController.java b/src/com/android/settings/password/SetNewPasswordController.java
index 03efa60..ef4ff75 100644
--- a/src/com/android/settings/password/SetNewPasswordController.java
+++ b/src/com/android/settings/password/SetNewPasswordController.java
@@ -19,7 +19,6 @@
 import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FACE;
 import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT;
-import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
 
 import static com.android.internal.util.Preconditions.checkNotNull;
 
@@ -145,10 +144,8 @@
 
     private Bundle getBiometricChooseLockExtras() {
         Bundle chooseLockExtras = new Bundle();
-        chooseLockExtras.putInt(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                PASSWORD_QUALITY_SOMETHING);
         chooseLockExtras.putBoolean(
-                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_BIOMETRICS, true);
         return chooseLockExtras;
@@ -156,10 +153,8 @@
 
     private Bundle getFingerprintChooseLockExtras() {
         Bundle chooseLockExtras = new Bundle();
-        chooseLockExtras.putInt(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                PASSWORD_QUALITY_SOMETHING);
         chooseLockExtras.putBoolean(
-                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, true);
         return chooseLockExtras;
@@ -167,10 +162,8 @@
 
     private Bundle getFaceChooseLockExtras() {
         Bundle chooseLockExtras = new Bundle();
-        chooseLockExtras.putInt(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                PASSWORD_QUALITY_SOMETHING);
         chooseLockExtras.putBoolean(
-                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS, true);
+                ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE, true);
         chooseLockExtras.putBoolean(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, true);
         return chooseLockExtras;
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 7818f0d..15a90e3 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -21,7 +21,6 @@
 
 import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUESTED_MIN_COMPLEXITY;
 
-import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Resources;
@@ -160,22 +159,12 @@
             return SetupChooseLockGeneric.InternalActivity.class;
         }
 
-        /***
-         * Disables preferences that are less secure than required quality and shows only secure
-         * screen lock options here.
-         *
-         * @param quality the requested quality.
-         */
         @Override
-        protected void disableUnusablePreferences(final int quality, boolean hideDisabled) {
+        protected boolean alwaysHideInsecureScreenLockTypes() {
             // At this part of the flow, the user has already indicated they want to add a pin,
-            // pattern or password, so don't show "None" or "Slide". We disable them here and set
-            // the HIDE_DISABLED flag to true to hide them. This only happens for setup wizard.
-            // We do the following max check here since the device may already have a Device Admin
-            // installed with a policy we need to honor.
-            final int newQuality = Math.max(quality,
-                    DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
-            super.disableUnusablePreferencesImpl(newQuality, true /* hideDisabled */);
+            // pattern or password, so don't show "None" or "Slide". We disable them here.
+            // This only happens for setup wizard.
+            return true;
         }
 
         @Override
diff --git a/src/com/android/settings/password/SetupChooseLockPassword.java b/src/com/android/settings/password/SetupChooseLockPassword.java
index 25f5a34..7cf90c0 100644
--- a/src/com/android/settings/password/SetupChooseLockPassword.java
+++ b/src/com/android/settings/password/SetupChooseLockPassword.java
@@ -17,7 +17,6 @@
 package com.android.settings.password;
 
 import android.app.Activity;
-import android.app.admin.DevicePolicyManager;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
@@ -81,9 +80,11 @@
             super.onViewCreated(view, savedInstanceState);
             final Activity activity = getActivity();
             ChooseLockGenericController chooseLockGenericController =
-                    new ChooseLockGenericController(activity, mUserId);
-            boolean anyOptionsShown = chooseLockGenericController.getVisibleScreenLockTypes(
-                    DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false).size() > 0;
+                    new ChooseLockGenericController.Builder(activity, mUserId)
+                    .setHideInsecureScreenLockTypes(true)
+                    .build();
+            boolean anyOptionsShown = chooseLockGenericController
+                    .getVisibleAndEnabledScreenLockTypes().size() > 0;
             boolean showOptionsButton = activity.getIntent().getBooleanExtra(
                     ChooseLockGeneric.ChooseLockGenericFragment.EXTRA_SHOW_OPTIONS_BUTTON, false);
             if (!anyOptionsShown) {
diff --git a/src/com/android/settings/security/OWNERS b/src/com/android/settings/security/OWNERS
index 6e4f553..701feb8 100644
--- a/src/com/android/settings/security/OWNERS
+++ b/src/com/android/settings/security/OWNERS
@@ -1,7 +1,9 @@
 # Enterprise security reviewers
-eranm@google.com
 pgrafov@google.com
 rubinxu@google.com
 
 # Emergency
 sandness@google.com
+
+# Emeritus
+eranm@google.com
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index 3fa098b..e219b44 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -136,8 +136,8 @@
             if (passwordQuality == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED) {
                 Intent chooseLockIntent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
                 chooseLockIntent.putExtra(
-                        ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                        DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+                        ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS,
+                        true);
                 startActivityForResult(chooseLockIntent, CHANGE_LOCK_METHOD_REQUEST);
                 return false;
             }
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index d88d8b5..5f14399 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -432,8 +432,8 @@
 
     private void launchChooseLockscreen() {
         Intent chooseLockIntent = new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
-        chooseLockIntent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY,
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
+        chooseLockIntent.putExtra(ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS,
+                true);
         startActivityForResult(chooseLockIntent, REQUEST_CHOOSE_LOCK);
     }
 
diff --git a/src/com/android/settings/vpn2/ManageablePreference.java b/src/com/android/settings/vpn2/ManageablePreference.java
index b785186..1aea947 100644
--- a/src/com/android/settings/vpn2/ManageablePreference.java
+++ b/src/com/android/settings/vpn2/ManageablePreference.java
@@ -121,6 +121,7 @@
             final String alwaysOnString = res.getString(R.string.vpn_always_on_summary_active);
             summary = TextUtils.isEmpty(summary) ? alwaysOnString : summary + " / "
                     + alwaysOnString;
+            setSummary(summary);
         } else {
             setSummary(summary);
         }
diff --git a/src/com/android/settings/widget/EntityHeaderController.java b/src/com/android/settings/widget/EntityHeaderController.java
index 91a20b3..791d6ca 100644
--- a/src/com/android/settings/widget/EntityHeaderController.java
+++ b/src/com/android/settings/widget/EntityHeaderController.java
@@ -18,15 +18,12 @@
 
 import android.annotation.IdRes;
 import android.annotation.UserIdInt;
-import android.app.ActionBar;
 import android.app.Activity;
 import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
-import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
-import android.os.Bundle;
 import android.os.UserHandle;
 import android.text.TextUtils;
 import android.util.Log;
@@ -48,7 +45,6 @@
 import com.android.settings.overlay.FeatureFactory;
 import com.android.settingslib.applications.ApplicationsState;
 import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.widget.ActionBarShadowController;
 import com.android.settingslib.widget.LayoutPreference;
 
 import java.lang.annotation.Retention;
@@ -244,7 +240,6 @@
      * Done mutating entity header, rebinds everything (optionally skip rebinding buttons).
      */
     public View done(Activity activity, boolean rebindActions) {
-        styleActionBar(activity);
         ImageView iconView = mHeader.findViewById(R.id.entity_header_icon);
         if (iconView != null) {
             iconView.setImageDrawable(mIcon);
@@ -303,32 +298,6 @@
     }
 
     /**
-     * Styles the action bar (elevation, scrolling behaviors, color, etc).
-     * <p/>
-     * This method must be called after {@link Fragment#onCreate(Bundle)}.
-     */
-    public EntityHeaderController styleActionBar(Activity activity) {
-        if (activity == null) {
-            Log.w(TAG, "No activity, cannot style actionbar.");
-            return this;
-        }
-        final ActionBar actionBar = activity.getActionBar();
-        if (actionBar == null) {
-            Log.w(TAG, "No actionbar, cannot style actionbar.");
-            return this;
-        }
-        actionBar.setBackgroundDrawable(
-                new ColorDrawable(
-                        Utils.getColorAttrDefaultColor(activity, android.R.attr.colorPrimaryDark)));
-        actionBar.setElevation(0);
-        if (mRecyclerView != null && mLifecycle != null) {
-            ActionBarShadowController.attachToView(mActivity, mLifecycle, mRecyclerView);
-        }
-
-        return this;
-    }
-
-    /**
      * Done mutating entity header, rebinds everything.
      */
     @VisibleForTesting
diff --git a/src/com/android/settings/widget/SettingsMainSwitchPreferenceController.java b/src/com/android/settings/widget/SettingsMainSwitchPreferenceController.java
new file mode 100644
index 0000000..5fa9259
--- /dev/null
+++ b/src/com/android/settings/widget/SettingsMainSwitchPreferenceController.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.widget;
+
+import android.content.Context;
+import android.widget.Switch;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.widget.MainSwitchPreference;
+import com.android.settingslib.widget.OnMainSwitchChangeListener;
+
+/**
+ * Preference controller for MainSwitchPreference.
+ */
+public abstract class SettingsMainSwitchPreferenceController extends
+        TogglePreferenceController implements OnMainSwitchChangeListener {
+
+    protected MainSwitchPreference mSwitchPreference;
+
+    public SettingsMainSwitchPreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+    }
+
+    @Override
+    public void displayPreference(PreferenceScreen screen) {
+        super.displayPreference(screen);
+        final Preference pref = screen.findPreference(getPreferenceKey());
+        if (pref != null && pref instanceof MainSwitchPreference) {
+            mSwitchPreference = (MainSwitchPreference) pref;
+            mSwitchPreference.addOnSwitchChangeListener(this);
+        }
+    }
+
+    @Override
+    public void onSwitchChanged(Switch switchView, boolean isChecked) {
+        mSwitchPreference.setChecked(isChecked);
+        setChecked(isChecked);
+    }
+}
diff --git a/src/com/android/settings/wifi/WifiConfigController2.java b/src/com/android/settings/wifi/WifiConfigController2.java
index 1e06707..1967371 100644
--- a/src/com/android/settings/wifi/WifiConfigController2.java
+++ b/src/com/android/settings/wifi/WifiConfigController2.java
@@ -923,7 +923,6 @@
                     return R.string.wifi_ip_settings_invalid_dns;
                 }
                 dnsServers.add(dnsAddr);
-                staticIpConfiguration.getDnsServers().add(dnsAddr);
             }
 
             if (mDns2View.length() > 0) {
@@ -933,14 +932,13 @@
                     return R.string.wifi_ip_settings_invalid_dns;
                 }
                 dnsServers.add(dnsAddr);
-                staticIpConfiguration.getDnsServers().add(dnsAddr);
             }
             staticIPBuilder.setDnsServers(dnsServers);
             return 0;
         } finally {
             // Caller of this method may rely on staticIpConfiguration, so build the final result
             // at the end of the method.
-            staticIpConfiguration = staticIPBuilder.build();
+            mStaticIpConfiguration = staticIPBuilder.build();
         }
     }
 
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index ceacefe..dac65c6 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -261,9 +261,9 @@
         mStatusMessagePreference = findPreference(PREF_KEY_STATUS_MESSAGE);
         mDataUsagePreference = findPreference(PREF_KEY_DATA_USAGE);
         mDataUsagePreference.setVisible(DataUsageUtils.hasWifiRadio(getContext()));
-        mDataUsagePreference.setTemplate(NetworkTemplate.buildTemplateWifiWildcard(),
-                0 /*subId*/,
-                null /*service*/);
+        mDataUsagePreference.setTemplate(
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */), 0 /*subId*/, null /*service*/);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
index 3c312b8..b66633e 100644
--- a/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
+++ b/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2.java
@@ -958,9 +958,11 @@
             mWifiEntry.forget(this);
         }
 
-        mMetricsFeatureProvider.action(
-                mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
-        mFragment.getActivity().finish();
+        final Activity activity = mFragment.getActivity();
+        if (activity != null) {
+            mMetricsFeatureProvider.action(activity, SettingsEnums.ACTION_WIFI_FORGET);
+            activity.finish();
+        }
     }
 
     @VisibleForTesting
@@ -1135,8 +1137,11 @@
             Log.e(TAG, "Forget Wi-Fi network failed");
         }
 
-        mMetricsFeatureProvider.action(mFragment.getActivity(), SettingsEnums.ACTION_WIFI_FORGET);
-        mFragment.getActivity().finish();
+        final Activity activity = mFragment.getActivity();
+        if (activity != null) {
+            mMetricsFeatureProvider.action(activity, SettingsEnums.ACTION_WIFI_FORGET);
+            activity.finish();
+        }
     }
 
     /**
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonPreviewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonPreviewPreferenceControllerTest.java
index eb88175..3065030 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonPreviewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonPreviewPreferenceControllerTest.java
@@ -33,6 +33,7 @@
 import androidx.test.core.app.ApplicationProvider;
 
 import com.android.settings.R;
+import com.android.settings.testutils.ImageTestUtils;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -73,8 +74,8 @@
 
         final Drawable navigationBarDrawable = mContext.getDrawable(
                 R.drawable.accessibility_button_navigation);
-        assertThat(mController.mPreview.getDrawable().getConstantState()).isEqualTo(
-                navigationBarDrawable.getConstantState());
+        assertThat(ImageTestUtils.drawableToBitmap(mController.mPreview.getDrawable()).sameAs(
+                ImageTestUtils.drawableToBitmap(navigationBarDrawable))).isTrue();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/accessibility/FloatingMenuLayerDrawableTest.java b/tests/robotests/src/com/android/settings/accessibility/FloatingMenuLayerDrawableTest.java
index ec449d2..45cefe4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/FloatingMenuLayerDrawableTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/FloatingMenuLayerDrawableTest.java
@@ -24,6 +24,7 @@
 import androidx.test.core.app.ApplicationProvider;
 
 import com.android.settings.R;
+import com.android.settings.testutils.ImageTestUtils;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -51,11 +52,10 @@
 
         final Drawable actual1stDrawable = actualDrawable.getDrawable(0);
         final Drawable actual2ndDrawable = actualDrawable.getDrawable(1);
-        // These are VectorDrawables, so it can use getConstantState() to compare.
-        assertThat(actual1stDrawable.getConstantState()).isEqualTo(
-                expected1stDrawable.getConstantState());
-        assertThat(actual2ndDrawable.getConstantState()).isEqualTo(
-                expected2ndDrawable.getConstantState());
+        assertThat(ImageTestUtils.drawableToBitmap(actual1stDrawable).sameAs(
+                ImageTestUtils.drawableToBitmap(expected1stDrawable))).isTrue();
+        assertThat(ImageTestUtils.drawableToBitmap(actual2ndDrawable).sameAs(
+                ImageTestUtils.drawableToBitmap(expected2ndDrawable))).isTrue();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
index 6684e1a..c5ed459 100644
--- a/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceControllerTest.java
@@ -16,23 +16,16 @@
 
 package com.android.settings.applications.appinfo;
 
-import static androidx.lifecycle.Lifecycle.Event.ON_START;
-
 import static com.google.common.truth.Truth.assertThat;
 
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
-import android.app.ActionBar;
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageInfo;
-import android.graphics.drawable.Drawable;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.widget.TextView;
@@ -116,18 +109,4 @@
         assertThat(title).isNotNull();
         assertThat(title.getText()).isEqualTo(appLabel);
     }
-
-    @Test
-    public void onStart_shouldStyleActionBar() {
-        final ActionBar actionBar = mock(ActionBar.class);
-        when(mActivity.getActionBar()).thenReturn(actionBar);
-
-        mController.displayPreference(mScreen);
-
-        verifyZeroInteractions(actionBar);
-
-        mLifecycle.handleLifecycleEvent(ON_START);
-
-        verify(actionBar).setBackgroundDrawable(any(Drawable.class));
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
deleted file mode 100644
index fa1b7a2..0000000
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/MusicViewHolderControllerTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.manageapplications;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.os.storage.VolumeInfo;
-import android.provider.DocumentsContract;
-import android.text.format.Formatter;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import androidx.fragment.app.Fragment;
-
-import com.android.settingslib.applications.StorageStatsSource;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class MusicViewHolderControllerTest {
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Fragment mFragment;
-    @Mock
-    private StorageStatsSource mSource;
-
-    private Context mContext;
-    private MusicViewHolderController mController;
-    private ApplicationViewHolder mHolder;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        final String fsUuid = new VolumeInfo("id", 0, null, "id").fsUuid;
-        mController = new MusicViewHolderController(mContext, mSource, fsUuid, UserHandle.of(-1));
-
-        View view = ApplicationViewHolder.newView(new FrameLayout(mContext));
-        mHolder = new ApplicationViewHolder(view);
-    }
-
-    @Test
-    public void storageShouldBeZeroBytesIfQueriedBeforeStorageQueryFinishes() {
-        mController.setupView(mHolder);
-
-        assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
-                Formatter.formatFileSize(mContext, 0));
-    }
-
-    @Test
-    public void storageShouldRepresentStorageStatsQuery() throws Exception {
-        when(mSource.getExternalStorageStats(nullable(String.class), nullable(UserHandle.class)))
-                .thenReturn(new StorageStatsSource.ExternalStorageStats(1, 1, 0, 0, 0));
-
-        mController.queryStats();
-        mController.setupView(mHolder);
-
-        assertThat(mHolder.mSummary.getText().toString()).isEqualTo(
-                Formatter.formatFileSize(mContext, 1));
-    }
-
-    @Test
-    public void clickingShouldIntentIntoFilesApp() {
-        mController.onClick(mFragment);
-
-        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment).startActivity(argumentCaptor.capture());
-        Intent intent = argumentCaptor.getValue();
-
-        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
-        assertThat(intent.getData()).isEqualTo(DocumentsContract.buildRootUri(
-                "com.android.providers.media.documents",
-                "audio_root"));
-        assertThat(intent.getType()).isEqualTo(DocumentsContract.Root.MIME_TYPE_ITEM);
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
deleted file mode 100644
index f3c699c..0000000
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/PhotosViewHolderControllerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.manageapplications;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.Intent;
-import android.os.UserHandle;
-import android.os.storage.VolumeInfo;
-import android.text.format.Formatter;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import androidx.fragment.app.Fragment;
-
-import com.android.settingslib.applications.StorageStatsSource;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-
-@RunWith(RobolectricTestRunner.class)
-public class PhotosViewHolderControllerTest {
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
-    private Fragment mFragment;
-    @Mock
-    private StorageStatsSource mSource;
-
-    private Context mContext;
-    private PhotosViewHolderController mController;
-    private ApplicationViewHolder mHolder;
-
-    @Before
-    public void setUp() throws Exception {
-        MockitoAnnotations.initMocks(this);
-        mContext = RuntimeEnvironment.application;
-        final String fsUuid = new VolumeInfo("id", 0, null, "id").fsUuid;
-        mController = new PhotosViewHolderController(mContext, mSource, fsUuid, UserHandle.of(-1));
-
-        final View view = ApplicationViewHolder.newView(new FrameLayout(mContext));
-        mHolder = new ApplicationViewHolder(view);
-    }
-
-    @Test
-    public void storageShouldBeZeroBytesIfQueriedBeforeStorageQueryFinishes() {
-        mController.setupView(mHolder);
-
-        assertThat(mHolder.mSummary.getText().toString())
-                .isEqualTo(Formatter.formatFileSize(mContext, 0));
-    }
-
-    @Test
-    public void storageShouldRepresentStorageStatsQuery() throws Exception {
-        when(mSource.getExternalStorageStats(nullable(String.class), nullable(UserHandle.class)))
-                .thenReturn(new StorageStatsSource.ExternalStorageStats(1, 0, 1, 10, 0));
-
-        mController.queryStats();
-        mController.setupView(mHolder);
-
-        assertThat(mHolder.mSummary.getText().toString())
-                .isEqualTo(Formatter.formatFileSize(mContext, 11));
-    }
-
-    @Test
-    public void clickingShouldIntentIntoFilesApp() {
-        mController.onClick(mFragment);
-
-        final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment).startActivity(argumentCaptor.capture());
-        Intent intent = argumentCaptor.getValue();
-
-        assertThat(intent.getType()).isEqualTo("image/*");
-        assertThat(intent.getAction()).isEqualTo(android.content.Intent.ACTION_VIEW);
-        assertThat(intent.getBooleanExtra(Intent.EXTRA_FROM_STORAGE, false)).isTrue();
-    }
-}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
index 4348e1b..924e246 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdaterTest.java
@@ -26,7 +26,9 @@
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
+import android.util.Pair;
 
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
@@ -62,6 +64,8 @@
     private CachedBluetoothDevice mCachedBluetoothDevice;
     @Mock
     private BluetoothDevice mBluetoothDevice;
+    @Mock
+    private Drawable mDrawable;
 
     private Context mContext;
     private AvailableMediaBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -83,10 +87,12 @@
                 Utils.getLocalBtManager(mContext).getCachedDeviceManager());
         mCachedDevices = new ArrayList<>();
         mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
 
         doReturn(mContext).when(mDashboardFragment).getContext();
         when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
+        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
 
         mBluetoothDeviceUpdater = spy(new AvailableMediaBluetoothDeviceUpdater(mContext,
                 mDashboardFragment, mDevicePreferenceCallback));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
index e0a61fe..6afa56c 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDeviceUpdaterTest.java
@@ -27,6 +27,8 @@
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.util.Pair;
 
 import androidx.preference.Preference;
 
@@ -78,6 +80,8 @@
     private LocalBluetoothManager mLocalManager;
     @Mock
     private CachedBluetoothDeviceManager mCachedDeviceManager;
+    @Mock
+    private Drawable mDrawable;
 
     private Context mContext;
     private BluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -89,6 +93,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
         mContext = RuntimeEnvironment.application;
         mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
         mCachedDevices.add(mCachedBluetoothDevice);
@@ -99,6 +104,7 @@
         when(mCachedDeviceManager.getCachedDevicesCopy()).thenReturn(mCachedDevices);
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
         when(mSubBluetoothDevice.getAddress()).thenReturn(SUB_MAC_ADDRESS);
+        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
 
         mPreference = new BluetoothDevicePreference(mContext, mCachedBluetoothDevice,
                 false, BluetoothDevicePreference.SortType.TYPE_DEFAULT);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
index 34bb069..ea841fa 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDetailTest.java
@@ -35,6 +35,8 @@
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.util.Pair;
 
 import androidx.preference.PreferenceGroup;
 
@@ -70,6 +72,9 @@
     private PreferenceGroup mPreferenceGroup;
     @Mock
     private CachedBluetoothDevice mCachedBluetoothDevice;
+    @Mock
+    private Drawable mDrawable;
+
     private BluetoothPairingDetail mFragment;
     private Context mContext;
     private BluetoothProgressCategory mAvailableDevicesCategory;
@@ -82,11 +87,13 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
         mContext = RuntimeEnvironment.application;
         mFragment = spy(new BluetoothPairingDetail());
         doReturn(mContext).when(mFragment).getContext();
         doReturn(mResource).when(mFragment).getResources();
         when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS);
+        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
 
         mAvailableDevicesCategory = spy(new BluetoothProgressCategory(mContext));
         mFooterPreference = new FooterPreference(mContext);
diff --git a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
index 13e138c..ea91fed 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdaterTest.java
@@ -28,7 +28,9 @@
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
+import android.graphics.drawable.Drawable;
 import android.media.AudioManager;
+import android.util.Pair;
 
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
@@ -65,6 +67,8 @@
     private CachedBluetoothDevice mCachedBluetoothDevice;
     @Mock
     private BluetoothDevice mBluetoothDevice;
+    @Mock
+    private Drawable mDrawable;
 
     private Context mContext;
     private ConnectedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -77,6 +81,7 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
         mContext = RuntimeEnvironment.application;
         mAudioManager = mContext.getSystemService(AudioManager.class);
         mShadowBluetoothAdapter = Shadow.extract(BluetoothAdapter.getDefaultAdapter());
@@ -88,6 +93,7 @@
 
         when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
+        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
         mShadowCachedBluetoothDeviceManager.setCachedDevicesCopy(mCachedDevices);
         mBluetoothDeviceUpdater = spy(new ConnectedBluetoothDeviceUpdater(mContext,
                 mDashboardFragment, mDevicePreferenceCallback));
diff --git a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
index 20cc59d..78a7a69 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdaterTest.java
@@ -28,6 +28,8 @@
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothProfile;
 import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.util.Pair;
 
 import com.android.settings.connecteddevice.DevicePreferenceCallback;
 import com.android.settings.dashboard.DashboardFragment;
@@ -69,6 +71,8 @@
     private CachedBluetoothDeviceManager mDeviceManager;
     @Mock
     private LocalBluetoothManager mBluetoothManager;
+    @Mock
+    private Drawable mDrawable;
 
     private Context mContext;
     private SavedBluetoothDeviceUpdater mBluetoothDeviceUpdater;
@@ -78,11 +82,13 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
         mContext = RuntimeEnvironment.application;
         doReturn(mContext).when(mDashboardFragment).getContext();
         when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice);
         when(mCachedBluetoothDevice.getAddress()).thenReturn(MAC_ADDRESS);
         when(mBluetoothDevice.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
+        when(mCachedBluetoothDevice.getDrawableWithDescription()).thenReturn(pairs);
 
         mBluetoothDeviceUpdater = spy(new SavedBluetoothDeviceUpdater(mContext, mDashboardFragment,
                 mDevicePreferenceCallback));
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AddDevicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AddDevicePreferenceControllerTest.java
index e2b1270..c3841c9 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/AddDevicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AddDevicePreferenceControllerTest.java
@@ -79,6 +79,7 @@
         String key = mAddDevicePreferenceController.getPreferenceKey();
         mAddDevicePreference = new RestrictedPreference(mContext);
         mAddDevicePreference.setKey(key);
+        when(mBluetoothAdapter.isEnabled()).thenReturn(true);
         when(mScreen.findPreference(key)).thenReturn(mAddDevicePreference);
         mAddDevicePreferenceController.displayPreference(mScreen);
     }
@@ -128,4 +129,13 @@
         assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
                 .isEqualTo(AVAILABLE);
     }
+
+    @Test
+    public void getAvailabilityStatus_bluetoothIsDisabled_unSupported() {
+        mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
+        when(mBluetoothAdapter.isEnabled()).thenReturn(false);
+
+        assertThat(mAddDevicePreferenceController.getAvailabilityStatus())
+                .isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceControllerTest.java
new file mode 100644
index 0000000..e134a16
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/connecteddevice/AddDeviceSummaryPreferenceControllerTest.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.settings.connecteddevice;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.BluetoothAdapter;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.text.TextUtils;
+
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.RestrictedPreference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowApplicationPackageManager;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = ShadowApplicationPackageManager.class)
+public class AddDeviceSummaryPreferenceControllerTest {
+
+    @Mock
+    private PreferenceScreen mScreen;
+    @Mock
+    private BluetoothAdapter mBluetoothAdapter;
+
+    private Context mContext;
+    private AddDeviceSummaryPreferenceController mAddDeviceSummaryPreferenceController;
+    private RestrictedPreference mAddDevicePreference;
+    private ShadowApplicationPackageManager mPackageManager;
+
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        mPackageManager = (ShadowApplicationPackageManager) Shadows.shadowOf(
+                mContext.getPackageManager());
+        mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
+
+        mAddDeviceSummaryPreferenceController = new AddDeviceSummaryPreferenceController(mContext,
+                "add_bt_devices");
+        ReflectionHelpers.setField(mAddDeviceSummaryPreferenceController,
+                "mBluetoothAdapter", mBluetoothAdapter);
+
+        String key = mAddDeviceSummaryPreferenceController.getPreferenceKey();
+        mAddDevicePreference = new RestrictedPreference(mContext);
+        mAddDevicePreference.setKey(key);
+        when(mScreen.findPreference(key)).thenReturn(mAddDevicePreference);
+        when(mBluetoothAdapter.isEnabled()).thenReturn(false);
+        mAddDeviceSummaryPreferenceController.displayPreference(mScreen);
+    }
+
+    @Test
+    public void getSummary_btOnThenOff_summaryShouldBeShown() {
+        when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+
+        mAddDeviceSummaryPreferenceController.updateState();
+
+        assertTrue(TextUtils.isEmpty(mAddDevicePreference.getSummary()));
+
+        Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
+        intent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_OFF);
+        BroadcastReceiver receiver = ReflectionHelpers.getField(
+                mAddDeviceSummaryPreferenceController, "mReceiver");
+        when(mBluetoothAdapter.isEnabled()).thenReturn(false);
+
+        receiver.onReceive(mContext, intent);
+
+        assertThat(mAddDevicePreference.getSummary()).isEqualTo(
+                mContext.getString(R.string.connected_device_add_device_summary));
+    }
+
+    @Test
+    public void getSummary_btOffThenOn_summaryShouldNotBeShown() {
+        when(mBluetoothAdapter.isEnabled()).thenReturn(false);
+
+        mAddDeviceSummaryPreferenceController.updateState();
+
+        assertThat(mAddDevicePreference.getSummary()).isEqualTo(
+                mContext.getString(R.string.connected_device_add_device_summary));
+
+        Intent intent = new Intent(BluetoothAdapter.ACTION_STATE_CHANGED);
+        intent.putExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.STATE_ON);
+        BroadcastReceiver receiver = ReflectionHelpers.getField(
+                mAddDeviceSummaryPreferenceController, "mReceiver");
+        when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+
+        receiver.onReceive(mContext, intent);
+
+        assertTrue(TextUtils.isEmpty(mAddDevicePreference.getSummary()));
+    }
+
+    @Test
+    public void getAvailabilityStatus_notHaveBluetoothFeature_unSupported() {
+        mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, false);
+
+        assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
+                .isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_haveBluetoothFeature_supported() {
+        mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
+
+        assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
+                .isEqualTo(AVAILABLE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_bluetoothIsEnabled_unSupported() {
+        mPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH, true);
+        when(mBluetoothAdapter.isEnabled()).thenReturn(true);
+
+        assertThat(mAddDeviceSummaryPreferenceController.getAvailabilityStatus())
+                .isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceControllerTest.java
index 0e03365..3d8c49a 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceControllerTest.java
@@ -29,6 +29,8 @@
 import android.bluetooth.BluetoothDevice;
 import android.content.Context;
 import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.util.Pair;
 
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
@@ -100,6 +102,8 @@
     private BluetoothDevice mBluetoothDevice4;
     @Mock
     private BluetoothDevice mBluetoothDevice5;
+    @Mock
+    private Drawable mDrawable;
 
     private Context mContext;
     private PreviouslyConnectedDevicePreferenceController mPreConnectedDeviceController;
@@ -109,6 +113,7 @@
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
+        Pair<Drawable, String> pairs = new Pair<>(mDrawable, "fake_device");
         mContext = spy(RuntimeEnvironment.application);
         doReturn(mContext).when(mDashboardFragment).getContext();
         doReturn(mPackageManager).when(mContext).getPackageManager();
@@ -120,14 +125,19 @@
 
         when(mCachedDevice1.getDevice()).thenReturn(mBluetoothDevice1);
         when(mCachedDevice1.getAddress()).thenReturn(FAKE_ADDRESS_1);
+        when(mCachedDevice1.getDrawableWithDescription()).thenReturn(pairs);
         when(mCachedDevice2.getDevice()).thenReturn(mBluetoothDevice2);
         when(mCachedDevice2.getAddress()).thenReturn(FAKE_ADDRESS_2);
+        when(mCachedDevice2.getDrawableWithDescription()).thenReturn(pairs);
         when(mCachedDevice3.getDevice()).thenReturn(mBluetoothDevice3);
         when(mCachedDevice3.getAddress()).thenReturn(FAKE_ADDRESS_3);
+        when(mCachedDevice3.getDrawableWithDescription()).thenReturn(pairs);
         when(mCachedDevice4.getDevice()).thenReturn(mBluetoothDevice4);
         when(mCachedDevice4.getAddress()).thenReturn(FAKE_ADDRESS_4);
+        when(mCachedDevice4.getDrawableWithDescription()).thenReturn(pairs);
         when(mCachedDevice5.getDevice()).thenReturn(mBluetoothDevice5);
         when(mCachedDevice5.getAddress()).thenReturn(FAKE_ADDRESS_5);
+        when(mCachedDevice5.getDrawableWithDescription()).thenReturn(pairs);
 
         final List<BluetoothDevice> mMostRecentlyConnectedDevices = new ArrayList<>();
         mMostRecentlyConnectedDevices.add(mBluetoothDevice1);
diff --git a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
index 77d4731..f3e1bce 100644
--- a/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/connecteddevice/usb/UsbDefaultFragmentTest.java
@@ -33,6 +33,7 @@
 
 import android.hardware.usb.UsbManager;
 import android.net.TetheringManager;
+import android.os.Handler;
 
 import androidx.preference.PreferenceScreen;
 
@@ -53,6 +54,8 @@
     private UsbBackend mUsbBackend;
     @Mock
     private TetheringManager mTetheringManager;
+    @Mock
+    private Handler mHandler;
 
     private UsbDefaultFragment mFragment;
 
@@ -62,6 +65,7 @@
         mFragment = new TestFragment();
         mFragment.mUsbBackend = mUsbBackend;
         mFragment.mTetheringManager = mTetheringManager;
+        mFragment.mHandler = mHandler;
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
index ded7d10..f75b7f0 100644
--- a/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/AppDataUsageTest.java
@@ -18,6 +18,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.assertNull;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
@@ -309,7 +310,8 @@
         ReflectionHelpers.setField(mFragment, "mContext", context);
         ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
         ReflectionHelpers.setField(mFragment, "mTemplate",
-                NetworkTemplate.buildTemplateWifiWildcard());
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
         final long end = System.currentTimeMillis();
         final long start = end - (DateUtils.WEEK_IN_MILLIS * 4);
 
@@ -334,7 +336,8 @@
         ReflectionHelpers.setField(mFragment, "mContext", context);
         ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
         ReflectionHelpers.setField(mFragment, "mTemplate",
-                NetworkTemplate.buildTemplateWifiWildcard());
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
         final long end = System.currentTimeMillis();
         final long start = end - (DateUtils.WEEK_IN_MILLIS * 4);
 
@@ -365,7 +368,8 @@
         ReflectionHelpers.setField(mFragment, "mCycles", testCycles);
         ReflectionHelpers.setField(mFragment, "mAppItem", appItem);
         ReflectionHelpers.setField(mFragment, "mTemplate",
-                NetworkTemplate.buildTemplateWifiWildcard());
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
 
         final NetworkCycleDataForUidLoader loader = (NetworkCycleDataForUidLoader)
                 mFragment.mUidDataCallbacks.onCreateLoader(0 /* id */, Bundle.EMPTY /* args */);
@@ -436,6 +440,9 @@
         mFragment.onCreate(Bundle.EMPTY);
 
         assertThat(mFragment.mTemplate.getMatchRule())
-                .isEqualTo(NetworkTemplate.MATCH_WIFI_WILDCARD);
+                .isEqualTo(NetworkTemplate.MATCH_WIFI);
+        assertNull(mFragment.mTemplate.getSubscriberId());
+        assertThat(mFragment.mTemplate.getNetworkId())
+                .isEqualTo(NetworkTemplate.WIFI_NETWORKID_ALL);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
index 6a7f237..71d5d7e 100644
--- a/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/datausage/DataUsageSummaryPreferenceControllerTest.java
@@ -29,7 +29,6 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
@@ -386,7 +385,6 @@
 
         verify(mHeaderController)
                 .setRecyclerView(any(RecyclerView.class), any(Lifecycle.class));
-        verify(mHeaderController).styleActionBar(any(Activity.class));
     }
 
     private DataUsageController.DataUsageInfo createTestDataUsageInfo(long now) {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
index 4a1ea40..1882741 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceControllerTest.java
@@ -20,6 +20,7 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.mock;
@@ -30,6 +31,7 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.content.res.Resources;
 import android.graphics.drawable.Drawable;
 import android.os.UserHandle;
 import android.os.storage.VolumeInfo;
@@ -172,38 +174,33 @@
     @Test
     public void launchImagesIntent_resolveActionViewNull_settingsIntent() {
         mPreference.setKey(StorageItemPreferenceController.IMAGES_KEY);
+        final Context mockContext = getMockContext();
+        mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
+                mSvp);
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mActivity).startActivityAsUser(argumentCaptor.capture(),
-                nullable(UserHandle.class));
+        verify(mockContext).startActivity(argumentCaptor.capture());
 
         final Intent intent = argumentCaptor.getValue();
-        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
-        assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
-        assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
-                .isEqualTo(ManageApplications.class.getName());
-        assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
-                .isEqualTo(R.string.storage_photos_videos);
+        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
+        assertThat(intent.getData()).isEqualTo(mController.mImagesUri);
     }
 
     @Test
     public void launchAudiosIntent_resolveActionViewNull_settingsIntent() {
         mPreference.setKey(StorageItemPreferenceController.AUDIOS_KEY);
+        final Context mockContext = getMockContext();
+        mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
+                mSvp);
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
-                nullable(UserHandle.class));
+        verify(mockContext).startActivity(argumentCaptor.capture());
         final Intent intent = argumentCaptor.getValue();
 
-        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
-        assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
-        assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
-            .isEqualTo(ManageApplications.class.getName());
-        assertThat(intent.getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS).getInt(
-                ManageApplications.EXTRA_STORAGE_TYPE, 0))
-            .isEqualTo(ManageApplications.STORAGE_TYPE_MUSIC);
+        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
+        assertThat(intent.getData()).isEqualTo(mController.mAudiosUri);
     }
 
     @Test
@@ -270,20 +267,18 @@
 
     @Test
     public void launchDocumentsAndOtherIntent_resolveActionViewNull_settingsIntent() {
-        when(mSvp.findEmulatedForPrivate(nullable(VolumeInfo.class))).thenReturn(mVolume);
-        when(mVolume.buildBrowseIntent()).thenReturn(new Intent());
         mPreference.setKey(StorageItemPreferenceController.DOCUMENTS_AND_OTHER_KEY);
-        assertThat(mController.handlePreferenceTreeClick(mPreference))
-            .isTrue();
+        final Context mockContext = getMockContext();
+        mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
+                mSvp);
+        mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
-                nullable(UserHandle.class));
+        verify(mockContext).startActivity(argumentCaptor.capture());
 
         Intent intent = argumentCaptor.getValue();
-        Intent browseIntent = mVolume.buildBrowseIntent();
-        assertThat(intent.getAction()).isEqualTo(browseIntent.getAction());
-        assertThat(intent.getData()).isEqualTo(browseIntent.getData());
+        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
+        assertThat(intent.getData()).isEqualTo(mController.mDocumentsAndOtherUri);
     }
 
     @Test
@@ -307,19 +302,17 @@
     @Test
     public void launchVideosIntent_resolveActionViewNull_settingsIntent() {
         mPreference.setKey(StorageItemPreferenceController.VIDEOS_KEY);
+        final Context mockContext = getMockContext();
+        mController = new StorageItemPreferenceController(mockContext, mFragment, mVolume,
+                mSvp);
         mController.handlePreferenceTreeClick(mPreference);
 
         final ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
-        verify(mFragment.getActivity()).startActivityAsUser(argumentCaptor.capture(),
-                nullable(UserHandle.class));
+        verify(mockContext).startActivity(argumentCaptor.capture());
 
         Intent intent = argumentCaptor.getValue();
-        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_MAIN);
-        assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
-        assertThat(intent.getStringExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT))
-            .isEqualTo(ManageApplications.class.getName());
-        assertThat(intent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
-            .isEqualTo(R.string.storage_movies_tv);
+        assertThat(intent.getAction()).isEqualTo(Intent.ACTION_VIEW);
+        assertThat(intent.getData()).isEqualTo(mController.mVideosUri);
     }
 
     @Test
@@ -463,4 +456,16 @@
         assertThat(mController.mSystemPreference.isVisible()).isFalse();
         assertThat(mController.mTrashPreference.isVisible()).isFalse();
     }
+
+    /**
+     * To verify startActivity, these test cases use mock Context because mContext is not an
+     * activity context and AndroidRuntimeException throws for no FLAG_ACTIVITY_NEW_TASK.
+     */
+    private Context getMockContext() {
+        final Resources resources = mock(Resources.class);
+        final Context context = mock(Context.class);
+        when(context.getResources()).thenReturn(resources);
+        when(resources.getString(anyInt())).thenReturn("");
+        return context;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
index 843870d..880f9cc 100644
--- a/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/display/AdaptiveSleepPreferenceControllerTest.java
@@ -84,6 +84,7 @@
                 eq(UserManager.DISALLOW_CONFIG_SCREEN_TIMEOUT))).thenReturn(null);
 
         mController = new AdaptiveSleepPreferenceController(mContext, mRestrictionUtils);
+        mController.initializePreference();
         when(mController.isCameraLocked()).thenReturn(false);
     }
 
diff --git a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
index c4f5580..24bcde8 100644
--- a/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/display/ScreenTimeoutSettingsTest.java
@@ -60,8 +60,6 @@
     private ScreenTimeoutSettings mSettings;
     private Context mContext;
     private ContentResolver mContentResolver;
-
-    @Mock
     private Resources mResources;
 
     @Mock
@@ -85,7 +83,9 @@
         FakeFeatureFactory.setupForTest();
         mContext = spy(getApplicationContext());
         mSettings = spy(new ScreenTimeoutSettings());
+        mSettings.mContext = mContext;
         mContentResolver = mContext.getContentResolver();
+        mResources = spy(mContext.getResources());
 
         doReturn(TIMEOUT_ENTRIES).when(mResources).getStringArray(R.array.screen_timeout_entries);
         doReturn(TIMEOUT_VALUES).when(mResources).getStringArray(R.array.screen_timeout_entries);
diff --git a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
index d58d7e8..6c8a8f6 100644
--- a/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/dream/StartNowPreferenceControllerTest.java
@@ -16,43 +16,37 @@
 
 package com.android.settings.dream;
 
-import static com.google.common.truth.Truth.assertThat;
-
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
-import android.view.View.OnClickListener;
-import android.widget.Button;
 
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.R;
 import com.android.settingslib.dream.DreamBackend;
-import com.android.settingslib.widget.LayoutPreference;
+import com.android.settingslib.widget.MainSwitchPreference;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
 import org.robolectric.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class StartNowPreferenceControllerTest {
 
     private StartNowPreferenceController mController;
-    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private Context mContext;
+
     @Mock
     private PreferenceScreen mScreen;
     @Mock
-    private LayoutPreference mLayoutPref;
-    @Mock
-    private Button mButton;
+    private MainSwitchPreference mPref;
     @Mock
     private DreamBackend mBackend;
 
@@ -60,36 +54,38 @@
     public void setup() {
         MockitoAnnotations.initMocks(this);
 
-        mController = new StartNowPreferenceController(mContext);
-        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mLayoutPref);
-        when(mLayoutPref.findViewById(R.id.dream_start_now_button)).thenReturn(mButton);
+        mContext = spy(RuntimeEnvironment.application);
+        mController = new StartNowPreferenceController(mContext, "key");
+        mPref = mock(MainSwitchPreference.class);
+        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPref);
 
         ReflectionHelpers.setField(mController, "mBackend", mBackend);
     }
 
     @Test
-    public void setsOnClickListenerForStartNow() {
-        ArgumentCaptor<OnClickListener> captor =
-                ArgumentCaptor.forClass(Button.OnClickListener.class);
-
+    public void displayPreference_shouldAddOnSwitchChangeListener() {
         mController.displayPreference(mScreen);
-        verify(mButton).setOnClickListener(captor.capture());
-        assertThat(captor.getValue()).isNotNull();
+
+        verify(mPref).addOnSwitchChangeListener(mController);
     }
 
     @Test
-    public void buttonIsDisabledWhenNeverDreaming() {
+    public void updateState_neverDreaming_preferenceShouldDidabled() {
         when(mBackend.getWhenToDreamSetting()).thenReturn(DreamBackend.NEVER);
+        mController.displayPreference(mScreen);
 
-        mController.updateState(mLayoutPref);
-        verify(mButton).setEnabled(false);
+        mController.updateState(mPref);
+
+        verify(mPref).setEnabled(false);
     }
 
     @Test
-    public void buttonIsEnabledWhenDreamIsAvailable() {
+    public void updateState_dreamIsAvailable_preferenceShouldEnabled() {
         when(mBackend.getWhenToDreamSetting()).thenReturn(DreamBackend.EITHER);
+        mController.displayPreference(mScreen);
 
-        mController.updateState(mLayoutPref);
-        verify(mButton).setEnabled(true);
+        mController.updateState(mPref);
+
+        verify(mPref).setEnabled(true);
     }
 }
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
index e36a831..6313da2 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
@@ -17,13 +17,9 @@
 
 package com.android.settings.fuelgauge;
 
-import static androidx.lifecycle.Lifecycle.Event.ON_START;
-
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
@@ -41,7 +37,6 @@
 import androidx.lifecycle.LifecycleOwner;
 import androidx.preference.PreferenceFragmentCompat;
 import androidx.preference.PreferenceScreen;
-import androidx.recyclerview.widget.RecyclerView;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
@@ -284,17 +279,6 @@
     }
 
     @Test
-    public void onStart_shouldStyleActionBar() {
-        when(mEntityHeaderController.setRecyclerView(nullable(RecyclerView.class), eq(mLifecycle)))
-                .thenReturn(mEntityHeaderController);
-
-        mController.displayPreference(mPreferenceScreen);
-        mLifecycle.handleLifecycleEvent(ON_START);
-
-        verify(mEntityHeaderController).styleActionBar(mActivity);
-    }
-
-    @Test
     public void quickUpdateHeaderPreference_onlyUpdateBatteryLevelAndChargingState() {
         mController.quickUpdateHeaderPreference();
 
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
index 9e4877c..4844a1c 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingParentPreferenceControllerTest.java
@@ -97,7 +97,8 @@
         Settings.Secure.putInt(mContext.getContentResolver(), VOLUME_HUSH_GESTURE,
                 VOLUME_HUSH_OFF);
         mController.updateState(mPreference);
-        assertThat(mPreference.getSummary()).isEqualTo(null);
+        assertThat(mPreference.getSummary()).isEqualTo(mContext.getResources().getText(
+                R.string.switch_off_text));
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java
index 4f38c46..8d643ad 100644
--- a/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/BubbleNotificationPreferenceControllerTest.java
@@ -26,17 +26,15 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.app.ActivityManager;
 import android.content.Context;
 import android.provider.Settings;
 
-import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
-import androidx.preference.TwoStatePreference;
+
+import com.android.settingslib.widget.MainSwitchPreference;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -57,7 +55,7 @@
     private PreferenceScreen mScreen;
 
     private BubbleNotificationPreferenceController mController;
-    private Preference mPreference;
+    private MainSwitchPreference mPreference;
 
     private static final String KEY_NOTIFICATION_BUBBLES = "notification_bubbles";
 
@@ -67,15 +65,16 @@
         mContext = RuntimeEnvironment.application;
         mController = new BubbleNotificationPreferenceController(mContext,
                 KEY_NOTIFICATION_BUBBLES);
-        mPreference = new Preference(RuntimeEnvironment.application);
+        mPreference = new MainSwitchPreference(RuntimeEnvironment.application);
         mPreference.setKey(mController.getPreferenceKey());
         when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
+        mController.displayPreference(mScreen);
     }
 
     @Test
     public void isAvailable_lowRam_returnsUnsupported() {
         final ShadowActivityManager activityManager =
-               Shadow.extract(mContext.getSystemService(ActivityManager.class));
+                Shadow.extract(mContext.getSystemService(ActivityManager.class));
         activityManager.setIsLowRamDevice(true);
         assertEquals(UNSUPPORTED_ON_DEVICE, mController.getAvailabilityStatus());
     }
@@ -83,45 +82,40 @@
     @Test
     public void isAvailable_notLowRam_returnsAvailable() {
         final ShadowActivityManager activityManager =
-               Shadow.extract(mContext.getSystemService(ActivityManager.class));
+                Shadow.extract(mContext.getSystemService(ActivityManager.class));
         activityManager.setIsLowRamDevice(false);
         assertEquals(AVAILABLE, mController.getAvailabilityStatus());
     }
 
     @Test
-    public void updateState_settingIsOn_preferenceSetChecked() {
-        final TwoStatePreference preference = mock(TwoStatePreference.class);
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
-
-        mController.updateState(preference);
-
-        verify(preference).setChecked(true);
-    }
-
-    @Test
     public void updateState_settingIsOff_preferenceSetUnchecked() {
-        final TwoStatePreference preference = mock(TwoStatePreference.class);
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
-        assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
+        Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
                 NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF);
 
-        mController.updateState(preference);
+        mPreference.updateStatus(false);
 
-        verify(preference).setChecked(false);
+        assertThat(mPreference.isChecked()).isFalse();
     }
 
     @Test
-    public void isChecked_settingIsOff_shouldReturnFalse() {
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
+    public void onSwitchChanged_true_settingIsOff_flagShouldOn() {
+        Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
 
-        assertThat(mController.isChecked()).isFalse();
+        mController.onSwitchChanged(null, true);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                NOTIFICATION_BUBBLES, OFF)).isEqualTo(ON);
     }
 
     @Test
-    public void isChecked_settingIsOn_shouldReturnTrue() {
-        Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
+    public void onSwitchChanged_false_settingIsOn_flagShouldOff() {
+        Settings.Global.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
 
-        assertThat(mController.isChecked()).isTrue();
+        mController.onSwitchChanged(null, false);
+
+        assertThat(Settings.Global.getInt(mContext.getContentResolver(),
+                NOTIFICATION_BUBBLES, ON)).isEqualTo(OFF);
     }
 
     @Test
@@ -129,8 +123,8 @@
         Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, ON);
 
         mController.setChecked(false);
-        int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
-                NOTIFICATION_BUBBLES, -1);
+        int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
+                NOTIFICATION_BUBBLES, ON);
 
         assertThat(updatedValue).isEqualTo(OFF);
     }
@@ -140,8 +134,8 @@
         Settings.Secure.putInt(mContext.getContentResolver(), NOTIFICATION_BUBBLES, OFF);
 
         mController.setChecked(true);
-        int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
-                NOTIFICATION_BUBBLES, -1);
+        int updatedValue = Settings.Global.getInt(mContext.getContentResolver(),
+                NOTIFICATION_BUBBLES, OFF);
 
         assertThat(updatedValue).isEqualTo(ON);
     }
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockGenericControllerTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockGenericControllerTest.java
index 02b89cb..049a349 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockGenericControllerTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockGenericControllerTest.java
@@ -20,23 +20,31 @@
 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.DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_COMPLEX;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_SOMETHING;
+import static android.app.admin.DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
 
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth.assertWithMessage;
 
 import static org.mockito.ArgumentMatchers.anyBoolean;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.when;
 import static org.robolectric.RuntimeEnvironment.application;
 
 import android.app.admin.DevicePolicyManager;
-import android.app.admin.DevicePolicyManager.PasswordComplexity;
 import android.app.admin.PasswordPolicy;
+import android.os.UserHandle;
 
 import com.android.internal.widget.LockPatternUtils;
 import com.android.settings.R;
 import com.android.settings.testutils.shadow.SettingsShadowResources;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
 import org.junit.After;
 import org.junit.Before;
@@ -48,10 +56,11 @@
 import org.robolectric.annotation.Config;
 
 import java.util.Arrays;
+import java.util.Set;
 import java.util.regex.Pattern;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = SettingsShadowResources.class)
+@Config(shadows = {ShadowUserManager.class, SettingsShadowResources.class})
 public class ChooseLockGenericControllerTest {
 
     private ChooseLockGenericController mController;
@@ -68,7 +77,7 @@
 
         when(mLockPatternUtils.hasSecureLockScreen()).thenReturn(true);
         setDevicePolicyPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
-        mController = createController(PASSWORD_COMPLEXITY_NONE);
+        mController = createBuilder().build();
         SettingsShadowResources.overrideResource(R.bool.config_hide_none_security_option, false);
         SettingsShadowResources.overrideResource(R.bool.config_hide_swipe_security_option, false);
     }
@@ -95,8 +104,8 @@
     }
 
     @Test
-    public void isScreenLockVisible_notCurrentUser_shouldHideInsecure() {
-        mController = new ChooseLockGenericController(application, 1 /* userId */);
+    public void isScreenLockVisible_ManagedProfile_shouldHideInsecure() {
+        ShadowUserManager.getShadow().setManagedProfiles(Set.of(0));
         assertWithMessage("SWIPE visible").that(
                 mController.isScreenLockVisible(ScreenLockType.SWIPE)).isFalse();
         assertWithMessage("NONE visible").that(mController.isScreenLockVisible(ScreenLockType.NONE))
@@ -112,62 +121,116 @@
     }
 
     @Test
-    public void isScreenLockEnabled_lowerQuality_shouldReturnFalse() {
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " enabled").that(
-                    mController.isScreenLockEnabled(lock, lock.maxQuality + 1)).isFalse();
-        }
+    public void isScreenLockEnabled_Default() {
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockEnabled_equalQuality_shouldReturnTrue() {
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " enabled").that(
-                    mController.isScreenLockEnabled(lock, lock.defaultQuality)).isTrue();
-        }
+    public void isScreenLockEnabled_QualityUnspecified() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_UNSPECIFIED);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockEnabled_higherQuality_shouldReturnTrue() {
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " enabled").that(
-                    mController.isScreenLockEnabled(lock, lock.maxQuality - 1)).isTrue();
-        }
+    public void isScreenLockEnabled_QualitySomething() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_SOMETHING);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockDisabledByAdmin_lowerQuality_shouldReturnTrue() {
-        doReturn(true).when(mManagedLockPasswordProvider).isManagedPasswordChoosable();
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " disabledByAdmin").that(
-                    mController.isScreenLockDisabledByAdmin(lock, lock.maxQuality + 1)).isTrue();
-        }
+    public void isScreenLockEnabled_QualityNumeric() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_NUMERIC);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockDisabledByAdmin_equalQuality_shouldReturnFalse() {
-        doReturn(true).when(mManagedLockPasswordProvider).isManagedPasswordChoosable();
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " disabledByAdmin").that(
-                    mController.isScreenLockDisabledByAdmin(lock, lock.maxQuality)).isFalse();
-        }
+    public void isScreenLockEnabled_QualityNumericComplex() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_NUMERIC_COMPLEX);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockDisabledByAdmin_higherQuality_shouldReturnFalse() {
-        doReturn(true).when(mManagedLockPasswordProvider).isManagedPasswordChoosable();
-        for (ScreenLockType lock : ScreenLockType.values()) {
-            assertWithMessage(lock + " disabledByAdmin").that(
-                    mController.isScreenLockDisabledByAdmin(lock, lock.maxQuality - 1)).isFalse();
-        }
+    public void isScreenLockEnabled_QualityAlphabetic() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_ALPHABETIC);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
-    public void isScreenLockDisabledByAdmin_managedNotChoosable_shouldReturnTrue() {
-        doReturn(false).when(mManagedLockPasswordProvider).isManagedPasswordChoosable();
-        assertWithMessage("MANANGED disabledByAdmin").that(mController.isScreenLockDisabledByAdmin(
-                ScreenLockType.MANAGED, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
-                .isTrue();
+    public void isScreenLockEnabled_QualityComplex() {
+        setDevicePolicyPasswordQuality(PASSWORD_QUALITY_COMPLEX);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
+    }
+
+    @Test
+    public void isScreenLockEnabled_NoneComplexity() {
+        when(mLockPatternUtils.getRequestedPasswordComplexity(anyInt(), anyBoolean()))
+                .thenReturn(PASSWORD_COMPLEXITY_NONE);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
+    }
+
+    @Test
+    public void isScreenLockEnabled_lowComplexity() {
+        when(mLockPatternUtils.getRequestedPasswordComplexity(anyInt(), anyBoolean()))
+                .thenReturn(PASSWORD_COMPLEXITY_LOW);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
+    }
+
+    @Test
+    public void isScreenLockEnabled_mediumComplexity() {
+        when(mLockPatternUtils.getRequestedPasswordComplexity(anyInt(), anyBoolean()))
+                .thenReturn(PASSWORD_COMPLEXITY_MEDIUM);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
+    }
+
+    @Test
+    public void isScreenLockEnabled_highComplexity() {
+        when(mLockPatternUtils.getRequestedPasswordComplexity(anyInt(), anyBoolean()))
+                .thenReturn(PASSWORD_COMPLEXITY_HIGH);
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.NONE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.SWIPE)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PATTERN)).isFalse();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PIN)).isTrue();
+        assertThat(mController.isScreenLockEnabled(ScreenLockType.PASSWORD)).isTrue();
     }
 
     @Test
@@ -181,8 +244,8 @@
 
     @Test
     public void getVisibleScreenLockTypes_qualitySomething_shouldReturnPatterPinPassword() {
-        assertThat(mController.getVisibleScreenLockTypes(
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, false))
+        mController = createBuilder().setHideInsecureScreenLockTypes(true).build();
+        assertThat(mController.getVisibleAndEnabledScreenLockTypes())
                 .isEqualTo(Arrays.asList(
                         ScreenLockType.PATTERN,
                         ScreenLockType.PIN,
@@ -191,8 +254,7 @@
 
     @Test
     public void getVisibleScreenLockTypes_showDisabled_shouldReturnAllButManaged() {
-        assertThat(mController.getVisibleScreenLockTypes(
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING, true))
+        assertThat(mController.getVisibleAndEnabledScreenLockTypes())
                 .isEqualTo(Arrays.asList(
                         ScreenLockType.NONE,
                         ScreenLockType.SWIPE,
@@ -223,31 +285,68 @@
 
     @Test
     public void upgradeQuality_complexityHigh_minQualityNumericComplex() {
+        mController = createBuilder().setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_HIGH)
+                .build();
         setDevicePolicyPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
-        ChooseLockGenericController controller = createController(PASSWORD_COMPLEXITY_HIGH);
 
-        assertThat(controller.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
+        assertThat(mController.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
                 .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX);
     }
 
     @Test
     public void upgradeQuality_complexityMedium_minQualityNumericComplex() {
+        mController = createBuilder().setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_MEDIUM)
+                .build();
         setDevicePolicyPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
-        ChooseLockGenericController controller = createController(PASSWORD_COMPLEXITY_MEDIUM);
 
-        assertThat(controller.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
+        assertThat(mController.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
                 .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX);
     }
 
     @Test
     public void upgradeQuality_complexityLow_minQualitySomething() {
+        mController = createBuilder().setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_LOW)
+                .build();
         setDevicePolicyPasswordQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
-        ChooseLockGenericController controller = createController(PASSWORD_COMPLEXITY_LOW);
 
-        assertThat(controller.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
+        assertThat(mController.upgradeQuality(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED))
                 .isEqualTo(DevicePolicyManager.PASSWORD_QUALITY_SOMETHING);
     }
 
+    @Test
+    public void getAggregatedPasswordComplexity_AppRequest() {
+        mController = createBuilder().setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_HIGH)
+                .build();
+        assertThat(mController.getAggregatedPasswordComplexity())
+                .isEqualTo(PASSWORD_COMPLEXITY_HIGH);
+    }
+
+    @Test
+    public void getAggregatedPasswordComplexity_DevicePolicy() {
+        mController = createBuilder().setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_LOW)
+                .build();
+        when(mLockPatternUtils.getRequestedPasswordComplexity(eq(UserHandle.myUserId()), eq(false)))
+                .thenReturn(PASSWORD_COMPLEXITY_MEDIUM);
+
+        assertThat(mController.getAggregatedPasswordComplexity())
+                .isEqualTo(PASSWORD_COMPLEXITY_MEDIUM);
+    }
+
+    @Test
+    public void getAggregatedPasswordComplexity_ProfileUnification() {
+        mController = createBuilder()
+                .setProfileToUnify(123)
+                .setAppRequestedMinComplexity(PASSWORD_COMPLEXITY_LOW)
+                .build();
+        when(mLockPatternUtils.getRequestedPasswordComplexity(eq(UserHandle.myUserId()), eq(false)))
+                .thenReturn(PASSWORD_COMPLEXITY_MEDIUM);
+        when(mLockPatternUtils.getRequestedPasswordComplexity(eq(123)))
+                .thenReturn(PASSWORD_COMPLEXITY_HIGH);
+
+        assertThat(mController.getAggregatedPasswordComplexity())
+                .isEqualTo(PASSWORD_COMPLEXITY_HIGH);
+    }
+
     private void setDevicePolicyPasswordQuality(int quality) {
         PasswordPolicy policy = new PasswordPolicy();
         policy.quality = quality;
@@ -256,13 +355,10 @@
                 .thenReturn(policy.getMinMetrics());
     }
 
-    private ChooseLockGenericController createController(
-            @PasswordComplexity int minPasswordComplexity) {
-        return new ChooseLockGenericController(
+    private ChooseLockGenericController.Builder createBuilder() {
+        return new ChooseLockGenericController.Builder(
                 application,
                 0 /* userId */,
-                minPasswordComplexity,
-                false,
                 mManagedLockPasswordProvider,
                 mLockPatternUtils);
     }
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
index 2233f1d..7da9c50 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPasswordTest.java
@@ -30,7 +30,6 @@
 
 import static com.android.internal.widget.LockPatternUtils.PASSWORD_TYPE_KEY;
 import static com.android.settings.password.ChooseLockGeneric.CONFIRM_CREDENTIALS;
-import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_UNIFICATION_PROFILE_ID;
 
 import static com.google.common.truth.Truth.assertThat;
 import static com.google.common.truth.Truth.assertWithMessage;
@@ -429,18 +428,6 @@
                 "PIN must be at least 8 digits");
     }
 
-    @Test
-    public void validateComplexityMergedFromUnificationUserOnCreate() {
-        ShadowLockPatternUtils.setRequiredPasswordComplexity(PASSWORD_COMPLEXITY_LOW);
-        ShadowLockPatternUtils.setRequiredPasswordComplexity(123, PASSWORD_COMPLEXITY_HIGH);
-
-        Intent intent = createIntentForPasswordValidation(null, PASSWORD_COMPLEXITY_NONE,
-                PASSWORD_QUALITY_NUMERIC);
-        intent.putExtra(EXTRA_KEY_UNIFICATION_PROFILE_ID, 123);
-        assertPasswordValidationResultForIntent(LockscreenCredential.createNone(), intent,
-                "PIN must be at least 8 digits");
-    }
-
     private ChooseLockPassword buildChooseLockPasswordActivity(Intent intent) {
         return Robolectric.buildActivity(ChooseLockPassword.class, intent).setup().get();
     }
diff --git a/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java b/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
index 3034807..f7b8d2d 100644
--- a/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetNewPasswordControllerTest.java
@@ -19,8 +19,7 @@
 import static android.content.pm.PackageManager.FEATURE_FACE;
 import static android.content.pm.PackageManager.FEATURE_FINGERPRINT;
 
-import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.HIDE_DISABLED_PREFS;
-import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.MINIMUM_QUALITY_KEY;
+import static com.android.settings.password.ChooseLockGeneric.ChooseLockGenericFragment.HIDE_INSECURE_OPTIONS;
 import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE;
 import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT;
 import static com.android.settings.password.ChooseLockSettingsHelper.EXTRA_KEY_REQUEST_GK_PW_HANDLE;
@@ -262,12 +261,9 @@
 
     private void compareFingerprintExtras(Bundle actualBundle) {
         assertEquals(
-                "Password quality must be something in order to config fingerprint.",
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING,
-                actualBundle.getInt(MINIMUM_QUALITY_KEY));
-        assertTrue(
-                "All disabled preference should be removed.",
-                actualBundle.getBoolean(HIDE_DISABLED_PREFS));
+                "Insecure options must be disabled in order to config fingerprint.",
+                true,
+                actualBundle.getBoolean(HIDE_INSECURE_OPTIONS));
         assertTrue(
                 "Fingerprint enroll must request Gatekeeper Password.",
                 actualBundle.getBoolean(EXTRA_KEY_REQUEST_GK_PW_HANDLE));
@@ -282,12 +278,9 @@
 
     private void compareFaceExtras(Bundle actualBundle) {
         assertEquals(
-                "Password quality must be something in order to config face.",
-                DevicePolicyManager.PASSWORD_QUALITY_SOMETHING,
-                actualBundle.getInt(MINIMUM_QUALITY_KEY));
-        assertTrue(
-                "All disabled preference should be removed.",
-                actualBundle.getBoolean(HIDE_DISABLED_PREFS));
+                "Insecure options must be disabled in order to config face.",
+                true,
+                actualBundle.getBoolean(HIDE_INSECURE_OPTIONS));
         assertTrue(
                 "Face enroll must request Gatekeeper Password",
                 actualBundle.getBoolean(EXTRA_KEY_REQUEST_GK_PW_HANDLE));
diff --git a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
index 5242e11..af4ae0b 100644
--- a/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
+++ b/tests/robotests/src/com/android/settings/password/SetupChooseLockPasswordTest.java
@@ -198,8 +198,7 @@
     @Implements(ChooseLockGenericController.class)
     public static class ShadowChooseLockGenericController {
         @Implementation
-        protected List<ScreenLockType> getVisibleScreenLockTypes(int quality,
-                boolean includeDisabled) {
+        protected List<ScreenLockType> getVisibleScreenLockTypes() {
             return Collections.emptyList();
         }
     }
diff --git a/tests/robotests/src/com/android/settings/testutils/ImageTestUtils.java b/tests/robotests/src/com/android/settings/testutils/ImageTestUtils.java
new file mode 100644
index 0000000..d7afe87
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/ImageTestUtils.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.testutils;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+
+import androidx.annotation.Nullable;
+
+/**
+ * Utilities for testing images within unit tests.
+ */
+public class ImageTestUtils {
+
+    /** Converts the drawable object to bitmap. */
+    @Nullable
+    public static Bitmap drawableToBitmap(@Nullable Drawable drawable) {
+        if (drawable == null) {
+            return null;
+        }
+
+        final Bitmap bitmap =
+                Bitmap.createBitmap(
+                        drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
+                        Bitmap.Config.ARGB_8888);
+        final Canvas canvas = new Canvas(bitmap);
+        drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
+        drawable.draw(canvas);
+
+        return bitmap;
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
index f73d0f7..cac1b34 100644
--- a/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
+++ b/tests/robotests/src/com/android/settings/widget/EntityHeaderControllerTest.java
@@ -26,13 +26,11 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.app.ActionBar;
 import android.content.Context;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageInfo;
 import android.content.pm.ResolveInfo;
-import android.graphics.drawable.ColorDrawable;
 import android.os.UserHandle;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -303,30 +301,6 @@
     }
 
     @Test
-    public void styleActionBar_invalidObjects_shouldNotCrash() {
-        mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
-        mController.styleActionBar(null);
-
-        when(mActivity.getActionBar()).thenReturn(null);
-        mController.styleActionBar(mActivity);
-
-        verify(mActivity).getActionBar();
-    }
-
-    @Test
-    public void styleActionBar_setElevationAndBackground() {
-        final ActionBar actionBar = mActivity.getActionBar();
-
-        mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
-        mController.styleActionBar(mActivity);
-
-        verify(actionBar).setElevation(0);
-        // Enforce a color drawable as background here, as image based drawables might not be
-        // wide enough to cover entire action bar.
-        verify(actionBar).setBackgroundDrawable(any(ColorDrawable.class));
-    }
-
-    @Test
     public void initAppHeaderController_appHeaderNull_useFragmentContext() {
         mController = EntityHeaderController.newInstance(mActivity, mFragment, null);
 
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
index 3f33405..70ae26b 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
@@ -1274,6 +1274,18 @@
     }
 
     @Test
+    public void forgetNetwork_activityGone_ignoreFinish() {
+        setUpForConnectedNetwork();
+        setUpSpyController();
+        displayAndResume();
+        when(mMockFragment.getActivity()).thenReturn(null);
+
+        mForgetClickListener.getValue().onClick(null);
+
+        verify(mMockActivity, never()).finish();
+    }
+
+    @Test
     public void forgetNetwork_standardWifiNetwork_forget() {
         setUpForConnectedNetwork();
         setUpSpyController();
diff --git a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
index f186238..4c271c6 100644
--- a/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
+++ b/tests/unit/src/com/android/settings/applications/manageapplications/AppFilterRegistryTest.java
@@ -31,10 +31,8 @@
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MANAGE_SOURCES;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MEDIA_MANAGEMENT_APPS;
-import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MOVIES;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY;
-import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_PHOTOGRAPHY;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_STORAGE;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USAGE_ACCESS;
 import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WRITE_SETTINGS;
@@ -75,7 +73,5 @@
         assertThat(registry.getDefaultFilterType(LIST_TYPE_STORAGE)).isEqualTo(FILTER_APPS_ALL);
 
         assertThat(registry.getDefaultFilterType(LIST_TYPE_GAMES)).isEqualTo(FILTER_APPS_ALL);
-        assertThat(registry.getDefaultFilterType(LIST_TYPE_MOVIES)).isEqualTo(FILTER_APPS_ALL);
-        assertThat(registry.getDefaultFilterType(LIST_TYPE_PHOTOGRAPHY)).isEqualTo(FILTER_APPS_ALL);
     }
 }
diff --git a/tests/unit/src/com/android/settings/datausage/DataUsageInfoControllerTest.java b/tests/unit/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
index d94d380..d770aba 100644
--- a/tests/unit/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
+++ b/tests/unit/src/com/android/settings/datausage/DataUsageInfoControllerTest.java
@@ -101,8 +101,8 @@
     }
 
     private NetworkPolicy getDefaultNetworkPolicy() {
-        NetworkTemplate template =
-            new NetworkTemplate(NetworkTemplate.MATCH_WIFI_WILDCARD, null, null);
+        NetworkTemplate template = NetworkTemplate.buildTemplateWifi(
+                NetworkTemplate.WIFI_NETWORKID_ALL, null /* subscriberId */);
         int cycleDay  = -1;
         String cycleTimezone = "UTC";
         long warningBytes = -1;
@@ -176,4 +176,4 @@
         
         assertThat(info.limitLevel).isEqualTo(policy.limitBytes);
     }
-}
\ No newline at end of file
+}
diff --git a/tests/unit/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java b/tests/unit/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
index 76deec6..7d814b5 100644
--- a/tests/unit/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
+++ b/tests/unit/src/com/android/settings/datausage/DataUsageSummaryPreferenceTest.java
@@ -531,11 +531,13 @@
 
         final Bundle expect = new Bundle(1);
         expect.putParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE,
-                NetworkTemplate.buildTemplateWifiWildcard());
+                NetworkTemplate.buildTemplateWifi(NetworkTemplate.WIFI_NETWORKID_ALL,
+                null /* subscriberId */));
         final Bundle actual = startedIntent
                 .getBundleExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
         assertThat((NetworkTemplate) actual.getParcelable(DataUsageList.EXTRA_NETWORK_TEMPLATE))
-                .isEqualTo(NetworkTemplate.buildTemplateWifiWildcard());
+                .isEqualTo(NetworkTemplate.buildTemplateWifi(
+                NetworkTemplate.WIFI_NETWORKID_ALL, null /* subscriberId */));
 
         assertThat(startedIntent.getIntExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID, 0))
                 .isEqualTo(ResourcesUtils.getResourcesId(mContext, "string", "wifi_data_usage"));
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java b/tests/unit/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
similarity index 68%
rename from tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
rename to tests/unit/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
index 7e6be9b..d4157b8 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
+++ b/tests/unit/src/com/android/settings/deviceinfo/TopLevelStoragePreferenceControllerTest.java
@@ -18,9 +18,11 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.nullable;
 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 import android.app.usage.StorageStatsManager;
@@ -31,9 +33,11 @@
 import android.util.FeatureFlagUtils;
 
 import androidx.preference.Preference;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
-import com.android.settings.R;
 import com.android.settings.core.FeatureFlags;
+import com.android.settings.testutils.ResourcesUtils;
 import com.android.settingslib.deviceinfo.StorageManagerVolumeProvider;
 
 import org.junit.Before;
@@ -41,14 +45,14 @@
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.robolectric.RobolectricTestRunner;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.util.ReflectionHelpers;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 
-@RunWith(RobolectricTestRunner.class)
+@RunWith(AndroidJUnit4.class)
 public class TopLevelStoragePreferenceControllerTest {
 
     @Mock
@@ -62,12 +66,12 @@
     public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        mContext = RuntimeEnvironment.application;
+        mContext = ApplicationProvider.getApplicationContext();
         mVolumes = new ArrayList<>();
         mVolumes.add(mock(VolumeInfo.class, RETURNS_DEEP_STUBS));
         when(mStorageManagerVolumeProvider.getVolumes()).thenReturn(mVolumes);
 
-        mController = new TopLevelStoragePreferenceController(mContext, "test_key");
+        mController = spy(new TopLevelStoragePreferenceController(mContext, "test_key"));
         FeatureFlagUtils.setEnabled(mContext, FeatureFlags.SILKY_HOME, false);
     }
 
@@ -82,16 +86,27 @@
         when(mStorageManagerVolumeProvider
                 .getFreeBytes(nullable(StorageStatsManager.class), nullable(VolumeInfo.class)))
                 .thenReturn(0L);
-        ReflectionHelpers.setField(mController,
-                "mStorageManagerVolumeProvider", mStorageManagerVolumeProvider);
+        when(mController.getStorageManagerVolumeProvider())
+                .thenReturn(mStorageManagerVolumeProvider);
         final String percentage = NumberFormat.getPercentInstance().format(1);
-        final String freeSpace = Formatter.formatFileSize(RuntimeEnvironment.application, 0);
+        final String freeSpace = Formatter.formatFileSize(mContext, 0);
         final Preference preference = new Preference(mContext);
 
-        mController.updateState(preference);
+        // Wait for asynchronous thread to finish, otherwise test will flake.
+        Future thread = mController.refreshSummaryThread(preference);
+        try {
+            thread.get();
+        } catch (ExecutionException | InterruptedException e) {
+            e.printStackTrace();
+            fail("Exception during automatic selection");
+        }
 
-        assertThat(preference.getSummary()).isEqualTo(
-                mContext.getString(R.string.storage_summary, percentage, freeSpace));
+
+        // Sleep for 5 seconds because a function is executed on the main thread from within
+        // the background thread.
+        TimeUnit.SECONDS.sleep(5);
+        assertThat(preference.getSummary()).isEqualTo(ResourcesUtils.getResourcesString(
+                mContext, "storage_summary", percentage, freeSpace));
     }
 
     @Test
diff --git a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
index d61ca00..5ab2ce0 100644
--- a/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
+++ b/tests/unit/src/com/android/settings/network/InternetUpdaterTest.java
@@ -108,6 +108,13 @@
     }
 
     @Test
+    public void onDestroy_shouldCloseCallback() {
+        mInternetUpdater.onDestroy();
+
+        verify(mAirplaneModeEnabler).close();
+    }
+
+    @Test
     public void updateInternetAvailable_wifiConnectedAndNoValidated_internetUnavailable() {
         final NetworkCapabilities networkCapabilities = new NetworkCapabilities.Builder()
                 .addTransportType(TRANSPORT_WIFI)
diff --git a/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
new file mode 100644
index 0000000..3bda96e
--- /dev/null
+++ b/tests/unit/src/com/android/settings/security/SecurityDashboardActivityTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.security;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Intent;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.settings.Settings;
+import com.android.settings.SettingsActivity;
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+
+@RunWith(AndroidJUnit4.class)
+public class SecurityDashboardActivityTest {
+    private static final String ALTERNATIVE_FRAGMENT_CLASSNAME = "AlternativeFragmentClassname";
+    private static final String DEFAULT_FRAGMENT_CLASSNAME = "DefaultFragmentClassname";
+
+    private SecuritySettingsFeatureProvider mSecuritySettingsFeatureProvider;
+    private Settings.SecurityDashboardActivity mActivity;
+    private Intent mDefaultIntent;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        FakeFeatureFactory mFeatureFactory = FakeFeatureFactory.setupForTest();
+        mSecuritySettingsFeatureProvider = mFeatureFactory.getSecuritySettingsFeatureProvider();
+        mDefaultIntent = new Intent();
+        mDefaultIntent.setAction(android.provider.Settings.ACTION_SECURITY_SETTINGS);
+        mDefaultIntent.setClass(InstrumentationRegistry.getInstrumentation().getTargetContext(),
+                Settings.SecurityDashboardActivity.class);
+        mDefaultIntent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT, DEFAULT_FRAGMENT_CLASSNAME);
+        InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
+            try {
+                mActivity =
+                        (Settings.SecurityDashboardActivity) InstrumentationRegistry
+                                .getInstrumentation().newActivity(
+                                        getClass().getClassLoader(),
+                                        Settings.SecurityDashboardActivity.class.getName(),
+                                        mDefaultIntent);
+            } catch (Exception e) {
+                throw new RuntimeException(e); // nothing to do
+            }
+        });
+    }
+
+    @Test
+    public void noAvailableAlternativeFragmentAvailable_defaultFragmentSet() {
+        when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
+                .thenReturn(false);
+
+        assertThat(mActivity.getInitialFragmentName(mDefaultIntent))
+                .isEqualTo(DEFAULT_FRAGMENT_CLASSNAME);
+    }
+
+    @Test
+    public void alternativeFragmentAvailable_alternativeFragmentSet() {
+        when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
+                .thenReturn(true);
+        when(mSecuritySettingsFeatureProvider.getAlternativeSecuritySettingsFragmentClassname())
+                .thenReturn(ALTERNATIVE_FRAGMENT_CLASSNAME);
+
+        assertThat(mActivity.getInitialFragmentName(mDefaultIntent))
+                .isEqualTo(ALTERNATIVE_FRAGMENT_CLASSNAME);
+    }
+
+    @Test
+    public void noAvailableAlternativeFragmentAvailable_alternativeFragmentNotValid() {
+        when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
+                .thenReturn(false);
+
+        assertThat(mActivity.isValidFragment(ALTERNATIVE_FRAGMENT_CLASSNAME)).isFalse();
+    }
+
+    @Test
+    public void alternativeFragmentAvailable_alternativeFragmentIsValid() {
+        when(mSecuritySettingsFeatureProvider.hasAlternativeSecuritySettingsFragment())
+                .thenReturn(true);
+        when(mSecuritySettingsFeatureProvider.getAlternativeSecuritySettingsFragmentClassname())
+                .thenReturn(ALTERNATIVE_FRAGMENT_CLASSNAME);
+
+        assertThat(mActivity.isValidFragment(ALTERNATIVE_FRAGMENT_CLASSNAME)).isTrue();
+    }
+}
diff --git a/tests/unit/src/com/android/settings/vpn2/VpnInfoPreferenceTest.java b/tests/unit/src/com/android/settings/vpn2/VpnInfoPreferenceTest.java
new file mode 100644
index 0000000..e0683ca
--- /dev/null
+++ b/tests/unit/src/com/android/settings/vpn2/VpnInfoPreferenceTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.vpn2;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.preference.PreferenceViewHolder;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import com.android.settings.testutils.ResourcesUtils;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class VpnInfoPreferenceTest {
+
+    private Context mContext;
+    private Resources mResources;
+    private VpnInfoPreference mVpnInfoPreference;
+    private AttributeSet mAttrs;
+    private PreferenceViewHolder mHolder;
+    private View mWarningButton;
+
+    @Before
+    public void setUp() {
+        mContext = spy(ApplicationProvider.getApplicationContext());
+        mResources = spy(mContext.getResources());
+        when(mContext.getResources()).thenReturn(mResources);
+
+        final int helpUrlId = ResourcesUtils.getResourcesId(
+                mContext, "string", "help_url_insecure_vpn");
+        when(mResources.getString(helpUrlId)).thenReturn("https://www.google.com/");
+
+        mVpnInfoPreference = new VpnInfoPreference(mContext, mAttrs);
+        LayoutInflater inflater = mContext.getSystemService(LayoutInflater.class);
+
+        // The VpnInfoPreference is a RestrictedPreference, which is a TwoTargetPreference
+        final int layoutId = ResourcesUtils.getResourcesId(
+                mContext, "layout", "preference_two_target");
+        View view = inflater.inflate(
+                layoutId,
+                null /* root */, false /* attachToRoot */);
+        mHolder = spy(PreferenceViewHolder.createInstanceForTests(view));
+        final int warningButtonId = ResourcesUtils.getResourcesId(
+                mContext, "id", "warning_button");
+        mWarningButton = spy(new View(mContext));
+        when(mWarningButton.getId()).thenReturn(warningButtonId);
+        when(mHolder.findViewById(warningButtonId)).thenReturn(mWarningButton);
+    }
+
+    @Test
+    public void onBindViewHolder_notInsecureVpn_iconInvisible() {
+        mVpnInfoPreference.setInsecureVpn(false);
+
+        mVpnInfoPreference.onBindViewHolder(mHolder);
+
+        verify(mWarningButton).setVisibility(View.GONE);
+        verify(mWarningButton).setEnabled(false);
+    }
+
+    @Test
+    public void onBindViewHolder_emptyUrl_iconInvisible() {
+        final int helpUrlId = ResourcesUtils.getResourcesId(
+                mContext, "string", "help_url_insecure_vpn");
+        when(mResources.getString(helpUrlId)).thenReturn("");
+        VpnInfoPreference vpnInfoPreference = new VpnInfoPreference(mContext, mAttrs);
+
+        vpnInfoPreference.setInsecureVpn(true);
+
+        vpnInfoPreference.onBindViewHolder(mHolder);
+
+        verify(mWarningButton).setVisibility(View.GONE);
+        verify(mWarningButton).setEnabled(false);
+    }
+
+    @Test
+    public void onBindViewHolder_insecureVpn_iconVisible() {
+        mVpnInfoPreference.setInsecureVpn(true);
+
+        mVpnInfoPreference.onBindViewHolder(mHolder);
+
+        verify(mWarningButton).setVisibility(View.VISIBLE);
+        verify(mWarningButton).setEnabled(true);
+    }
+
+    @Test
+    public void onBindViewHolder_dividerInvisible() {
+        mVpnInfoPreference.onBindViewHolder(mHolder);
+
+        final int dividerId = ResourcesUtils.getResourcesId(mContext, "id", "two_target_divider");
+        final View divider = mHolder.findViewById(dividerId);
+        assertEquals(View.GONE, divider.getVisibility());
+    }
+}