Merge "clean up layout & styling of notification history" into rvc-dev
diff --git a/res/layout/notif_priority_conversation_preference.xml b/res/layout/notif_priority_conversation_preference.xml
index 981cd69..f68dbde 100644
--- a/res/layout/notif_priority_conversation_preference.xml
+++ b/res/layout/notif_priority_conversation_preference.xml
@@ -61,7 +61,7 @@
             android:clickable="false"
             android:focusable="false"
             android:ellipsize="end"
-            android:maxLines="2"
+            android:maxLines="3"
             android:layout_below="@id/priority_icon"
             android:textAppearance="@style/TextAppearance.NotificationImportanceDetail"
             android:visibility="gone" />
@@ -143,7 +143,7 @@
         <TextView
             android:id="@+id/silence_summary"
             android:paddingTop="@dimen/notification_importance_button_padding"
-            android:text="@string/notification_channel_summary_low"
+            android:text="@string/notification_conversation_summary_low"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:clickable="false"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9faceac..812ff86 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -8301,17 +8301,17 @@
 
 
     <!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] -->
-    <string name="lock_screen_notifs_title">Notifications on lockscreen</string>
+    <string name="lock_screen_notifs_title">Notifications on lock screen</string>
 
     <!-- Configure notifications: Value for lockscreen notifications: all notifications shown
     regardless of noisiness [CHAR LIMIT=60] -->
-    <string name="lock_screen_notifs_show_all">Show alerting and silent notifications</string>
+    <string name="lock_screen_notifs_show_all">Show conversations, default, and silent</string>
 
     <!-- Configure notifications: Value for lockscreen notifications: show alerting notifications [CHAR LIMIT=60] -->
-    <string name="lock_screen_notifs_show_alerting">Show alerting notifications only</string>
+    <string name="lock_screen_notifs_show_alerting">Hide silent conversations and notifications</string>
 
     <!-- Configure notifications: Value for lockscreen notifications: don't show notifications [CHAR LIMIT=60] -->
-    <string name="lock_screen_notifs_show_none">Don\u2019t show notifications</string>
+    <string name="lock_screen_notifs_show_none">Don\u2019t show any notifications</string>
 
     <!-- Configure notifications: Title for redacting sensitive content on lockscreen [CHAR LIMIT=60] -->
     <string name="lock_screen_notifs_redact">Sensitive notifications</string>
@@ -8395,7 +8395,7 @@
     <string name="conversation_section_switch_title">Conversation section</string>
 
     <!-- [CHAR LIMIT=100] Summary for switch that says whether this app can appear in the conversation notification section-->
-    <string name="conversation_section_switch_summary">Allow <xliff:g id="app">%1$s</xliff:g> to appear in the conversation section</string>
+    <string name="conversation_section_switch_summary">Allow app to use conversation section</string>
 
     <!-- [CHAR LIMIT=NONE] Conversation preference summary, the parent channel this conversation was spawned from (separator) the parent channel group (e.g. an account name)-->
     <string name="notification_conversation_summary" translatable="false">"<xliff:g id="parent_category_name">%1$s</xliff:g> • <xliff:g id="parent_category_group_name">%2$s</xliff:g>"</string>
@@ -8434,7 +8434,7 @@
     <string name="important_conversations_summary">Show at top of conversation section</string>
 
     <!-- [CHAR LIMIT=100] preference category title -->
-    <string name="other_conversations">Modified conversations</string>
+    <string name="other_conversations">Other conversations</string>
 
     <!-- summary for other conversations list -->
     <string name="other_conversations_summary">Conversations you\u2019ve made changes to</string>
@@ -8494,7 +8494,7 @@
     <string name="notification_silence_title">Silent</string>
 
     <!-- [CHAR LIMIT=100] Notification Importance title -->
-    <string name="notification_alert_title">Alerting</string>
+    <string name="notification_alert_title">Default</string>
 
     <!-- [CHAR LIMIT=40] Notification importance title. This setting controls how notifications in older apps may alert the user (eg, sound, visual, vibrate). -->
     <string name="allow_interruption">Allow interruptions</string>
@@ -8506,9 +8506,9 @@
     <string name="notification_priority_title">Priority</string>
 
     <!-- [CHAR LIMIT=150] Notification Importance title: important conversation level summary -->
-    <string name="notification_channel_summary_priority">Shows at top of conversation section and appears as a bubble</string>
+    <string name="notification_channel_summary_priority">Shows at top of conversation section, appears as floating bubble, displays profile picture on lock screen</string>
 
-    <string name="convo_not_supported_summary"><xliff:g id="app_name" example="Android Services">%1$s</xliff:g> does not support conversation-specific settings.</string>
+    <string name="convo_not_supported_summary"><xliff:g id="app_name" example="Android Services">%1$s</xliff:g> doesn\u2019t support most conversation features. You can’t set a conversation as priority, and conversations won’t appear as floating bubbles.</string>
 
     <!-- Channel summaries for the app notification page -->
 
@@ -8516,10 +8516,13 @@
     <string name="notification_channel_summary_min">In the pull-down shade, collapse notifications to one line</string>
 
     <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
-    <string name="notification_channel_summary_low">Helps you focus without sound or vibration</string>
+    <string name="notification_channel_summary_low">No sound or vibration</string>
+
+    <!-- [CHAR LIMIT=150] Notification Importance title: low importance level summary -->
+    <string name="notification_conversation_summary_low">No sound or vibration and appears lower in conversation section</string>
 
     <!-- [CHAR LIMIT=150] Notification Importance title: normal importance level summary -->
-    <string name="notification_channel_summary_default">Gets your attention with sound or vibration</string>
+    <string name="notification_channel_summary_default">May ring or vibrate based on phone settings</string>
 
     <!-- [CHAR LIMIT=150] Notification Importance title: high importance level summary -->
     <string name="notification_channel_summary_high">When device is unlocked, show notifications as a banner across the top of the screen</string>
@@ -8850,7 +8853,7 @@
     <string name="notification_channel_sound_title">Sound</string>
 
     <!-- [CHAR LIMIT=180] Notification conversation: important -->
-    <string name="notification_conversation_important">Important</string>
+    <string name="notification_conversation_important">Priority</string>
 
     <!-- [CHAR LIMIT=180] Notification conversation: add to home screen -->
     <string name="notification_conversation_add_to_home">Add to home</string>
diff --git a/src/com/android/settings/media/MediaDeviceUpdateWorker.java b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
index bce9c34..719d2d5 100644
--- a/src/com/android/settings/media/MediaDeviceUpdateWorker.java
+++ b/src/com/android/settings/media/MediaDeviceUpdateWorker.java
@@ -51,8 +51,8 @@
 public class MediaDeviceUpdateWorker extends SliceBackgroundWorker
         implements LocalMediaManager.DeviceCallback {
 
-    private final Context mContext;
-    private final Collection<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
+    protected final Context mContext;
+    protected final Collection<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
     private final DevicesChangedBroadcastReceiver mReceiver;
     private final String mPackageName;
 
diff --git a/src/com/android/settings/media/MediaOutputSlice.java b/src/com/android/settings/media/MediaOutputSlice.java
index 773013e..4e54d7b 100644
--- a/src/com/android/settings/media/MediaOutputSlice.java
+++ b/src/com/android/settings/media/MediaOutputSlice.java
@@ -375,7 +375,7 @@
 
     @Override
     public Class getBackgroundWorkerClass() {
-        return MediaDeviceUpdateWorker.class;
+        return MediaOutputSliceWorker.class;
     }
 
     private boolean isVisible() {
diff --git a/src/com/android/settings/media/MediaOutputSliceWorker.java b/src/com/android/settings/media/MediaOutputSliceWorker.java
new file mode 100644
index 0000000..357b234
--- /dev/null
+++ b/src/com/android/settings/media/MediaOutputSliceWorker.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2020 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.media;
+
+import static android.media.MediaRoute2ProviderService.REASON_INVALID_COMMAND;
+import static android.media.MediaRoute2ProviderService.REASON_NETWORK_ERROR;
+import static android.media.MediaRoute2ProviderService.REASON_REJECTED;
+import static android.media.MediaRoute2ProviderService.REASON_ROUTE_NOT_AVAILABLE;
+import static android.media.MediaRoute2ProviderService.REASON_UNKNOWN_ERROR;
+
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.net.Uri;
+import android.util.Log;
+
+import com.android.settings.core.instrumentation.SettingsStatsLog;
+import com.android.settingslib.media.MediaDevice;
+
+/**
+ * SliceBackgroundWorker for the MediaOutputSlice class.
+ * It inherits from MediaDeviceUpdateWorker and add metrics logging.
+ */
+public class MediaOutputSliceWorker extends MediaDeviceUpdateWorker {
+
+    private static final String TAG = "MediaOutputSliceWorker";
+    private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG);
+
+    private MediaDevice mSourceDevice, mTargetDevice;
+    private int mWiredDeviceCount;
+    private int mConnectedBluetoothDeviceCount;
+    private int mRemoteDeviceCount;
+    private int mAppliedDeviceCountWithinRemoteGroup;
+
+    public MediaOutputSliceWorker(Context context, Uri uri) {
+        super(context, uri);
+    }
+
+    @Override
+    public void connectDevice(MediaDevice device) {
+        mSourceDevice = mLocalMediaManager.getCurrentConnectedDevice();
+        mTargetDevice = device;
+
+        if (DBG) {
+            Log.d(TAG, "connectDevice -"
+                    + " source:" + mSourceDevice.toString()
+                    + " target:" + mTargetDevice.toString());
+        }
+
+        super.connectDevice(device);
+    }
+
+    private int getLoggingDeviceType(MediaDevice device, boolean isSourceDevice) {
+        switch (device.getDeviceType()) {
+            case MediaDevice.MediaDeviceType.TYPE_PHONE_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__BUILTIN_SPEAKER
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__BUILTIN_SPEAKER;
+            case MediaDevice.MediaDeviceType.TYPE_3POINT5_MM_AUDIO_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog
+                        .MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__WIRED_3POINT5_MM_AUDIO
+                        : SettingsStatsLog
+                                .MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__WIRED_3POINT5_MM_AUDIO;
+            case MediaDevice.MediaDeviceType.TYPE_USB_C_AUDIO_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__USB_C_AUDIO
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__USB_C_AUDIO;
+            case MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__BLUETOOTH
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__BLUETOOTH;
+            case MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__REMOTE_SINGLE
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__REMOTE_SINGLE;
+            case MediaDevice.MediaDeviceType.TYPE_CAST_GROUP_DEVICE:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__REMOTE_GROUP
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__REMOTE_GROUP;
+            default:
+                return isSourceDevice
+                        ? SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SOURCE__UNKNOWN_TYPE
+                        : SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__TARGET__UNKNOWN_TYPE;
+        }
+    }
+
+    private int getLoggingSwitchOpSubResult(int reason) {
+        switch (reason) {
+            case REASON_REJECTED:
+                return SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__REJECTED;
+            case REASON_NETWORK_ERROR:
+                return SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__NETWORK_ERROR;
+            case REASON_ROUTE_NOT_AVAILABLE:
+                return SettingsStatsLog
+                        .MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__ROUTE_NOT_AVAILABLE;
+            case REASON_INVALID_COMMAND:
+                return SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__INVALID_COMMAND;
+            case REASON_UNKNOWN_ERROR:
+            default:
+                return SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__UNKNOWN_ERROR;
+        }
+    }
+
+    private String getLoggingPackageName() {
+        final String packageName = getPackageName();
+        if (packageName != null && !packageName.isEmpty()) {
+            try {
+                final ApplicationInfo applicationInfo = mContext.getPackageManager()
+                        .getApplicationInfo(packageName, /* default flag */ 0);
+                if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
+                        || (applicationInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
+                    return packageName;
+                }
+            } catch (Exception ex) {
+                Log.e(TAG, packageName + "is invalid.");
+            }
+        }
+
+        return "";
+    }
+
+    private void updateLoggingDeviceCount() {
+        mWiredDeviceCount = mConnectedBluetoothDeviceCount = mRemoteDeviceCount = 0;
+        mAppliedDeviceCountWithinRemoteGroup = 0;
+
+        for (MediaDevice mediaDevice : mMediaDevices) {
+            if (mediaDevice.isConnected()) {
+                switch (mediaDevice.getDeviceType()) {
+                    case MediaDevice.MediaDeviceType.TYPE_3POINT5_MM_AUDIO_DEVICE:
+                    case MediaDevice.MediaDeviceType.TYPE_USB_C_AUDIO_DEVICE:
+                        mWiredDeviceCount++;
+                        break;
+                    case MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE:
+                        mConnectedBluetoothDeviceCount++;
+                        break;
+                    case MediaDevice.MediaDeviceType.TYPE_CAST_DEVICE:
+                    case MediaDevice.MediaDeviceType.TYPE_CAST_GROUP_DEVICE:
+                        mRemoteDeviceCount++;
+                        break;
+                    default:
+                }
+            }
+        }
+
+        if (DBG) {
+            Log.d(TAG, "connected devices:" + " wired: " + mWiredDeviceCount
+                    + " bluetooth: " + mConnectedBluetoothDeviceCount
+                    + " remote: " + mRemoteDeviceCount);
+        }
+    }
+
+    @Override
+    public void onSelectedDeviceStateChanged(MediaDevice device, int state) {
+        if (DBG) {
+            Log.d(TAG, "onSelectedDeviceStateChanged - " + device.toString());
+        }
+
+        updateLoggingDeviceCount();
+
+        SettingsStatsLog.write(
+                SettingsStatsLog.MEDIAOUTPUT_OP_SWITCH_REPORTED,
+                getLoggingDeviceType(mSourceDevice, true),
+                getLoggingDeviceType(mTargetDevice, false),
+                SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__RESULT__OK,
+                SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__SUBRESULT__NO_ERROR,
+                getLoggingPackageName(),
+                mWiredDeviceCount,
+                mConnectedBluetoothDeviceCount,
+                mRemoteDeviceCount,
+                mAppliedDeviceCountWithinRemoteGroup);
+
+        super.onSelectedDeviceStateChanged(device, state);
+    }
+
+    @Override
+    public void onRequestFailed(int reason) {
+        if (DBG) {
+            Log.e(TAG, "onRequestFailed - " + reason);
+        }
+
+        updateLoggingDeviceCount();
+
+        SettingsStatsLog.write(
+                SettingsStatsLog.MEDIAOUTPUT_OP_SWITCH_REPORTED,
+                getLoggingDeviceType(mSourceDevice, true),
+                getLoggingDeviceType(mTargetDevice, false),
+                SettingsStatsLog.MEDIA_OUTPUT_OP_SWITCH_REPORTED__RESULT__ERROR,
+                getLoggingSwitchOpSubResult(reason),
+                getLoggingPackageName(),
+                mWiredDeviceCount,
+                mConnectedBluetoothDeviceCount,
+                mRemoteDeviceCount,
+                mAppliedDeviceCountWithinRemoteGroup);
+
+        super.onRequestFailed(reason);
+    }
+}
diff --git a/src/com/android/settings/notification/app/AllConversationsPreferenceController.java b/src/com/android/settings/notification/app/AllConversationsPreferenceController.java
index 8a0d7b8..4b28b11 100644
--- a/src/com/android/settings/notification/app/AllConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/AllConversationsPreferenceController.java
@@ -23,6 +23,7 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 
+import com.android.settings.R;
 import com.android.settings.notification.NotificationBackend;
 
 import java.util.Collections;
@@ -50,6 +51,14 @@
     }
 
     @Override
+    Preference getSummaryPreference() {
+        Preference pref = new Preference(mContext);
+        pref.setOrder(1);
+        pref.setSummary(R.string.other_conversations_summary);
+        return pref;
+    }
+
+    @Override
     boolean matchesFilter(ConversationChannelWrapper conversation) {
         return !conversation.getNotificationChannel().isImportantConversation();
     }
diff --git a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
index 0ba9436..364a81c 100644
--- a/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/AppConversationListPreferenceController.java
@@ -150,7 +150,7 @@
         ShortcutInfo si = conversation.getShortcutInfo();
 
         pref.setTitle(si != null
-                ? si.getShortLabel()
+                ? si.getLabel()
                 : conversation.getNotificationChannel().getName());
         pref.setSummary(conversation.getNotificationChannel().getGroup() != null
                 ? mContext.getString(R.string.notification_conversation_summary,
diff --git a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
index c74b032..50a8b23 100644
--- a/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationHeaderPreferenceController.java
@@ -124,7 +124,7 @@
     @VisibleForTesting
     CharSequence getLabel() {
         return mConversationInfo != null
-                ? mConversationInfo.getShortLabel()
+                ? mConversationInfo.getLabel()
                 : mChannel.getName();
     }
 }
diff --git a/src/com/android/settings/notification/app/ConversationListPreferenceController.java b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
index b750a66..afb965f 100644
--- a/src/com/android/settings/notification/app/ConversationListPreferenceController.java
+++ b/src/com/android/settings/notification/app/ConversationListPreferenceController.java
@@ -73,24 +73,33 @@
             containerGroup.setVisible(false);
         } else {
             containerGroup.setVisible(true);
+            Preference summaryPref = getSummaryPreference();
+            if (summaryPref != null) {
+                containerGroup.addPreference(summaryPref);
+            }
         }
     }
 
+    abstract Preference getSummaryPreference();
+
     abstract boolean matchesFilter(ConversationChannelWrapper conversation);
 
     protected void populateConversations(List<ConversationChannelWrapper> conversations,
             PreferenceGroup containerGroup) {
+        int order = 100;
         for (ConversationChannelWrapper conversation : conversations) {
             if (conversation.getNotificationChannel().isDemoted()
                     || !matchesFilter(conversation)) {
                 continue;
             }
-            containerGroup.addPreference(createConversationPref(conversation));
+            containerGroup.addPreference(createConversationPref(conversation, order++));
         }
     }
 
-    protected Preference createConversationPref(final ConversationChannelWrapper conversation) {
+    protected Preference createConversationPref(final ConversationChannelWrapper conversation,
+            int order) {
         Preference pref = new Preference(mContext);
+        pref.setOrder(order);
 
         pref.setTitle(getTitle(conversation));
         pref.setSummary(getSummary(conversation));
@@ -116,7 +125,7 @@
     CharSequence getTitle(ConversationChannelWrapper conversation) {
         ShortcutInfo si = conversation.getShortcutInfo();
         return si != null
-                ? si.getShortLabel()
+                ? si.getLabel()
                 : conversation.getNotificationChannel().getName();
     }
 
@@ -154,8 +163,8 @@
                         return o1.getNotificationChannel().getId().compareTo(
                                 o2.getNotificationChannel().getId());
                     }
-                    return sCollator.compare(o1.getShortcutInfo().getShortLabel(),
-                            o2.getShortcutInfo().getShortLabel());
+                    return sCollator.compare(o1.getShortcutInfo().getLabel(),
+                            o2.getShortcutInfo().getLabel());
                 }
             };
 }
diff --git a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
index 74f5773..cf66474 100644
--- a/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
+++ b/src/com/android/settings/notification/app/InvalidConversationPreferenceController.java
@@ -59,8 +59,7 @@
         pref.setDisabledByAdmin(mAdmin);
         pref.setEnabled(!pref.isDisabledByAdmin());
         pref.setChecked(!mBackend.hasUserDemotedInvalidMsgApp(mAppRow.pkg, mAppRow.uid));
-        preference.setSummary(mContext.getString(
-                R.string.conversation_section_switch_summary, mAppRow.label));
+        preference.setSummary(mContext.getString(R.string.conversation_section_switch_summary));
     }
 
     @Override
diff --git a/src/com/android/settings/notification/app/NoConversationsPreferenceController.java b/src/com/android/settings/notification/app/NoConversationsPreferenceController.java
index 7b626f6..40faadc 100644
--- a/src/com/android/settings/notification/app/NoConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/NoConversationsPreferenceController.java
@@ -51,6 +51,11 @@
     }
 
     @Override
+    Preference getSummaryPreference() {
+        return null;
+    }
+
+    @Override
     boolean matchesFilter(ConversationChannelWrapper conversation) {
         return false;
     }
diff --git a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
index ae20d12..5533912 100644
--- a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
+++ b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java
@@ -23,6 +23,7 @@
 import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 
+import com.android.settings.R;
 import com.android.settings.notification.NotificationBackend;
 
 import java.util.Collections;
@@ -50,6 +51,14 @@
     }
 
     @Override
+    Preference getSummaryPreference() {
+        Preference pref = new Preference(mContext);
+        pref.setOrder(1);
+        pref.setSummary(R.string.important_conversations_summary_bubbles);
+        return pref;
+    }
+
+    @Override
     boolean matchesFilter(ConversationChannelWrapper conversation) {
         return conversation.getNotificationChannel().isImportantConversation();
     }
diff --git a/src/com/android/settings/notification/history/NotificationHistoryActivity.java b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
index 5531f12..1e5e21e 100644
--- a/src/com/android/settings/notification/history/NotificationHistoryActivity.java
+++ b/src/com/android/settings/notification/history/NotificationHistoryActivity.java
@@ -300,7 +300,7 @@
             LinearLayoutManager lm = new LinearLayoutManager(NotificationHistoryActivity.this);
             mSnoozedRv.setLayoutManager(lm);
             mSnoozedRv.setAdapter(
-                    new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
+                    new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm, mUm));
             mSnoozedRv.setNestedScrollingEnabled(false);
 
             if (snoozed == null || snoozed.length == 0) {
@@ -315,7 +315,7 @@
                 new LinearLayoutManager(NotificationHistoryActivity.this);
             mDismissedRv.setLayoutManager(dismissLm);
             mDismissedRv.setAdapter(
-                new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm));
+                new NotificationSbnAdapter(NotificationHistoryActivity.this, mPm, mUm));
             mDismissedRv.setNestedScrollingEnabled(false);
 
             if (dismissed == null || dismissed.length == 0) {
diff --git a/src/com/android/settings/notification/history/NotificationSbnAdapter.java b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
index 5d4e716..27ecabd 100644
--- a/src/com/android/settings/notification/history/NotificationSbnAdapter.java
+++ b/src/com/android/settings/notification/history/NotificationSbnAdapter.java
@@ -32,6 +32,7 @@
 import android.graphics.PorterDuff;
 import android.graphics.drawable.Drawable;
 import android.os.UserHandle;
+import android.os.UserManager;
 import android.service.notification.StatusBarNotification;
 import android.text.TextUtils;
 import android.util.Log;
@@ -47,6 +48,7 @@
 import com.android.settings.R;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -62,8 +64,9 @@
     private @ColorInt int mBackgroundColor;
     private boolean mInNightMode;
     private @UserIdInt int mCurrentUser;
+    private List<Integer> mEnabledProfiles = new ArrayList<>();
 
-    public NotificationSbnAdapter(Context context, PackageManager pm) {
+    public NotificationSbnAdapter(Context context, PackageManager pm, UserManager um) {
         mContext = context;
         mPm = pm;
         mUserBadgeCache = new HashMap<>();
@@ -74,6 +77,12 @@
         mInNightMode = (currentConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
                 == Configuration.UI_MODE_NIGHT_YES;
         mCurrentUser = ActivityManager.getCurrentUser();
+        int[] enabledUsers = um.getEnabledProfileIds(mCurrentUser);
+        for (int id : enabledUsers) {
+            if (!um.isQuietModeEnabled(UserHandle.of(id))) {
+                mEnabledProfiles.add(id);
+            }
+        }
         setHasStableIds(true);
     }
 
@@ -115,10 +124,9 @@
     }
 
     public void onRebuildComplete(List<StatusBarNotification> notifications) {
-        // summaries are low content; don't bother showing them
         for (int i = notifications.size() - 1; i >= 0; i--) {
             StatusBarNotification sbn = notifications.get(i);
-            if (sbn.isGroup() && sbn.getNotification().isGroupSummary()) {
+            if (!shouldShowSbn(sbn)) {
                 notifications.remove(i);
             }
         }
@@ -127,13 +135,25 @@
     }
 
     public void addSbn(StatusBarNotification sbn) {
-        if (sbn.isGroup() && sbn.getNotification().isGroupSummary()) {
+        if (!shouldShowSbn(sbn)) {
             return;
         }
         mValues.add(0, sbn);
         notifyDataSetChanged();
     }
 
+    private boolean shouldShowSbn(StatusBarNotification sbn) {
+        // summaries are low content; don't bother showing them
+        if (sbn.isGroup() && sbn.getNotification().isGroupSummary()) {
+            return false;
+        }
+        // also don't show profile notifications if the profile is currently disabled
+        if (!mEnabledProfiles.contains(normalizeUserId(sbn))) {
+            return false;
+        }
+        return true;
+    }
+
     private @NonNull CharSequence loadPackageLabel(String pkg) {
         try {
             ApplicationInfo info = mPm.getApplicationInfo(pkg,
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
index 96f4e0b..428a1a8 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationHeaderPreferenceControllerTest.java
@@ -103,10 +103,10 @@
     @Test
     public void testGetLabel() {
         ShortcutInfo si = mock(ShortcutInfo.class);
-        when(si.getShortLabel()).thenReturn("hello");
+        when(si.getLabel()).thenReturn("hello");
         NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
         mController.onResume(appRow, null, null, null, si, null);
-        assertEquals(si.getShortLabel(), mController.getLabel());
+        assertEquals(si.getLabel(), mController.getLabel());
 
         NotificationChannel channel = new NotificationChannel("cid", "cname", IMPORTANCE_NONE);
         mController.onResume(appRow, channel, null, null, null, null);
diff --git a/tests/robotests/src/com/android/settings/notification/app/ConversationListPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/app/ConversationListPreferenceControllerTest.java
index cbd9115..6714031 100644
--- a/tests/robotests/src/com/android/settings/notification/app/ConversationListPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/app/ConversationListPreferenceControllerTest.java
@@ -34,6 +34,7 @@
 import android.provider.Settings;
 import android.service.notification.ConversationChannelWrapper;
 
+import androidx.preference.Preference;
 import androidx.preference.PreferenceCategory;
 import androidx.preference.PreferenceManager;
 import androidx.preference.PreferenceScreen;
@@ -169,12 +170,12 @@
         ccw.setPkg("pkg");
         ccw.setUid(1);
         ShortcutInfo si = mock(ShortcutInfo.class);
-        when(si.getShortLabel()).thenReturn("conversation name");
+        when(si.getLabel()).thenReturn("conversation name");
         ccw.setShortcutInfo(si);
         ccw.setGroupLabel("group");
         ccw.setParentChannelLabel("parent");
 
-        assertThat(mController.getTitle(ccw).toString()).isEqualTo(si.getShortLabel());
+        assertThat(mController.getTitle(ccw).toString()).isEqualTo(si.getLabel());
     }
 
     @Test
@@ -225,5 +226,10 @@
         public String getPreferenceKey() {
             return "test";
         }
+
+        @Override
+        Preference getSummaryPreference() {
+            return null;
+        }
     }
 }