Loading services/core/java/com/android/server/notification/PreferencesHelper.java +3 −2 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public class PreferencesHelper implements RankingConfig { private static final int XML_VERSION = 2; /** What version to check to do the upgrade for bubbles. */ private static final int XML_VERSION_BUBBLES_UPGRADE = 1; private static final int UNKNOWN_UID = UserHandle.USER_NULL; @VisibleForTesting static final int UNKNOWN_UID = UserHandle.USER_NULL; private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":"; @VisibleForTesting Loading Loading @@ -224,7 +225,7 @@ public class PreferencesHelper implements RankingConfig { } boolean skipWarningLogged = false; boolean hasSAWPermission = false; if (upgradeForBubbles) { if (upgradeForBubbles && uid != UNKNOWN_UID) { hasSAWPermission = mAppOps.noteOpNoThrow( OP_SYSTEM_ALERT_WINDOW, uid, name, null, "check-notif-bubble") == AppOpsManager.MODE_ALLOWED; Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static com.android.server.notification.PreferencesHelper.DEFAULT_BUBBLE_PREFERENCE; import static com.android.server.notification.PreferencesHelper.NOTIFICATION_CHANNEL_COUNT_LIMIT; import static com.android.server.notification.PreferencesHelper.UNKNOWN_UID; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -2510,6 +2511,26 @@ public class PreferencesHelperTest extends UiServiceTestCase { mHelper.getAppLockedFields(PKG_O, UID_O)); } @Test public void testBubblePrefence_noSAWCheckForUnknownUid() throws Exception { final String xml = "<ranking version=\"1\">\n" + "<package name=\"" + PKG_O + "\" uid=\"" + UNKNOWN_UID + "\">\n" + "<channel id=\"someId\" name=\"hi\"" + " importance=\"3\"/>" + "</package>" + "</ranking>"; XmlPullParser parser = Xml.newPullParser(); parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())), null); parser.nextTag(); mHelper.readXml(parser, false, UserHandle.USER_ALL); assertEquals(DEFAULT_BUBBLE_PREFERENCE, mHelper.getBubblePreference(PKG_O, UID_O)); assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O)); verify(mAppOpsManager, never()).noteOpNoThrow(eq(OP_SYSTEM_ALERT_WINDOW), anyInt(), anyString(), eq(null), anyString()); } @Test public void testBubblePreference_xml() throws Exception { mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE); Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +3 −2 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public class PreferencesHelper implements RankingConfig { private static final int XML_VERSION = 2; /** What version to check to do the upgrade for bubbles. */ private static final int XML_VERSION_BUBBLES_UPGRADE = 1; private static final int UNKNOWN_UID = UserHandle.USER_NULL; @VisibleForTesting static final int UNKNOWN_UID = UserHandle.USER_NULL; private static final String NON_BLOCKABLE_CHANNEL_DELIM = ":"; @VisibleForTesting Loading Loading @@ -224,7 +225,7 @@ public class PreferencesHelper implements RankingConfig { } boolean skipWarningLogged = false; boolean hasSAWPermission = false; if (upgradeForBubbles) { if (upgradeForBubbles && uid != UNKNOWN_UID) { hasSAWPermission = mAppOps.noteOpNoThrow( OP_SYSTEM_ALERT_WINDOW, uid, name, null, "check-notif-bubble") == AppOpsManager.MODE_ALLOWED; Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +21 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import static com.android.server.notification.PreferencesHelper.DEFAULT_BUBBLE_PREFERENCE; import static com.android.server.notification.PreferencesHelper.NOTIFICATION_CHANNEL_COUNT_LIMIT; import static com.android.server.notification.PreferencesHelper.UNKNOWN_UID; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -2510,6 +2511,26 @@ public class PreferencesHelperTest extends UiServiceTestCase { mHelper.getAppLockedFields(PKG_O, UID_O)); } @Test public void testBubblePrefence_noSAWCheckForUnknownUid() throws Exception { final String xml = "<ranking version=\"1\">\n" + "<package name=\"" + PKG_O + "\" uid=\"" + UNKNOWN_UID + "\">\n" + "<channel id=\"someId\" name=\"hi\"" + " importance=\"3\"/>" + "</package>" + "</ranking>"; XmlPullParser parser = Xml.newPullParser(); parser.setInput(new BufferedInputStream(new ByteArrayInputStream(xml.getBytes())), null); parser.nextTag(); mHelper.readXml(parser, false, UserHandle.USER_ALL); assertEquals(DEFAULT_BUBBLE_PREFERENCE, mHelper.getBubblePreference(PKG_O, UID_O)); assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O)); verify(mAppOpsManager, never()).noteOpNoThrow(eq(OP_SYSTEM_ALERT_WINDOW), anyInt(), anyString(), eq(null), anyString()); } @Test public void testBubblePreference_xml() throws Exception { mHelper.setBubblesAllowed(PKG_O, UID_O, BUBBLE_PREFERENCE_NONE); Loading