Merge "Add progress bar for Privacy screen"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 84b12dc..70dce8f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -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/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/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/strings.xml b/res/values/strings.xml
index 7bd9950..7eb8efe 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] -->
@@ -9169,8 +9169,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>
@@ -9200,25 +9203,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>
@@ -10442,27 +10436,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
@@ -10636,6 +10630,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 323d39b..747210e 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -454,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">
@@ -476,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/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/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/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 a9606ab..94b1761 100644
--- a/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/EnabledNetworkModePreferenceController.java
@@ -177,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/gsm/AutoSelectPreferenceController.java b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
index a5d445f..7db9df0 100644
--- a/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
+++ b/src/com/android/settings/network/telephony/gsm/AutoSelectPreferenceController.java
@@ -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/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/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 876c04a..2c6368e 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -78,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)
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/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..8df15a5 100644
--- a/src/com/android/settings/wifi/AddNetworkFragment.java
+++ b/src/com/android/settings/wifi/AddNetworkFragment.java
@@ -66,16 +66,14 @@
         mCancelBtn.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));
-                });
-            }
+        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;
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..4847f07 100644
--- a/src/com/android/settings/wifi/WifiDialog.java
+++ b/src/com/android/settings/wifi/WifiDialog.java
@@ -80,20 +80,18 @@
     @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.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));
+            });
         }
         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 2e12bce..4ca9f86 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -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/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/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/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/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/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;
+        }
     }
 }