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

Commit 887f09c5 authored by Kweku Adams's avatar Kweku Adams
Browse files

Adding NonNull annotation to DumpFilter.

Bug: 65750824
Test: flash device and check notification dump
Change-Id: I620e43fff40b839ae7b80047fb83730500b59dae
parent 2dd2cbcb
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -2720,9 +2720,9 @@ public class NotificationManagerService extends SystemService {
        protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
            if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
            final DumpFilter filter = DumpFilter.parseFromArguments(args);
            if (filter != null && filter.stats) {
            if (filter.stats) {
                dumpJson(pw, filter);
            } else if (filter != null && filter.proto) {
            } else if (filter.proto) {
                dumpProto(fd, filter);
            } else {
                dumpImpl(pw, filter);
@@ -3236,7 +3236,7 @@ public class NotificationManagerService extends SystemService {
        return null;
    };

    private void dumpJson(PrintWriter pw, DumpFilter filter) {
    private void dumpJson(PrintWriter pw, @NonNull DumpFilter filter) {
        JSONObject dump = new JSONObject();
        try {
            dump.put("service", "Notification Manager");
@@ -3250,7 +3250,7 @@ public class NotificationManagerService extends SystemService {
        pw.println(dump);
    }

    private void dumpProto(FileDescriptor fd, DumpFilter filter) {
    private void dumpProto(FileDescriptor fd, @NonNull DumpFilter filter) {
        final ProtoOutputStream proto = new ProtoOutputStream(fd);
        synchronized (mNotificationLock) {
            long records = proto.start(NotificationServiceDumpProto.RECORDS);
@@ -3332,7 +3332,7 @@ public class NotificationManagerService extends SystemService {
        proto.flush();
    }

    void dumpImpl(PrintWriter pw, DumpFilter filter) {
    void dumpImpl(PrintWriter pw, @NonNull DumpFilter filter) {
        pw.print("Current Notification Manager state");
        if (filter.filtered) {
            pw.print(" (filtered to "); pw.print(filter); pw.print(")");
@@ -5901,6 +5901,7 @@ public class NotificationManagerService extends SystemService {
        public boolean redact = true;
        public boolean proto = false;

        @NonNull
        public static DumpFilter parseFromArguments(String[] args) {
            final DumpFilter filter = new DumpFilter();
            for (int ai = 0; ai < args.length; ai++) {
+22 −18
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.internal.logging.nano.MetricsProto;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;

import android.annotation.NonNull;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
@@ -915,8 +916,8 @@ public class RankingHelper implements RankingConfig {
        }
    }

    public void dump(PrintWriter pw, String prefix, NotificationManagerService.DumpFilter filter) {
        if (filter == null) {
    public void dump(PrintWriter pw, String prefix,
            @NonNull NotificationManagerService.DumpFilter filter) {
        final int N = mSignalExtractors.length;
        pw.print(prefix);
        pw.print("mSignalExtractors.length = ");
@@ -924,12 +925,12 @@ public class RankingHelper implements RankingConfig {
        for (int i = 0; i < N; i++) {
            pw.print(prefix);
            pw.print("  ");
                pw.println(mSignalExtractors[i]);
            pw.println(mSignalExtractors[i].getClass().getSimpleName());
        }

        pw.print(prefix);
        pw.println("per-package config:");
        }

        pw.println("Records:");
        synchronized (mRecords) {
            dumpRecords(pw, prefix, filter, mRecords);
@@ -938,7 +939,8 @@ public class RankingHelper implements RankingConfig {
        dumpRecords(pw, prefix, filter, mRestoredWithoutUids);
    }

    public void dump(ProtoOutputStream proto, NotificationManagerService.DumpFilter filter) {
    public void dump(ProtoOutputStream proto,
            @NonNull NotificationManagerService.DumpFilter filter) {
        final int N = mSignalExtractors.length;
        for (int i = 0; i < N; i++) {
            proto.write(RankingHelperProto.NOTIFICATION_SIGNAL_EXTRACTORS,
@@ -952,12 +954,13 @@ public class RankingHelper implements RankingConfig {
    }

    private static void dumpRecords(ProtoOutputStream proto, long fieldId,
            NotificationManagerService.DumpFilter filter, ArrayMap<String, Record> records) {
            @NonNull NotificationManagerService.DumpFilter filter,
            ArrayMap<String, Record> records) {
        final int N = records.size();
        long fToken;
        for (int i = 0; i < N; i++) {
            final Record r = records.valueAt(i);
            if (filter == null || filter.matches(r.pkg)) {
            if (filter.matches(r.pkg)) {
                fToken = proto.start(fieldId);

                proto.write(RecordProto.PACKAGE, r.pkg);
@@ -985,11 +988,12 @@ public class RankingHelper implements RankingConfig {
    }

    private static void dumpRecords(PrintWriter pw, String prefix,
            NotificationManagerService.DumpFilter filter, ArrayMap<String, Record> records) {
            @NonNull NotificationManagerService.DumpFilter filter,
            ArrayMap<String, Record> records) {
        final int N = records.size();
        for (int i = 0; i < N; i++) {
            final Record r = records.valueAt(i);
            if (filter == null || filter.matches(r.pkg)) {
            if (filter.matches(r.pkg)) {
                pw.print(prefix);
                pw.print("  AppSettings: ");
                pw.print(r.pkg);