Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2445037b authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Sorting and intrusiveness updates

- The intrusiveness extractor needs to know about channels
- Allow comparisons by contact affinity even in the min bucket.

Test: cts-verifier, attention management test
Bug: 36197567
Change-Id: I1bb53d758fc2334aad5e380620fc6e39a724195c
parent 251894b1
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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();
+8 −6
Original line number Diff line number Diff line
@@ -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);
            }
        }