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

Commit cdee8cd1 authored by Chris Wren's avatar Chris Wren
Browse files

change the default notification rules

should make devices less noisy by default
more metrics so we can tell exactly what we're doing.

Change-Id: I2504df91083074de8fe08c896e017335bc0bc1c7
parent 313b825f
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.server.EventLogTags;

import java.io.PrintWriter;
@@ -106,6 +107,7 @@ public final class NotificationRecord {
        mCreationTimeMs = sbn.getPostTime();
        mUpdateTimeMs = mCreationTimeMs;
        mContext = context;
        stats = new NotificationUsageStats.SingleNotificationStats();
        mImportance = defaultImportance();
    }

@@ -133,27 +135,22 @@ public final class NotificationRecord {
                importance = IMPORTANCE_MAX;
                break;
        }
        stats.requestedImportance = importance;

        boolean isNoisy = (n.defaults & Notification.DEFAULT_SOUND) != 0
                || (n.defaults & Notification.DEFAULT_VIBRATE) != 0
                || n.sound != null
                || n.vibrate != null;
        stats.isNoisy = isNoisy;
        if (!isNoisy && importance > IMPORTANCE_DEFAULT) {
            importance = IMPORTANCE_DEFAULT;
        }
        // maybe only do this for target API < N?
        if (isNoisy) {
            if (importance >= IMPORTANCE_HIGH) {
                importance = IMPORTANCE_MAX;
            } else {
                importance = IMPORTANCE_HIGH;
            }
        }

        if (n.fullScreenIntent != null) {
            importance = IMPORTANCE_MAX;
        }

        stats.naturalImportance = importance;
        return importance;
    }

+242 −88

File changed.

Preview size limit exceeded, changes collapsed.