Merge "Sorting and intrusiveness updates" into oc-dev

This commit is contained in:
TreeHugger Robot
2017-05-03 15:39:26 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 8 deletions

View File

@@ -73,11 +73,13 @@ public class NotificationComparator
// Next: sufficiently import person to person communication
boolean leftPeople = isImportantPeople(left);
boolean rightPeople = isImportantPeople(right);
final int contactAffinityComparison =
Float.compare(left.getContactAffinity(), right.getContactAffinity());
if (leftPeople && rightPeople){
// by contact proximity, close to far. if same proximity, check further fields.
if (Float.compare(left.getContactAffinity(), right.getContactAffinity()) != 0) {
return -1 * Float.compare(left.getContactAffinity(), right.getContactAffinity());
if (contactAffinityComparison != 0) {
return -1 * contactAffinityComparison;
}
} else if (leftPeople != rightPeople) {
// People, messaging higher than non-messaging
@@ -91,6 +93,11 @@ public class NotificationComparator
return -1 * Integer.compare(leftImportance, rightImportance);
}
// by contact proximity, close to far. if same proximity, check further fields.
if (contactAffinityComparison != 0) {
return -1 * contactAffinityComparison;
}
// Whether or not the notification can bypass DND.
final int leftPackagePriority = left.getPackagePriority();
final int rightPackagePriority = right.getPackagePriority();

View File

@@ -19,6 +19,7 @@ package com.android.server.notification;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.net.Uri;
import android.service.notification.NotificationListenerService;
import android.util.Log;
import android.util.Slog;
@@ -46,12 +47,13 @@ public class NotificationIntrusivenessExtractor implements NotificationSignalExt
}
if (record.getImportance() >= NotificationManager.IMPORTANCE_DEFAULT) {
final Notification notification = record.getNotification();
if ((notification.defaults & Notification.DEFAULT_VIBRATE) != 0 ||
notification.vibrate != null ||
(notification.defaults & Notification.DEFAULT_SOUND) != 0 ||
notification.sound != null ||
notification.fullScreenIntent != null) {
if (record.getSound() != null && record.getSound() != Uri.EMPTY) {
record.setRecentlyIntrusive(true);
}
if (record.getVibration() != null) {
record.setRecentlyIntrusive(true);
}
if (record.getNotification().fullScreenIntent != null) {
record.setRecentlyIntrusive(true);
}
}