Finer-grain control of people sorting via plugin

This change allows for NotificationPersonExtractorPlugin implementors
to mark notifications as "people" (to be sorted into the People
bucket) separately from extracting data from them for PeopleHub.

Test: manual
Change-Id: Ieb8a9aeea06bbfe70976ebf46274567347e695d7
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 802a8da..6650c15 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 @@
 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 @@
         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 9091d94..987b52db 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 @@
 interface NotificationPersonExtractor {
     fun extractPerson(sbn: StatusBarNotification): PersonModel?
     fun extractPersonKey(sbn: StatusBarNotification): String?
+    fun isPersonNotification(sbn: StatusBarNotification): Boolean
 }
 
 @Singleton
@@ -75,6 +76,9 @@
             }
 
     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 bfd4070..78eaf3e 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 @@
 
     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