Merge "Add prepainting background while swiping to dismiss."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9f6cdb5..dbefdfa 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -620,8 +620,7 @@
 
         <activity
             android:name="Settings$ManageAssistActivity"
-            android:label="@string/assist_and_voice_input_title"
-            android:parentActivityName="Settings">
+            android:label="@string/assist_and_voice_input_title">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.VOICE_INPUT_SETTINGS" />
                 <category android:name="android.intent.category.DEFAULT" />
@@ -795,7 +794,8 @@
 
         <activity android:name="Settings$WallpaperSettingsActivity"
                   android:label="@string/wallpaper_settings_fragment_title"
-                  android:icon="@drawable/ic_wallpaper">
+                  android:icon="@drawable/ic_wallpaper"
+                  android:exported="true">
             <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                        android:value="com.android.settings.wallpaper.WallpaperTypeSettings" />
         </activity>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2e2320d..f02848e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -11013,11 +11013,11 @@
     <!-- Message for forget passpoint dialog [CHAR LIMIT=none] -->
     <string name="forget_passpoint_dialog_message">You may lose access to any remaining time or data. Check with your provider before removing.</string>
 
-    <!-- Keywords for Content Capture feature [CHAR_LIMIT=32] -->
-    <string name="keywords_content_capture">content capture</string>
+    <!-- Keywords for Content Capture / Smart Suggestions feature [CHAR_LIMIT=none] -->
+    <string name="keywords_content_capture">content capture, smart suggestions</string>
     <!-- Title of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=none]-->
-    <string name="content_capture">Content Capture</string>
-    <!-- Description of the 'Content Capture' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
+    <string name="content_capture">Smart Suggestions</string>
+    <!-- Description of the 'Content Capture / Smart Suggestions' feature toggle in the Settings -> Privacy screen [CHAR LIMIT=NONE]-->
     <string name="content_capture_summary">Allow Android to save information seen on your screen or heard in video or audio content. Android makes helpful suggestions based on your device activity.</string>
 
     <!-- Title for the button to initiate a heap dump for the system server. [CHAR LIMIT=NONE] -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index a8ae506..d777fd0 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -103,6 +103,7 @@
         <item name="android:trackTint">@color/switchbar_switch_track_tint</item>
         <item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item>
         <item name="android:minHeight">@dimen/min_tap_target_size</item>
+        <item name="android:minWidth">@dimen/min_tap_target_size</item>
     </style>
 
     <style name="Theme.CryptKeeper" parent="@android:style/Theme.Material.NoActionBar">
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index 1efe2c2..0e417c9 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -58,12 +58,10 @@
             android:title="@string/screen_zoom_title"
             settings:searchable="false"/>
 
-        <ListPreference
+        <Preference
             android:key="dark_ui_mode_accessibility"
+            android:fragment="com.android.settings.display.DarkUISettings"
             android:title="@string/dark_ui_mode"
-            android:dialogTitle="@string/dark_ui_mode_title"
-            android:entries="@array/dark_ui_mode_entries"
-            android:entryValues="@array/dark_ui_mode_values"
             settings:searchable="false" />
 
         <Preference
diff --git a/res/xml/app_and_notification.xml b/res/xml/app_and_notification.xml
index 2996afa..fd3725a 100644
--- a/res/xml/app_and_notification.xml
+++ b/res/xml/app_and_notification.xml
@@ -20,7 +20,7 @@
     xmlns:settings="http://schemas.android.com/apk/res-auto"
     android:key="apps_and_notification_screen"
     android:title="@string/app_and_notification_dashboard_title"
-    settings:initialExpandedChildrenCount="8">
+    settings:initialExpandedChildrenCount="3">
     <!-- the initial count should include the dynamic tiles -->
 
     <Preference
diff --git a/res/xml/channel_notification_settings.xml b/res/xml/channel_notification_settings.xml
index 3158819..14e0366 100644
--- a/res/xml/channel_notification_settings.xml
+++ b/res/xml/channel_notification_settings.xml
@@ -63,8 +63,7 @@
             android:dialogTitle="@string/notification_channel_sound_title"
             android:order="11"
             android:showSilent="true"
-            android:showDefault="true"
-            android:ringtoneType="notification" />
+            android:showDefault="true"/>
 
         <!-- Vibration -->
         <com.android.settingslib.RestrictedSwitchPreference
diff --git a/res/xml/power_usage_summary.xml b/res/xml/power_usage_summary.xml
index 94ead86..88f88f1 100644
--- a/res/xml/power_usage_summary.xml
+++ b/res/xml/power_usage_summary.xml
@@ -26,13 +26,11 @@
         android:title="@string/summary_placeholder"
         android:selectable="false"
         android:layout="@layout/battery_header"
-        settings:allowDividerBelow="true"
         settings:controller="com.android.settings.fuelgauge.BatteryHeaderPreferenceController" />
 
     <com.android.settings.widget.CardPreference
         android:key="battery_tip"
         android:title="@string/summary_placeholder"
-        settings:allowDividerAbove="true"
         settings:controller="com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController" />
 
     <Preference
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index f39880c..45b9d19 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -62,26 +62,6 @@
         android:summary="@string/summary_placeholder"
         settings:searchable="false"/>
 
-    <!-- Content Capture -->
-
-    <!-- NOTE: content capture has a different preference, depending whether or not the
-         ContentCaptureService implementations defines a custom settings activitiy on its manifest.
-         Hence, we show both here, but the controller itself will decide if it's available or not.
-    -->
-
-    <SwitchPreference
-        android:key="content_capture"
-        android:title="@string/content_capture"
-        android:summary="@string/content_capture_summary"
-        settings:controller="com.android.settings.privacy.EnableContentCapturePreferenceController"/>
-
-    <com.android.settings.widget.MasterSwitchPreference
-        android:key="content_capture_custom_settings"
-        android:title="@string/content_capture"
-        android:summary="@string/content_capture_summary"
-        settings:controller="com.android.settings.privacy.EnableContentCaptureWithServiceSettingsPreferenceController">
-    </com.android.settings.widget.MasterSwitchPreference>
-
     <!-- Privacy Service -->
     <PreferenceCategory
         android:key="privacy_services"/>
@@ -105,4 +85,24 @@
             settings:searchable="false"/>
     </PreferenceCategory>
 
+    <!-- Content Capture -->
+
+    <!-- NOTE: content capture has a different preference, depending whether or not the
+         ContentCaptureService implementations defines a custom settings activitiy on its manifest.
+         Hence, we show both here, but the controller itself will decide if it's available or not.
+    -->
+
+    <SwitchPreference
+        android:key="content_capture"
+        android:title="@string/content_capture"
+        android:summary="@string/content_capture_summary"
+        settings:controller="com.android.settings.privacy.EnableContentCapturePreferenceController"/>
+
+    <com.android.settings.widget.MasterSwitchPreference
+        android:key="content_capture_custom_settings"
+        android:title="@string/content_capture"
+        android:summary="@string/content_capture_summary"
+        settings:controller="com.android.settings.privacy.EnableContentCaptureWithServiceSettingsPreferenceController">
+    </com.android.settings.widget.MasterSwitchPreference>
+
 </PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/settings/SetupWizardUtils.java b/src/com/android/settings/SetupWizardUtils.java
index 70ee2ca..166e065 100644
--- a/src/com/android/settings/SetupWizardUtils.java
+++ b/src/com/android/settings/SetupWizardUtils.java
@@ -67,9 +67,6 @@
     }
 
     public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
-        toIntent.putExtra(WizardManagerHelper.EXTRA_THEME,
-                fromIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
-        toIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE,
-                fromIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false));
+        WizardManagerHelper.copyWizardManagerExtras(fromIntent, toIntent);
     }
 }
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 4ba605f..efa14f6 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -244,7 +244,7 @@
     private SwitchPreference mToggleInversionPreference;
     private ColorInversionPreferenceController mInversionPreferenceController;
     private AccessibilityHearingAidPreferenceController mHearingAidPreferenceController;
-    private ListPreference mDarkUIModePreference;
+    private Preference mDarkUIModePreference;
     private DarkUIPreferenceController mDarkUIPreferenceController;
     private LiveCaptionPreferenceController mLiveCaptionPreferenceController;
 
diff --git a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
index 796df46..57bae45 100644
--- a/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
+++ b/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsController.java
@@ -20,6 +20,8 @@
 import android.os.PowerManager;
 import android.provider.Settings;
 import android.provider.Settings.Global;
+import android.text.TextUtils;
+import com.android.settingslib.fuelgauge.BatterySaverUtils;
 
 /**
  * Responds to user actions in the Settings > Battery > Set a Schedule Screen
@@ -66,24 +68,34 @@
 
     public boolean setDefaultKey(String key) {
         final ContentResolver resolver = mContext.getContentResolver();
-        switch(key) {
-            case KEY_NO_SCHEDULE:
-                Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
-                        PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
-                Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
-                break;
-            case KEY_PERCENTAGE:
-                Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
-                        PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
-                Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 5);
-                break;
-            case KEY_ROUTINE:
-                Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
-                        PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC);
-                break;
-            default:
-                throw new IllegalStateException(
-                        "Not a valid key for " + this.getClass().getSimpleName());
+
+        int mode = PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE;
+        int triggerLevel = 0;
+        if (!TextUtils.equals(key, KEY_NO_SCHEDULE)
+                && BatterySaverUtils.maybeShowBatterySaverConfirmation(
+                        mContext, true /* confirmOnly */)) {
+            return true;
+        } else {
+            switch (key) {
+                case KEY_NO_SCHEDULE:
+                    break;
+                case KEY_PERCENTAGE:
+                    triggerLevel = 5;
+                    break;
+                case KEY_ROUTINE:
+                    mode = PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC;
+                    break;
+                default:
+                    throw new IllegalStateException(
+                            "Not a valid key for " + this.getClass().getSimpleName());
+            }
+        }
+
+        // Trigger level is intentionally left alone when going between dynamic and percentage modes
+        // so that a users percentage based schedule is preserved when they toggle between the two.
+        Settings.Global.putInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE, mode);
+        if (mode != PowerManager.POWER_SAVE_MODE_TRIGGER_DYNAMIC) {
+            Settings.Global.putInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, triggerLevel);
         }
         mSeekBarController.updateSeekBar();
         return true;
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
index 341e061..61b24df 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionController.java
@@ -22,21 +22,27 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
 import android.hardware.display.ColorDisplayManager;
 import android.util.Log;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.settings.R;
 import com.android.settings.homepage.contextualcards.ContextualCard;
 
 import java.net.URISyntaxException;
+import java.util.List;
 import java.util.Objects;
 
 public class GrayscaleConditionController implements ConditionalCardController {
     static final int ID = Objects.hash("GrayscaleConditionController");
 
+    @VisibleForTesting
+    static final String ACTION_GRAYSCALE_CHANGED = "android.settings.action.GRAYSCALE_CHANGED";
+
     private static final String TAG = "GrayscaleCondition";
-    private static final String ACTION_GRAYSCALE_CHANGED =
-            "android.settings.action.GRAYSCALE_CHANGED";
     private static final IntentFilter GRAYSCALE_CHANGED_FILTER = new IntentFilter(
             ACTION_GRAYSCALE_CHANGED);
 
@@ -113,9 +119,13 @@
     }
 
     private void sendBroadcast() {
-        final Intent intent = new Intent();
-        intent.setAction(ACTION_GRAYSCALE_CHANGED);
-        mAppContext.sendBroadcast(intent, Manifest.permission.CONTROL_DISPLAY_COLOR_TRANSFORMS);
+        final PackageManager pm = mAppContext.getPackageManager();
+        final Intent intent = new Intent(ACTION_GRAYSCALE_CHANGED);
+        final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(intent, 0 /* flags */);
+        for (ResolveInfo receiver : receivers) {
+            intent.setPackage(receiver.activityInfo.packageName);
+            mAppContext.sendBroadcast(intent);
+        }
     }
 
     public class Receiver extends BroadcastReceiver {
diff --git a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
index d174156..0278f90 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSlice.java
@@ -176,15 +176,10 @@
                 .setSubtitle(getSubTitle(mPackageName, mUid))
                 .setPrimaryAction(getPrimarySliceAction(icon, title, getIntent())));
 
-        // Get rows by notification channel.
+        // Add notification channel rows.
         final List<ListBuilder.RowBuilder> rows = getNotificationChannelRows(packageInfo, icon);
-
-        // Get displayable notification channel count.
-        final int channelCount = Math.min(rows.size(), DEFAULT_EXPANDED_ROW_COUNT);
-
-        // According to the displayable channel count to add rows.
-        for (int i = 0; i < channelCount; i++) {
-            listBuilder.addRow(rows.get(i));
+        for (ListBuilder.RowBuilder rowBuilder : rows) {
+            listBuilder.addRow(rowBuilder);
         }
 
         return listBuilder.build();
@@ -279,10 +274,9 @@
     private List<ListBuilder.RowBuilder> getNotificationChannelRows(PackageInfo packageInfo,
             IconCompat icon) {
         final List<ListBuilder.RowBuilder> notificationChannelRows = new ArrayList<>();
-        final List<NotificationChannel> enabledChannels = getEnabledChannels(mPackageName, mUid,
-                mAppRow);
+        final List<NotificationChannel> displayableChannels = getDisplayableChannels(mAppRow);
 
-        for (NotificationChannel channel : enabledChannels) {
+        for (NotificationChannel channel : displayableChannels) {
             notificationChannelRows.add(new ListBuilder.RowBuilder()
                     .setTitle(channel.getName())
                     .setSubtitle(NotificationBackend.getSentSummary(
@@ -356,10 +350,9 @@
                 title);
     }
 
-    private List<NotificationChannel> getEnabledChannels(String packageName, int uid,
-            NotificationBackend.AppRow appRow) {
+    private List<NotificationChannel> getDisplayableChannels(NotificationBackend.AppRow appRow) {
         final List<NotificationChannelGroup> channelGroupList =
-                mNotificationBackend.getGroups(packageName, uid).getList();
+                mNotificationBackend.getGroups(appRow.pkg, appRow.uid).getList();
         final List<NotificationChannel> channels = channelGroupList.stream()
                 .flatMap(group -> group.getChannels().stream().filter(
                         channel -> isChannelEnabled(group, channel, appRow)))
@@ -376,8 +369,11 @@
         }
 
         // Sort the notification channels with notification sent count by descending.
-        return channelStates.stream().sorted(CHANNEL_STATE_COMPARATOR).map(
-                state -> state.getNotificationChannel()).collect(Collectors.toList());
+        return channelStates.stream()
+                .sorted(CHANNEL_STATE_COMPARATOR)
+                .map(state -> state.getNotificationChannel())
+                .limit(DEFAULT_EXPANDED_ROW_COUNT)
+                .collect(Collectors.toList());
     }
 
     private PackageInfo getMaxSentNotificationsPackage(List<PackageInfo> packageInfoList) {
@@ -391,10 +387,14 @@
         for (PackageInfo packageInfo : packageInfoList) {
             final NotificationBackend.AppRow appRow = mNotificationBackend.loadAppRow(mContext,
                     mContext.getPackageManager(), packageInfo);
+            // Ignore packages which are banned notifications or block all displayable channels.
+            if (appRow.banned || isAllChannelsBlocked(getDisplayableChannels(appRow))) {
+                continue;
+            }
+
             // Get sent notification count from app.
             final int sentCount = appRow.sentByApp.sentCount;
-            if (!appRow.banned && sentCount >= MIN_NOTIFICATION_SENT_COUNT
-                    && sentCount > maxSentCount) {
+            if (sentCount >= MIN_NOTIFICATION_SENT_COUNT && sentCount > maxSentCount) {
                 maxSentCount = sentCount;
                 maxSentCountPackage = packageInfo;
                 mAppRow = appRow;
@@ -404,6 +404,15 @@
         return maxSentCountPackage;
     }
 
+    private boolean isAllChannelsBlocked(List<NotificationChannel> channels) {
+        for (NotificationChannel channel : channels) {
+            if (channel.getImportance() != IMPORTANCE_NONE) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     protected CharSequence getSubTitle(String packageName, int uid) {
         final int channelCount = mNotificationBackend.getChannelCount(packageName, uid);
 
diff --git a/src/com/android/settings/notification/SoundPreferenceController.java b/src/com/android/settings/notification/SoundPreferenceController.java
index e53a560..73cbad3 100644
--- a/src/com/android/settings/notification/SoundPreferenceController.java
+++ b/src/com/android/settings/notification/SoundPreferenceController.java
@@ -16,10 +16,14 @@
 
 package com.android.settings.notification;
 
+import static android.media.AudioAttributes.USAGE_ALARM;
+import static android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
+
 import android.app.NotificationChannel;
 import android.app.NotificationManager;
 import android.content.Context;
 import android.content.Intent;
+import android.media.RingtoneManager;
 import android.net.Uri;
 import android.preference.PreferenceManager;
 
@@ -91,6 +95,16 @@
     public boolean handlePreferenceTreeClick(Preference preference) {
         if (KEY_SOUND.equals(preference.getKey()) && mFragment != null) {
             NotificationSoundPreference pref = (NotificationSoundPreference) preference;
+            if (mChannel != null && mChannel.getAudioAttributes() != null) {
+                if (USAGE_ALARM == mChannel.getAudioAttributes().getUsage()) {
+                    pref.setRingtoneType(RingtoneManager.TYPE_ALARM);
+                } else if (USAGE_NOTIFICATION_RINGTONE
+                        == mChannel.getAudioAttributes().getUsage()) {
+                    pref.setRingtoneType(RingtoneManager.TYPE_RINGTONE);
+                } else {
+                    pref.setRingtoneType(RingtoneManager.TYPE_NOTIFICATION);
+                }
+            }
             pref.onPrepareRingtonePickerIntent(pref.getIntent());
             mFragment.startActivityForResult(preference.getIntent(), CODE);
             return true;
diff --git a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
index cbf909f..b043cb1 100644
--- a/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
+++ b/src/com/android/settings/notification/VibrateWhenRingPreferenceController.java
@@ -39,6 +39,8 @@
 public class VibrateWhenRingPreferenceController extends TogglePreferenceController
         implements LifecycleObserver, OnResume, OnPause {
 
+    /** Flag for whether or not to apply ramping ringer on incoming phone calls. */
+    private static final String RAMPING_RINGER_ENABLED = "ramping_ringer_enabled";
     private static final String KEY_VIBRATE_WHEN_RINGING = "vibrate_when_ringing";
     private final int DEFAULT_VALUE = 0;
     private final int NOTIFICATION_VIBRATE_WHEN_RINGING = 1;
@@ -130,8 +132,8 @@
     }
 
     private boolean isRampingRingerEnabled() {
-        return DeviceConfig.getBoolean(DeviceConfig.Telephony.NAMESPACE,
-                DeviceConfig.Telephony.RAMPING_RINGER_ENABLED, false);
+        return DeviceConfig.getBoolean(
+                DeviceConfig.NAMESPACE_TELEPHONY, RAMPING_RINGER_ENABLED, false);
     }
 
 }
diff --git a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
index b47ad9c..9358392 100644
--- a/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
+++ b/src/com/android/settings/privacy/PermissionBarChartPreferenceController.java
@@ -16,6 +16,10 @@
 
 package com.android.settings.privacy;
 
+import static android.Manifest.permission_group.CAMERA;
+import static android.Manifest.permission_group.LOCATION;
+import static android.Manifest.permission_group.MICROPHONE;
+
 import static com.android.settingslib.widget.BarChartPreference.MAXIMUM_BAR_VIEWS;
 
 import static java.util.concurrent.TimeUnit.DAYS;
@@ -131,8 +135,28 @@
 
     @Override
     public void onPermissionUsageResult(@NonNull List<RuntimePermissionUsageInfo> usageInfos) {
-        usageInfos.sort(Comparator.comparingInt(
-                RuntimePermissionUsageInfo::getAppAccessCount).reversed());
+        usageInfos.sort((x, y) -> {
+            int usageDiff = y.getAppAccessCount() - x.getAppAccessCount();
+            if (usageDiff != 0) {
+                return usageDiff;
+            }
+            String xName = x.getName();
+            String yName = y.getName();
+            if (xName.equals(LOCATION)) {
+                return -1;
+            } else if (yName.equals(LOCATION)) {
+                return 1;
+            } else if (xName.equals(MICROPHONE)) {
+                return -1;
+            } else if (yName.equals(MICROPHONE)) {
+                return 1;
+            } else if (xName.equals(CAMERA)) {
+                return -1;
+            } else if (yName.equals(CAMERA)) {
+                return 1;
+            }
+            return x.getName().compareTo(y.getName());
+        });
 
         // If the result is different, we need to update bar views.
         if (!areSamePermissionGroups(usageInfos)) {
@@ -176,6 +200,7 @@
             barViewInfos[index].setClickListener((View v) -> {
                 final Intent intent = new Intent(Intent.ACTION_REVIEW_PERMISSION_USAGE);
                 intent.putExtra(Intent.EXTRA_PERMISSION_GROUP_NAME, permissionGroupInfo.getName());
+                intent.putExtra(Intent.EXTRA_DURATION_MILLIS, DAYS.toMillis(1));
                 mContext.startActivity(intent);
             });
         }
diff --git a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
index 14564b1..0713872 100644
--- a/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
+++ b/src/com/android/settings/wallpaper/WallpaperSuggestionActivity.java
@@ -28,10 +28,18 @@
 
 import com.android.settings.R;
 import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settings.search.SearchIndexableRaw;
+import com.android.settingslib.search.SearchIndexable;
 
 import com.google.android.setupcompat.util.WizardManagerHelper;
 
-public class WallpaperSuggestionActivity extends Activity {
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class WallpaperSuggestionActivity extends Activity implements Indexable {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -79,4 +87,30 @@
         return context.getResources().getBoolean(
                 com.android.internal.R.bool.config_enableWallpaperService);
     }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                private static final String SUPPORT_SEARCH_INDEX_KEY = "wallpaper_type";
+
+                @Override
+                public List<SearchIndexableRaw> getRawDataToIndex(Context context,
+                        boolean enabled) {
+
+                    final List<SearchIndexableRaw> result = new ArrayList<>();
+
+                    SearchIndexableRaw data = new SearchIndexableRaw(context);
+                    data.title = context.getString(R.string.wallpaper_settings_fragment_title);
+                    data.screenTitle = context.getString(
+                            R.string.wallpaper_settings_fragment_title);
+                    data.intentTargetPackage = context.getString(
+                            R.string.config_wallpaper_picker_package);
+                    data.intentTargetClass = context.getString(
+                            R.string.config_wallpaper_picker_class);
+                    data.intentAction = Intent.ACTION_MAIN;
+                    data.key = SUPPORT_SEARCH_INDEX_KEY;
+                    result.add(data);
+
+                    return result;
+                }
+            };
 }
diff --git a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
index 0e0f8df..2d4a16f 100644
--- a/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
+++ b/src/com/android/settings/wallpaper/WallpaperTypeSettings.java
@@ -17,21 +17,11 @@
 package com.android.settings.wallpaper;
 
 import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 
 import com.android.settings.R;
 import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settings.search.SearchIndexableRaw;
-import com.android.settingslib.search.SearchIndexable;
 
-import java.util.ArrayList;
-import java.util.List;
 
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
 public class WallpaperTypeSettings extends DashboardFragment {
     private static final String TAG = "WallpaperTypeSettings";
 
@@ -54,42 +44,4 @@
     protected int getPreferenceScreenResId() {
         return R.xml.wallpaper_settings;
     }
-
-    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
-        new BaseSearchIndexProvider() {
-            @Override
-            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
-                final List<SearchIndexableRaw> result = new ArrayList<>();
-
-                final Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
-                final PackageManager pm = context.getPackageManager();
-                final List<ResolveInfo> rList = pm.queryIntentActivities(intent,
-                        PackageManager.MATCH_DEFAULT_ONLY);
-
-                // Add indexable data for package that is in config_wallpaper_picker_package
-                final String wallpaperPickerPackage =
-                        context.getString(R.string.config_wallpaper_picker_package);
-                for (ResolveInfo info : rList) {
-                    if (!wallpaperPickerPackage.equals(info.activityInfo.packageName)) {
-                        continue;
-                    }
-                    CharSequence label = info.loadLabel(pm);
-                    if (label == null) {
-                        label = info.activityInfo.packageName;
-                    }
-                    final SearchIndexableRaw data = new SearchIndexableRaw(context);
-                    data.title = label.toString();
-                    data.key = "wallpaper_type_settings";
-                    data.screenTitle = context.getResources().getString(
-                            R.string.wallpaper_settings_fragment_title);
-                    data.intentAction = Intent.ACTION_SET_WALLPAPER;
-                    data.intentTargetPackage = info.activityInfo.packageName;
-                    data.intentTargetClass = info.activityInfo.name;
-                    data.keywords = context.getString(R.string.keywords_wallpaper);
-                    result.add(data);
-                }
-
-                return result;
-            }
-        };
 }
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index 955525d..22b9376 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -663,7 +663,8 @@
         }
 
         // return randomized MAC address
-        if (mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
+        if (mWifiConfig != null &&
+                mWifiConfig.macRandomizationSetting == WifiConfiguration.RANDOMIZATION_PERSISTENT) {
             return mWifiConfig.getRandomizedMacAddress().toString();
         }
 
diff --git a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
index ee4cc29..10d1d48 100644
--- a/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
+++ b/src/com/android/settings/wifi/details/WifiNetworkDetailsFragment.java
@@ -140,6 +140,8 @@
                 context);
         privacyController.setWifiConfiguration(mAccessPoint.getConfig());
         privacyController.setIsEphemeral(mAccessPoint.isEphemeral());
+        privacyController.setIsPasspoint(
+                mAccessPoint.isPasspoint() || mAccessPoint.isPasspointConfig());
         controllers.add(privacyController);
 
         return controllers;
diff --git a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
index a549e21..7bec411 100644
--- a/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiPrivacyPreferenceController.java
@@ -41,6 +41,7 @@
     private WifiConfiguration mWifiConfiguration;
     private WifiManager mWifiManager;
     private boolean mIsEphemeral = false;
+    private boolean mIsPasspoint = false;
 
     public WifiPrivacyPreferenceController(Context context) {
         super(context, KEY_WIFI_PRIVACY);
@@ -56,6 +57,10 @@
         mIsEphemeral = isEphemeral;
     }
 
+    public void setIsPasspoint(boolean isPasspoint) {
+        mIsPasspoint = isPasspoint;
+    }
+
     @Override
     public int getAvailabilityStatus() {
         return mContext.getResources().getBoolean(
@@ -71,7 +76,7 @@
         updateSummary(dropDownPreference, randomizationLevel);
 
         // Makes preference not selectable, when this is a ephemeral network.
-        if (mIsEphemeral) {
+        if (mIsEphemeral || mIsPasspoint) {
             preference.setSelectable(false);
             dropDownPreference.setSummary(R.string.wifi_privacy_settings_ephemeral_summary);
         }
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index 8ca65ff..d7e5585 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -75,6 +75,7 @@
 com.android.settings.users.UserDetailsSettings
 com.android.settings.vpn2.AppManagementFragment
 com.android.settings.vpn2.VpnSettings
+com.android.settings.wallpaper.WallpaperTypeSettings
 com.android.settings.wifi.calling.WifiCallingSettingsForSub
 com.android.settings.wifi.ChangeWifiStateDetails
 com.android.settings.wifi.details.WifiNetworkDetailsFragment
diff --git a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
index f718a67..4fe8fa8a 100644
--- a/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
+++ b/tests/robotests/src/com/android/settings/SetupWizardUtilsTest.java
@@ -36,12 +36,12 @@
         Intent fromIntent = new Intent();
         final String theme = "TEST_THEME";
         fromIntent.putExtra(WizardManagerHelper.EXTRA_THEME, theme);
-        fromIntent.putExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, true);
+        fromIntent.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true);
         Intent toIntent = new Intent();
         SetupWizardUtils.copySetupExtras(fromIntent, toIntent);
 
         assertThat(theme).isEqualTo(toIntent.getStringExtra(WizardManagerHelper.EXTRA_THEME));
-        assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_USE_IMMERSIVE_MODE, false))
+        assertThat(toIntent.getBooleanExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, false))
                 .isTrue();
     }
 
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index 8c53019..0cc9dc4 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -156,7 +156,7 @@
 
     @Test
     public void testDarkUIModePreferenceSummary_shouldUpdateSummary() {
-        final ListPreference darkUIModePreference = new ListPreference(mContext);
+        final Preference darkUIModePreference = new Preference(mContext);
         final DarkUIPreferenceController mController;
         doReturn(darkUIModePreference).when(mSettings).findPreference(
             DARK_UI_MODE_PREFERENCE);
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
index 6012dbb..8654a4e 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/batterysaver/BatterySaverScheduleRadioButtonsControllerTest.java
@@ -7,6 +7,7 @@
 import android.os.PowerManager;
 import android.provider.Settings;
 import android.provider.Settings.Global;
+import android.provider.Settings.Secure;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -54,4 +55,13 @@
         assertThat(mController.getDefaultKey())
                 .isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
     }
+
+    @Test
+    public void setDefaultKey_any_defaultsToNoScheduleIfWarningNotSeen() {
+        Secure.putString(
+            mContext.getContentResolver(), Secure.LOW_POWER_WARNING_ACKNOWLEDGED, "null");
+        mController.setDefaultKey(BatterySaverScheduleRadioButtonsController.KEY_ROUTINE);
+        assertThat(mController.getDefaultKey())
+                .isEqualTo(BatterySaverScheduleRadioButtonsController.KEY_NO_SCHEDULE);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
index 2fe4697..11e76b5 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/GrayscaleConditionControllerTest.java
@@ -25,6 +25,8 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.ResolveInfo;
 import android.hardware.display.ColorDisplayManager;
 
 import org.junit.Before;
@@ -34,7 +36,9 @@
 import org.mockito.MockitoAnnotations;
 import org.robolectric.RobolectricTestRunner;
 import org.robolectric.RuntimeEnvironment;
+import org.robolectric.Shadows;
 import org.robolectric.annotation.Config;
+import org.robolectric.shadows.ShadowPackageManager;
 
 @RunWith(RobolectricTestRunner.class)
 public class GrayscaleConditionControllerTest {
@@ -45,6 +49,7 @@
     private ColorDisplayManager mColorDisplayManager;
     private Context mContext;
     private GrayscaleConditionController mController;
+    private ShadowPackageManager mPackageManager;
 
     @Before
     public void setUp() {
@@ -53,6 +58,7 @@
         mColorDisplayManager = spy(mContext.getSystemService(ColorDisplayManager.class));
         doReturn(mColorDisplayManager).when(mContext).getSystemService(ColorDisplayManager.class);
         mController = new GrayscaleConditionController(mContext, mConditionManager);
+        mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
     }
 
     @Test
@@ -85,8 +91,13 @@
 
     @Test
     public void onActionClick_shouldSendBroadcast() {
+        final Intent intent = new Intent(GrayscaleConditionController.ACTION_GRAYSCALE_CHANGED);
+        final ResolveInfo info = new ResolveInfo();
+        info.activityInfo = new ActivityInfo();
+        mPackageManager.addResolveInfoForIntent(intent, info);
+
         mController.onActionClick();
 
-        verify(mContext).sendBroadcast(any(Intent.class), any(String.class));
+        verify(mContext).sendBroadcast(any(Intent.class));
     }
 }
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
index a744e68..12513f6 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/NotificationChannelSliceTest.java
@@ -16,6 +16,7 @@
 
 package com.android.settings.homepage.contextualcards.slices;
 
+import static android.app.NotificationManager.IMPORTANCE_LOW;
 import static android.app.NotificationManager.IMPORTANCE_NONE;
 import static android.app.slice.Slice.HINT_LIST_ITEM;
 import static android.app.slice.SliceItem.FORMAT_SLICE;
@@ -116,7 +117,8 @@
     public void getSlice_hasSuggestedApp_shouldHaveNotificationChannelTitle() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -130,7 +132,8 @@
     public void getSlice_hasSuggestedApp_shouldSortByNotificationSentCount() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -157,7 +160,8 @@
     public void getSlice_noRecentlyInstalledApp_shouldHaveNoSuggestedAppTitle() {
         addMockPackageToPackageManager(false /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -169,7 +173,8 @@
     public void getSlice_noMultiChannelApp_shouldHaveNoSuggestedAppTitle() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(1 /* channelCount */, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(1 /* channelCount */, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -178,10 +183,12 @@
     }
 
     @Test
+    @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
     public void getSlice_insufficientNotificationSentCount_shouldHaveNoSuggestedAppTitle() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, 1 /* notificationCount */, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, 1 /* notificationCount */, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -192,7 +199,8 @@
     @Test
     public void getSlice_isSystemApp_shouldHaveNoSuggestedAppTitle() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */, ApplicationInfo.FLAG_SYSTEM);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -204,7 +212,8 @@
     public void getSlice_isNotificationBanned_shouldHaveNoSuggestedAppTitle() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, true /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, true /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -218,7 +227,7 @@
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
         mockNotificationBackend(NotificationChannelSlice.DEFAULT_EXPANDED_ROW_COUNT * 2,
-                NOTIFICATION_COUNT, false /* banned */);
+                NOTIFICATION_COUNT, false /* banned */, false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -234,7 +243,8 @@
     public void getSlice_channelCountIsLessThanDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT - 1, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -249,7 +259,8 @@
     public void getSlice_channelCountIsEqualToDefaultRows_subTitleShouldNotHaveTapToManagerAll() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -263,7 +274,8 @@
     public void getSlice_channelCountIsMoreThanDefaultRows_subTitleShouldHaveTapToManagerAll() {
         addMockPackageToPackageManager(true /* isRecentlyInstalled */,
                 ApplicationInfo.FLAG_INSTALLED);
-        mockNotificationBackend(CHANNEL_COUNT + 1, NOTIFICATION_COUNT, false /* banned */);
+        mockNotificationBackend(CHANNEL_COUNT + 1, NOTIFICATION_COUNT, false /* banned */,
+                false /* isChannelBlocked */);
 
         final Slice slice = mNotificationChannelSlice.getSlice();
 
@@ -273,6 +285,20 @@
                         CHANNEL_COUNT + 1));
     }
 
+    @Test
+    @Config(shadows = ShadowRestrictedLockUtilsInternal.class)
+    public void getSlice_isAllDisplayableChannelBlocked_shouldHaveNoSuggestedAppTitle() {
+        addMockPackageToPackageManager(true /* isRecentlyInstalled */,
+                ApplicationInfo.FLAG_INSTALLED);
+        mockNotificationBackend(CHANNEL_COUNT, NOTIFICATION_COUNT, false /* banned */,
+                true /* isChannelBlocked */);
+
+        final Slice slice = mNotificationChannelSlice.getSlice();
+
+        final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+        assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.no_suggested_app));
+    }
+
     private void addMockPackageToPackageManager(boolean isRecentlyInstalled, int flags) {
         final ApplicationInfo applicationInfo = new ApplicationInfo();
         applicationInfo.name = APP_LABEL;
@@ -294,8 +320,10 @@
         return System.currentTimeMillis();
     }
 
-    private void mockNotificationBackend(int channelCount, int notificationCount, boolean banned) {
-        final List<NotificationChannel> channels = buildNotificationChannel(channelCount);
+    private void mockNotificationBackend(int channelCount, int notificationCount, boolean banned,
+            boolean isChannelBlocked) {
+        final List<NotificationChannel> channels = buildNotificationChannel(channelCount,
+                isChannelBlocked);
         final AppRow appRow = buildAppRow(channelCount, notificationCount, banned);
 
         doReturn(buildNotificationChannelGroups(channels)).when(mNotificationBackend).getGroups(
@@ -308,6 +336,8 @@
 
     private AppRow buildAppRow(int channelCount, int sentCount, boolean banned) {
         final AppRow appRow = new AppRow();
+        appRow.pkg = PACKAGE_NAME;
+        appRow.uid = UID;
         appRow.banned = banned;
         appRow.channelCount = channelCount;
         appRow.sentByApp = new NotificationsSentState();
@@ -317,11 +347,12 @@
         return appRow;
     }
 
-    private List<NotificationChannel> buildNotificationChannel(int channelCount) {
+    private List<NotificationChannel> buildNotificationChannel(int channelCount,
+            boolean isChannelBlock) {
         final List<NotificationChannel> channels = new ArrayList<>();
         for (int i = 0; i < channelCount; i++) {
             channels.add(new NotificationChannel(CHANNEL_NAME_PREFIX + i, CHANNEL_NAME_PREFIX + i,
-                    IMPORTANCE_NONE));
+                    isChannelBlock ? IMPORTANCE_NONE : IMPORTANCE_LOW));
         }
 
         return channels;
@@ -369,4 +400,4 @@
         // Index 0: title; Index 1: summary.
         return rowSliceItems.get(1).getText();
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
index 1b4ede5..866f866 100644
--- a/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/SoundPreferenceControllerTest.java
@@ -39,6 +39,8 @@
 import android.app.NotificationManager;
 import android.content.Context;
 import android.content.Intent;
+import android.media.AudioAttributes;
+import android.media.RingtoneManager;
 import android.net.Uri;
 import android.os.UserManager;
 import android.provider.Settings;
@@ -54,6 +56,7 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
+import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.robolectric.Robolectric;
@@ -231,6 +234,69 @@
     }
 
     @Test
+    public void testOnPreferenceTreeClick_alarmSound() {
+        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+        channel.setSound(null, new AudioAttributes.Builder().setUsage(
+                AudioAttributes.USAGE_ALARM).build());
+        mController.onResume(appRow, channel, null, null);
+
+        AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+        NotificationSoundPreference pref =
+                spy(new NotificationSoundPreference(mContext, attributeSet));
+        pref.setKey(mController.getPreferenceKey());
+        mController.handlePreferenceTreeClick(pref);
+
+        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+        assertEquals(RingtoneManager.TYPE_ALARM,
+                intentArgumentCaptor.getValue().getIntExtra(
+                        RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+    }
+
+    @Test
+    public void testOnPreferenceTreeClick_ringtoneSound() {
+        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+        channel.setSound(null, new AudioAttributes.Builder().setUsage(
+                AudioAttributes.USAGE_NOTIFICATION_RINGTONE).build());
+        mController.onResume(appRow, channel, null, null);
+
+        AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+        NotificationSoundPreference pref =
+                spy(new NotificationSoundPreference(mContext, attributeSet));
+        pref.setKey(mController.getPreferenceKey());
+        mController.handlePreferenceTreeClick(pref);
+
+        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+        assertEquals(RingtoneManager.TYPE_RINGTONE,
+                intentArgumentCaptor.getValue().getIntExtra(
+                        RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+    }
+
+    @Test
+    public void testOnPreferenceTreeClick_otherSound() {
+        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
+        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_HIGH);
+        channel.setSound(null, new AudioAttributes.Builder().setUsage(
+                AudioAttributes.USAGE_UNKNOWN).build());
+        mController.onResume(appRow, channel, null, null);
+
+        AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+        NotificationSoundPreference pref =
+                spy(new NotificationSoundPreference(mContext, attributeSet));
+        pref.setKey(mController.getPreferenceKey());
+        mController.handlePreferenceTreeClick(pref);
+
+        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
+        verify(pref, times(1)).onPrepareRingtonePickerIntent(intentArgumentCaptor.capture());
+        assertEquals(RingtoneManager.TYPE_NOTIFICATION,
+                intentArgumentCaptor.getValue().getIntExtra(
+                        RingtoneManager.EXTRA_RINGTONE_TYPE, 0));
+    }
+
+    @Test
     public void testOnActivityResult() {
         NotificationSoundPreference pref = mock(NotificationSoundPreference.class);
         when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(pref);
diff --git a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
index 332156e..9888168 100644
--- a/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/privacy/PermissionBarChartPreferenceControllerTest.java
@@ -16,6 +16,14 @@
 
 package com.android.settings.privacy;
 
+import static android.Manifest.permission_group.CALENDAR;
+import static android.Manifest.permission_group.CAMERA;
+import static android.Manifest.permission_group.CONTACTS;
+import static android.Manifest.permission_group.LOCATION;
+import static android.Manifest.permission_group.MICROPHONE;
+import static android.Manifest.permission_group.PHONE;
+import static android.Manifest.permission_group.SMS;
+
 import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
 import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
 
@@ -221,4 +229,27 @@
         verify(mFragment).setLoadingEnabled(false /* enabled */);
         verify(mPreference).updateLoadingState(false /* isLoading */);
     }
+
+    @Test
+    public void onPermissionUsageResult_shouldBeSorted() {
+        final List<RuntimePermissionUsageInfo> infos = new ArrayList<>();
+        infos.add(new RuntimePermissionUsageInfo(PHONE, 10));
+        infos.add(new RuntimePermissionUsageInfo(LOCATION, 10));
+        infos.add(new RuntimePermissionUsageInfo(CAMERA, 10));
+        infos.add(new RuntimePermissionUsageInfo(SMS, 1));
+        infos.add(new RuntimePermissionUsageInfo(MICROPHONE, 10));
+        infos.add(new RuntimePermissionUsageInfo(CONTACTS, 42));
+        infos.add(new RuntimePermissionUsageInfo(CALENDAR, 10));
+        mController.displayPreference(mScreen);
+
+        mController.onPermissionUsageResult(infos);
+
+        assertThat(infos.get(0).getName()).isEqualTo(CONTACTS);
+        assertThat(infos.get(1).getName()).isEqualTo(LOCATION);
+        assertThat(infos.get(2).getName()).isEqualTo(MICROPHONE);
+        assertThat(infos.get(3).getName()).isEqualTo(CAMERA);
+        assertThat(infos.get(4).getName()).isEqualTo(CALENDAR);
+        assertThat(infos.get(5).getName()).isEqualTo(PHONE);
+        assertThat(infos.get(6).getName()).isEqualTo(SMS);
+    }
 }
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
index a1af8bf..2e588b5 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
@@ -109,4 +109,20 @@
 
         assertThat(mDropDownPreference.isSelectable()).isFalse();
     }
+
+    @Test
+    public void testUpdateState_isNotPasspointNetwork_shouldBeSelectable() {
+        mPreferenceController.setIsPasspoint(false);
+        mPreferenceController.updateState(mDropDownPreference);
+
+        assertThat(mDropDownPreference.isSelectable()).isTrue();
+    }
+
+    @Test
+    public void testUpdateState_isPasspointNetwork_shouldNotSelectable() {
+        mPreferenceController.setIsPasspoint(true);
+        mPreferenceController.updateState(mDropDownPreference);
+
+        assertThat(mDropDownPreference.isSelectable()).isFalse();
+    }
 }