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

Commit 3d495294 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Include notification delegates in NMS dump" into main

parents ffa39ec1 14342a5e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2353,6 +2353,12 @@ public class PreferencesHelper implements RankingConfig {
                    pw.print(r.canHavePromotedNotifs);
                }
                pw.println();
                if (r.delegate != null) {
                    pw.print(prefix);
                    pw.printf("    Delegate: %s (%s) enabled=%s", r.delegate.mPkg, r.delegate.mUid,
                            r.delegate.mEnabled);
                    pw.println();
                }
                for (NotificationChannel channel : r.channels.values()) {
                    pw.print(prefix);
                    channel.dump(pw, "    ", filter.redact);
+24 −8
Original line number Diff line number Diff line
@@ -3903,11 +3903,11 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        notExpected.add(PKG_P + " (" + UID_P + ") importance=");  // no importance for PKG_P

        for (String exp : expected) {
            assertTrue(actual.contains(exp));
            assertThat(actual).contains(exp);
        }

        for (String notExp : notExpected) {
            assertFalse(actual.contains(notExp));
            assertThat(actual).doesNotContain(notExp);
        }
    }

@@ -3920,14 +3920,21 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        mHelper.canShowBadge(PKG_P, UID_P);

        // get dump output
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        mHelper.dump(pw, "", new NotificationManagerService.DumpFilter(), null);
        pw.flush();
        String actual = sw.toString();
        String actual = dumpToString(mHelper);

        // nobody gets any importance
        assertFalse(actual.contains("importance="));
        assertThat(actual).doesNotContain("importance=");
    }

    @Test
    public void testDumpString_includesDelegates() {
        mHelper.setNotificationDelegate(PKG_P, UID_P, "the.delegate.package", 456);

        String dump = dumpToString(mHelper);

        assertThat(dump).contains(
                "AppSettings: com.example.p (10003)\n"
                + "    Delegate: the.delegate.package (456) enabled=true");
    }

    @Test
@@ -6848,6 +6855,15 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        assertThat(channels.getList().size()).isEqualTo(0);
    }

    private static String dumpToString(PreferencesHelper helper) {
        StringWriter sw = new StringWriter();
        try (PrintWriter pw = new PrintWriter(sw)) {
            helper.dump(pw, "", new NotificationManagerService.DumpFilter(), null);
            pw.flush();
            return sw.toString();
        }
    }

    // Test version of PreferencesHelper whose only functional difference is that it does not
    // interact with the real IpcDataCache, and instead tracks whether or not the cache has been
    // invalidated since creation or the last reset.