diff --git a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationPersonExtractorPlugin.java b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationPersonExtractorPlugin.java index 802a8dab92d94..6650c15d6742f 100644 --- a/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationPersonExtractorPlugin.java +++ b/packages/SystemUI/plugin/src/com/android/systemui/plugins/NotificationPersonExtractorPlugin.java @@ -32,12 +32,13 @@ import com.android.systemui.plugins.annotations.ProvidesInterface; public interface NotificationPersonExtractorPlugin extends Plugin { String ACTION = "com.android.systemui.action.PEOPLE_HUB_PERSON_EXTRACTOR"; - int VERSION = 0; + int VERSION = 1; /** * Attempts to extract a person from a notification. Returns {@code null} if one is not found. */ - @Nullable PersonData extractPerson(StatusBarNotification sbn); + @Nullable + PersonData extractPerson(StatusBarNotification sbn); /** * Attempts to extract a person id from a notification. Returns {@code null} if one is not @@ -50,6 +51,14 @@ public interface NotificationPersonExtractorPlugin extends Plugin { return extractPerson(sbn).key; } + /** + * Determines whether or not a notification should be treated as having a person. Used for + * appropriate positioning in the notification shade. + */ + default boolean isPersonNotification(StatusBarNotification sbn) { + return extractPersonKey(sbn) != null; + } + /** A person to be surfaced in PeopleHub. */ @ProvidesInterface(version = PersonData.VERSION) final class PersonData { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt index 9091d94e45f05..987b52dbc2e8d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleHubNotificationListener.kt @@ -47,6 +47,7 @@ private const val MAX_STORED_INACTIVE_PEOPLE = 10 interface NotificationPersonExtractor { fun extractPerson(sbn: StatusBarNotification): PersonModel? fun extractPersonKey(sbn: StatusBarNotification): String? + fun isPersonNotification(sbn: StatusBarNotification): Boolean } @Singleton @@ -75,6 +76,9 @@ class NotificationPersonExtractorPluginBoundary @Inject constructor( } override fun extractPersonKey(sbn: StatusBarNotification) = plugin?.extractPersonKey(sbn) + + override fun isPersonNotification(sbn: StatusBarNotification): Boolean = + plugin?.isPersonNotification(sbn) ?: false } @Singleton diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleNotificationIdentifier.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleNotificationIdentifier.kt index bfd4070846f32..78eaf3ee10a4a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleNotificationIdentifier.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/people/PeopleNotificationIdentifier.kt @@ -32,5 +32,5 @@ class PeopleNotificationIdentifierImpl @Inject constructor( override fun isPeopleNotification(sbn: StatusBarNotification) = sbn.notification.notificationStyle == Notification.MessagingStyle::class.java || - personExtractor.extractPersonKey(sbn) != null + personExtractor.isPersonNotification(sbn) } \ No newline at end of file