summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulia Reynolds <juliacr@google.com>2022-01-21 02:33:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-01-21 02:33:54 +0000
commitf1dc5b1ee15cd8e4876239d20512dd17bb340999 (patch)
treeb076ea453754de613d7039bdb4021cdaf4a7d575
parent13ad919ff5e6561b99385bf14c639a0577288665 (diff)
parentb993531c0da0b2f2076bc83af7591c7df8bfb2cb (diff)
downloadbase-f1dc5b1ee15cd8e4876239d20512dd17bb340999.tar.gz
Merge "DO NOT MERGE Prevent apps from creating blocked channel groups" into qt-dev
-rw-r--r--services/core/java/com/android/server/notification/PreferencesHelper.java3
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java13
2 files changed, 16 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index 7b45a1b1997c..417314adc7a5 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -589,6 +589,9 @@ public class PreferencesHelper implements RankingConfig {
if (r == null) {
throw new IllegalArgumentException("Invalid package");
}
+ if (fromTargetApp) {
+ group.setBlocked(false);
+ }
final NotificationChannelGroup oldGroup = r.groups.get(group.getId());
if (!group.equals(oldGroup)) {
// will log for new entries as well as name/description changes
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index 8f8b746b59d4..648208256fa5 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -2031,6 +2031,19 @@ public class PreferencesHelperTest extends UiServiceTestCase {
}
@Test
+ public void testIsGroupBlocked_appCannotCreateAsBlocked() throws Exception {
+ NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
+ group.setBlocked(true);
+ mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group, true);
+ assertFalse(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
+
+ NotificationChannelGroup group3 = group.clone();
+ group3.setBlocked(false);
+ mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group3, true);
+ assertFalse(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
+ }
+
+ @Test
public void testIsGroup_appCannotResetBlock() throws Exception {
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group, true);