Merge "Prevent apps from creating blocked channel groups" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fc06439710
@@ -759,6 +759,9 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
if (r == null) {
|
if (r == null) {
|
||||||
throw new IllegalArgumentException("Invalid package");
|
throw new IllegalArgumentException("Invalid package");
|
||||||
}
|
}
|
||||||
|
if (fromTargetApp) {
|
||||||
|
group.setBlocked(false);
|
||||||
|
}
|
||||||
final NotificationChannelGroup oldGroup = r.groups.get(group.getId());
|
final NotificationChannelGroup oldGroup = r.groups.get(group.getId());
|
||||||
if (oldGroup != null) {
|
if (oldGroup != null) {
|
||||||
group.setChannels(oldGroup.getChannels());
|
group.setChannels(oldGroup.getChannels());
|
||||||
|
|||||||
@@ -2131,6 +2131,19 @@ public class PreferencesHelperTest extends UiServiceTestCase {
|
|||||||
assertTrue(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
|
assertTrue(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testIsGroup_appCannotResetBlock() throws Exception {
|
public void testIsGroup_appCannotResetBlock() throws Exception {
|
||||||
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
|
NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
|
||||||
@@ -3270,7 +3283,7 @@ public class PreferencesHelperTest extends UiServiceTestCase {
|
|||||||
public void testGetConversations_noDisabledGroups() {
|
public void testGetConversations_noDisabledGroups() {
|
||||||
NotificationChannelGroup group = new NotificationChannelGroup("a", "a");
|
NotificationChannelGroup group = new NotificationChannelGroup("a", "a");
|
||||||
group.setBlocked(true);
|
group.setBlocked(true);
|
||||||
mHelper.createNotificationChannelGroup(PKG_O, UID_O, group, true);
|
mHelper.createNotificationChannelGroup(PKG_O, UID_O, group, false);
|
||||||
NotificationChannel parent = new NotificationChannel("parent", "p", 1);
|
NotificationChannel parent = new NotificationChannel("parent", "p", 1);
|
||||||
mHelper.createNotificationChannel(PKG_O, UID_O, parent, true, false);
|
mHelper.createNotificationChannel(PKG_O, UID_O, parent, true, false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user