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
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user