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

Commit 0b4db747 authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "ZenLog: Track changes to effect suppressorship."

parents dbbeeb3f a7082994
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1026,6 +1026,7 @@ public class NotificationManagerService extends SystemService {
    private void updateListenerHintsLocked() {
        final int hints = mListenersDisablingEffects.isEmpty() ? 0 : HINT_HOST_DISABLE_EFFECTS;
        if (hints == mListenerHints) return;
        ZenLog.traceListenerHintsChanged(mListenerHints, hints, mListenersDisablingEffects.size());
        mListenerHints = hints;
        scheduleListenerHintsChanged(hints);
    }
@@ -1034,6 +1035,7 @@ public class NotificationManagerService extends SystemService {
        final ComponentName suppressor = !mListenersDisablingEffects.isEmpty()
                ? mListenersDisablingEffects.valueAt(0).component : null;
        if (Objects.equals(suppressor, mEffectsSuppressor)) return;
        ZenLog.traceEffectsSuppressorChanged(mEffectsSuppressor, suppressor);
        mEffectsSuppressor = suppressor;
        mZenModeHelper.setEffectsSuppressed(suppressor != null);
        getContext().sendBroadcast(new Intent(NotificationManager.ACTION_EFFECTS_SUPPRESSOR_CHANGED)
+24 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.RemoteException;
import android.provider.Settings.Global;
import android.service.notification.Condition;
import android.service.notification.IConditionProvider;
import android.service.notification.NotificationListenerService;
import android.service.notification.ZenModeConfig;
import android.util.Slog;

@@ -56,6 +57,8 @@ public class ZenLog {
    private static final int TYPE_CONFIG = 11;
    private static final int TYPE_NOT_INTERCEPTED = 12;
    private static final int TYPE_DISABLE_EFFECTS = 13;
    private static final int TYPE_SUPPRESSOR_CHANGED = 14;
    private static final int TYPE_LISTENER_HINTS_CHANGED = 15;

    private static int sNext;
    private static int sSize;
@@ -120,6 +123,17 @@ public class ZenLog {
        append(TYPE_DISABLE_EFFECTS, record.getKey() + "," + reason);
    }

    public static void traceEffectsSuppressorChanged(ComponentName oldSuppressor,
            ComponentName newSuppressor) {
        append(TYPE_SUPPRESSOR_CHANGED, componentToString(oldSuppressor) + "->"
            + componentToString(newSuppressor));
    }

    public static void traceListenerHintsChanged(int oldHints, int newHints, int listenerCount) {
        append(TYPE_LISTENER_HINTS_CHANGED, hintsToString(oldHints) + "->"
            + hintsToString(newHints) + ",listeners=" + listenerCount);
    }

    private static String subscribeResult(IConditionProvider provider, RemoteException e) {
        return provider == null ? "no provider" : e != null ? e.getMessage() : "ok";
    }
@@ -139,6 +153,8 @@ public class ZenLog {
            case TYPE_CONFIG: return "config";
            case TYPE_NOT_INTERCEPTED: return "not_intercepted";
            case TYPE_DISABLE_EFFECTS: return "disable_effects";
            case TYPE_SUPPRESSOR_CHANGED: return "suppressor_changed";
            case TYPE_LISTENER_HINTS_CHANGED: return "listener_hints_changed";
            default: return "unknown";
        }
    }
@@ -161,6 +177,14 @@ public class ZenLog {
        }
    }

    private static String hintsToString(int hints) {
        switch (hints) {
            case 0 : return "none";
            case NotificationListenerService.HINT_HOST_DISABLE_EFFECTS : return "disable_effects";
            default: return Integer.toString(hints);
        }
    }

    private static String componentToString(ComponentName component) {
        return component != null ? component.toShortString() : null;
    }