Merge "Hide "Pair new device" from connected device slice"
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 88f66ff..7eb8efe 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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
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/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/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/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/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/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/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/privacy/AccessibilityUsagePreferenceController.java b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
index 8aff223..bcf8f47 100644
--- a/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
+++ b/src/com/android/settings/privacy/AccessibilityUsagePreferenceController.java
@@ -18,6 +18,7 @@
 
 import android.accessibilityservice.AccessibilityServiceInfo;
 import android.content.Context;
+import android.provider.DeviceConfig;
 import android.view.accessibility.AccessibilityManager;
 
 import androidx.annotation.NonNull;
@@ -44,7 +45,10 @@
 
     @Override
     public int getAvailabilityStatus() {
-        return mEnabledServiceInfos.isEmpty() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
+        return (mEnabledServiceInfos.isEmpty() || !Boolean.parseBoolean(
+                DeviceConfig.getProperty(DeviceConfig.Privacy.NAMESPACE,
+                        DeviceConfig.Privacy.PROPERTY_PERMISSIONS_HUB_ENABLED)))
+                ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
     }
 
     @Override
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/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/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/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/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 2efd4fc..8e72f65 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -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/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/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/privacy/AccessibilityUsagePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
index 1033446..05ce30a 100644
--- a/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/AccessibilityUsagePreferenceControllerTest.java
@@ -22,8 +22,11 @@
 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;
@@ -31,6 +34,7 @@
 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;
 
@@ -38,6 +42,7 @@
 import java.util.Arrays;
 
 @RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowDeviceConfig.class})
 public class AccessibilityUsagePreferenceControllerTest {
 
     private Context mContext;
@@ -54,10 +59,23 @@
     @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");
@@ -67,6 +85,8 @@
 
     @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 =
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;
+    }
 }