Merge "[Mac Randomization] Fix MAC randomization option does not work when ephemeral newtork"
diff --git a/Android.mk b/Android.mk
index cc45130..e385b34 100644
--- a/Android.mk
+++ b/Android.mk
@@ -20,8 +20,6 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_USE_AAPT2 := true
 
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_STATIC_ANDROID_LIBRARIES := \
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6cb0023..70dce8f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -41,7 +41,7 @@
     <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
     <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
-    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
     <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"/>
     <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES"/>
     <uses-permission android:name="android.permission.READ_USER_DICTIONARY"/>
@@ -443,7 +443,7 @@
             android:exported="true"
             android:permission="android.permission.TETHER_PRIVILEGED" />
 
-        <activity android:name="network.TetherProvisioningActivity"
+        <activity android:name=".network.TetherProvisioningActivity"
             android:exported="true"
             android:permission="android.permission.TETHER_PRIVILEGED"
             android:excludeFromRecents="true"
diff --git a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml b/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
deleted file mode 100644
index 070b9a1..0000000
--- a/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- Variant of progress_indeterminate_horizontal_material in frameworks/base/core/res, which
-     draws the whole height of the progress bar instead having blank space above and below the
-     bar. -->
-<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" >
-    <target
-        android:name="rect2_grp"
-        android:animation="@*android:anim/progress_indeterminate_horizontal_rect2" />
-    <target
-        android:name="rect1_grp"
-        android:animation="@*android:anim/progress_indeterminate_horizontal_rect1" />
-</animated-vector>
diff --git a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml b/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
deleted file mode 100644
index 39e3a37..0000000
--- a/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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.
--->
-
-<!-- Variant of vector_drawable_progress_indeterminate_horizontal in frameworks/base/core/res, which
-     draws the whole height of the progress bar instead having blank space above and below the
-     bar. -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:height="10dp"
-    android:width="360dp"
-    android:viewportHeight="10"
-    android:viewportWidth="360" >
-    <group
-        android:name="progress_group"
-        android:translateX="180"
-        android:translateY="5" >
-        <path
-            android:name="background_track"
-            android:pathData="M -180.0,-5.0 l 360.0,0 l 0,10.0 l -360.0,0 Z"
-            android:fillColor="?android:attr/colorControlActivated"
-            android:fillAlpha="?android:attr/disabledAlpha"/>
-        <group
-            android:name="rect2_grp"
-            android:translateX="-197.60001"
-            android:scaleX="0.1" >
-            <path
-                android:name="rect2"
-                android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
-                android:fillColor="?android:attr/colorControlActivated" />
-        </group>
-        <group
-            android:name="rect1_grp"
-            android:translateX="-522.59998"
-            android:scaleX="0.1" >
-            <path
-                android:name="rect1"
-                android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
-                android:fillColor="?android:attr/colorControlActivated" />
-        </group>
-    </group>
-</vector>
diff --git a/res/layout-land/storage_summary_donut.xml b/res/layout-land/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-land/storage_summary_donut.xml
+++ b/res/layout-land/storage_summary_donut.xml
@@ -18,7 +18,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center_vertical"
     android:orientation="horizontal" >
 
diff --git a/res/layout-sw360dp/storage_summary_donut.xml b/res/layout-sw360dp/storage_summary_donut.xml
index f43737a..db91547 100644
--- a/res/layout-sw360dp/storage_summary_donut.xml
+++ b/res/layout-sw360dp/storage_summary_donut.xml
@@ -18,7 +18,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center_vertical"
     android:orientation="horizontal" >
 
diff --git a/res/layout/homepage_slice_deferred_setup_tile.xml b/res/layout/homepage_slice_deferred_setup_tile.xml
index 8c83c09..73199d4 100644
--- a/res/layout/homepage_slice_deferred_setup_tile.xml
+++ b/res/layout/homepage_slice_deferred_setup_tile.xml
@@ -32,10 +32,10 @@
             android:layout_height="match_parent"
             android:gravity="left"
             android:orientation="vertical"
-            android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom"
-            android:paddingEnd="@dimen/homepage_card_padding_end"
             android:paddingStart="@dimen/homepage_card_padding_start"
-            android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top">
+            android:paddingEnd="@dimen/homepage_card_padding_end"
+            android:paddingTop="@dimen/homepage_deferred_setup_card_padding_top"
+            android:paddingBottom="@dimen/homepage_deferred_setup_card_padding_bottom">
 
             <ImageView
                 android:id="@android:id/icon"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 2b7c1b0..807c26b 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -31,8 +31,7 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical"
-            android:paddingStart="@dimen/homepage_card_padding_start"
-            android:paddingEnd="@dimen/homepage_card_padding_end"/>
+            style="@style/SliceViewStyle"/>
 
         <!--dismissal view-->
         <include layout="@layout/homepage_dismissal_view"/>
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 1637189..88f5b36 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -17,7 +17,6 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
-    android:background="?android:attr/colorPrimary"
     android:gravity="center"
     android:orientation="vertical"
     android:paddingTop="32dp"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index df676fc..8ee2fba 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -56,6 +56,7 @@
                     <EditText android:id="@+id/ssid"
                             android:layout_width="match_parent"
                             android:layout_height="wrap_content"
+                            android:layout_alignParentStart="true"
                             style="@style/wifi_item_edit_content"
                             android:hint="@string/wifi_ssid_hint"
                             android:singleLine="true"
@@ -64,12 +65,11 @@
                         android:id="@+id/ssid_scanner_button"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignParentRight="true"
+                        android:layout_alignParentEnd="true"
                         android:layout_centerVertical="true"
                         android:layout_margin="5dp"
                         android:background="@null"
                         android:src="@drawable/ic_scan_24dp"
-                        android:visibility="gone"
                         android:contentDescription="@string/wifi_add_network" />
                 </RelativeLayout>
 
@@ -291,6 +291,7 @@
                     <EditText android:id="@+id/password"
                               android:layout_width="match_parent"
                               android:layout_height="wrap_content"
+                              android:layout_alignParentStart="true"
                               style="@style/wifi_item_edit_content"
                               android:singleLine="true"
                               android:password="true" />
@@ -299,12 +300,11 @@
                         android:id="@+id/password_scanner_button"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
-                        android:layout_alignParentRight="true"
+                        android:layout_alignParentEnd="true"
                         android:layout_centerVertical="true"
                         android:layout_margin="5dp"
                         android:background="@null"
                         android:src="@drawable/ic_scan_24dp"
-                        android:visibility="gone"
                         android:contentDescription="@string/wifi_add_network" />
                 </RelativeLayout>
             </LinearLayout>
diff --git a/res/layout/wifi_progress_header.xml b/res/layout/wifi_progress_header.xml
deleted file mode 100644
index 3f5d428..0000000
--- a/res/layout/wifi_progress_header.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-    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.
--->
-
-<FrameLayout
-    android:layout_width="match_parent"
-    android:layout_height="3dp"
-    xmlns:android="http://schemas.android.com/apk/res/android">
-    <View
-        android:id="@+id/progress_bar_background"
-        style="@style/TrimmedHorizontalProgressBar"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="?android:attr/colorSecondary" />
-    <ProgressBar
-        android:id="@+id/progress_bar_animation"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        style="@style/TrimmedHorizontalProgressBar"
-        android:indeterminate="true" />
-</FrameLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index cdbeada..617feb3 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -23,6 +23,7 @@
   <color name="homepage_support_background">#3F5FBD</color>
   <!-- 80% black for status bar of homepage -->
   <color name="homepage_status_bar_color">#cc000000</color>
-  <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
+  <color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
+  <color name="contextual_card_background">@*android:color/material_grey_900</color>
 </resources>
 
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 7f707d2..82c3fef 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -15,7 +15,6 @@
 -->
 
 <resources>
-    <dimen name="settings_side_margin">112dp</dimen>
 
     <!-- ActionBar contentInsetStart -->
     <dimen name="actionbar_contentInsetStart">128dp</dimen>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 6accad7..c701044 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -17,8 +17,6 @@
 <resources>
     <dimen name="pager_tabs_padding">0dp</dimen>
 
-    <dimen name="settings_side_margin">64dp</dimen>
-
     <!-- Weight of the left pane in a multi-pane preference layout. -->
     <integer name="preferences_left_pane_weight">1</integer>
     <!-- Weight of the right pane in a multi-pane preference layout. So the split is 1:2 -->
diff --git a/res/values/colors.xml b/res/values/colors.xml
index f6723a8..a10d1d7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -100,8 +100,10 @@
     <color name="homepage_location_background">#2EC7DC</color>
     <color name="homepage_about_background">#9FA8DA</color>
     <color name="homepage_privacy_background">#5E97F6</color>
+
     <color name="homepage_card_stroke_color">#1f000000</color>
     <color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
+    <color name="contextual_card_background">@*android:color/background_device_default_light</color>
     <!-- End of dashboard/homepage icon background colors -->
 
     <color name="switchbar_text_color">@android:color/white</color>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 110fe47..365bda8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1433,13 +1433,13 @@
     <string name="unlock_change_lock_password_title">Change unlock password</string>
 
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a strong PIN or password  [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a strong PIN or password.</string>
+    <string name="unlock_footer_high_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a strong PIN or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and that it requests for a medium strength PIN or password [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new PIN or password.</string>
+    <string name="unlock_footer_medium_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new PIN or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock and it requests for any screen lock [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new pattern, PIN or password.</string>
+    <string name="unlock_footer_low_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new pattern, PIN, or password and may not work as expected without one</string>
     <!-- Footer preference text in the screen lock type picker to indicate which app is requesting a new screen lock [CHAR LIMIT=NONE] -->
-    <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> requests a new screen lock.</string>
+    <string name="unlock_footer_none_complexity_requested"><xliff:g id="app_name" example="Gmail">%1$s</xliff:g> recommends a new screen lock</string>
 
 
     <!-- Message shown on the lock screen when the user incorrectly enters their lock and it counts towards the max attempts before their data on the device is wiped. [CHAR LIMIT=NONE] -->
@@ -6859,10 +6859,10 @@
     <!-- Wizard finish button label [CHAR LIMIT=25] -->
     <string name="wizard_finish">Finish</string>
 
-    <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
-    <string name="user_image_take_photo" msgid="7496128293167402354">Take photo</string>
-    <!-- An option in a photo selection dialog, if there is no photo yet [CHAR LIMIT=50] -->
-    <string name="user_image_choose_photo" msgid="3746334626214970837">Choose photo from Gallery</string>
+    <!-- An option in a photo selection dialog to take a new photo [CHAR LIMIT=50] -->
+    <string name="user_image_take_photo" msgid="7496128293167402354">Take a photo</string>
+    <!-- An option in a photo selection dialog to choose a pre-existing image [CHAR LIMIT=50] -->
+    <string name="user_image_choose_photo" msgid="3746334626214970837">Choose an image</string>
     <!-- Accessibility message for the photo selector which is a button/popup with the current photo [CHAR LIMIT=50] -->
     <string name="user_image_photo_selector">Select photo</string>
 
@@ -7080,7 +7080,7 @@
     <string name="keywords_display_auto_brightness">dim screen, touchscreen, battery, smart brightness, dynamic brightness</string>
 
     <!-- Search keywords for adaptive sleep setting [CHAR LIMIT=NONE]-->
-    <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention</string>
+    <string name="keywords_display_adaptive_sleep">dim screen, sleep, battery, timeout, attention, display, screen, inactivity</string>
 
     <!-- List of synonyms for the auto rotate (rotate the virtual display when the device rotates) setting, used to match in settings search [CHAR LIMIT=NONE] -->
     <string name="keywords_auto_rotate">rotate, flip, rotation, portrait, landscape, orientation, vertical, horizontal</string>
@@ -9171,8 +9171,11 @@
     <!-- Title of condition that do not disturb is on [CHAR LIMIT=36] -->
     <string name="condition_zen_title">Do Not Disturb is on</string>
 
-    <!-- Summary of condition that do not disturb is on [CHAR LIMIT=36] -->
-    <string name="condition_zen_summary">Impacts what you hear and see</string>
+    <!-- Summary of condition that do not disturb is on and all exceptions set to off [CHAR LIMIT=36] -->
+    <string name="condition_zen_summary_phone_muted">Phone muted</string>
+
+    <!-- Summary of condition that do not disturb is on and some exceptions are allowed [CHAR LIMIT=36] -->
+    <string name="condition_zen_summary_with_exceptions">With exceptions</string>
 
     <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
     <string name="condition_battery_title">Battery Saver is on</string>
@@ -9202,25 +9205,16 @@
     <string name="condition_device_muted_action_turn_on_sound">Turn on sound</string>
 
     <!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
-    <string name="condition_device_muted_title" product="tablet">Device is muted</string>
-
-    <!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
-    <string name="condition_device_muted_title" product="default">Phone muted</string>
+    <string name="condition_device_muted_title">Ringer muted</string>
 
     <!-- Summary of condition that indicates device is muted -->
     <string name="condition_device_muted_summary">For calls &amp; notifications</string>
 
     <!-- Title of condition that indicates device is set to vibrate [CHAR LIMIT=50] -->
-    <string name="condition_device_vibrate_title" product="tablet">Device is set to vibrate</string>
-
-    <!-- Title of condition that indicates device is muted [CHAR LIMIT=50] -->
-    <string name="condition_device_vibrate_title" product="default">Vibration only</string>
+    <string name="condition_device_vibrate_title">Vibration only</string>
 
     <!-- Summary of condition that indicates device is set to vibrate -->
-    <string name="condition_device_vibrate_summary" product="tablet">Calls and notifications will vibrate device</string>
-
-    <!-- Summary of condition that indicates device is set to vibrate -->
-    <string name="condition_device_vibrate_summary" product="default">For calls &amp; notifications</string>
+    <string name="condition_device_vibrate_summary">For calls &amp; notifications</string>
 
     <!--  Night display: Title for the night display option Suggestion (renamed "Night Light" with title caps). [CHAR LIMIT=46] -->
     <string name="night_display_suggestion_title">Set Night Light schedule</string>
@@ -10444,27 +10438,27 @@
     </plurals>
 
     <!-- Network & internet page. Summary indicating that a SIM is used by default for calls when
-         multiple SIMs are present. [CHAR LIMIT=40] -->
+         multiple SIMs are present. [CHAR LIMIT=50] -->
     <string name="default_for_calls">Default for calls</string>
     <!-- Network & internet page. Summary indicating that a SIM is used by default for SMS messages
-         when multiple SIMs are present. [CHAR LIMIT=40] -->
+         when multiple SIMs are present. [CHAR LIMIT=50] -->
     <string name="default_for_sms">Default for SMS</string>
     <!-- Network & internet page. Summary indicating that a SIM is used by default for calls and SMS
-         messages when multiple SIMs are present. [CHAR LIMIT=40] -->
+         messages when multiple SIMs are present. [CHAR LIMIT=50] -->
     <string name="default_for_calls_and_sms">Default for calls &amp; SMS</string>
     <!-- Network & internet page. Summary indicating that a SIM is used by default for mobile data
-         when multiple SIMs are present. [CHAR LIMIT=40] -->
+         when multiple SIMs are present. [CHAR LIMIT=50] -->
     <string name="default_for_mobile_data">Default for mobile data</string>
     <!-- Network & internet page. Summary indicating that a SIM has an active mobile data connection
-         when multiple SIMs are present. [CHAR LIMIT=40] -->
+         when multiple SIMs are present. [CHAR LIMIT=50] -->
     <string name="mobile_data_active">Mobile data active</string>
     <!-- Network & internet page. Summary indicating that a SIM is used by default for mobile data
          when multiple SIMs are present, but mobile data is currently turned off.
-         [CHAR LIMIT=40] -->
+         [CHAR LIMIT=50] -->
     <string name="mobile_data_off">Mobile data off</string>
     <!-- Network & internet page. Summary indicating that a SIM is available to be used for services
          such as calls, SMS, or data when multiple SIMs are present, but is not currently the
-          default SIM for any of those services. [CHAR LIMIT=40] -->
+          default SIM for any of those services. [CHAR LIMIT=50] -->
     <string name="subscription_available">Available</string>
 
     <!-- Title of item shown at the bottom of the page listing multiple mobile service
@@ -10638,6 +10632,15 @@
     <!-- Text for permission bar chart details in Privacy page.  [CHAR LIMIT=NONE] -->
     <string name="permission_bar_chart_details">See all usage</string>
 
+    <!-- Title for the accessibility usage preference in the Privacy page.  [CHAR LIMIT=NONE] -->
+    <string name="accessibility_usage_title">Accessibility usage</string>
+
+    <!-- Summary for the accessibility usage preference in the Privacy page.  [CHAR LIMIT=NONE] -->
+    <plurals name="accessibility_usage_summary">
+        <item quantity="one">1 service has full access to your device</item>
+        <item quantity="other"><xliff:g id="service_count">%1$d</xliff:g> services have full access to your device</item>
+    </plurals>
+
     <!-- Title for notification channel slice. [CHAR LIMIT=NONE] -->
     <string name="manage_app_notification">Manage <xliff:g id="app_name" example="Settings">%1$s</xliff:g> Notifications</string>
     <!-- Title for no suggested app in notification channel slice. [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index f1b401a..747210e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -82,15 +82,6 @@
         <item name="android:scrollbarStyle">outsideOverlay</item>
     </style>
 
-    <style name="TrimmedHorizontalProgressBar"
-           parent="android:Widget.Material.ProgressBar.Horizontal">
-        <item name="android:indeterminateDrawable">
-            @drawable/progress_indeterminate_horizontal_material_trimmed
-        </item>
-        <item name="android:minHeight">3dip</item>
-        <item name="android:maxHeight">3dip</item>
-    </style>
-
     <style name="bt_item">
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
@@ -286,6 +277,7 @@
 
     <style name="TextAppearance.ConditionCardTitle"
            parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
+        <item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
         <item name="android:textSize">16sp</item>
     </style>
 
@@ -419,6 +411,7 @@
         <item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
         <item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
         <item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
+        <item name="cardBackgroundColor">@color/contextual_card_background</item>
         <item name="cardCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
         <item name="cardElevation">0dp</item>
         <item name="strokeColor">@color/homepage_card_stroke_color</item>
@@ -461,6 +454,7 @@
 
     <style name="Widget.SliceView.Settings">
         <item name="titleSize">@*android:dimen/text_size_subhead_material</item>
+        <item name="rowStyle">@style/SliceRowStyle.Settings</item>
     </style>
 
     <style name="TextAppearance.DeferredSetupCardTitle">
@@ -483,4 +477,41 @@
         <item name="android:textSize">14sp</item>
     </style>
 
+    <style name="SliceViewStyle">
+        <!-- 4dp start padding for the start icon -->
+        <item name="android:paddingStart">4dp</item>
+
+        <!-- End margin of content without end items is 24dp.
+             android:paddingEnd = 24 - 16(contentEndPadding) -->
+        <item name="android:paddingEnd">8dp</item>
+
+        <item name="rowStyle">@style/SliceRowStyle</item>
+    </style>
+
+    <style name="SliceRowStyle">
+        <item name="titleItemEndPadding">0dp</item>
+
+        <!-- Padding between content and the start icon is 12dp. -->
+        <item name="contentStartPadding">12dp</item>
+        <!-- Padding between content and end items is 16dp. -->
+        <item name="contentEndPadding">16dp</item>
+
+        <!-- Both side margins of end item are 16dp.
+             endItemEndPadding = 16 - 8(android:paddingEnd) -->
+        <item name="endItemStartPadding">16dp</item>
+        <item name="endItemEndPadding">8dp</item>
+
+        <!-- Both side margins of bottom divider are 12dp.
+             bottomDividerStartPadding = 12 - 4(android:paddingStart)
+             bottomDividerEndPadding = 12 - 8(android:paddingEnd) -->
+        <item name="bottomDividerStartPadding">8dp</item>
+        <item name="bottomDividerEndPadding">4dp</item>
+
+        <item name="actionDividerHeight">32dp</item>
+    </style>
+
+    <style name="SliceRowStyle.Settings">
+        <!-- Padding between content and the start icon is 8dp. -->
+        <item name="contentStartPadding">8dp</item>
+    </style>
 </resources>
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 44ac10a..eaca161 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -20,13 +20,22 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="privacy_dashboard_page"
     android:title="@string/privacy_dashboard_title"
-    settings:initialExpandedChildrenCount="3">
+    settings:initialExpandedChildrenCount="4">
 
     <com.android.settingslib.widget.BarChartPreference
         android:key="permission_bar_chart"
         android:title="@string/privacy_dashboard_title"
         settings:controller="com.android.settings.privacy.PermissionBarChartPreferenceController"/>
 
+    <!-- Accessibility usage -->
+    <Preference
+        android:key="privacy_accessibility_usage"
+        android:title="@string/accessibility_usage_title"
+        settings:allowDividerAbove="true"
+        settings:controller="com.android.settings.privacy.AccessibilityUsagePreferenceController">
+        <intent android:action="android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"/>
+    </Preference>
+
     <!-- App permissions -->
     <Preference
         android:key="privacy_manage_perms"
diff --git a/res/xml/security_lockscreen_settings.xml b/res/xml/security_lockscreen_settings.xml
index c5765d3..6833922 100644
--- a/res/xml/security_lockscreen_settings.xml
+++ b/res/xml/security_lockscreen_settings.xml
@@ -60,6 +60,12 @@
             settings:controller="com.android.settings.display.AmbientDisplayAlwaysOnPreferenceController" />
 
         <Preference
+            android:key="ambient_display_wake_screen"
+            android:title="@string/ambient_display_wake_screen_title"
+            android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
+            settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
+
+        <Preference
             android:key="ambient_display_tap"
             android:title="@string/ambient_display_tap_screen_title"
             android:fragment="com.android.settings.gestures.TapScreenGestureSettings"
@@ -77,12 +83,6 @@
             android:fragment="com.android.settings.gestures.PickupGestureSettings"
             settings:controller="com.android.settings.gestures.PickupGesturePreferenceController" />
 
-        <Preference
-            android:key="ambient_display_wake_screen"
-            android:title="@string/ambient_display_wake_screen_title"
-            android:fragment="com.android.settings.gestures.WakeScreenGestureSettings"
-            settings:controller="com.android.settings.gestures.WakeScreenGesturePreferenceController" />
-
         <SwitchPreference
             android:key="ambient_display_notification"
             android:title="@string/doze_title"
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 8dad57f..58bc58c 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -65,10 +65,10 @@
 import com.android.settings.password.ConfirmLockPattern;
 import com.android.settingslib.RestrictedLockUtilsInternal;
 
-import com.google.android.setupcompat.TemplateLayout;
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
 
 import java.util.List;
 
@@ -416,7 +416,7 @@
             return;
         }
 
-        final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+        final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
         final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
         mixin.setPrimaryButton(
                 new FooterButton.Builder(getActivity())
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index c25f2af..618dd2c 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -44,10 +44,10 @@
 import com.android.settings.enterprise.ActionDisabledByAdminDialogHelper;
 import com.android.settingslib.RestrictedLockUtilsInternal;
 
-import com.google.android.setupcompat.TemplateLayout;
 import com.google.android.setupcompat.template.FooterBarMixin;
 import com.google.android.setupcompat.template.FooterButton;
 import com.google.android.setupcompat.template.FooterButton.ButtonType;
+import com.google.android.setupdesign.GlifLayout;
 
 /**
  * Confirm and execute a reset of the device to a clean "just out of the box"
@@ -152,7 +152,7 @@
      * Configure the UI for the final confirmation interaction
      */
     private void establishFinalConfirmationState() {
-        final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
+        final GlifLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
 
         final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
         mixin.setPrimaryButton(
diff --git a/src/com/android/settings/SmsDefaultDialog.java b/src/com/android/settings/SmsDefaultDialog.java
index e4b49ee..c25961d 100644
--- a/src/com/android/settings/SmsDefaultDialog.java
+++ b/src/com/android/settings/SmsDefaultDialog.java
@@ -16,6 +16,8 @@
 
 package com.android.settings;
 
+import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
@@ -30,6 +32,8 @@
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.BaseAdapter;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -60,6 +64,21 @@
     }
 
     @Override
+    protected void onStart() {
+        super.onStart();
+        getWindow().addSystemFlags(SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        final Window window = getWindow();
+        final WindowManager.LayoutParams attrs = window.getAttributes();
+        attrs.privateFlags &= ~SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;
+        window.setAttributes(attrs);
+    }
+
+    @Override
     public void onClick(DialogInterface dialog, int which) {
         switch (which) {
             case BUTTON_POSITIVE:
@@ -84,7 +103,7 @@
     }
 
     private boolean buildDialog(String packageName) {
-        TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
+        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
         if (!tm.isSmsCapable()) {
             // No phone, no SMS
             return false;
@@ -198,7 +217,7 @@
             } else {
                 view.findViewById(R.id.default_label).setVisibility(View.GONE);
             }
-            ImageView imageView = (ImageView)view.findViewById(android.R.id.icon);
+            ImageView imageView = (ImageView) view.findViewById(android.R.id.icon);
             imageView.setImageDrawable(item.icon);
             return view;
         }
diff --git a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
index 617a9bb..1881ca7 100644
--- a/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
+++ b/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java
@@ -148,7 +148,8 @@
         mFragmentManager = fragmentManager;
     }
 
-    private CachedBluetoothDevice getConnectedHearingAidDevice() {
+    @VisibleForTesting
+    CachedBluetoothDevice getConnectedHearingAidDevice() {
         if (!mHearingAidProfileSupported) {
             return null;
         }
@@ -158,9 +159,11 @@
         final List<BluetoothDevice> deviceList = mLocalBluetoothManager.getProfileManager()
                 .getHearingAidProfile().getConnectedDevices();
         final Iterator it = deviceList.iterator();
-        if (it.hasNext()) {
+        while (it.hasNext()) {
             BluetoothDevice obj = (BluetoothDevice)it.next();
-            return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+            if (!mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(obj)) {
+                return mLocalBluetoothManager.getCachedDeviceManager().findDevice(obj);
+            }
         }
         return null;
     }
diff --git a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
index d762095..11fcaff 100644
--- a/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountHeaderPreferenceController.java
@@ -84,7 +84,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mHeaderPreference = (LayoutPreference) screen.findPreference(KEY_ACCOUNT_HEADER);
+        mHeaderPreference = screen.findPreference(KEY_ACCOUNT_HEADER);
     }
 
     @Override
diff --git a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
index 5523cce..938606b 100644
--- a/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
+++ b/src/com/android/settings/accounts/RemoveAccountPreferenceController.java
@@ -66,8 +66,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference removeAccountPreference =
-                (LayoutPreference) screen.findPreference(KEY_REMOVE_ACCOUNT);
+        final LayoutPreference removeAccountPreference = screen.findPreference(KEY_REMOVE_ACCOUNT);
         Button removeAccountButton = (Button) removeAccountPreference.findViewById(R.id.button);
         removeAccountButton.setOnClickListener(this);
     }
diff --git a/src/com/android/settings/applications/RecentAppsPreferenceController.java b/src/com/android/settings/applications/RecentAppsPreferenceController.java
index 364aeff..6e0ae45 100644
--- a/src/com/android/settings/applications/RecentAppsPreferenceController.java
+++ b/src/com/android/settings/applications/RecentAppsPreferenceController.java
@@ -138,7 +138,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
         mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
         mDivider = screen.findPreference(KEY_DIVIDER);
         super.displayPreference(screen);
diff --git a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
index f65bb9b..c9f0e31 100644
--- a/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/AppHeaderViewPreferenceController.java
@@ -63,7 +63,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mHeader = (LayoutPreference) screen.findPreference(KEY_HEADER);
+        mHeader = screen.findPreference(KEY_HEADER);
         final Activity activity = mParent.getActivity();
         mEntityHeaderController = EntityHeaderController
                 .newInstance(activity, mParent, mHeader.findViewById(R.id.entity_header))
diff --git a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
index 23c0121..21e641d 100644
--- a/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
+++ b/src/com/android/settings/applications/appinfo/InstantAppButtonsPreferenceController.java
@@ -77,7 +77,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (LayoutPreference) screen.findPreference(KEY_INSTANT_APP_BUTTONS);
+        mPreference = screen.findPreference(KEY_INSTANT_APP_BUTTONS);
         initButtons(mPreference.findViewById(R.id.instant_app_button_container));
     }
 
@@ -85,7 +85,7 @@
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         if (!TextUtils.isEmpty(mLaunchUri)) {
             menu.add(0, AppInfoDashboardFragment.INSTALL_INSTANT_APP_MENU, 2, R.string.install_text)
-                .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+                    .setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
         }
     }
 
@@ -137,7 +137,7 @@
 
     private void showDialog() {
         final DialogFragment newFragment =
-            InstantAppButtonDialogFragment.newInstance(mPackageName);
+                InstantAppButtonDialogFragment.newInstance(mPackageName);
         newFragment.setTargetFragment(mParent, 0);
         newFragment.show(mParent.getFragmentManager(), KEY_INSTANT_APP_BUTTONS);
     }
@@ -148,7 +148,7 @@
         intent.addCategory(Intent.CATEGORY_LAUNCHER);
         intent.setPackage(mPackageName);
         final List<ResolveInfo> infos = manager.queryIntentActivities(
-            intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
+                intent, PackageManager.GET_META_DATA | PackageManager.MATCH_INSTANT);
         for (ResolveInfo info : infos) {
             final Bundle metaData = info.activityInfo.metaData;
             if (metaData != null) {
diff --git a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
index 12d1512..c859db2 100644
--- a/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
+++ b/src/com/android/settings/applications/managedomainurls/DomainAppPreferenceController.java
@@ -63,7 +63,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mDomainAppList = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mDomainAppList = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
index 0ff4233..319d62f 100644
--- a/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
+++ b/src/com/android/settings/applications/specialaccess/deviceadmin/DeviceAdminListPreferenceController.java
@@ -116,7 +116,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 4e2c711..490580d 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -58,7 +58,9 @@
     private FaceSettingsAttentionPreferenceController mAttentionController;
 
     private final FaceSettingsRemoveButtonPreferenceController.Listener mRemovalListener = () -> {
-        getActivity().finish();
+        if (getActivity() != null) {
+            getActivity().finish();
+        }
     };
 
     public static boolean isAvailable(Context context) {
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
index b910fe5..da7e9b5 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsAttentionPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (SwitchPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
index 8c063b5..4edbb67 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsVideoPreferenceController.java
@@ -44,7 +44,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mVideoPreference = (VideoPreference) screen.findPreference(KEY_VIDEO);
+        mVideoPreference = screen.findPreference(KEY_VIDEO);
         mVideoPreference.onViewVisible(false /* paused */);
     }
 }
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
index 95b16b9..994daa7 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHeaderController.java
@@ -52,8 +52,7 @@
 
     @Override
     protected void init(PreferenceScreen screen) {
-        final LayoutPreference headerPreference =
-                (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+        final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
         mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
                 headerPreference.findViewById(R.id.entity_header));
         screen.addPreference(headerPreference);
diff --git a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
index 3239dd5..9706c17 100644
--- a/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/AddDevicePreferenceController.java
@@ -68,7 +68,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreference = (Preference) screen.findPreference(getPreferenceKey());
+            mPreference = screen.findPreference(getPreferenceKey());
         }
     }
 
diff --git a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
index 2681288..be82284 100644
--- a/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/AvailableMediaDeviceGroupController.java
@@ -84,7 +84,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
             updateTitle();
             mBluetoothDeviceUpdater.setPrefContext(screen.getContext());
@@ -127,7 +127,7 @@
 
     @VisibleForTesting
     public void setBluetoothDeviceUpdater(BluetoothDeviceUpdater bluetoothDeviceUpdater) {
-        mBluetoothDeviceUpdater  = bluetoothDeviceUpdater;
+        mBluetoothDeviceUpdater = bluetoothDeviceUpdater;
     }
 
     @Override
diff --git a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
index daa9932..aa83e67 100644
--- a/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/ConnectedDeviceGroupController.java
@@ -74,7 +74,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
 
             final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
index ffcd1fc..45f128d 100644
--- a/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
+++ b/src/com/android/settings/connecteddevice/PreviouslyConnectedDevicePreferenceController.java
@@ -47,7 +47,7 @@
         super(context, preferenceKey);
 
         mSavedDockUpdater = FeatureFactory.getFactory(
-            context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
+                context).getDockUpdaterFeatureProvider().getSavedDockUpdater(context, this);
     }
 
     @Override
@@ -60,7 +60,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
         mPreferenceGroup.setVisible(false);
 
         if (isAvailable()) {
diff --git a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
index 951f3d1..e1dc750 100644
--- a/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
+++ b/src/com/android/settings/connecteddevice/SavedDeviceGroupController.java
@@ -74,7 +74,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         if (isAvailable()) {
-            mPreferenceGroup = (PreferenceGroup) screen.findPreference(KEY);
+            mPreferenceGroup = screen.findPreference(KEY);
             mPreferenceGroup.setVisible(false);
 
             final Context context = screen.getContext();
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
index 01977d8..4b08b74 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsDataRoleController.java
@@ -57,7 +57,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mHostPref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_HOST),
                 R.string.usb_control_host);
         mDevicePref = makeRadioPreference(UsbBackend.dataRoleToString(DATA_ROLE_DEVICE),
@@ -74,7 +74,7 @@
             mDevicePref.setChecked(false);
             mHostPref.setChecked(true);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || dataRole == DATA_ROLE_NONE){
+        } else if (!connected || dataRole == DATA_ROLE_NONE) {
             mPreferenceCategory.setEnabled(false);
             if (mNextRolePref == null) {
                 // Disconnected with no operation pending, so clear subtexts
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
index 77ae13f..858a01c 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsFunctionsController.java
@@ -68,14 +68,14 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mProfilesContainer = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mProfilesContainer = screen.findPreference(getPreferenceKey());
     }
 
     /**
      * Gets a switch preference for the particular option, creating it if needed.
      */
     private RadioButtonPreference getProfilePreference(String key, int titleId) {
-        RadioButtonPreference pref = (RadioButtonPreference) mProfilesContainer.findPreference(key);
+        RadioButtonPreference pref = mProfilesContainer.findPreference(key);
         if (pref == null) {
             pref = new RadioButtonPreference(mProfilesContainer.getContext());
             pref.setKey(key);
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
index 26b21a1..e151258 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsHeaderController.java
@@ -40,8 +40,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference headerPreference =
-                (LayoutPreference) screen.findPreference(KEY_DEVICE_HEADER);
+        final LayoutPreference headerPreference = screen.findPreference(KEY_DEVICE_HEADER);
         mHeaderController = EntityHeaderController.newInstance(mFragment.getActivity(), mFragment,
                 headerPreference.findViewById(R.id.entity_header));
     }
diff --git a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
index 42c5bae..13b3076 100644
--- a/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
+++ b/src/com/android/settings/connecteddevice/usb/UsbDetailsPowerRoleController.java
@@ -58,7 +58,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mSwitchPreference = new SwitchPreference(mPreferenceCategory.getContext());
         mSwitchPreference.setTitle(R.string.usb_use_power_only);
         mSwitchPreference.setOnPreferenceClickListener(this);
@@ -70,7 +70,7 @@
         // Hide this option if this is not a PD compatible connection
         if (connected && !mUsbBackend.areAllRolesSupported()) {
             mFragment.getPreferenceScreen().removePreference(mPreferenceCategory);
-        } else if (connected && mUsbBackend.areAllRolesSupported()){
+        } else if (connected && mUsbBackend.areAllRolesSupported()) {
             mFragment.getPreferenceScreen().addPreference(mPreferenceCategory);
         }
         if (powerRole == POWER_ROLE_SOURCE) {
@@ -79,7 +79,7 @@
         } else if (powerRole == POWER_ROLE_SINK) {
             mSwitchPreference.setChecked(false);
             mPreferenceCategory.setEnabled(true);
-        } else if (!connected || powerRole == POWER_ROLE_NONE){
+        } else if (!connected || powerRole == POWER_ROLE_NONE) {
             mPreferenceCategory.setEnabled(false);
             if (mNextPowerRole == POWER_ROLE_NONE) {
                 mSwitchPreference.setSummary("");
diff --git a/src/com/android/settings/core/BasePreferenceController.java b/src/com/android/settings/core/BasePreferenceController.java
index 1c85009..324b509 100644
--- a/src/com/android/settings/core/BasePreferenceController.java
+++ b/src/com/android/settings/core/BasePreferenceController.java
@@ -15,7 +15,6 @@
 
 import android.annotation.IntDef;
 import android.content.Context;
-import android.content.IntentFilter;
 import android.text.TextUtils;
 import android.util.Log;
 
@@ -24,6 +23,7 @@
 
 import com.android.settings.search.SearchIndexableRaw;
 import com.android.settings.slices.SliceData;
+import com.android.settings.slices.Sliceable;
 import com.android.settingslib.core.AbstractPreferenceController;
 
 import java.lang.annotation.Retention;
@@ -37,7 +37,8 @@
  * for Slices. The abstract classes that inherit from this class will act as the direct interfaces
  * for each type when plugging into Slices.
  */
-public abstract class BasePreferenceController extends AbstractPreferenceController {
+public abstract class BasePreferenceController extends AbstractPreferenceController implements
+        Sliceable {
 
     private static final String TAG = "SettingsPrefController";
 
@@ -119,7 +120,7 @@
             final Class<?> clazz = Class.forName(controllerName);
             final Constructor<?> preferenceConstructor =
                     clazz.getConstructor(Context.class, String.class);
-            final Object[] params = new Object[] {context, key};
+            final Object[] params = new Object[]{context, key};
             return (BasePreferenceController) preferenceConstructor.newInstance(params);
         } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
                 IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -137,7 +138,7 @@
         try {
             final Class<?> clazz = Class.forName(controllerName);
             final Constructor<?> preferenceConstructor = clazz.getConstructor(Context.class);
-            final Object[] params = new Object[] {context};
+            final Object[] params = new Object[]{context};
             return (BasePreferenceController) preferenceConstructor.newInstance(params);
         } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException |
                 IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
@@ -227,41 +228,6 @@
     }
 
     /**
-     * @return an {@link IntentFilter} that includes all broadcasts which can affect the state of
-     * this Setting.
-     */
-    public IntentFilter getIntentFilter() {
-        return null;
-    }
-
-    /**
-     * Determines if the controller should be used as a Slice.
-     * <p>
-     *     Important criteria for a Slice are:
-     *     - Must be secure
-     *     - Must not be a privacy leak
-     *     - Must be understandable as a stand-alone Setting.
-     * <p>
-     *     This does not guarantee the setting is available. {@link #isAvailable()} should sill be
-     *     called.
-     *
-     * @return {@code true} if the controller should be used externally as a Slice.
-     */
-    public boolean isSliceable() {
-        return false;
-    }
-
-    /**
-     * @return {@code true} if the setting update asynchronously.
-     * <p>
-     * For example, a Wifi controller would return true, because it needs to update the radio
-     * and wait for it to turn on.
-     */
-    public boolean hasAsyncUpdate() {
-        return false;
-    }
-
-    /**
      * Updates non-indexable keys for search provider.
      *
      * Called by SearchIndexProvider#getNonIndexableKeys
@@ -293,6 +259,7 @@
 
     /**
      * Set {@link UiBlockListener}
+     *
      * @param uiBlockListener listener to set
      */
     public void setUiBlockListener(UiBlockListener uiBlockListener) {
@@ -306,6 +273,7 @@
         /**
          * To notify client that UI related background work is finished.
          * (i.e. Slice is fully loaded.)
+         *
          * @param controller Controller that contains background work
          */
         void onBlockerWorkFinished(BasePreferenceController controller);
@@ -321,5 +289,6 @@
      *
      * This music be used in {@link BasePreferenceController}
      */
-    public interface UiBlocker {}
+    public interface UiBlocker {
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/core/FeatureFlags.java b/src/com/android/settings/core/FeatureFlags.java
index d1c2fd5..78fdfe7 100644
--- a/src/com/android/settings/core/FeatureFlags.java
+++ b/src/com/android/settings/core/FeatureFlags.java
@@ -26,7 +26,6 @@
     public static final String MOBILE_NETWORK_V2 = "settings_mobile_network_v2";
     public static final String WIFI_MAC_RANDOMIZATION = "settings_wifi_mac_randomization";
     public static final String NETWORK_INTERNET_V2 = "settings_network_and_internet_v2";
-    public static final String WIFI_SHARING = "settings_wifi_sharing";
     public static final String SLICE_INJECTION = "settings_slice_injection";
     public static final String MAINLINE_MODULE = "settings_mainline_module";
 }
diff --git a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
index 0f21dee..0f429c7 100644
--- a/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
+++ b/src/com/android/settings/development/AbstractBluetoothA2dpPreferenceController.java
@@ -65,7 +65,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (ListPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         // Set a default value because BluetoothCodecConfig is null initially.
         mPreference.setValue(mListValues[getDefaultIndex()]);
@@ -177,7 +177,7 @@
 
     @VisibleForTesting
     void setCodecConfigPreference(BluetoothDevice device,
-                                  BluetoothCodecConfig config) {
+            BluetoothCodecConfig config) {
         mBluetoothA2dp.setCodecConfigPreference(device, config);
     }
 
diff --git a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
index d26f0dd..d698436 100644
--- a/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
+++ b/src/com/android/settings/development/BluetoothSnoopLogPreferenceController.java
@@ -55,8 +55,7 @@
         mListEntries = context.getResources().getStringArray(R.array.bt_hci_snoop_log_entries);
     }
 
-    // Default mode is FILTERED on userdebug/eng build, DISABLED on user build,
-    // or can be changed by modifying the global setting.
+    // Default mode is DISABLED. It can also be changed by modifying the global setting.
     public int getDefaultModeIndex() {
         if (!Build.IS_DEBUGGABLE) {
             return BTSNOOP_LOG_MODE_DISABLED_INDEX;
@@ -71,7 +70,7 @@
             }
         }
 
-        return BTSNOOP_LOG_MODE_FILTERED_INDEX;
+        return BTSNOOP_LOG_MODE_DISABLED_INDEX;
     }
 
     @Override
diff --git a/src/com/android/settings/development/OemUnlockPreferenceController.java b/src/com/android/settings/development/OemUnlockPreferenceController.java
index b6b4d17..2a397f1 100644
--- a/src/com/android/settings/development/OemUnlockPreferenceController.java
+++ b/src/com/android/settings/development/OemUnlockPreferenceController.java
@@ -77,7 +77,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/development/OverlayCategoryPreferenceController.java b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
index 0ba9d79..7a2ee08 100644
--- a/src/com/android/settings/development/OverlayCategoryPreferenceController.java
+++ b/src/com/android/settings/development/OverlayCategoryPreferenceController.java
@@ -41,7 +41,6 @@
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
-import java.util.Optional;
 
 /**
  * Preference controller to allow users to choose an overlay from a list for a given category.
@@ -91,7 +90,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        setPreference((ListPreference) screen.findPreference(getPreferenceKey()));
+        setPreference(screen.findPreference(getPreferenceKey()));
     }
 
     @VisibleForTesting
@@ -124,7 +123,8 @@
                     if (PACKAGE_DEVICE_DEFAULT.equals(packageName)) {
                         return mOverlayManager.setEnabled(currentPackageName, false, USER_SYSTEM);
                     } else {
-                        return mOverlayManager.setEnabledExclusiveInCategory(packageName, USER_SYSTEM);
+                        return mOverlayManager.setEnabledExclusiveInCategory(packageName,
+                                USER_SYSTEM);
                     }
                 } catch (RemoteException re) {
                     Log.w(TAG, "Error enabling overlay.", re);
diff --git a/src/com/android/settings/development/PictureColorModePreferenceController.java b/src/com/android/settings/development/PictureColorModePreferenceController.java
index 3cf1f4e..1acf5d0 100644
--- a/src/com/android/settings/development/PictureColorModePreferenceController.java
+++ b/src/com/android/settings/development/PictureColorModePreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ColorModePreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference != null) {
             mPreference.updateCurrentAndSupported();
         }
diff --git a/src/com/android/settings/development/StayAwakePreferenceController.java b/src/com/android/settings/development/StayAwakePreferenceController.java
index 4091537..25a92b2 100644
--- a/src/com/android/settings/development/StayAwakePreferenceController.java
+++ b/src/com/android/settings/development/StayAwakePreferenceController.java
@@ -40,7 +40,7 @@
 
 
 public class StayAwakePreferenceController extends DeveloperOptionsPreferenceController
-        implements Preference.OnPreferenceChangeListener, LifecycleObserver,  OnResume, OnPause,
+        implements Preference.OnPreferenceChangeListener, LifecycleObserver, OnResume, OnPause,
         PreferenceControllerMixin {
 
     private static final String TAG = "StayAwakeCtrl";
@@ -72,7 +72,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedSwitchPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
index 1c4df4c..638c7c1 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagsPreferenceController.java
@@ -45,7 +45,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
@@ -60,6 +60,6 @@
         mGroup.removeAll();
         final Context prefContext = mGroup.getContext();
         featureMap.keySet().stream().sorted().forEach(feature ->
-            mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
+                mGroup.addPreference(new FeatureFlagPreference(prefContext, feature)));
     }
 }
diff --git a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
index 3877c45..09659be 100644
--- a/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
+++ b/src/com/android/settings/development/gamedriver/GameDriverAppPreferenceController.java
@@ -55,8 +55,8 @@
  */
 public class GameDriverAppPreferenceController extends BasePreferenceController
         implements Preference.OnPreferenceChangeListener,
-                   GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
-                   OnStart, OnStop {
+        GameDriverContentObserver.OnGameDriverContentChangedListener, LifecycleObserver,
+        OnStart, OnStop {
 
     private final Context mContext;
     private final ContentResolver mContentResolver;
@@ -103,9 +103,9 @@
     @Override
     public int getAvailabilityStatus() {
         return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
-                        && (Settings.Global.getInt(mContentResolver,
-                                    Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
-                                != GAME_DRIVER_OFF)
+                && (Settings.Global.getInt(mContentResolver,
+                Settings.Global.GAME_DRIVER_ALL_APPS, GAME_DRIVER_DEFAULT)
+                != GAME_DRIVER_OFF)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
@@ -113,7 +113,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
 
         final Context context = mPreferenceGroup.getContext();
         for (AppInfo appInfo : mAppInfos) {
@@ -179,6 +179,7 @@
             info = applicationInfo;
             label = packageManager.getApplicationLabel(applicationInfo).toString();
         }
+
         final ApplicationInfo info;
         final String label;
     }
diff --git a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
index 95c02fd..50027f2 100644
--- a/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/AutomaticStorageManagementSwitchPreferenceController.java
@@ -61,7 +61,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mSwitch = (MasterSwitchPreference) screen.findPreference(getPreferenceKey());
+        mSwitch = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
index ee9fad6..c78d108 100644
--- a/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
+++ b/src/com/android/settings/deviceinfo/storage/SecondaryUserController.java
@@ -49,8 +49,10 @@
     private static final int USER_PROFILE_INSERTION_LOCATION = 6;
     private static final int SIZE_NOT_SET = -1;
 
-    private @NonNull UserInfo mUser;
-    private @Nullable StorageItemPreference mStoragePreference;
+    private @NonNull
+    UserInfo mUser;
+    private @Nullable
+    StorageItemPreference mStoragePreference;
     private Drawable mUserIcon;
     private long mSize;
     private long mTotalSizeBytes;
@@ -58,7 +60,8 @@
     /**
      * Adds the appropriate controllers to a controller list for handling all secondary users on
      * a device.
-     * @param context Context for initializing the preference controllers.
+     *
+     * @param context     Context for initializing the preference controllers.
      * @param userManager UserManagerWrapper for figuring out which controllers to add.
      */
     public static List<AbstractPreferenceController> getSecondaryUserControllers(
@@ -91,8 +94,9 @@
 
     /**
      * Constructor for a given secondary user.
+     *
      * @param context Context to initialize the underlying {@link AbstractPreferenceController}.
-     * @param info {@link UserInfo} for the secondary user which this controllers covers.
+     * @param info    {@link UserInfo} for the secondary user which this controllers covers.
      */
     @VisibleForTesting
     SecondaryUserController(Context context, @NonNull UserInfo info) {
@@ -107,7 +111,7 @@
             mStoragePreference = new StorageItemPreference(screen.getContext());
 
             PreferenceGroup group =
-                    (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+                    screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
             mStoragePreference.setTitle(mUser.name);
             mStoragePreference.setKey(PREFERENCE_KEY_BASE + mUser.id);
             if (mSize != SIZE_NOT_SET) {
@@ -140,6 +144,7 @@
 
     /**
      * Sets the size for the preference.
+     *
      * @param size Size in bytes.
      */
     public void setSize(long size) {
@@ -151,6 +156,7 @@
 
     /**
      * Sets the total size for the preference for the progress bar.
+     *
      * @param totalSizeBytes Total size in bytes.
      */
     public void setTotalSize(long totalSizeBytes) {
@@ -185,8 +191,7 @@
 
         @Override
         public void displayPreference(PreferenceScreen screen) {
-            PreferenceGroup group =
-                    (PreferenceGroup) screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
+            final PreferenceGroup group = screen.findPreference(TARGET_PREFERENCE_GROUP_KEY);
             if (group == null) {
                 return;
             }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
index 4bc7cde..525a887 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageItemPreferenceController.java
@@ -77,7 +77,7 @@
     static final String FILES_KEY = "pref_files";
 
     private final Fragment mFragment;
-    private final  MetricsFeatureProvider mMetricsFeatureProvider;
+    private final MetricsFeatureProvider mMetricsFeatureProvider;
     private final StorageVolumeProvider mSvp;
     private VolumeInfo mVolume;
     private int mUserId;
@@ -225,7 +225,7 @@
 
     private static Drawable applyTint(Context context, Drawable icon) {
         TypedArray array =
-                context.obtainStyledAttributes(new int[] {android.R.attr.colorControlNormal});
+                context.obtainStyledAttributes(new int[]{android.R.attr.colorControlNormal});
         icon = icon.mutate();
         icon.setTint(array.getColor(0, 0));
         array.recycle();
@@ -235,13 +235,13 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         mScreen = screen;
-        mPhotoPreference = (StorageItemPreference) screen.findPreference(PHOTO_KEY);
-        mAudioPreference = (StorageItemPreference) screen.findPreference(AUDIO_KEY);
-        mGamePreference = (StorageItemPreference) screen.findPreference(GAME_KEY);
-        mMoviesPreference = (StorageItemPreference) screen.findPreference(MOVIES_KEY);
-        mAppPreference = (StorageItemPreference) screen.findPreference(OTHER_APPS_KEY);
-        mSystemPreference = (StorageItemPreference) screen.findPreference(SYSTEM_KEY);
-        mFilePreference = (StorageItemPreference) screen.findPreference(FILES_KEY);
+        mPhotoPreference = screen.findPreference(PHOTO_KEY);
+        mAudioPreference = screen.findPreference(AUDIO_KEY);
+        mGamePreference = screen.findPreference(GAME_KEY);
+        mMoviesPreference = screen.findPreference(MOVIES_KEY);
+        mAppPreference = screen.findPreference(OTHER_APPS_KEY);
+        mSystemPreference = screen.findPreference(SYSTEM_KEY);
+        mFilePreference = screen.findPreference(FILES_KEY);
 
         setFilesPreferenceVisibility();
     }
diff --git a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
index 1dd3d98..d450a2a 100644
--- a/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/storage/StorageSummaryDonutPreferenceController.java
@@ -46,7 +46,6 @@
     /**
      * Converts a used storage amount to a formatted text.
      *
-     * @param context Context
      * @param usedBytes used bytes of storage
      * @return a formatted text.
      */
@@ -59,7 +58,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mSummary = (StorageSummaryDonutPreference) screen.findPreference("pref_summary");
+        mSummary = screen.findPreference("pref_summary");
         mSummary.setEnabled(true);
     }
 
@@ -94,7 +93,7 @@
     /**
      * Updates the state of the donut preference for the next update.
      *
-     * @param used Total number of used bytes on the summarized volume.
+     * @param used  Total number of used bytes on the summarized volume.
      * @param total Total number of bytes on the summarized volume.
      */
     public void updateBytes(long used, long total) {
diff --git a/src/com/android/settings/display/NightModePreferenceController.java b/src/com/android/settings/display/NightModePreferenceController.java
index 5846a65..a4d96f6 100644
--- a/src/com/android/settings/display/NightModePreferenceController.java
+++ b/src/com/android/settings/display/NightModePreferenceController.java
@@ -52,8 +52,7 @@
             setVisible(screen, KEY_NIGHT_MODE, false /* visible */);
             return;
         }
-        ListPreference mNightModePreference = (ListPreference) screen.findPreference(
-                KEY_NIGHT_MODE);
+        final ListPreference mNightModePreference = screen.findPreference(KEY_NIGHT_MODE);
         if (mNightModePreference != null) {
             final UiModeManager uiManager =
                     (UiModeManager) mContext.getSystemService(UI_MODE_SERVICE);
diff --git a/src/com/android/settings/dream/StartNowPreferenceController.java b/src/com/android/settings/dream/StartNowPreferenceController.java
index 9e45ea3..0541bca 100644
--- a/src/com/android/settings/dream/StartNowPreferenceController.java
+++ b/src/com/android/settings/dream/StartNowPreferenceController.java
@@ -54,8 +54,8 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
-        Button startButton = (Button)pref.findViewById(R.id.dream_start_now_button);
+        LayoutPreference pref = screen.findPreference(getPreferenceKey());
+        Button startButton = pref.findViewById(R.id.dream_start_now_button);
         startButton.setOnClickListener(v -> mBackend.startDreaming());
     }
 
@@ -63,7 +63,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
 
-        Button startButton = (Button)((LayoutPreference)preference)
+        Button startButton = ((LayoutPreference) preference)
                 .findViewById(R.id.dream_start_now_button);
         startButton.setEnabled(mBackend.getWhenToDreamSetting() != DreamBackend.NEVER);
     }
diff --git a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
index e2d1c53..5366ba1 100644
--- a/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryAppListPreferenceController.java
@@ -143,7 +143,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPrefContext = screen.getContext();
-        mAppListGroup = (PreferenceGroup) screen.findPreference(mPreferenceKey);
+        mAppListGroup = screen.findPreference(mPreferenceKey);
     }
 
     @Override
diff --git a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
index ce85be8..c4da670 100644
--- a/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceController.java
@@ -80,7 +80,9 @@
         }
         CharSequence label;
         final BidiFormatter formatter = BidiFormatter.getInstance();
-        if (info.remainingLabel == null) {
+        if (!info.discharging && info.chargeLabel != null) {
+            label = info.chargeLabel;
+        } else if (info.remainingLabel == null) {
             label = info.batteryPercentString;
         } else {
             label = context.getString(R.string.power_remaining_settings_home_page,
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
index 80a72e6..bb12d1a 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverButtonPreferenceController.java
@@ -72,7 +72,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (TwoStateButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/GesturePreferenceController.java b/src/com/android/settings/gestures/GesturePreferenceController.java
index a4274bf..d7b386a 100644
--- a/src/com/android/settings/gestures/GesturePreferenceController.java
+++ b/src/com/android/settings/gestures/GesturePreferenceController.java
@@ -51,7 +51,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+            mVideoPreference = screen.findPreference(getVideoPrefKey());
         }
     }
 
diff --git a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
index d22e42a..04f7e476 100644
--- a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
@@ -45,9 +45,11 @@
         implements RadioButtonPreference.OnClickListener, LifecycleObserver, OnSaveInstanceState,
         OnResume, OnPause, OnCreate, PreferenceControllerMixin {
 
-    @VisibleForTesting static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
+    @VisibleForTesting
+    static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
 
-    @VisibleForTesting static final String KEY_MUTE = "prevent_ringing_option_mute";
+    @VisibleForTesting
+    static final String KEY_MUTE = "prevent_ringing_option_mute";
 
     private final String KEY_VIDEO_PAUSED = "key_video_paused";
     private final String PREF_KEY_VIDEO = "gesture_prevent_ringing_video";
@@ -57,9 +59,12 @@
     private VideoPreference mVideoPreference;
     private boolean mVideoPaused;
 
-    @VisibleForTesting PreferenceCategory mPreferenceCategory;
-    @VisibleForTesting RadioButtonPreference mVibratePref;
-    @VisibleForTesting RadioButtonPreference mMutePref;
+    @VisibleForTesting
+    PreferenceCategory mPreferenceCategory;
+    @VisibleForTesting
+    RadioButtonPreference mVibratePref;
+    @VisibleForTesting
+    RadioButtonPreference mMutePref;
 
     private SettingObserver mSettingObserver;
 
@@ -75,17 +80,18 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        if (isAvailable()) {
-            mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
-            mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
-            mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
-
-            if (mPreferenceCategory != null) {
-                mSettingObserver = new SettingObserver(mPreferenceCategory);
-            }
-
-            mVideoPreference = (VideoPreference) screen.findPreference(getVideoPrefKey());
+        if (!isAvailable()) {
+            return;
         }
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
+        mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
+        mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
+
+        if (mPreferenceCategory != null) {
+            mSettingObserver = new SettingObserver(mPreferenceCategory);
+        }
+
+        mVideoPreference = screen.findPreference(getVideoPrefKey());
     }
 
     @Override
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
index b94cfff..35ff2ec 100644
--- a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -35,13 +35,14 @@
 import com.android.settingslib.widget.LayoutPreference;
 
 public class PreventRingingSwitchPreferenceController extends AbstractPreferenceController
-    implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
+        implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
 
     private static final String KEY = "gesture_prevent_ringing_switch";
     private final Context mContext;
     private SettingObserver mSettingObserver;
 
-    @VisibleForTesting SwitchBar mSwitch;
+    @VisibleForTesting
+    SwitchBar mSwitch;
 
     public PreventRingingSwitchPreferenceController(Context context) {
         super(context);
@@ -57,7 +58,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+            LayoutPreference pref = screen.findPreference(getPreferenceKey());
             if (pref != null) {
                 mSettingObserver = new SettingObserver(pref);
                 mSwitch = pref.findViewById(R.id.switch_bar);
diff --git a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
index a43fad1..96a3580 100644
--- a/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/WakeScreenGesturePreferenceController.java
@@ -53,7 +53,18 @@
                 || !mFeatureProvider.isSupported(mContext)) {
             return UNSUPPORTED_ON_DEVICE;
         }
-        return mFeatureProvider.isEnabled(mContext) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
+
+        if (!mFeatureProvider.isEnabled(mContext)) {
+            return CONDITIONALLY_UNAVAILABLE;
+        }
+
+        return getAmbientConfig().alwaysOnEnabled(mUserId)
+                ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+    }
+
+    @Override
+    protected boolean canHandleClicks() {
+        return getAmbientConfig().alwaysOnEnabled(mUserId);
     }
 
     @Override
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
index 43ff537..5f95de4 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/DndConditionCardController.java
@@ -23,6 +23,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.provider.Settings;
+import android.service.notification.ZenModeConfig;
 
 import androidx.annotation.VisibleForTesting;
 
@@ -97,7 +98,7 @@
                 .setName(mAppContext.getPackageName() + "/"
                         + mAppContext.getText(R.string.condition_zen_title))
                 .setTitleText(mAppContext.getText(R.string.condition_zen_title).toString())
-                .setSummaryText(mAppContext.getText(R.string.condition_zen_summary).toString())
+                .setSummaryText(getSummary())
                 .setIconDrawable(mAppContext.getDrawable(R.drawable.ic_do_not_disturb_on_24dp))
                 .setViewType(ConditionContextualCardRenderer.VIEW_TYPE_HALF_WIDTH)
                 .build();
@@ -112,4 +113,11 @@
             }
         }
     }
+
+    private String getSummary() {
+        if (ZenModeConfig.areAllZenBehaviorSoundsMuted(mNotificationManager.getZenModeConfig())) {
+            return mAppContext.getText(R.string.condition_zen_summary_phone_muted).toString();
+        }
+        return mAppContext.getText(R.string.condition_zen_summary_with_exceptions).toString();
+    }
 }
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 5673948..0156ac6 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -37,7 +37,6 @@
 import com.android.settings.SubSettings;
 import com.android.settings.Utils;
 import com.android.settings.bluetooth.BluetoothDeviceDetailsFragment;
-import com.android.settings.bluetooth.BluetoothPairingDetail;
 import com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment;
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.slices.CustomSliceRegistry;
@@ -127,11 +126,6 @@
             listBuilder.addRow(rows.get(i));
         }
 
-        // Add "Pair new device" if need.
-        if (rows.size() < DEFAULT_EXPANDED_ROW_COUNT) {
-            listBuilder.addRow(getPairNewDeviceRowBuilder());
-        }
-
         return listBuilder.build();
     }
 
@@ -268,26 +262,4 @@
         return mContext.getResources().getQuantityString(R.plurals.show_bluetooth_devices,
                 deviceCount, deviceCount);
     }
-
-    private ListBuilder.RowBuilder getPairNewDeviceRowBuilder() {
-        final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title);
-        final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add);
-        final SliceAction sliceAction = SliceAction.createDeeplink(
-                getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title);
-
-        return new ListBuilder.RowBuilder()
-                .setTitleItem(icon, ListBuilder.ICON_IMAGE)
-                .setTitle(title)
-                .setPrimaryAction(sliceAction);
-    }
-
-    private PendingIntent getPairNewDeviceIntent() {
-        final Intent intent = new SubSettingLauncher(mContext)
-                .setDestination(BluetoothPairingDetail.class.getName())
-                .setTitleRes(R.string.bluetooth_pairing_page_title)
-                .setSourceMetricsCategory(SettingsEnums.BLUETOOTH_PAIRING)
-                .toIntent();
-
-        return PendingIntent.getActivity(mContext, 0  /* requestCode */, intent, 0  /* flags */);
-    }
 }
diff --git a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
index 4be70d5..4a409e1 100644
--- a/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
+++ b/src/com/android/settings/inputmethod/UserDictionaryListPreferenceController.java
@@ -79,7 +79,7 @@
     @NonNull
     public static TreeSet<String> getUserDictionaryLocalesSet(Context context) {
         final Cursor cursor = context.getContentResolver().query(
-                UserDictionary.Words.CONTENT_URI, new String[] {UserDictionary.Words.LOCALE},
+                UserDictionary.Words.CONTENT_URI, new String[]{UserDictionary.Words.LOCALE},
                 null, null, null);
         final TreeSet<String> localeSet = new TreeSet<>();
         if (cursor == null) {
@@ -124,14 +124,14 @@
         // enabled subtypes. If we already have the locale-without-country version of the system
         // locale, we don't add the system locale to avoid confusion even though it's technically
         // correct to add it.
-        if (!localeSet.contains(Locale.getDefault().getLanguage().toString())) {
+        if (!localeSet.contains(Locale.getDefault().getLanguage())) {
             localeSet.add(Locale.getDefault().toString());
         }
 
         return localeSet;
     }
 
-    @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+    @VisibleForTesting
     TreeSet<String> getUserDictLocalesSet(Context context) {
         return getUserDictionaryLocalesSet(context);
     }
@@ -140,7 +140,6 @@
      * Creates the entries that allow the user to go into the user dictionary for each locale.
      */
     private void createUserDictSettings() {
-
         final TreeSet<String> localeSet = getUserDictLocalesSet(mContext);
         final int prefCount = mScreen.getPreferenceCount();
         String prefKey;
@@ -160,8 +159,8 @@
         if (prefCount > 0) {
             for (int i = prefCount - 1; i >= 0; i--) {
                 prefKey = mScreen.getPreference(i).getKey();
-                if (KEY_ALL_LANGUAGE.equals(prefKey)) {
-                    prefKey = "";
+                if (TextUtils.isEmpty(prefKey) || TextUtils.equals(KEY_ALL_LANGUAGE, prefKey)) {
+                    continue;
                 }
                 if (!localeSet.isEmpty() && localeSet.contains(prefKey)) {
                     localeSet.remove(prefKey);
diff --git a/src/com/android/settings/location/LocationForWorkPreferenceController.java b/src/com/android/settings/location/LocationForWorkPreferenceController.java
index 580f888..1208ea2 100644
--- a/src/com/android/settings/location/LocationForWorkPreferenceController.java
+++ b/src/com/android/settings/location/LocationForWorkPreferenceController.java
@@ -57,8 +57,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference =
-                (RestrictedSwitchPreference) screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
+        mPreference = screen.findPreference(KEY_MANAGED_PROFILE_SWITCH);
     }
 
     @Override
diff --git a/src/com/android/settings/location/LocationServicePreferenceController.java b/src/com/android/settings/location/LocationServicePreferenceController.java
index 43d35f1..e604261 100644
--- a/src/com/android/settings/location/LocationServicePreferenceController.java
+++ b/src/com/android/settings/location/LocationServicePreferenceController.java
@@ -84,8 +84,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mCategoryLocationServices =
-                (PreferenceCategory) screen.findPreference(KEY_LOCATION_SERVICES);
+        mCategoryLocationServices = screen.findPreference(KEY_LOCATION_SERVICES);
     }
 
     @Override
diff --git a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
index 214dcd5..44d600e 100644
--- a/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
+++ b/src/com/android/settings/location/RecentLocationAccessPreferenceController.java
@@ -69,8 +69,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        final LayoutPreference preference = (LayoutPreference) screen.findPreference(
-                KEY_APPS_DASHBOARD);
+        final LayoutPreference preference = screen.findPreference(KEY_APPS_DASHBOARD);
         final View view = preference.findViewById(R.id.app_entities_header);
         mController = AppEntitiesHeaderController.newInstance(mContext, view)
                 .setHeaderTitleRes(R.string.location_category_recent_location_access)
diff --git a/src/com/android/settings/network/AirplaneModePreferenceController.java b/src/com/android/settings/network/AirplaneModePreferenceController.java
index 1490e8a..5c1913b 100644
--- a/src/com/android/settings/network/AirplaneModePreferenceController.java
+++ b/src/com/android/settings/network/AirplaneModePreferenceController.java
@@ -81,7 +81,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mAirplaneModePreference = (SwitchPreference) screen.findPreference(getPreferenceKey());
+            mAirplaneModePreference = screen.findPreference(getPreferenceKey());
         }
     }
 
diff --git a/src/com/android/settings/network/MultiNetworkHeaderController.java b/src/com/android/settings/network/MultiNetworkHeaderController.java
index 938c753..ba201a5 100644
--- a/src/com/android/settings/network/MultiNetworkHeaderController.java
+++ b/src/com/android/settings/network/MultiNetworkHeaderController.java
@@ -65,7 +65,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(mPreferenceKey);
+        mPreferenceCategory = screen.findPreference(mPreferenceKey);
         mPreferenceCategory.setVisible(isAvailable());
         mWifiController.displayPreference(screen);
         mSubscriptionsController.displayPreference(screen);
diff --git a/src/com/android/settings/network/SubscriptionUtil.java b/src/com/android/settings/network/SubscriptionUtil.java
index 237e08a..224fc41 100644
--- a/src/com/android/settings/network/SubscriptionUtil.java
+++ b/src/com/android/settings/network/SubscriptionUtil.java
@@ -38,7 +38,7 @@
         if (sResultsForTesting != null) {
             return sResultsForTesting;
         }
-        List<SubscriptionInfo> subscriptions = manager.getAvailableSubscriptionInfoList();
+        List<SubscriptionInfo> subscriptions = manager.getSelectableSubscriptionInfoList();
         if (subscriptions == null) {
             subscriptions = new ArrayList<>();
         }
diff --git a/src/com/android/settings/network/SubscriptionsPreferenceController.java b/src/com/android/settings/network/SubscriptionsPreferenceController.java
index a639782..b6e8f58 100644
--- a/src/com/android/settings/network/SubscriptionsPreferenceController.java
+++ b/src/com/android/settings/network/SubscriptionsPreferenceController.java
@@ -107,7 +107,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+        mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
         update();
     }
 
@@ -129,7 +129,7 @@
         mSubscriptionPreferences = new ArrayMap<>();
 
         int order = mStartOrder;
-        for (SubscriptionInfo info :  SubscriptionUtil.getAvailableSubscriptions(mManager)) {
+        for (SubscriptionInfo info : SubscriptionUtil.getAvailableSubscriptions(mManager)) {
             final int subId = info.getSubscriptionId();
             Preference pref = existingPrefs.remove(subId);
             if (pref == null) {
@@ -209,7 +209,6 @@
     }
 
     /**
-     *
      * @return true if there are at least 2 available subscriptions.
      */
     @Override
diff --git a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
index 9c5a98e..94b1761 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -54,6 +54,8 @@
     public int getAvailabilityStatus(int subId) {
         boolean visible;
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             visible = false;
         } else if (carrierConfig == null) {
@@ -63,8 +65,8 @@
             visible = false;
         } else if (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
-                && !mTelephonyManager.getServiceState().getRoaming()
-                && mTelephonyManager.getServiceState().getDataRegState()
+                && !telephonyManager.getServiceState().getRoaming()
+                && telephonyManager.getServiceState().getDataRegState()
                 == ServiceState.STATE_IN_SERVICE) {
             visible = false;
         } else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
@@ -175,18 +177,21 @@
                         R.array.enabled_networks_tdscdma_choices);
                 preference.setEntryValues(
                         R.array.enabled_networks_tdscdma_values);
-            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
+            } else if (carrierConfig != null
+                    && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)
                     && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
                 preference.setEntries(R.array.enabled_networks_except_gsm_lte_choices);
                 preference.setEntryValues(R.array.enabled_networks_except_gsm_lte_values);
-            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
+            } else if (carrierConfig != null
+                    && !carrierConfig.getBoolean(CarrierConfigManager.KEY_PREFER_2G_BOOL)) {
                 int select = mShow4GForLTE
                         ? R.array.enabled_networks_except_gsm_4g_choices
                         : R.array.enabled_networks_except_gsm_choices;
                 preference.setEntries(select);
                 preference.setEntryValues(
                         R.array.enabled_networks_except_gsm_values);
-            } else if (!carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
+            } else if (carrierConfig != null
+                    && !carrierConfig.getBoolean(CarrierConfigManager.KEY_LTE_ENABLED_BOOL)) {
                 preference.setEntries(
                         R.array.enabled_networks_except_lte_choices);
                 preference.setEntryValues(
diff --git a/src/com/android/settings/network/telephony/MobileNetworkActivity.java b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
index 821b1e1e..3c0940d 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkActivity.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkActivity.java
@@ -160,7 +160,7 @@
             final int subId = intent.getIntExtra(Settings.EXTRA_SUB_ID, SUB_ID_NULL);
             if (subId != SUB_ID_NULL) {
                 for (SubscriptionInfo subscription :
-                        mSubscriptionManager.getAvailableSubscriptionInfoList()) {
+                        mSubscriptionManager.getSelectableSubscriptionInfoList()) {
                     if (subscription.getSubscriptionId() == subId) {
                         return subscription;
                     }
diff --git a/src/com/android/settings/network/telephony/MobileNetworkUtils.java b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
index 8e44dd4..42c1b93 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkUtils.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkUtils.java
@@ -347,6 +347,7 @@
         final PersistableBundle carrierConfig = context.getSystemService(
                 CarrierConfigManager.class).getConfigForSubId(subId);
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
+                || carrierConfig == null
                 || !carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_OPERATOR_SELECTION_EXPAND_BOOL)
                 || (carrierConfig.getBoolean(CarrierConfigManager.KEY_CSP_ENABLED_BOOL)
diff --git a/src/com/android/settings/network/telephony/NetworkSelectSettings.java b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
index ff04583..2495ca5 100644
--- a/src/com/android/settings/network/telephony/NetworkSelectSettings.java
+++ b/src/com/android/settings/network/telephony/NetworkSelectSettings.java
@@ -122,7 +122,7 @@
 
         final Activity activity = getActivity();
         if (activity != null) {
-            mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+            mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
                     .findViewById(R.id.progress_bar_animation);
             setProgressBarVisible(false);
         }
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index 27a7bce..294f05f 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -30,7 +30,6 @@
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneConstants;
 import com.android.settings.R;
-import com.android.settings.core.BasePreferenceController;
 
 /**
  * Preference controller for "Preferred network mode"
@@ -51,6 +50,8 @@
     @Override
     public int getAvailabilityStatus(int subId) {
         final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
         boolean visible;
         if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             visible = false;
@@ -61,8 +62,8 @@
             visible = false;
         } else if (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_HIDE_PREFERRED_NETWORK_TYPE_BOOL)
-                && !mTelephonyManager.getServiceState().getRoaming()
-                && mTelephonyManager.getServiceState().getDataRegState()
+                && !telephonyManager.getServiceState().getRoaming()
+                && telephonyManager.getServiceState().getDataRegState()
                 == ServiceState.STATE_IN_SERVICE) {
             visible = false;
         } else if (carrierConfig.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL)) {
diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
index 44984e6..8c32df0 100644
--- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java
@@ -34,7 +34,6 @@
 import androidx.preference.SwitchPreference;
 
 import com.android.ims.ImsManager;
-import com.android.settings.core.TogglePreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -49,7 +48,6 @@
     private Preference mPreference;
     private TelephonyManager mTelephonyManager;
     private CarrierConfigManager mCarrierConfigManager;
-    private PersistableBundle mCarrierConfig;
     @VisibleForTesting
     ImsManager mImsManager;
     private PhoneCallStateListener mPhoneStateListener;
@@ -67,7 +65,7 @@
         return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                 && MobileNetworkUtils.isWifiCallingEnabled(mContext,
                 SubscriptionManager.getPhoneId(subId))
-                && isVideoCallEnabled()
+                && isVideoCallEnabled(subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
@@ -94,7 +92,7 @@
     public void updateState(Preference preference) {
         super.updateState(preference);
         final SwitchPreference switchPreference = (SwitchPreference) preference;
-        final boolean videoCallEnabled = isVideoCallEnabled();
+        final boolean videoCallEnabled = isVideoCallEnabled(mSubId, mImsManager);
         switchPreference.setVisible(videoCallEnabled);
         if (videoCallEnabled) {
             final boolean is4gLteEnabled = mImsManager.isEnhanced4gLteModeSettingEnabledByUser()
@@ -119,7 +117,6 @@
     public VideoCallingPreferenceController init(int subId) {
         mSubId = subId;
         mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
-        mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
         if (mSubId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
             mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
         }
@@ -127,15 +124,25 @@
         return this;
     }
 
+    private boolean isVideoCallEnabled(int subId) {
+        final ImsManager imsManager = subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+                ? ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(subId))
+                : null;
+        return isVideoCallEnabled(subId, imsManager);
+    }
+
     @VisibleForTesting
-    boolean isVideoCallEnabled() {
-        return mCarrierConfig != null && mImsManager != null
-                && mImsManager.isVtEnabledByPlatform()
-                && mImsManager.isVtProvisionedOnDevice()
-                && MobileNetworkUtils.isImsServiceStateReady(mImsManager)
-                && (mCarrierConfig.getBoolean(
+    boolean isVideoCallEnabled(int subId, ImsManager imsManager) {
+        final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(subId);
+        final TelephonyManager telephonyManager = TelephonyManager
+                .from(mContext).createForSubscriptionId(subId);
+        return carrierConfig != null && imsManager != null
+                && imsManager.isVtEnabledByPlatform()
+                && imsManager.isVtProvisionedOnDevice()
+                && MobileNetworkUtils.isImsServiceStateReady(imsManager)
+                && (carrierConfig.getBoolean(
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS)
-                || mTelephonyManager.isDataEnabled());
+                || telephonyManager.isDataEnabled());
     }
 
     @Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 26c4d06..dfa1271 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -67,7 +67,7 @@
     public int getAvailabilityStatus(int subId) {
         return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                 && MobileNetworkUtils.isWifiCallingEnabled(mContext,
-                SubscriptionManager.getPhoneId(mSubId))
+                SubscriptionManager.getPhoneId(subId))
                 ? AVAILABLE
                 : UNSUPPORTED_ON_DEVICE;
     }
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
index a5498bc..ea7d82f 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaBasePreferenceController.java
@@ -29,8 +29,8 @@
 import androidx.preference.PreferenceManager;
 import androidx.preference.PreferenceScreen;
 
-import com.android.settings.core.BasePreferenceController;
 import com.android.settings.network.telephony.MobileNetworkUtils;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
 import com.android.settingslib.core.lifecycle.LifecycleObserver;
 import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.core.lifecycle.events.OnStop;
@@ -38,7 +38,7 @@
 /**
  * Preference controller related to CDMA category
  */
-public abstract class CdmaBasePreferenceController extends BasePreferenceController
+public abstract class CdmaBasePreferenceController extends TelephonyBasePreferenceController
         implements LifecycleObserver, OnStart, OnStop {
 
     protected Preference mPreference;
@@ -64,8 +64,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.isCdmaOptions(mContext, mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.isCdmaOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
index c653890..e6c1c22 100644
--- a/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
+++ b/src/com/android/settings/network/telephony/cdma/CdmaSubscriptionPreferenceController.java
@@ -44,8 +44,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.isCdmaOptions(mContext, mSubId) && deviceSupportsNvAndRuim()
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.isCdmaOptions(mContext, subId) && deviceSupportsNvAndRuim()
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index fdc9f7f..7db9df0 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -29,9 +29,9 @@
 
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
-import com.android.settings.core.TogglePreferenceController;
 import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyTogglePreferenceController;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -39,7 +39,7 @@
 /**
  * Preference controller for "Auto Select Network"
  */
-public class AutoSelectPreferenceController extends TogglePreferenceController {
+public class AutoSelectPreferenceController extends TelephonyTogglePreferenceController {
 
     private int mSubId;
     private TelephonyManager mTelephonyManager;
@@ -54,8 +54,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext,mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
@@ -112,8 +112,10 @@
         mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
         final PersistableBundle carrierConfig = mContext.getSystemService(
                 CarrierConfigManager.class).getConfigForSubId(mSubId);
-        mOnlyAutoSelectInHome = carrierConfig.getBoolean(
-                CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL);
+        mOnlyAutoSelectInHome = carrierConfig != null
+                ? carrierConfig.getBoolean(
+                CarrierConfigManager.KEY_ONLY_AUTO_SELECT_IN_HOME_NETWORK_BOOL)
+                : false;
 
         return this;
     }
diff --git a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
index e8a392a..9ac0d12 100644
--- a/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/OpenNetworkSelectPagePreferenceController.java
@@ -33,11 +33,13 @@
 import com.android.settings.core.SubSettingLauncher;
 import com.android.settings.network.telephony.MobileNetworkUtils;
 import com.android.settings.network.telephony.NetworkSelectSettings;
+import com.android.settings.network.telephony.TelephonyBasePreferenceController;
 
 /**
  * Preference controller for "Open network select"
  */
-public class OpenNetworkSelectPagePreferenceController extends BasePreferenceController implements
+public class OpenNetworkSelectPagePreferenceController extends
+        TelephonyBasePreferenceController implements
         AutoSelectPreferenceController.OnNetworkSelectModeListener {
 
     private int mSubId;
@@ -51,8 +53,8 @@
     }
 
     @Override
-    public int getAvailabilityStatus() {
-        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, mSubId)
+    public int getAvailabilityStatus(int subId) {
+        return MobileNetworkUtils.shouldDisplayNetworkSelectOptions(mContext, subId)
                 ? AVAILABLE
                 : CONDITIONALLY_UNAVAILABLE;
     }
diff --git a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
index b784dc5..15c15aa 100644
--- a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
+++ b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
@@ -47,8 +47,7 @@
             return;
         }
 
-        final RestrictedPreference restrictedPreference =
-                (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        final RestrictedPreference restrictedPreference = screen.findPreference(getPreferenceKey());
         mAndroidBeamEnabler = new AndroidBeamEnabler(mContext, restrictedPreference);
     }
 
@@ -57,7 +56,7 @@
     public int getAvailabilityStatus() {
         PackageManager pm = mContext.getPackageManager();
         if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
-                return UNSUPPORTED_ON_DEVICE;
+            return UNSUPPORTED_ON_DEVICE;
         }
         return mNfcAdapter != null
                 ? AVAILABLE
diff --git a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
index b0c9168..b02608e 100644
--- a/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcForegroundPreferenceController.java
@@ -81,16 +81,16 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (DropDownPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference == null) {
             return;
         }
 
-        mPreference.setEntries(new CharSequence[] {
+        mPreference.setEntries(new CharSequence[]{
                 mContext.getText(R.string.nfc_payment_favor_open),
                 mContext.getText(R.string.nfc_payment_favor_default)
         });
-        mPreference.setEntryValues(new CharSequence[] {"1", "0"});
+        mPreference.setEntryValues(new CharSequence[]{"1", "0"});
     }
 
     @Override
@@ -124,7 +124,7 @@
         mPaymentBackend.setForegroundMode(foregroundMode);
         mMetricsFeatureProvider.action(mContext,
                 foregroundMode ? SettingsEnums.ACTION_NFC_PAYMENT_FOREGROUND_SETTING
-                               : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
+                        : SettingsEnums.ACTION_NFC_PAYMENT_ALWAYS_SETTING);
         return true;
     }
 
diff --git a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
index a7dd2a6..5215243 100644
--- a/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
+++ b/src/com/android/settings/nfc/NfcPaymentPreferenceController.java
@@ -98,7 +98,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (NfcPaymentPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         if (mPreference != null) {
             mPreference.initialize(this);
         }
diff --git a/src/com/android/settings/nfc/SecureNfcPreferenceController.java b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
index 2c23672..cbff3ea 100644
--- a/src/com/android/settings/nfc/SecureNfcPreferenceController.java
+++ b/src/com/android/settings/nfc/SecureNfcPreferenceController.java
@@ -17,7 +17,6 @@
 
 import android.content.Context;
 import android.nfc.NfcAdapter;
-import android.os.SystemProperties;
 
 import androidx.preference.PreferenceScreen;
 import androidx.preference.SwitchPreference;
@@ -30,7 +29,6 @@
 public class SecureNfcPreferenceController extends TogglePreferenceController
         implements LifecycleObserver, OnResume, OnPause {
 
-    public static final String KEY_TOGGLE_NFC = "nfc_secure_setting";
     private final NfcAdapter mNfcAdapter;
     private SecureNfcEnabler mSecureNfcEnabler;
 
@@ -47,8 +45,7 @@
             return;
         }
 
-        final SwitchPreference switchPreference =
-                (SwitchPreference) screen.findPreference(getPreferenceKey());
+        final SwitchPreference switchPreference = screen.findPreference(getPreferenceKey());
 
         mSecureNfcEnabler = new SecureNfcEnabler(mContext, switchPreference);
     }
@@ -69,8 +66,9 @@
         if (mNfcAdapter == null) {
             return UNSUPPORTED_ON_DEVICE;
         }
-        return mNfcAdapter.deviceSupportsNfcSecure() ? AVAILABLE
-            : UNSUPPORTED_ON_DEVICE;
+        return mNfcAdapter.deviceSupportsNfcSecure()
+                ? AVAILABLE
+                : UNSUPPORTED_ON_DEVICE;
     }
 
     @Override
diff --git a/src/com/android/settings/notification/AppNotificationSettings.java b/src/com/android/settings/notification/AppNotificationSettings.java
index 3977e45..5553dd7 100644
--- a/src/com/android/settings/notification/AppNotificationSettings.java
+++ b/src/com/android/settings/notification/AppNotificationSettings.java
@@ -51,6 +51,8 @@
     private static String KEY_ADVANCED_CATEGORY = "app_advanced";
     private static String KEY_BADGE = "badge";
     private static String KEY_APP_LINK = "app_link";
+    private static String KEY_BUBBLE = "bubble";
+    private static String[] LEGACY_NON_ADVANCED_KEYS = {KEY_BADGE, KEY_APP_LINK, KEY_BUBBLE};
 
     private List<NotificationChannelGroup> mChannelGroupList;
 
@@ -65,21 +67,16 @@
         final PreferenceScreen screen = getPreferenceScreen();
         if (mShowLegacyChannelConfig && screen != null) {
             // if showing legacy settings, pull advanced settings out of the advanced category
-            Preference badge = findPreference(KEY_BADGE);
-            Preference appLink = findPreference(KEY_APP_LINK);
             PreferenceGroup advanced = (PreferenceGroup) findPreference(KEY_ADVANCED_CATEGORY);
             removePreference(KEY_ADVANCED_CATEGORY);
-            if (badge != null) {
-                if (advanced != null) {
-                    advanced.removePreference(badge);
+            if (advanced != null) {
+                for (String key : LEGACY_NON_ADVANCED_KEYS) {
+                    Preference pref = advanced.findPreference(key);
+                    advanced.removePreference(pref);
+                    if (pref != null) {
+                        screen.addPreference(pref);
+                    }
                 }
-                screen.addPreference(badge);
-            }
-            if (appLink != null) {
-                if (advanced != null) {
-                    advanced.removePreference(appLink);
-                }
-                screen.addPreference(appLink);
             }
         }
     }
@@ -255,7 +252,7 @@
                 int childCount = groupGroup.getPreferenceCount();
                 for (int i = 0; i < childCount; i++) {
                     Preference pref = groupGroup.getPreference(i);
-                    if (pref instanceof MasterCheckBoxPreference) {
+                    if (pref instanceof ChannelSummaryPreference) {
                         toRemove.add(pref);
                     }
                 }
diff --git a/src/com/android/settings/notification/BootSoundPreferenceController.java b/src/com/android/settings/notification/BootSoundPreferenceController.java
index a687163..2e7327d 100644
--- a/src/com/android/settings/notification/BootSoundPreferenceController.java
+++ b/src/com/android/settings/notification/BootSoundPreferenceController.java
@@ -43,7 +43,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            SwitchPreference preference = (SwitchPreference) screen.findPreference(KEY_BOOT_SOUNDS);
+            SwitchPreference preference = screen.findPreference(KEY_BOOT_SOUNDS);
             preference.setChecked(SystemProperties.getBoolean(PROPERTY_BOOT_SOUNDS, true));
         }
     }
diff --git a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
index 1563bc4..1c024e3 100644
--- a/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
+++ b/src/com/android/settings/notification/LockScreenNotificationPreferenceController.java
@@ -92,13 +92,13 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mLockscreen = (RestrictedListPreference) screen.findPreference(mSettingKey);
+        mLockscreen = screen.findPreference(mSettingKey);
         if (mLockscreen == null) {
             Log.i(TAG, "Preference not found: " + mSettingKey);
             return;
         }
         if (mProfileUserId != UserHandle.USER_NULL) {
-            mLockscreenProfile = (RestrictedListPreference) screen.findPreference(mWorkSettingKey);
+            mLockscreenProfile = screen.findPreference(mWorkSettingKey);
             mLockscreenProfile.setRequiresActiveUnlockedProfile(true);
             mLockscreenProfile.setProfileUserId(mProfileUserId);
         } else {
diff --git a/src/com/android/settings/notification/NotificationSettingsBase.java b/src/com/android/settings/notification/NotificationSettingsBase.java
index 19aeb51..b9fabb6 100644
--- a/src/com/android/settings/notification/NotificationSettingsBase.java
+++ b/src/com/android/settings/notification/NotificationSettingsBase.java
@@ -309,7 +309,9 @@
                         return true;
                     }
                 });
-        parent.addPreference(channelPref);
+        if (parent.findPreference(channelPref.getKey()) == null) {
+            parent.addPreference(channelPref);
+        }
         return channelPref;
     }
 
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1c8c88e..1ec3c4f 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -118,7 +118,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
         mSeeAllPref = screen.findPreference(KEY_SEE_ALL);
         mDivider = screen.findPreference(KEY_DIVIDER);
         super.displayPreference(screen);
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index d0b098c..e53a560 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -67,7 +67,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
 
-        mPreference = (NotificationSoundPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     public void updateState(Preference preference) {
diff --git a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
index 32f2aa6..fff9aaf 100644
--- a/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
+++ b/src/com/android/settings/notification/VolumeSeekBarPreferenceController.java
@@ -54,7 +54,7 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         if (isAvailable()) {
-            mPreference = (VolumeSeekBarPreference) screen.findPreference(getPreferenceKey());
+            mPreference = screen.findPreference(getPreferenceKey());
             mPreference.setCallback(mVolumePreferenceCallback);
             mPreference.setStream(getAudioStream());
             mPreference.setMuteIcon(getMuteIcon());
diff --git a/src/com/android/settings/notification/WorkSoundPreferenceController.java b/src/com/android/settings/notification/WorkSoundPreferenceController.java
index c708b37..e23d9ea 100644
--- a/src/com/android/settings/notification/WorkSoundPreferenceController.java
+++ b/src/com/android/settings/notification/WorkSoundPreferenceController.java
@@ -100,7 +100,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mWorkPreferenceCategory = (PreferenceGroup) screen.findPreference(KEY_WORK_CATEGORY);
+        mWorkPreferenceCategory = screen.findPreference(KEY_WORK_CATEGORY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
index e5ca754..807d944 100644
--- a/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
+++ b/src/com/android/settings/notification/ZenAutomaticRuleSwitchPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        LayoutPreference pref = (LayoutPreference) screen.findPreference(KEY);
+        LayoutPreference pref = screen.findPreference(KEY);
         mSwitchBar = pref.findViewById(R.id.switch_bar);
 
         if (mSwitchBar != null) {
diff --git a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
index 7da90c8..499bfbc 100644
--- a/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeAutomaticRulesPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
+        mPreferenceCategory = screen.findPreference(getPreferenceKey());
         mPreferenceCategory.setPersistent(false);
     }
 
diff --git a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
index 9872188..cec97f5 100644
--- a/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityCallsPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
index cfda367..752edf2 100644
--- a/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModePriorityMessagesPreferenceController.java
@@ -56,7 +56,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ListPreference) screen.findPreference(KEY);
+        mPreference = screen.findPreference(KEY);
     }
 
     @Override
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
index 07e3429..14285d6 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsAllPreferenceController.java
@@ -49,7 +49,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         mPreference.setOnRadioButtonClickListener(this);
     }
 
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
index 6948669..837f999 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsCustomPreferenceController.java
@@ -51,7 +51,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             launchCustomSettings();
diff --git a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
index 7f729c7..4a58c62 100644
--- a/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
+++ b/src/com/android/settings/notification/ZenModeVisEffectsNonePreferenceController.java
@@ -49,7 +49,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
         mPreference.setOnRadioButtonClickListener(this);
     }
 
diff --git a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
index e41d55f..527803df 100644
--- a/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleCustomPolicyPreferenceController.java
@@ -39,7 +39,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             setCustomPolicy();
diff --git a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
index da40e6c..b4036fa 100644
--- a/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleDefaultPolicyPreferenceController.java
@@ -40,7 +40,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnRadioButtonClickListener(p -> {
             mRule.setZenPolicy(null);
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
index 1c6874e..7b7eae2 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsAllPreferenceController.java
@@ -41,7 +41,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnRadioButtonClickListener(p -> {
             mMetricsFeatureProvider.action(mContext, SettingsEnums.ACTION_ZEN_SOUND_ONLY,
diff --git a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
index 3cdd86a..2314c5a 100644
--- a/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
+++ b/src/com/android/settings/notification/ZenRuleVisEffectsCustomPreferenceController.java
@@ -41,7 +41,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (ZenCustomRadioButtonPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
 
         mPreference.setOnGearClickListener(p -> {
             launchCustomSettings();
diff --git a/src/com/android/settings/panel/InternetConnectivityPanel.java b/src/com/android/settings/panel/InternetConnectivityPanel.java
index d20b75a..4e4fc0c 100644
--- a/src/com/android/settings/panel/InternetConnectivityPanel.java
+++ b/src/com/android/settings/panel/InternetConnectivityPanel.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.panel;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -64,4 +65,9 @@
     public Intent getSeeMoreIntent() {
         return new Intent(Settings.ACTION_WIRELESS_SETTINGS);
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_INTERNET_CONNECTIVITY;
+    }
 }
diff --git a/src/com/android/settings/panel/MediaOutputPanel.java b/src/com/android/settings/panel/MediaOutputPanel.java
index f7639d9..c42906d 100644
--- a/src/com/android/settings/panel/MediaOutputPanel.java
+++ b/src/com/android/settings/panel/MediaOutputPanel.java
@@ -19,6 +19,7 @@
 import static com.android.settings.media.MediaOutputSlice.MEDIA_PACKAGE_NAME;
 import static com.android.settings.slices.CustomSliceRegistry.MEDIA_OUTPUT_SLICE_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -71,4 +72,9 @@
     public Intent getSeeMoreIntent() {
         return null;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_MEDIA_OUTPUT;
+    }
 }
diff --git a/src/com/android/settings/panel/NfcPanel.java b/src/com/android/settings/panel/NfcPanel.java
index 70452a3..8fa41d9 100644
--- a/src/com/android/settings/panel/NfcPanel.java
+++ b/src/com/android/settings/panel/NfcPanel.java
@@ -50,4 +50,9 @@
         intent.setClassName(mContext.getPackageName(), SubSettings.class.getName());
         return intent;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_NFC;
+    }
 }
diff --git a/src/com/android/settings/panel/PanelContent.java b/src/com/android/settings/panel/PanelContent.java
index bd84c2f..496bac3 100644
--- a/src/com/android/settings/panel/PanelContent.java
+++ b/src/com/android/settings/panel/PanelContent.java
@@ -19,12 +19,14 @@
 import android.content.Intent;
 import android.net.Uri;
 
+import com.android.settingslib.core.instrumentation.Instrumentable;
+
 import java.util.List;
 
 /**
  * Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
  */
-public interface PanelContent {
+public interface PanelContent extends Instrumentable {
 
     /**
      * @return a string for the title of the Panel.
diff --git a/src/com/android/settings/panel/PanelFeatureProvider.java b/src/com/android/settings/panel/PanelFeatureProvider.java
index 5af5ac8..85e098d 100644
--- a/src/com/android/settings/panel/PanelFeatureProvider.java
+++ b/src/com/android/settings/panel/PanelFeatureProvider.java
@@ -21,7 +21,8 @@
 public interface PanelFeatureProvider {
 
     /**
-     * Returns {@link PanelContent} as specified by the {@code panelType} and {@code packageName}.
+     * Returns {@link PanelContent} as specified by the {@param panelType}, and
+     * {@param mediaPackageName}.
      */
-    PanelContent getPanel(Context context, String panelType, String packageName);
+    PanelContent getPanel(Context context, String panelType, String mediaPackageName);
 }
diff --git a/src/com/android/settings/panel/PanelFeatureProviderImpl.java b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
index c3d611d..6b096a1 100644
--- a/src/com/android/settings/panel/PanelFeatureProviderImpl.java
+++ b/src/com/android/settings/panel/PanelFeatureProviderImpl.java
@@ -24,7 +24,7 @@
 public class PanelFeatureProviderImpl implements PanelFeatureProvider {
 
     @Override
-    public PanelContent getPanel(Context context, String panelType, String packageName) {
+    public PanelContent getPanel(Context context, String panelType, String mediaPackageName) {
         switch (panelType) {
             case Settings.Panel.ACTION_INTERNET_CONNECTIVITY:
                 return InternetConnectivityPanel.create(context);
@@ -33,7 +33,7 @@
             case Settings.Panel.ACTION_NFC:
                 return NfcPanel.create(context);
             case ACTION_MEDIA_OUTPUT:
-                return MediaOutputPanel.create(context, packageName);
+                return MediaOutputPanel.create(context, mediaPackageName);
         }
 
         throw new IllegalStateException("No matching panel for: "  + panelType);
diff --git a/src/com/android/settings/panel/PanelFragment.java b/src/com/android/settings/panel/PanelFragment.java
index db0bf0e..a222d36 100644
--- a/src/com/android/settings/panel/PanelFragment.java
+++ b/src/com/android/settings/panel/PanelFragment.java
@@ -16,9 +16,9 @@
 
 package com.android.settings.panel;
 
-import android.content.Intent;
+import android.app.settings.SettingsEnums;
+import android.content.Context;
 import android.os.Bundle;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -35,6 +35,8 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
 import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
+import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
 
 public class PanelFragment extends Fragment {
 
@@ -45,15 +47,15 @@
     private Button mDoneButton;
     private RecyclerView mPanelSlices;
 
+    private PanelContent mPanel;
+    private final MetricsFeatureProvider mMetricsProvider;
+
     @VisibleForTesting
     PanelSlicesAdapter mAdapter;
 
-    private View.OnClickListener mDoneButtonListener = (v) -> {
-        Log.d(TAG, "Closing dialog");
-        getActivity().finish();
-    };
-
     public PanelFragment() {
+        final Context context = getActivity();
+        mMetricsProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
     }
 
     @Nullable
@@ -69,38 +71,70 @@
         mTitleView = view.findViewById(R.id.panel_title);
 
         final Bundle arguments = getArguments();
-        final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
-        final String packageName =
-                arguments.getString(SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME);
+        final String panelType =
+                arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
+        final String callingPackageName =
+                arguments.getString(SettingsPanelActivity.KEY_CALLING_PACKAGE_NAME);
+        final String mediaPackageName =
+                arguments.getString(SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME);
 
-        final PanelContent panel = FeatureFactory.getFactory(activity)
+        // TODO (b/124399577) transform interface to take a context and bundle.
+        mPanel = FeatureFactory.getFactory(activity)
                 .getPanelFeatureProvider()
-                .getPanel(activity, panelType, packageName);
+                .getPanel(activity, panelType, mediaPackageName);
 
-        mAdapter = new PanelSlicesAdapter(this, panel.getSlices());
+        // Log panel opened.
+        mMetricsProvider.action(
+                0 /* attribution */,
+                SettingsEnums.PAGE_VISIBLE /* opened panel - Action */,
+                mPanel.getMetricsCategory(),
+                callingPackageName,
+                0 /* value */);
+
+        mAdapter = new PanelSlicesAdapter(this, mPanel);
 
         mPanelSlices.setHasFixedSize(true);
         mPanelSlices.setLayoutManager(new LinearLayoutManager((activity)));
         mPanelSlices.setAdapter(mAdapter);
 
-        mTitleView.setText(panel.getTitle());
+        mTitleView.setText(mPanel.getTitle());
 
-        mSeeMoreButton.setOnClickListener(getSeeMoreListener(panel.getSeeMoreIntent()));
-        mDoneButton.setOnClickListener(mDoneButtonListener);
+        mSeeMoreButton.setOnClickListener(getSeeMoreListener());
+        mDoneButton.setOnClickListener(getCloseListener());
 
         //If getSeeMoreIntent() is null, hide the mSeeMoreButton.
-        if (panel.getSeeMoreIntent() == null) {
+        if (mPanel.getSeeMoreIntent() == null) {
             mSeeMoreButton.setVisibility(View.GONE);
         }
 
         return view;
     }
 
-    private View.OnClickListener getSeeMoreListener(final Intent intent) {
+    @VisibleForTesting
+    View.OnClickListener getSeeMoreListener() {
         return (v) -> {
+            mMetricsProvider.action(
+                    0 /* attribution */,
+                    SettingsEnums.PAGE_HIDE ,
+                    mPanel.getMetricsCategory(),
+                    PanelClosedKeys.KEY_SEE_MORE,
+                    0 /* value */);
             final FragmentActivity activity = getActivity();
-            activity.startActivity(intent);
+            activity.startActivityForResult(mPanel.getSeeMoreIntent(), 0);
             activity.finish();
         };
     }
+
+    @VisibleForTesting
+    View.OnClickListener getCloseListener() {
+        return (v) -> {
+            mMetricsProvider.action(
+                    0 /* attribution */,
+                    SettingsEnums.PAGE_HIDE,
+                    mPanel.getMetricsCategory(),
+                    PanelClosedKeys.KEY_DONE,
+                    0 /* value */);
+            getActivity().finish();
+        };
+    }
 }
diff --git a/src/com/android/settings/panel/PanelLoggingContract.java b/src/com/android/settings/panel/PanelLoggingContract.java
new file mode 100644
index 0000000..e149186
--- /dev/null
+++ b/src/com/android/settings/panel/PanelLoggingContract.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2019 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.panel;
+
+/**
+ * Simple contract class to track keys in Panel logging.
+ *
+ * <p>
+ *    Constants should only be removed if underlying panel, or use case is removed.
+ * </p>
+ */
+public class PanelLoggingContract {
+
+    /**
+     * Keys tracking different ways users exit Panels.
+     */
+    interface PanelClosedKeys {
+        /**
+         * The user clicked the See More button linking deeper into Settings.
+         */
+        String KEY_SEE_MORE = "see_more";
+
+        /**
+         * The user clicked the Done button, closing the Panel.
+         */
+        String KEY_DONE = "done";
+
+        /**
+         * The user clicked outside the dialog, closing the Panel.
+         */
+        String KEY_CLICKED_OUT = "clicked_out";
+    }
+}
diff --git a/src/com/android/settings/panel/PanelSlicesAdapter.java b/src/com/android/settings/panel/PanelSlicesAdapter.java
index f688512..c1cb049 100644
--- a/src/com/android/settings/panel/PanelSlicesAdapter.java
+++ b/src/com/android/settings/panel/PanelSlicesAdapter.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.panel;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.net.Uri;
 import android.view.LayoutInflater;
@@ -31,8 +32,8 @@
 import androidx.slice.widget.SliceView;
 
 import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -43,10 +44,12 @@
 
     private final List<Uri> mSliceUris;
     private final PanelFragment mPanelFragment;
+    private final PanelContent mPanelContent;
 
-    public PanelSlicesAdapter(PanelFragment fragment, List<Uri> sliceUris) {
+    public PanelSlicesAdapter(PanelFragment fragment, PanelContent panel) {
         mPanelFragment = fragment;
-        mSliceUris = new ArrayList<>(sliceUris);
+        mSliceUris = panel.getSlices();
+        mPanelContent = panel;
     }
 
     @NonNull
@@ -56,7 +59,7 @@
         final LayoutInflater inflater = LayoutInflater.from(context);
         final View view = inflater.inflate(R.layout.panel_slice_row, viewGroup, false);
 
-        return new SliceRowViewHolder(view);
+        return new SliceRowViewHolder(view, mPanelContent);
     }
 
     @Override
@@ -79,22 +82,38 @@
      */
     public static class SliceRowViewHolder extends RecyclerView.ViewHolder {
 
+        private final PanelContent mPanelContent;
+
         @VisibleForTesting
         LiveData<Slice> sliceLiveData;
 
         @VisibleForTesting
         final SliceView sliceView;
 
-        public SliceRowViewHolder(View view) {
+        public SliceRowViewHolder(View view, PanelContent panelContent) {
             super(view);
             sliceView = view.findViewById(R.id.slice_view);
             sliceView.setMode(SliceView.MODE_LARGE);
+            mPanelContent = panelContent;
         }
 
         public void onBind(PanelFragment fragment, Uri sliceUri) {
             final Context context = sliceView.getContext();
             sliceLiveData = SliceLiveData.fromUri(context, sliceUri);
             sliceLiveData.observe(fragment.getViewLifecycleOwner(), sliceView);
+
+            // Log Panel interaction
+            sliceView.setOnSliceActionListener(
+                    ((eventInfo, sliceItem) -> {
+                        FeatureFactory.getFactory(context)
+                                .getMetricsFeatureProvider()
+                                .action(0 /* attribution */,
+                                        SettingsEnums.ACTION_PANEL_INTERACTION,
+                                        mPanelContent.getMetricsCategory(),
+                                        sliceUri.toString() /* log key */,
+                                        eventInfo.actionType /* value */);
+                    })
+            );
         }
     }
 }
diff --git a/src/com/android/settings/panel/SettingsPanelActivity.java b/src/com/android/settings/panel/SettingsPanelActivity.java
index 4cf535e..3819c80 100644
--- a/src/com/android/settings/panel/SettingsPanelActivity.java
+++ b/src/com/android/settings/panel/SettingsPanelActivity.java
@@ -19,11 +19,13 @@
 import static com.android.settingslib.media.MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT;
 import static com.android.settingslib.media.MediaOutputSliceConstants.EXTRA_PACKAGE_NAME;
 
+import android.app.settings.SettingsEnums;
 import android.content.Intent;
 import android.os.Bundle;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.Gravity;
+import android.view.MotionEvent;
 import android.view.Window;
 import android.view.WindowManager;
 
@@ -34,6 +36,8 @@
 
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.settings.R;
+import com.android.settings.overlay.FeatureFactory;
+import com.android.settings.panel.PanelLoggingContract.PanelClosedKeys;
 
 /**
  * Dialog Activity to host Settings Slices.
@@ -49,7 +53,16 @@
      * Key specifying which Panel the app is requesting.
      */
     public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
-    public static final String KEY_PANEL_PACKAGE_NAME = "PANEL_PACKAGE_NAME";
+
+    /**
+     * Key specifying the package which requested the Panel.
+     */
+    public static final String KEY_CALLING_PACKAGE_NAME = "PANEL_CALLING_PACKAGE_NAME";
+
+    /**
+     * Key specifying the package name for which the
+     */
+    public static final String KEY_MEDIA_PACKAGE_NAME = "PANEL_MEDIA_PACKAGE_NAME";
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -62,12 +75,12 @@
             return;
         }
 
-        final String packageName =
+        final String mediaPackageName =
                 callingIntent.getStringExtra(EXTRA_PACKAGE_NAME);
 
         if (TextUtils.equals(ACTION_MEDIA_OUTPUT, callingIntent.getAction())
-                && TextUtils.isEmpty(packageName)) {
-            Log.e(TAG, "Null package name, closing Panel Activity");
+                && TextUtils.isEmpty(mediaPackageName)) {
+            Log.e(TAG, "Missing EXTRA_PACKAGE_NAME, closing Panel Activity");
             finish();
             return;
         }
@@ -81,7 +94,8 @@
                 WindowManager.LayoutParams.WRAP_CONTENT);
 
         mBundle.putString(KEY_PANEL_TYPE_ARGUMENT, callingIntent.getAction());
-        mBundle.putString(KEY_PANEL_PACKAGE_NAME, packageName);
+        mBundle.putString(KEY_CALLING_PACKAGE_NAME, getCallingPackage());
+        mBundle.putString(KEY_MEDIA_PACKAGE_NAME, mediaPackageName);
 
         final PanelFragment panelFragment = new PanelFragment();
         panelFragment.setArguments(mBundle);
@@ -92,4 +106,21 @@
             fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
         }
     }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
+            final PanelContent panelContent = FeatureFactory.getFactory(this)
+                    .getPanelFeatureProvider()
+                    .getPanel(this, getIntent().getAction(), null /* Media Package Name */);
+            FeatureFactory.getFactory(this)
+                    .getMetricsFeatureProvider()
+                    .action(0 /* attribution */,
+                            SettingsEnums.PAGE_HIDE,
+                            panelContent.getMetricsCategory(),
+                            PanelClosedKeys.KEY_CLICKED_OUT,
+                            0 /* value */);
+        }
+        return super.onTouchEvent(event);
+    }
 }
diff --git a/src/com/android/settings/panel/VolumePanel.java b/src/com/android/settings/panel/VolumePanel.java
index 352fed5..20c2272 100644
--- a/src/com/android/settings/panel/VolumePanel.java
+++ b/src/com/android/settings/panel/VolumePanel.java
@@ -21,6 +21,7 @@
 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_MEDIA_URI;
 import static com.android.settings.slices.CustomSliceRegistry.VOLUME_RINGER_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
@@ -62,4 +63,9 @@
     public Intent getSeeMoreIntent() {
         return new Intent(Settings.ACTION_SOUND_SETTINGS);
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.PANEL_VOLUME;
+    }
 }
\ No newline at end of file
diff --git a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
index 236e3d9..ec1e835 100644
--- a/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
+++ b/src/com/android/settings/password/ConfirmDeviceCredentialActivity.java
@@ -184,7 +184,7 @@
         } else {
             bpBundle = new Bundle();
             bpBundle.putString(BiometricPrompt.KEY_TITLE, mTitle);
-            bpBundle.putString(BiometricPrompt.KEY_SUBTITLE, mDetails);
+            bpBundle.putString(BiometricPrompt.KEY_DESCRIPTION, mDetails);
         }
 
         boolean launchedBiometric = false;
diff --git a/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
new file mode 100644
index 0000000..bcf8f47
--- /dev/null
+++ b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2019 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.privacy;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.view.accessibility.AccessibilityManager;
+
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import java.util.List;
+
+
+public class AccessibilityUsagePreferenceController extends BasePreferenceController  {
+
+    private final @NonNull List<AccessibilityServiceInfo> mEnabledServiceInfos;
+
+    public AccessibilityUsagePreferenceController(Context context, String preferenceKey) {
+        super(context, preferenceKey);
+
+        final AccessibilityManager accessibilityManager = context.getSystemService(
+                AccessibilityManager.class);
+        mEnabledServiceInfos = accessibilityManager.getEnabledAccessibilityServiceList(
+                AccessibilityServiceInfo.FEEDBACK_ALL_MASK);
+    }
+
+    @Override
+    public int getAvailabilityStatus() {
+        return (mEnabledServiceInfos.isEmpty() || !Boolean.parseBoolean(
+                DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
+                        DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED)))
+                ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
+    }
+
+    @Override
+    public CharSequence getSummary() {
+        return mContext.getResources().getQuantityString(R.plurals.accessibility_usage_summary,
+                mEnabledServiceInfos.size(), mEnabledServiceInfos.size());
+    }
+}
diff --git a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
index 8b9b595..2c6368e 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -31,28 +31,29 @@
 import android.view.View;
 
 import androidx.annotation.NonNull;
-import androidx.preference.Preference;
 import androidx.preference.PreferenceScreen;
 
 import com.android.settings.R;
 import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.Utils;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
 import com.android.settingslib.widget.BarChartInfo;
 import com.android.settingslib.widget.BarChartPreference;
 import com.android.settingslib.widget.BarViewInfo;
-import com.android.settingslib.Utils;
 
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
-import java.util.concurrent.Executors;
 
 
 public class PermissionBarChartPreferenceController extends BasePreferenceController implements
-        PermissionControllerManager.OnPermissionUsageResultCallback {
+        PermissionControllerManager.OnPermissionUsageResultCallback, LifecycleObserver, OnStart {
 
     private static final String TAG = "BarChartPreferenceCtl";
 
     private PackageManager mPackageManager;
+    private PrivacyDashboardFragment mParent;
     private BarChartPreference mBarChartPreference;
     private List<RuntimePermissionUsageInfo> mOldUsageInfos;
 
@@ -62,6 +63,10 @@
         mPackageManager = context.getPackageManager();
     }
 
+    public void setFragment(PrivacyDashboardFragment fragment) {
+        mParent = fragment;
+    }
+
     @Override
     public int getAvailabilityStatus() {
         return Boolean.parseBoolean(
@@ -73,7 +78,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mBarChartPreference = (BarChartPreference) screen.findPreference(getPreferenceKey());
+        mBarChartPreference = screen.findPreference(getPreferenceKey());
 
         final BarChartInfo info = new BarChartInfo.Builder()
                 .setTitle(R.string.permission_bar_chart_title)
@@ -90,7 +95,13 @@
     }
 
     @Override
-    public void updateState(Preference preference) {
+    public void onStart() {
+        if (!isAvailable()) {
+            return;
+        }
+
+        mBarChartPreference.updateLoadingState(true /* isLoading */);
+        mParent.setLoadingEnabled(true /* enabled */);
         retrievePermissionUsageData();
     }
 
@@ -104,6 +115,9 @@
             mBarChartPreference.setBarViewInfos(createBarViews(usageInfos));
             mOldUsageInfos = usageInfos;
         }
+
+        mBarChartPreference.updateLoadingState(false /* isLoading */);
+        mParent.setLoadingEnabled(false /* enabled */);
     }
 
     private void retrievePermissionUsageData() {
diff --git a/src/com/android/settings/privacy/PrivacyDashboardFragment.java b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
index 5823407..be6701e 100644
--- a/src/com/android/settings/privacy/PrivacyDashboardFragment.java
+++ b/src/com/android/settings/privacy/PrivacyDashboardFragment.java
@@ -48,6 +48,11 @@
     private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
             "privacy_lock_screen_work_profile_notifications";
 
+    @VisibleForTesting
+    View mProgressHeader;
+    @VisibleForTesting
+    View mProgressAnimation;
+
     @Override
     public int getMetricsCategory() {
         return SettingsEnums.TOP_LEVEL_PRIVACY;
@@ -74,9 +79,16 @@
     }
 
     @Override
+    public void onAttach(Context context) {
+        super.onAttach(context);
+        use(PermissionBarChartPreferenceController.class).setFragment(this /* fragment */);
+    }
+
+    @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
         styleActionBar();
+        initLoadingBar();
     }
 
     @VisibleForTesting
@@ -97,6 +109,21 @@
         }
     }
 
+    @VisibleForTesting
+    void initLoadingBar() {
+        mProgressHeader = setPinnedHeaderView(R.layout.progress_header);
+        mProgressAnimation = mProgressHeader.findViewById(R.id.progress_bar_animation);
+        setLoadingEnabled(false);
+    }
+
+    @VisibleForTesting
+    void setLoadingEnabled(boolean enabled) {
+        if (mProgressHeader != null && mProgressAnimation != null) {
+            mProgressHeader.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+            mProgressAnimation.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+        }
+    }
+
     private static List<AbstractPreferenceController> buildPreferenceControllers(
             Context context, Lifecycle lifecycle) {
         final List<AbstractPreferenceController> controllers = new ArrayList<>();
diff --git a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
index a58c528..650b1e3 100644
--- a/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
+++ b/src/com/android/settings/security/ChangeScreenLockPreferenceController.java
@@ -79,7 +79,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/security/LockUnificationPreferenceController.java b/src/com/android/settings/security/LockUnificationPreferenceController.java
index 1aebe24..978986c 100644
--- a/src/com/android/settings/security/LockUnificationPreferenceController.java
+++ b/src/com/android/settings/security/LockUnificationPreferenceController.java
@@ -77,7 +77,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mUnifyProfile = (RestrictedSwitchPreference) screen.findPreference(KEY_UNIFICATION);
+        mUnifyProfile = screen.findPreference(KEY_UNIFICATION);
     }
 
     public LockUnificationPreferenceController(Context context, SecuritySettings host) {
diff --git a/src/com/android/settings/security/OwnerInfoPreferenceController.java b/src/com/android/settings/security/OwnerInfoPreferenceController.java
index f7a20ba..5276722 100644
--- a/src/com/android/settings/security/OwnerInfoPreferenceController.java
+++ b/src/com/android/settings/security/OwnerInfoPreferenceController.java
@@ -61,7 +61,7 @@
 
     @Override
     public void displayPreference(PreferenceScreen screen) {
-        mOwnerInfoPref  = (RestrictedPreference) screen.findPreference(KEY_OWNER_INFO);
+        mOwnerInfoPref  = screen.findPreference(KEY_OWNER_INFO);
     }
 
     @Override
diff --git a/src/com/android/settings/security/ResetCredentialsPreferenceController.java b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
index ee09bca..0700b46 100644
--- a/src/com/android/settings/security/ResetCredentialsPreferenceController.java
+++ b/src/com/android/settings/security/ResetCredentialsPreferenceController.java
@@ -52,7 +52,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (RestrictedPreference) screen.findPreference(getPreferenceKey());
+        mPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
index 6f5d7eb..eb50b7c 100644
--- a/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
+++ b/src/com/android/settings/security/trustagent/TrustAgentListPreferenceController.java
@@ -91,7 +91,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mSecurityCategory = (PreferenceCategory) screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
+        mSecurityCategory = screen.findPreference(PREF_KEY_SECURITY_CATEGORY);
         updateTrustAgents();
     }
 
diff --git a/src/com/android/settings/slices/CustomSliceable.java b/src/com/android/settings/slices/CustomSliceable.java
index 220cdc8..d32e266 100644
--- a/src/com/android/settings/slices/CustomSliceable.java
+++ b/src/com/android/settings/slices/CustomSliceable.java
@@ -52,7 +52,7 @@
  * <p>
  *     If you implement this interface, you should add your Slice to {@link CustomSliceManager}.
  */
-public interface CustomSliceable {
+public interface CustomSliceable extends Sliceable {
 
     /**
      * @return an complete instance of the {@link Slice}.
@@ -79,17 +79,6 @@
     Intent getIntent();
 
     /**
-     * Settings Slices which can represent components that are updatable by the framework should
-     * listen to changes matched to the {@link IntentFilter} returned here.
-     *
-     * @return an {@link IntentFilter} for updates related to the {@link Slice} returned by
-     * {@link #getSlice()}.
-     */
-    default IntentFilter getIntentFilter() {
-        return null;
-    }
-
-    /**
      * Settings Slices which require background work, such as updating lists should implement a
      * {@link SliceBackgroundWorker} and return it here. An example of background work is updating
      * a list of Wifi networks available in the area.
@@ -116,12 +105,16 @@
                 PendingIntent.FLAG_CANCEL_CURRENT);
     }
 
+    @Override
+    default boolean isSliceable() {
+        return true;
+    }
+
     /**
      * Build an instance of a {@link CustomSliceable} which has a {@link Context}-only constructor.
      */
     static CustomSliceable createInstance(Context context, Class<CustomSliceable> sliceableClass) {
         try {
-            //final Class<CustomSliceable> clazz = Class.forName(sliceableClassName);
             final Constructor<CustomSliceable> sliceable =
                     sliceableClass.getConstructor(Context.class);
             final Object[] params = new Object[]{context};
diff --git a/src/com/android/settings/slices/SettingsSliceProvider.java b/src/com/android/settings/slices/SettingsSliceProvider.java
index d1648e0..5c662e5 100644
--- a/src/com/android/settings/slices/SettingsSliceProvider.java
+++ b/src/com/android/settings/slices/SettingsSliceProvider.java
@@ -129,8 +129,6 @@
     @VisibleForTesting
     Map<Uri, SliceData> mSliceDataCache;
 
-    final Set<Uri> mRegisteredUris = new ArraySet<>();
-
     final Map<Uri, SliceBackgroundWorker> mPinnedWorkers = new ArrayMap<>();
 
     public SettingsSliceProvider() {
@@ -173,14 +171,8 @@
 
     @Override
     public void onSliceUnpinned(Uri sliceUri) {
-        if (mRegisteredUris.contains(sliceUri)) {
-            Log.d(TAG, "Unregistering uri broadcast relay: " + sliceUri);
-            SliceBroadcastRelay.unregisterReceivers(getContext(), sliceUri);
-            mRegisteredUris.remove(sliceUri);
-        }
-        ThreadUtils.postOnMainThread(() -> {
-            stopBackgroundWorker(sliceUri);
-        });
+        SliceBroadcastRelay.unregisterReceivers(getContext(), sliceUri);
+        ThreadUtils.postOnMainThread(() -> stopBackgroundWorker(sliceUri));
         mSliceDataCache.remove(sliceUri);
     }
 
@@ -419,9 +411,7 @@
 
     @VisibleForTesting
     void loadSliceInBackground(Uri uri) {
-        ThreadUtils.postOnBackgroundThread(() -> {
-            loadSlice(uri);
-        });
+        ThreadUtils.postOnBackgroundThread(() -> loadSlice(uri));
     }
 
     /**
@@ -462,8 +452,6 @@
      * {@param intentFilter} happen.
      */
     void registerIntentToUri(IntentFilter intentFilter, Uri sliceUri) {
-        Log.d(TAG, "Registering Uri for broadcast relay: " + sliceUri);
-        mRegisteredUris.add(sliceUri);
         SliceBroadcastRelay.registerReceiver(getContext(), sliceUri, SliceRelayReceiver.class,
                 intentFilter);
     }
diff --git a/src/com/android/settings/slices/Sliceable.java b/src/com/android/settings/slices/Sliceable.java
new file mode 100644
index 0000000..ddec2e1
--- /dev/null
+++ b/src/com/android/settings/slices/Sliceable.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 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.slices;
+
+import android.content.IntentFilter;
+
+/**
+ * A collection of API making a PreferenceController "sliceable"
+ */
+public interface Sliceable {
+    /**
+     * @return an {@link IntentFilter} that includes all broadcasts which can affect the state of
+     * this Setting.
+     */
+    default IntentFilter getIntentFilter() {
+        return null;
+    }
+
+    /**
+     * Determines if the controller should be used as a Slice.
+     * <p>
+     * Important criteria for a Slice are:
+     * - Must be secure
+     * - Must not be a privacy leak
+     * - Must be understandable as a stand-alone Setting.
+     * <p>
+     * This does not guarantee the setting is available.
+     *
+     * @return {@code true} if the controller should be used externally as a Slice.
+     */
+    default boolean isSliceable() {
+        return false;
+    }
+
+    /**
+     * @return {@code true} if the setting update asynchronously.
+     * <p>
+     * For example, a Wifi controller would return true, because it needs to update the radio
+     * and wait for it to turn on.
+     */
+    default boolean hasAsyncUpdate() {
+        return false;
+    }
+}
diff --git a/src/com/android/settings/widget/AdaptiveHomepageIcon.java b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
index bec5d8d..bc7aaa7 100644
--- a/src/com/android/settings/widget/AdaptiveHomepageIcon.java
+++ b/src/com/android/settings/widget/AdaptiveHomepageIcon.java
@@ -72,11 +72,13 @@
                 // If found anything, use it.
                 if (bgColor != 0) {
                     setBackgroundColor(bgColor);
+                    return;
                 }
             }
         } catch (PackageManager.NameNotFoundException e) {
             Log.e(TAG, "Failed to set background color for " + tile.getPackageName());
         }
+        setBackgroundColor(context.getColor(R.color.homepage_generic_icon_background));
     }
 
     public void setBackgroundColor(int color) {
diff --git a/src/com/android/settings/widget/VideoPreferenceController.java b/src/com/android/settings/widget/VideoPreferenceController.java
index a7bb754..78a837c 100644
--- a/src/com/android/settings/widget/VideoPreferenceController.java
+++ b/src/com/android/settings/widget/VideoPreferenceController.java
@@ -43,7 +43,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mVideoPreference = (VideoPreference) screen.findPreference(getPreferenceKey());
+        mVideoPreference = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java
index e4d0fb1..656f8ef 100644
--- a/src/com/android/settings/wifi/AddNetworkFragment.java
+++ b/src/com/android/settings/wifi/AddNetworkFragment.java
@@ -40,6 +40,7 @@
     final static int SUBMIT_BUTTON_ID = android.R.id.button1;
     @VisibleForTesting
     final static int CANCEL_BUTTON_ID = android.R.id.button2;
+    final static int SCANNER_BUTTON_ID = R.id.ssid_scanner_button;
 
     private WifiConfigController mUIController;
     private Button mSubmitBtn;
@@ -62,22 +63,12 @@
 
         mSubmitBtn = rootView.findViewById(SUBMIT_BUTTON_ID);
         mCancelBtn = rootView.findViewById(CANCEL_BUTTON_ID);
+        final ImageButton scannerButton = rootView.findViewById(SCANNER_BUTTON_ID);
         mSubmitBtn.setOnClickListener(this);
         mCancelBtn.setOnClickListener(this);
+        scannerButton.setOnClickListener(this);
         mUIController = new WifiConfigController(this, rootView, null, getMode());
 
-        if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
-            final ImageButton scannerButton = rootView.findViewById(R.id.ssid_scanner_button);
-            if (scannerButton != null) {
-                scannerButton.setVisibility(View.VISIBLE);
-                scannerButton.setOnClickListener((View v) -> {
-                    // Launch QR code scanner to join a network.
-                    getContext().startActivity(
-                            WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
-                });
-            }
-        }
-
         return rootView;
     }
 
@@ -96,6 +87,11 @@
             case CANCEL_BUTTON_ID:
                 handleCancelAction();
                 break;
+            case SCANNER_BUTTON_ID:
+                // Launch QR code scanner to join a network.
+                getContext().startActivity(
+                        WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
+                break;
         }
     }
 
diff --git a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
index 33eaceb..36c4455 100644
--- a/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiConnectionPreferenceController.java
@@ -99,7 +99,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(mPreferenceGroupKey);
+        mPreferenceGroup = screen.findPreference(mPreferenceGroupKey);
         mPrefContext = screen.getContext();
         update();
     }
diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java
index 9420c4c..7d5f3b3 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -80,20 +80,17 @@
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null);
-        if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
-            final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button);
-            if (scannerButton != null) {
-                scannerButton.setVisibility(View.VISIBLE);
-                scannerButton.setOnClickListener((View v) -> {
-                    String ssid = null;
-                    if (mAccessPoint != null) {
-                        ssid = mAccessPoint.getSsidStr();
-                    }
-                    // Launch QR code scanner to join a network.
-                    getContext().startActivity(
-                            WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
-                });
-            }
+        final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button);
+        if (scannerButton != null) {
+            scannerButton.setOnClickListener((View v) -> {
+                String ssid = null;
+                if (mAccessPoint != null) {
+                    ssid = mAccessPoint.getSsidStr();
+                }
+                // Launch QR code scanner to join a network.
+                getContext().startActivity(
+                        WifiDppUtils.getEnrolleeQrCodeScannerIntent(ssid));
+            });
         }
         setView(mView);
         mController = new WifiConfigController(this, mView, mAccessPoint, mMode);
diff --git a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
index 692608c..6a4774b 100644
--- a/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiMasterSwitchPreferenceController.java
@@ -53,7 +53,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mWifiPreference = (MasterSwitchPreference) screen.findPreference(KEY_TOGGLE_WIFI);
+        mWifiPreference = screen.findPreference(KEY_TOGGLE_WIFI);
     }
 
     @Override
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 881e3d2..4ca9f86 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -203,7 +203,7 @@
         super.onViewCreated(view, savedInstanceState);
         final Activity activity = getActivity();
         if (activity != null) {
-            mProgressHeader = setPinnedHeaderView(R.layout.wifi_progress_header)
+            mProgressHeader = setPinnedHeaderView(R.layout.progress_header)
                     .findViewById(R.id.progress_bar_animation);
             setProgressBarVisible(false);
         }
@@ -239,14 +239,12 @@
         mAddPreference = new ButtonPreference(prefContext);
         mAddPreference.setIcon(R.drawable.ic_menu_add);
         mAddPreference.setTitle(R.string.wifi_add_network);
-        if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
-            mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
-            mAddPreference.setButtonOnClickListener((View v) -> {
-                // Launch QR code scanner to join a network.
-                getContext().startActivity(
-                        WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
-            });
-        }
+        mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
+        mAddPreference.setButtonOnClickListener((View v) -> {
+            // Launch QR code scanner to join a network.
+            getContext().startActivity(
+                    WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null));
+        });
         mStatusMessagePreference = (LinkablePreference) findPreference(PREF_KEY_STATUS_MESSAGE);
 
         mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
diff --git a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
index 435f8f1..15bffd9 100644
--- a/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
+++ b/src/com/android/settings/wifi/WifiWakeupPreferenceController.java
@@ -62,7 +62,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreference = (SwitchPreference) screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
+        mPreference = screen.findPreference(KEY_ENABLE_WIFI_WAKEUP);
         updateState(mPreference);
     }
 
diff --git a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
index 40cc0dc..9ed2035 100644
--- a/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
+++ b/src/com/android/settings/wifi/calling/WifiCallingSettingsForSub.java
@@ -29,6 +29,7 @@
 import android.telephony.PhoneStateListener;
 import android.telephony.SubscriptionManager;
 import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -44,7 +45,9 @@
 import androidx.preference.PreferenceScreen;
 
 import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
 import com.android.ims.ImsManager;
+import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telephony.Phone;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -152,6 +155,19 @@
                 }
             };
 
+    private final ProvisioningManager.Callback mProvisioningCallback =
+            new ProvisioningManager.Callback() {
+                @Override
+                public void onProvisioningIntChanged(int item, int value) {
+                    if (item == ImsConfig.ConfigConstants.VOICE_OVER_WIFI_SETTING_ENABLED
+                            || item == ImsConfig.ConfigConstants.VLT_SETTING_ENABLED) {
+                        // The provisioning policy might have changed. Update the body to make sure
+                        // this change takes effect if needed.
+                        updateBody();
+                    }
+                }
+            };
+
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
@@ -221,6 +237,11 @@
         return 0;
     }
 
+    @VisibleForTesting
+    ImsManager getImsManager() {
+        return ImsManager.getInstance(getActivity(), SubscriptionManager.getPhoneId(mSubId));
+    }
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -236,8 +257,7 @@
                     FRAGMENT_BUNDLE_SUBID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
         }
 
-        mImsManager = ImsManager.getInstance(
-                getActivity(), SubscriptionManager.getPhoneId(mSubId));
+        mImsManager = getImsManager();
 
         mTelephonyManager = ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE))
                 .createForSubscriptionId(mSubId);
@@ -277,6 +297,13 @@
     }
 
     private void updateBody() {
+        if (!mImsManager.isWfcProvisionedOnDevice()) {
+            // This screen is not allowed to be shown due to provisioning policy and should
+            // therefore be closed.
+            finish();
+            return;
+        }
+
         CarrierConfigManager configManager = (CarrierConfigManager)
                 getSystemService(Context.CARRIER_CONFIG_SERVICE);
         boolean isWifiOnlySupported = true;
@@ -336,6 +363,14 @@
         if (intent.getBooleanExtra(Phone.EXTRA_KEY_ALERT_SHOW, false)) {
             showAlert(intent);
         }
+
+        // Register callback for provisioning changes.
+        try {
+            mImsManager.getConfigInterface().addConfigCallback(mProvisioningCallback);
+        } catch (ImsException e) {
+            Log.w(TAG, "onResume: Unable to register callback for provisioning changes.");
+        }
+
     }
 
     @Override
@@ -354,6 +389,15 @@
         }
 
         context.unregisterReceiver(mIntentReceiver);
+
+        // Remove callback for provisioning changes.
+        try {
+            mImsManager.getConfigInterface().removeConfigCallback(
+                    mProvisioningCallback.getBinder());
+        } catch (ImsException e) {
+            Log.w(TAG, "onPause: Unable to remove callback for provisioning changes");
+        }
+
     }
 
     /**
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 27db7cd..8e72f65 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -305,14 +305,14 @@
         mSubnetPref = screen.findPreference(KEY_SUBNET_MASK_PREF);
         mDnsPref = screen.findPreference(KEY_DNS_PREF);
 
-        mIpv6Category = (PreferenceCategory) screen.findPreference(KEY_IPV6_CATEGORY);
+        mIpv6Category = screen.findPreference(KEY_IPV6_CATEGORY);
         mIpv6AddressPref = screen.findPreference(KEY_IPV6_ADDRESSES_PREF);
 
         mSecurityPref.setSummary(mAccessPoint.getSecurityString(/* concise */ false));
     }
 
     private void setupEntityHeader(PreferenceScreen screen) {
-        LayoutPreference headerPref = (LayoutPreference) screen.findPreference(KEY_HEADER);
+        LayoutPreference headerPref = screen.findPreference(KEY_HEADER);
         mEntityHeaderController =
                 EntityHeaderController.newInstance(
                         mFragment.getActivity(), mFragment,
@@ -502,7 +502,7 @@
     private static String ipv4PrefixLengthToSubnetMask(int prefixLength) {
         try {
             InetAddress all = InetAddress.getByAddress(
-                    new byte[] {(byte) 255, (byte) 255, (byte) 255, (byte) 255});
+                    new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255});
             return NetworkUtils.getNetworkPart(all, prefixLength).getHostAddress();
         } catch (UnknownHostException e) {
             return null;
@@ -534,8 +534,7 @@
      * Returns whether the user can share the network represented by this preference with QR code.
      */
     private boolean canShareNetwork() {
-        return mAccessPoint.getConfig() != null && FeatureFlagUtils.isEnabled(mContext,
-                FeatureFlags.WIFI_SHARING);
+        return mAccessPoint.getConfig() != null;
     }
 
     /**
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index 7bc80e0..8b333e2 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -75,14 +75,6 @@
     public static final String EXTRA_TEST = "test";
 
     /**
-     * Returns whether the user can share the network represented by this preference with QR code.
-     */
-    public static boolean isSharingNetworkEnabled(Context context) {
-        return FeatureFlagUtils.isEnabled(context,
-                com.android.settings.core.FeatureFlags.WIFI_SHARING);
-    }
-
-    /**
      * Returns whether the device support WiFi DPP.
      */
     public static boolean isWifiDppEnabled(Context context) {
diff --git a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
index ac8113b..032649c 100644
--- a/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
+++ b/src/com/android/settings/wifi/p2p/P2pCategoryPreferenceController.java
@@ -42,7 +42,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mCategory = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mCategory = screen.findPreference(getPreferenceKey());
     }
 
     public void removeAllChildren() {
diff --git a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
index dea4443..4155ef7 100644
--- a/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
+++ b/src/com/android/settings/wifi/savedaccesspoints/SavedAccessPointsPreferenceController.java
@@ -76,7 +76,7 @@
     @Override
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
-        mPreferenceGroup = (PreferenceGroup) screen.findPreference(getPreferenceKey());
+        mPreferenceGroup = screen.findPreference(getPreferenceKey());
     }
 
     @Override
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
index 951f203..3f4e82d 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java
@@ -181,6 +181,15 @@
         verify(mContext, never()).unregisterReceiver(any());
     }
 
+    @Test
+    public void getConnectedHearingAidDevice_doNotReturnSubDevice() {
+        when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
+        when(mLocalBluetoothManager.getCachedDeviceManager().isSubDevice(mBluetoothDevice))
+                .thenReturn(true);
+
+        assertThat(mPreferenceController.getConnectedHearingAidDevice()).isNull();
+    }
+
     private void setupBluetoothEnvironment() {
         ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
         mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
index 7568987..58ed6b4 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/TopLevelBatteryPreferenceControllerTest.java
@@ -61,5 +61,9 @@
 
         info.remainingLabel = "Phone will shut down soon";
         assertThat(getDashboardLabel(mContext, info)).isEqualTo("3% - Phone will shut down soon");
+
+        info.discharging = false;
+        info.chargeLabel = "5% - charging";
+        assertThat(getDashboardLabel(mContext, info)).isEqualTo("5% - charging");
     }
 }
diff --git a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
index 6149539..ecda5fd 100644
--- a/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/WakeScreenGesturePreferenceControllerTest.java
@@ -17,12 +17,14 @@
 package com.android.settings.gestures;
 
 import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
 import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
 
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -77,6 +79,7 @@
 
     @Test
     public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
         when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
@@ -85,6 +88,7 @@
 
     @Test
     public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
         when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
         final int availabilityStatus = mController.getAvailabilityStatus();
 
@@ -92,6 +96,25 @@
     }
 
     @Test
+    public void getAvailabilityStatus_gestureSupported_DISABLED_DEPENDENT_SETTING() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+        when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
+        final int availabilityStatus = mController.getAvailabilityStatus();
+
+        assertThat(availabilityStatus).isEqualTo(DISABLED_DEPENDENT_SETTING);
+    }
+
+    @Test
+    public void canHandleClicks_onlyWhenAlwaysOn() {
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(false);
+        assertThat(mController.canHandleClicks()).isEqualTo(false);
+
+        reset(mAmbientDisplayConfiguration);
+        when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
+        assertThat(mController.canHandleClicks()).isEqualTo(true);
+    }
+
+    @Test
     public void isSliceableCorrectKey_returnsTrue() {
         final WakeScreenGesturePreferenceController controller =
                 new WakeScreenGesturePreferenceController(mContext, "gesture_wake_screen");
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
index 5d72ee4..dcd0963 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/DndConditionalCardControllerTest.java
@@ -16,13 +16,22 @@
 
 package com.android.settings.homepage.contextualcards.conditional;
 
+import static com.google.common.truth.Truth.assertThat;
+
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 
+import android.app.NotificationManager;
 import android.content.Context;
+import android.service.notification.ZenModeConfig;
 
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.testutils.shadow.ShadowNotificationManager;
+
+import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -30,7 +39,10 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
 
+@Config(shadows = ShadowNotificationManager.class)
 @RunWith(RobolectricTestRunner.class)
 public class DndConditionalCardControllerTest {
 
@@ -38,12 +50,14 @@
     private ConditionManager mConditionManager;
     private Context mContext;
     private DndConditionCardController mController;
+    private ShadowNotificationManager mNotificationManager;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
         mContext = spy(RuntimeEnvironment.application);
         mController = new DndConditionCardController(mContext, mConditionManager);
+        mNotificationManager = Shadow.extract(mContext.getSystemService(NotificationManager.class));
     }
 
     @Test
@@ -55,4 +69,58 @@
                 eq(DndConditionCardController.DND_FILTER));
         verify(mContext).unregisterReceiver(any(DndConditionCardController.Receiver.class));
     }
+
+    @Test
+    public void buildContextualCard_allSoundsMuted_shouldHavePhoneMutedSummary() {
+        mNotificationManager.setZenModeConfig(getMutedAllConfig());
+
+        final ContextualCard card = mController.buildContextualCard();
+
+        assertThat(card.getSummaryText()).isEqualTo(
+                mContext.getString(R.string.condition_zen_summary_phone_muted));
+    }
+
+    @Test
+    public void buildContextualCard_allowSomeSounds_shouldHaveWittExceptionsSummary() {
+        mNotificationManager.setZenModeConfig(getCustomConfig());
+
+        final ContextualCard card = mController.buildContextualCard();
+
+        assertThat(card.getSummaryText()).isEqualTo(
+                mContext.getString(R.string.condition_zen_summary_with_exceptions));
+    }
+
+    private ZenModeConfig getCustomConfig() {
+        final ZenModeConfig config = new ZenModeConfig();
+        // Some sounds allowed
+        config.allowAlarms = true;
+        config.allowMedia = false;
+        config.allowSystem = false;
+        config.allowCalls = true;
+        config.allowRepeatCallers = true;
+        config.allowMessages = false;
+        config.allowReminders = false;
+        config.allowEvents = false;
+        config.areChannelsBypassingDnd = false;
+        config.allowCallsFrom = ZenModeConfig.SOURCE_ANYONE;
+        config.allowMessagesFrom = ZenModeConfig.SOURCE_ANYONE;
+        config.suppressedVisualEffects = 0;
+        return config;
+    }
+
+    private ZenModeConfig getMutedAllConfig() {
+        final ZenModeConfig config = new ZenModeConfig();
+        // No sounds allowed
+        config.allowAlarms = false;
+        config.allowMedia = false;
+        config.allowSystem = false;
+        config.allowCalls = false;
+        config.allowRepeatCallers = false;
+        config.allowMessages = false;
+        config.allowReminders = false;
+        config.allowEvents = false;
+        config.areChannelsBypassingDnd = false;
+        config.suppressedVisualEffects = 0;
+        return config;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index 02d7a9d..77fc5d9 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -30,7 +30,6 @@
 import android.app.PendingIntent;
 import android.content.Context;
 import android.content.Intent;
-import android.text.TextUtils;
 
 import androidx.core.graphics.drawable.IconCompat;
 import androidx.slice.Slice;
@@ -123,18 +122,6 @@
     }
 
     @Test
-    public void getSlice_hasBluetoothDevices_shouldHavePairNewDevice() {
-        mockBluetoothDeviceList(1);
-        doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
-
-        final Slice slice = mBluetoothDevicesSlice.getSlice();
-
-        final List<SliceItem> sliceItems = slice.getItems();
-        SliceTester.assertAnySliceItemContainsTitle(sliceItems,
-                mContext.getString(R.string.bluetooth_pairing_pref_title));
-    }
-
-    @Test
     public void getSlice_noBluetoothDevices_shouldHaveNoBluetoothDevicesTitle() {
         doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
 
@@ -146,17 +133,6 @@
     }
 
     @Test
-    public void getSlice_noBluetoothDevices_shouldNotHavePairNewDevice() {
-        doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
-
-        final Slice slice = mBluetoothDevicesSlice.getSlice();
-
-        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
-        assertThat(hasTitle(metadata,
-                mContext.getString(R.string.bluetooth_pairing_pref_title))).isFalse();
-    }
-
-    @Test
     public void getSlice_exceedDefaultRowCount_shouldOnlyShowDefaultRows() {
         mockBluetoothDeviceList(BluetoothDevicesSlice.DEFAULT_EXPANDED_ROW_COUNT + 1);
         doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getConnectedBluetoothDevices();
@@ -204,9 +180,4 @@
             mBluetoothDeviceList.add(mCachedBluetoothDevice);
         }
     }
-
-    private boolean hasTitle(SliceMetadata metadata, String title) {
-        final CharSequence sliceTitle = metadata.getTitle();
-        return TextUtils.equals(sliceTitle, title);
-    }
 }
diff --git a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
index ff3f0ec..fd6d6a1 100644
--- a/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
+++ b/tests/robotests/src/com/android/settings/inputmethod/UserDictionaryListControllerTest.java
@@ -142,9 +142,9 @@
                 String sortOrder) {
             if (hasDictionary) {
                 final MatrixCursor cursor = new MatrixCursor(
-                        new String[] {UserDictionary.Words.LOCALE});
-                cursor.addRow(new Object[] {"en"});
-                cursor.addRow(new Object[] {"es"});
+                        new String[]{UserDictionary.Words.LOCALE});
+                cursor.addRow(new Object[]{"en"});
+                cursor.addRow(new Object[]{"es"});
                 return cursor;
             } else {
                 return null;
diff --git a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
index e0334b1..dbc122a 100644
--- a/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
+++ b/tests/robotests/src/com/android/settings/network/SubscriptionUtilTest.java
@@ -47,7 +47,7 @@
 
     @Test
     public void getAvailableSubscriptions_nullInfoFromSubscriptionManager_nonNullResult() {
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(null);
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(null);
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).isEmpty();
@@ -57,7 +57,7 @@
     public void getAvailableSubscriptions_oneSubscription_oneResult() {
         final SubscriptionInfo info = mock(SubscriptionInfo.class);
         when(info.getMncString()).thenReturn("fake1234");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).hasSize(1);
@@ -69,7 +69,7 @@
         final SubscriptionInfo info2 = mock(SubscriptionInfo.class);
         when(info1.getMncString()).thenReturn("fake1234");
         when(info2.getMncString()).thenReturn("fake5678");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(Arrays.asList(info1, info2));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
         assertThat(subs).hasSize(2);
@@ -82,7 +82,7 @@
         final SubscriptionInfo info3 = mock(SubscriptionInfo.class);
         when(info1.getSubscriptionId()).thenReturn(1);
         when(info1.getMncString()).thenReturn("fake1234");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(
                 new ArrayList<>(Arrays.asList(info1, info2, info3)));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
@@ -100,7 +100,7 @@
         when(info1.getMncString()).thenReturn("fake1234");
         when(info4.getSubscriptionId()).thenReturn(4);
         when(info4.getMncString()).thenReturn("fake5678");
-        when(mManager.getAvailableSubscriptionInfoList()).thenReturn(new ArrayList<>(
+        when(mManager.getSelectableSubscriptionInfoList()).thenReturn(new ArrayList<>(
                 Arrays.asList(info1, info2, info3, info4)));
         final List<SubscriptionInfo> subs = SubscriptionUtil.getAvailableSubscriptions(mManager);
         assertThat(subs).isNotNull();
diff --git a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
index 447931e..3b5cdf9 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/MobileNetworkActivityTest.java
@@ -148,7 +148,7 @@
         doReturn(intent).when(mMobileNetworkActivity).getIntent();
         mSubscriptionInfos.add(mSubscriptionInfo);
         mSubscriptionInfos.add(mSubscriptionInfo2);
-        doReturn(mSubscriptionInfos).when(mSubscriptionManager).getAvailableSubscriptionInfoList();
+        doReturn(mSubscriptionInfos).when(mSubscriptionManager).getSelectableSubscriptionInfoList();
         doReturn(true).when(mSubscriptionManager).isActiveSubscriptionId(CURRENT_SUB_ID);
 
         assertThat(mMobileNetworkActivity.getSubscriptionId()).isEqualTo(CURRENT_SUB_ID);
diff --git a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
index a057022..d904ab3 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/VideoCallingPreferenceControllerTest.java
@@ -84,14 +84,14 @@
 
     @Test
     public void isVideoCallEnabled_allFlagsOn_returnTrue() {
-        assertThat(mController.isVideoCallEnabled()).isTrue();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isTrue();
     }
 
     @Test
     public void isVideoCallEnabled_disabledByPlatform_returnFalse() {
         doReturn(false).when(mImsManager).isVtEnabledByPlatform();
 
-        assertThat(mController.isVideoCallEnabled()).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
     }
 
     @Test
@@ -100,7 +100,7 @@
                 CarrierConfigManager.KEY_IGNORE_DATA_ENABLED_CHANGED_FOR_VIDEO_CALLS, false);
         doReturn(false).when(mTelephonyManager).isDataEnabled();
 
-        assertThat(mController.isVideoCallEnabled()).isFalse();
+        assertThat(mController.isVideoCallEnabled(SUB_ID, mImsManager)).isFalse();
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
index 6639aae..e9cd731 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceControllerTest.java
@@ -111,4 +111,12 @@
                 mContext.getString(R.string.manual_mode_disallowed_summary,
                         mTelephonyManager.getSimOperatorName()));
     }
+
+    @Test
+    public void init_carrierConfigNull_shouldNotCrash() {
+        when(mCarrierConfigManager.getConfigForSubId(SUB_ID)).thenReturn(null);
+
+        // Should not crash
+        mController.init(SUB_ID);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
index 1d79952..8f54115 100644
--- a/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
+++ b/tests/robotests/src/com/android/settings/panel/FakePanelContent.java
@@ -18,6 +18,7 @@
 
 import static com.android.settings.slices.CustomSliceRegistry.WIFI_SLICE_URI;
 
+import android.app.settings.SettingsEnums;
 import android.content.Intent;
 import android.net.Uri;
 
@@ -53,4 +54,9 @@
     public Intent getSeeMoreIntent() {
         return INTENT;
     }
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.TESTING;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
index 389c31e..be8d8bc 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelFragmentTest.java
@@ -22,10 +22,13 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
 
+import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.os.Bundle;
 import android.view.LayoutInflater;
+import android.view.View;
 import android.widget.LinearLayout;
 
 import com.android.settings.R;
@@ -71,13 +74,14 @@
                                 .get()
                                 .getSupportFragmentManager()
                                 .findFragmentById(R.id.main_content));
+
+        final Bundle bundle = new Bundle();
+        bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
+        doReturn(bundle).when(mPanelFragment).getArguments();
     }
 
     @Test
     public void onCreateView_adapterGetsDataset() {
-        final Bundle bundle = new Bundle();
-        bundle.putString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT, FAKE_EXTRA);
-        doReturn(bundle).when(mPanelFragment).getArguments();
         mPanelFragment.onCreateView(LayoutInflater.from(mContext),
                 new LinearLayout(mContext), null);
         PanelSlicesAdapter adapter = mPanelFragment.mAdapter;
@@ -85,4 +89,43 @@
         assertThat(adapter.getData()).containsAllIn(mFakePanelContent.getSlices());
     }
 
+    @Test
+    public void onCreate_logsOpenEvent() {
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_VISIBLE,
+                mFakePanelContent.getMetricsCategory(),
+                null,
+                0);
+    }
+
+    @Test
+    public void panelSeeMoreClick_logsCloseEvent() {
+        final View.OnClickListener listener = mPanelFragment.getSeeMoreListener();
+
+        listener.onClick(null);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                mFakePanelContent.getMetricsCategory(),
+                PanelLoggingContract.PanelClosedKeys.KEY_SEE_MORE,
+                0
+        );
+    }
+
+    @Test
+    public void panelDoneClick_logsCloseEvent() {
+        final View.OnClickListener listener = mPanelFragment.getCloseListener();
+
+        listener.onClick(null);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                mFakePanelContent.getMetricsCategory(),
+                PanelLoggingContract.PanelClosedKeys.KEY_DONE,
+                0
+        );
+    }
 }
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
index abefa67..4dce15e 100644
--- a/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
+++ b/tests/robotests/src/com/android/settings/panel/PanelSlicesAdapterTest.java
@@ -71,7 +71,7 @@
                                 .getSupportFragmentManager()
                                 .findFragmentById(R.id.main_content));
 
-        mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent.getSlices());
+        mAdapter = new PanelSlicesAdapter(mPanelFragment, mFakePanelContent);
     }
 
     @Test
diff --git a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
index 359cf5d..a51b7b0 100644
--- a/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
+++ b/tests/robotests/src/com/android/settings/panel/SettingsPanelActivityTest.java
@@ -16,13 +16,25 @@
 
 package com.android.settings.panel;
 
-import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_PACKAGE_NAME;
+import static com.android.settings.panel.SettingsPanelActivity.KEY_MEDIA_PACKAGE_NAME;
 import static com.android.settings.panel.SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT;
 
 import static com.google.common.truth.Truth.assertThat;
 
-import android.content.Intent;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
+import android.app.settings.SettingsEnums;
+import android.content.Intent;
+import android.view.MotionEvent;
+
+import com.android.settings.testutils.FakeFeatureFactory;
+
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.robolectric.Robolectric;
@@ -31,6 +43,22 @@
 @RunWith(RobolectricTestRunner.class)
 public class SettingsPanelActivityTest {
 
+    private FakeFeatureFactory mFakeFeatureFactory;
+    private FakeSettingsPanelActivity mSettingsPanelActivity;
+    private PanelFeatureProvider mPanelFeatureProvider;
+    private FakePanelContent mFakePanelContent;
+
+    @Before
+    public void setUp() {
+        mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
+        mSettingsPanelActivity = Robolectric.buildActivity(FakeSettingsPanelActivity.class)
+                .create().get();
+        mPanelFeatureProvider = spy(new PanelFeatureProviderImpl());
+        mFakeFeatureFactory.panelFeatureProvider = mPanelFeatureProvider;
+        mFakePanelContent = new FakePanelContent();
+        doReturn(mFakePanelContent).when(mPanelFeatureProvider).getPanel(any(), any(), any());
+    }
+
     @Test
     public void startMediaOutputSlice_withPackageName_bundleShouldHaveValue() {
         final Intent intent = new Intent()
@@ -41,7 +69,7 @@
         final SettingsPanelActivity activity =
                 Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
 
-        assertThat(activity.mBundle.getString(KEY_PANEL_PACKAGE_NAME))
+        assertThat(activity.mBundle.getString(KEY_MEDIA_PACKAGE_NAME))
                 .isEqualTo("com.google.android.music");
         assertThat(activity.mBundle.getString(KEY_PANEL_TYPE_ARGUMENT))
                 .isEqualTo("com.android.settings.panel.action.MEDIA_OUTPUT");
@@ -55,7 +83,23 @@
         final SettingsPanelActivity activity =
                 Robolectric.buildActivity(SettingsPanelActivity.class, intent).create().get();
 
-        assertThat(activity.mBundle.containsKey(KEY_PANEL_PACKAGE_NAME)).isFalse();
+        assertThat(activity.mBundle.containsKey(KEY_MEDIA_PACKAGE_NAME)).isFalse();
         assertThat(activity.mBundle.containsKey(KEY_PANEL_TYPE_ARGUMENT)).isFalse();
     }
+
+    @Test
+    public void onTouchEvent_outsideAction_logsPanelClosed() {
+        final MotionEvent event = mock(MotionEvent.class);
+        when(event.getAction()).thenReturn(MotionEvent.ACTION_OUTSIDE);
+
+        mSettingsPanelActivity.onTouchEvent(event);
+
+        verify(mFakeFeatureFactory.metricsFeatureProvider).action(
+                0,
+                SettingsEnums.PAGE_HIDE,
+                SettingsEnums.TESTING,
+                PanelLoggingContract.PanelClosedKeys.KEY_CLICKED_OUT,
+                0
+        );
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
new file mode 100644
index 0000000..05ce30a
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2019 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.privacy;
+
+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 android.accessibilityservice.AccessibilityServiceInfo;
+import android.content.Context;
+import android.provider.DeviceConfig;
+import android.view.accessibility.AccessibilityManager;
+
+import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowAccessibilityManager;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
+public class AccessibilityUsagePreferenceControllerTest {
+
+    private Context mContext;
+    private ShadowAccessibilityManager mAccessibilityManager;
+
+    @Before
+    public void setUp() {
+        MockitoAnnotations.initMocks(this);
+        mContext = RuntimeEnvironment.application;
+        mAccessibilityManager = Shadow.extract(
+                RuntimeEnvironment.application.getSystemService(AccessibilityManager.class));
+    }
+
+    @After
+    public void tearDown() {
+        ShadowAccessibilityManager.reset();
+        ShadowDeviceConfig.reset();
+    }
+
+    @Test
+    public void isAvailable_permissionHubNotSet_shouldReturnUnsupported() {
+        mAccessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
+        AccessibilityUsagePreferenceController controller =
+                new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+        // We have not yet set the property to show the Permissions Hub.
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_noEnabledServices_shouldReturnUnsupported() {
+        DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+                DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+        mAccessibilityManager.setEnabledAccessibilityServiceList(new ArrayList<>());
+        AccessibilityUsagePreferenceController controller =
+                new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+    }
+
+    @Test
+    public void getAvailabilityStatus_enabledServices_shouldReturnAvailableUnsearchable() {
+        DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+                DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+        mAccessibilityManager.setEnabledAccessibilityServiceList(
+                new ArrayList<>(Arrays.asList(new AccessibilityServiceInfo())));
+        AccessibilityUsagePreferenceController controller =
+                new AccessibilityUsagePreferenceController(mContext, "test_key");
+
+        assertThat(controller.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
index b947630..f9913f6 100644
--- a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
@@ -22,18 +22,25 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
 import android.permission.RuntimePermissionUsageInfo;
 import android.provider.DeviceConfig;
 
 import androidx.preference.PreferenceScreen;
 
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
 import com.android.settings.testutils.shadow.ShadowDeviceConfig;
+import com.android.settings.testutils.shadow.ShadowPermissionControllerManager;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settingslib.widget.BarChartInfo;
 import com.android.settingslib.widget.BarChartPreference;
 import com.android.settingslib.widget.BarViewInfo;
@@ -47,26 +54,41 @@
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
 
 import java.util.ArrayList;
 import java.util.List;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = {ShadowDeviceConfig.class})
+@Config(shadows = {ShadowDeviceConfig.class, ShadowUserManager.class,
+        ShadowPermissionControllerManager.class})
 public class PermissionBarChartPreferenceControllerTest {
 
     @Mock
     private PreferenceScreen mScreen;
+    @Mock
+    private LockPatternUtils mLockPatternUtils;
 
     private PermissionBarChartPreferenceController mController;
     private BarChartPreference mPreference;
+    private PrivacyDashboardFragment mFragment;
 
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        Context Context = RuntimeEnvironment.application;
-        mController = new PermissionBarChartPreferenceController(Context, "test_key");
-        mPreference = spy(new BarChartPreference(Context));
+        final Context context = RuntimeEnvironment.application;
+        final UserManager userManager = context.getSystemService(UserManager.class);
+        final ShadowUserManager shadowUserManager = Shadow.extract(userManager);
+        shadowUserManager.addProfile(new UserInfo(123, null, 0));
+        when(FakeFeatureFactory.setupForTest().securityFeatureProvider.getLockPatternUtils(
+                any(Context.class))).thenReturn(mLockPatternUtils);
+
+        mController = spy(new PermissionBarChartPreferenceController(context, "test_key"));
+        mFragment = spy(FragmentController.of(new PrivacyDashboardFragment())
+                .create().start().get());
+        mController.setFragment(mFragment);
+        mPreference = spy(new BarChartPreference(context));
         when(mScreen.findPreference(mController.getPreferenceKey()))
                 .thenReturn((BarChartPreference) mPreference);
     }
@@ -130,4 +152,41 @@
 
         verify(mPreference, times(1)).setBarViewInfos(any(BarViewInfo[].class));
     }
+
+    @Test
+    public void onStart_permissionHubEnabled_shouldShowProgressBar() {
+        DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+                DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "true", true);
+        mController.displayPreference(mScreen);
+
+        mController.onStart();
+
+        verify(mFragment).setLoadingEnabled(true /* enabled */);
+        verify(mPreference).updateLoadingState(true /* isLoading */);
+    }
+
+    @Test
+    public void onStart_permissionHubDisabled_shouldNotShowProgressBar() {
+        DeviceConfig.setProperty(DeviceConfig.Privacy.NAMESPACE,
+                DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED, "false", false);
+
+        mController.onStart();
+
+        verify(mFragment, never()).setLoadingEnabled(true /* enabled */);
+        verify(mPreference, never()).updateLoadingState(true /* isLoading */);
+    }
+
+    @Test
+    public void onPermissionUsageResult_shouldHideProgressBar() {
+        final List<RuntimePermissionUsageInfo> infos1 = new ArrayList<>();
+        final RuntimePermissionUsageInfo info1 =
+                new RuntimePermissionUsageInfo("permission 1", 10);
+        infos1.add(info1);
+        mController.displayPreference(mScreen);
+
+        mController.onPermissionUsageResult(infos1);
+
+        verify(mFragment).setLoadingEnabled(false /* enabled */);
+        verify(mPreference).updateLoadingState(false /* isLoading */);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
index d073e9b..161c39a 100644
--- a/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/PrivacyDashboardFragmentTest.java
@@ -16,53 +16,89 @@
 
 package com.android.settings.privacy;
 
-import static org.mockito.Mockito.mock;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.app.ActionBar;
 import android.content.Context;
+import android.content.pm.UserInfo;
 import android.os.Bundle;
+import android.os.UserManager;
+import android.permission.PermissionControllerManager;
 import android.view.View;
 
-import androidx.fragment.app.FragmentActivity;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.internal.widget.LockPatternUtils;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.testutils.shadow.ShadowPermissionControllerManager;
+import com.android.settings.testutils.shadow.ShadowUserManager;
 
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.robolectric.Robolectric;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.androidx.fragment.FragmentController;
+
 
 @RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class, ShadowPermissionControllerManager.class})
 public class PrivacyDashboardFragmentTest {
 
+    @Mock
+    private LockPatternUtils mLockPatternUtils;
+    @Mock
+    private PermissionControllerManager mPCM;
+
     private Context mContext;
     private PrivacyDashboardFragment mFragment;
 
     @Before
     public void setUp() {
+        MockitoAnnotations.initMocks(this);
         mContext = RuntimeEnvironment.application;
-        mFragment = spy(new PrivacyDashboardFragment());
+        final UserManager userManager = mContext.getSystemService(UserManager.class);
+        final ShadowUserManager shadowUserManager = Shadow.extract(userManager);
+        shadowUserManager.addProfile(new UserInfo(123, null, 0));
+        when(FakeFeatureFactory.setupForTest().securityFeatureProvider.getLockPatternUtils(
+                any(Context.class))).thenReturn(mLockPatternUtils);
+        mFragment = spy(FragmentController.of(new PrivacyDashboardFragment())
+                .create().start().get());
     }
 
     @Test
     public void onViewCreated_shouldCallStyleActionBar() {
-        final FragmentActivity activity = spy(
-                Robolectric.buildActivity(FragmentActivity.class).get());
-        final ActionBar actionBar = mock(ActionBar.class);
-
-        when(mFragment.getActivity()).thenReturn(activity);
-        when(mFragment.getSettingsLifecycle()).thenReturn(mock(Lifecycle.class));
-        when(mFragment.getListView()).thenReturn(mock(RecyclerView.class));
-        when(activity.getActionBar()).thenReturn(actionBar);
-
         mFragment.onViewCreated(new View(mContext), new Bundle());
 
         verify(mFragment).styleActionBar();
     }
+
+    @Test
+    public void onViewCreated_shouldInitLinearProgressBar() {
+        mFragment.onViewCreated(new View(mContext), new Bundle());
+
+        verify(mFragment).initLoadingBar();
+    }
+
+    @Test
+    public void updateLinearProgressbar_isVisible_shouldShowProgressBar() {
+        mFragment.setLoadingEnabled(true /* enabled */);
+
+        assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.VISIBLE);
+        assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.VISIBLE);
+    }
+
+    @Test
+    public void updateLinearProgressbar_isInVisible_shouldHideProgressBar() {
+        mFragment.setLoadingEnabled(false /* enabled */);
+
+        assertThat(mFragment.mProgressHeader.getVisibility()).isEqualTo(View.INVISIBLE);
+        assertThat(mFragment.mProgressAnimation.getVisibility()).isEqualTo(View.INVISIBLE);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
index a1b1a23..8325777 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNotificationManager.java
@@ -18,6 +18,7 @@
 
 import android.app.NotificationManager;
 import android.net.Uri;
+import android.service.notification.ZenModeConfig;
 
 import org.robolectric.annotation.Implementation;
 import org.robolectric.annotation.Implements;
@@ -26,6 +27,7 @@
 public class ShadowNotificationManager {
 
     private int mZenMode;
+    private ZenModeConfig mZenModeConfig;
 
     @Implementation
     protected void setZenMode(int mode, Uri conditionId, String reason) {
@@ -36,4 +38,13 @@
     protected int getZenMode() {
         return mZenMode;
     }
+
+    @Implementation
+    public ZenModeConfig getZenModeConfig() {
+        return mZenModeConfig;
+    }
+
+    public void setZenModeConfig(ZenModeConfig config) {
+        mZenModeConfig = config;
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java
new file mode 100644
index 0000000..091b244
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 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.shadow;
+
+import android.annotation.CallbackExecutor;
+import android.content.Context;
+import android.permission.PermissionControllerManager;
+
+import androidx.annotation.NonNull;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.concurrent.Executor;
+
+@Implements(PermissionControllerManager.class)
+public class ShadowPermissionControllerManager {
+
+    protected void __constructor__(Context context) {
+        // no nothing, everything is shadowed
+    }
+
+    @Implementation
+    public void getPermissionUsages(boolean countSystem, long numMillis,
+            @NonNull @CallbackExecutor Executor executor,
+            @NonNull PermissionControllerManager.OnPermissionUsageResultCallback callback) {
+
+        // Do nothing
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
index db8a85c..05a9cfb 100644
--- a/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
+++ b/tests/robotests/src/com/android/settings/widget/AdaptiveHomepageIconTest.java
@@ -97,6 +97,20 @@
     }
 
     @Test
+    public void setBackgroundColor_tileWithoutBackgroundColor_shouldSetDefaultBackgroundColor() {
+        final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
+        doReturn(Icon.createWithResource(mContext, R.drawable.ic_settings_accent))
+            .when(tile).getIcon(mContext);
+        final AdaptiveHomepageIcon icon =
+            new AdaptiveHomepageIcon(mContext, new ColorDrawable(Color.BLACK));
+
+        icon.setBackgroundColor(mContext, tile);
+
+        assertThat(icon.mBackgroundColor).isEqualTo(
+            mContext.getColor(R.color.homepage_generic_icon_background));
+    }
+
+    @Test
     public void onBindTile_externalTileWithBackgroundColorHint_shouldUpdateIcon() {
         final Tile tile = spy(new Tile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE));
         mActivityInfo.metaData.putInt(META_DATA_PREFERENCE_ICON_BACKGROUND_HINT,
diff --git a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
index b194d73..98795a7 100644
--- a/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/calling/WifiCallingSettingsForSubTest.java
@@ -18,15 +18,140 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.telephony.TelephonyManager;
+import android.telephony.ims.ProvisioningManager;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.ims.ImsConfig;
+import com.android.ims.ImsException;
+import com.android.ims.ImsManager;
+import com.android.settings.R;
+import com.android.settings.SettingsActivity;
+import com.android.settings.testutils.FakeFeatureFactory;
+import com.android.settings.widget.SwitchBar;
+import com.android.settings.widget.ToggleSwitch;
+
+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.util.ReflectionHelpers;
 
 @RunWith(RobolectricTestRunner.class)
 public class WifiCallingSettingsForSubTest {
+    private TestFragment mFragment;
+    private Context mContext;
+    private TextView mEmptyView;
+
+    @Mock private ImsManager mImsManager;
+    @Mock private TelephonyManager mTelephonyManager;
+    @Mock private PreferenceScreen mPreferenceScreen;
+    @Mock private SettingsActivity mActivity;
+    @Mock private SwitchBar mSwitchBar;
+    @Mock private ToggleSwitch mToggleSwitch;
+    @Mock private View mView;
+    @Mock private ImsConfig mImsConfig;
+
+    @Before
+    public void setUp() throws NoSuchFieldException, ImsException {
+        MockitoAnnotations.initMocks(this);
+
+        mContext = RuntimeEnvironment.application;
+        doReturn(mContext.getTheme()).when(mActivity).getTheme();
+
+        mFragment = spy(new TestFragment());
+        doReturn(mActivity).when(mFragment).getActivity();
+        doReturn(mContext).when(mFragment).getContext();
+        doReturn(mock(Intent.class)).when(mActivity).getIntent();
+        doReturn(mContext.getResources()).when(mFragment).getResources();
+        doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
+        doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(anyInt());
+        final Bundle bundle = new Bundle();
+        when(mFragment.getArguments()).thenReturn(bundle);
+        doNothing().when(mFragment).addPreferencesFromResource(anyInt());
+        doReturn(mock(ListPreference.class)).when(mFragment).findPreference(any());
+        doNothing().when(mFragment).finish();
+        doReturn(mView).when(mFragment).getView();
+
+        mEmptyView = new TextView(mContext);
+        doReturn(mEmptyView).when(mView).findViewById(android.R.id.empty);
+
+        ReflectionHelpers.setField(mSwitchBar, "mSwitch", mToggleSwitch);
+        doReturn(mSwitchBar).when(mView).findViewById(R.id.switch_bar);
+
+        doReturn(mImsManager).when(mFragment).getImsManager();
+        doReturn(mImsConfig).when(mImsManager).getConfigInterface();
+        doReturn(true).when(mImsManager).isWfcProvisionedOnDevice();
+
+        mFragment.onAttach(mContext);
+        mFragment.onCreate(null);
+        mFragment.onActivityCreated(null);
+    }
 
     @Test
     public void getHelpResource_shouldReturn0() {
-        assertThat(new WifiCallingSettingsForSub().getHelpResource()).isEqualTo(0);
+        assertThat(mFragment.getHelpResource()).isEqualTo(0);
+    }
+
+    @Test
+    public void onResume_provisioningAllowed_shouldNotFinish() throws ImsException {
+        // Call onResume while provisioning is allowed.
+        mFragment.onResume();
+
+        // Verify that finish() is not called.
+        verify(mFragment, never()).finish();
+    }
+
+    @Test
+    public void onResume_provisioningDisallowed_shouldFinish() {
+        // Call onResume while provisioning is disallowed.
+        doReturn(false).when(mImsManager).isWfcProvisionedOnDevice();
+        mFragment.onResume();
+
+        // Verify that finish() is called
+        verify(mFragment).finish();
+    }
+
+    @Test
+    public void onResumeOnPause_provisioningCallbackRegistration() throws ImsException {
+        // Verify that provisioning callback is registered after call to onResume().
+        mFragment.onResume();
+        verify(mImsConfig).addConfigCallback(any(ProvisioningManager.Callback.class));
+
+        // Verify that provisioning callback is unregistered after call to onPause.
+        mFragment.onPause();
+        verify(mImsConfig).removeConfigCallback(any());
+    }
+
+    protected class TestFragment extends WifiCallingSettingsForSub {
+        @Override
+        protected Object getSystemService(final String name) {
+            if (Context.TELEPHONY_SERVICE.equals(name)) {
+                return mTelephonyManager;
+            }
+            return null;
+        }
     }
 }