Merge "Allow users to block notification channels" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
73871cad72
@@ -1116,7 +1116,8 @@ public class PreferencesHelper implements RankingConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mPermissionHelper.isMigrationEnabled()) {
|
if (mPermissionHelper.isMigrationEnabled()) {
|
||||||
if (mPermissionHelper.isPermissionFixed(r.pkg, UserHandle.getUserId(r.uid))) {
|
if (mPermissionHelper.isPermissionFixed(r.pkg, UserHandle.getUserId(r.uid))
|
||||||
|
&& !(channel.isBlockable() || channel.getImportance() == IMPORTANCE_NONE)) {
|
||||||
updatedChannel.setImportance(channel.getImportance());
|
updatedChannel.setImportance(channel.getImportance());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4015,6 +4015,45 @@ public class PreferencesHelperTest extends UiServiceTestCase {
|
|||||||
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble());
|
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateNotificationChannel_fixedPermission_butUserPreviouslyBlockedIt() {
|
||||||
|
when(mPermissionHelper.isMigrationEnabled()).thenReturn(true);
|
||||||
|
when(mPermissionHelper.isPermissionFixed(PKG_O, 0)).thenReturn(true);
|
||||||
|
|
||||||
|
NotificationChannel a = new NotificationChannel("a", "a", IMPORTANCE_NONE);
|
||||||
|
mHelper.createNotificationChannel(PKG_O, UID_O, a, false, false);
|
||||||
|
|
||||||
|
NotificationChannel update = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
|
||||||
|
update.setAllowBubbles(false);
|
||||||
|
|
||||||
|
mHelper.updateNotificationChannel(PKG_O, UID_O, update, true);
|
||||||
|
|
||||||
|
assertEquals(IMPORTANCE_HIGH,
|
||||||
|
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance());
|
||||||
|
assertEquals(false,
|
||||||
|
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateNotificationChannel_fixedPermission_butAppAllowsIt() {
|
||||||
|
when(mPermissionHelper.isMigrationEnabled()).thenReturn(true);
|
||||||
|
when(mPermissionHelper.isPermissionFixed(PKG_O, 0)).thenReturn(true);
|
||||||
|
|
||||||
|
NotificationChannel a = new NotificationChannel("a", "a", IMPORTANCE_HIGH);
|
||||||
|
a.setBlockable(true);
|
||||||
|
mHelper.createNotificationChannel(PKG_O, UID_O, a, true, false);
|
||||||
|
|
||||||
|
NotificationChannel update = new NotificationChannel("a", "a", IMPORTANCE_NONE);
|
||||||
|
update.setAllowBubbles(false);
|
||||||
|
|
||||||
|
mHelper.updateNotificationChannel(PKG_O, UID_O, update, true);
|
||||||
|
|
||||||
|
assertEquals(IMPORTANCE_NONE,
|
||||||
|
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).getImportance());
|
||||||
|
assertEquals(false,
|
||||||
|
mHelper.getNotificationChannel(PKG_O, UID_O, a.getId(), false).canBubble());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateNotificationChannel_notFixedPermission() {
|
public void testUpdateNotificationChannel_notFixedPermission() {
|
||||||
when(mPermissionHelper.isMigrationEnabled()).thenReturn(true);
|
when(mPermissionHelper.isMigrationEnabled()).thenReturn(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user