Loading services/core/java/com/android/server/notification/PreferencesHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +24 −8 Original line number Diff line number Diff line Loading @@ -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); } } Loading @@ -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 Loading Loading @@ -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. Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +6 −0 Original line number Diff line number Diff line Loading @@ -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); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +24 −8 Original line number Diff line number Diff line Loading @@ -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); } } Loading @@ -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 Loading Loading @@ -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. Loading