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

Commit d810b582 authored by Yuri Lin's avatar Yuri Lin
Browse files

Log all non-intercepted notifications in Zen Log with the reason.

Also, log the contact affinity whenever we check it in shouldInterceptAudience (whether or not the notification is intercepted).

Bug: 232941276
Test: manual
Change-Id: I09816c1055d149b59c0d4a1f2963b105647e6bc0
parent f68bb6df
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -149,8 +149,13 @@ public class ZenModeFiltering {
     */
    public boolean shouldIntercept(int zen, NotificationManager.Policy policy,
            NotificationRecord record) {
        if (zen == ZEN_MODE_OFF) {
            return false;
        }

        if (isCritical(record)) {
            // Zen mode is ignored for critical notifications.
        if (zen == ZEN_MODE_OFF || isCritical(record)) {
            ZenLog.traceNotIntercepted(record, "criticalNotification");
            return false;
        }
        // Make an exception to policy for the notification saying that policy has changed
@@ -168,6 +173,7 @@ public class ZenModeFiltering {
            case Global.ZEN_MODE_ALARMS:
                if (isAlarm(record)) {
                    // Alarms only
                    ZenLog.traceNotIntercepted(record, "alarm");
                    return false;
                }
                ZenLog.traceIntercepted(record, "alarmsOnly");
@@ -184,6 +190,7 @@ public class ZenModeFiltering {
                        ZenLog.traceIntercepted(record, "!allowAlarms");
                        return true;
                    }
                    ZenLog.traceNotIntercepted(record, "allowedAlarm");
                    return false;
                }
                if (isEvent(record)) {
@@ -191,6 +198,7 @@ public class ZenModeFiltering {
                        ZenLog.traceIntercepted(record, "!allowEvents");
                        return true;
                    }
                    ZenLog.traceNotIntercepted(record, "allowedEvent");
                    return false;
                }
                if (isReminder(record)) {
@@ -198,6 +206,7 @@ public class ZenModeFiltering {
                        ZenLog.traceIntercepted(record, "!allowReminders");
                        return true;
                    }
                    ZenLog.traceNotIntercepted(record, "allowedReminder");
                    return false;
                }
                if (isMedia(record)) {
@@ -205,6 +214,7 @@ public class ZenModeFiltering {
                        ZenLog.traceIntercepted(record, "!allowMedia");
                        return true;
                    }
                    ZenLog.traceNotIntercepted(record, "allowedMedia");
                    return false;
                }
                if (isSystem(record)) {
@@ -212,6 +222,7 @@ public class ZenModeFiltering {
                        ZenLog.traceIntercepted(record, "!allowSystem");
                        return true;
                    }
                    ZenLog.traceNotIntercepted(record, "allowedSystem");
                    return false;
                }
                if (isConversation(record)) {
@@ -253,6 +264,7 @@ public class ZenModeFiltering {
                ZenLog.traceIntercepted(record, "!priority");
                return true;
            default:
                ZenLog.traceNotIntercepted(record, "unknownZenMode");
                return false;
        }
    }
@@ -271,10 +283,12 @@ public class ZenModeFiltering {
    }

    private static boolean shouldInterceptAudience(int source, NotificationRecord record) {
        if (!audienceMatches(source, record.getContactAffinity())) {
            ZenLog.traceIntercepted(record, "!audienceMatches");
        float affinity = record.getContactAffinity();
        if (!audienceMatches(source, affinity)) {
            ZenLog.traceIntercepted(record, "!audienceMatches,affinity=" + affinity);
            return true;
        }
        ZenLog.traceNotIntercepted(record, "affinity=" + affinity);
        return false;
    }