Cannot have badge only channels
Test: runtest systemui-notification & cts Change-Id: I256e35a79400c1d25b3d2f1c7c5f8c513242a2aa
This commit is contained in:
@@ -5393,7 +5393,6 @@ package android.app {
|
||||
method public android.net.Uri getSound();
|
||||
method public long[] getVibrationPattern();
|
||||
method public boolean isAllowed();
|
||||
method public void setAllowed(boolean);
|
||||
method public void setBypassDnd(boolean);
|
||||
method public void setImportance(int);
|
||||
method public void setLights(boolean);
|
||||
|
||||
@@ -5555,7 +5555,6 @@ package android.app {
|
||||
method public boolean isAllowed();
|
||||
method public void lockFields(int);
|
||||
method public void populateFromXml(org.xmlpull.v1.XmlPullParser);
|
||||
method public void setAllowed(boolean);
|
||||
method public void setBypassDnd(boolean);
|
||||
method public void setImportance(int);
|
||||
method public void setLights(boolean);
|
||||
|
||||
@@ -5403,7 +5403,6 @@ package android.app {
|
||||
method public android.net.Uri getSound();
|
||||
method public long[] getVibrationPattern();
|
||||
method public boolean isAllowed();
|
||||
method public void setAllowed(boolean);
|
||||
method public void setBypassDnd(boolean);
|
||||
method public void setImportance(int);
|
||||
method public void setLights(boolean);
|
||||
|
||||
@@ -55,7 +55,6 @@ public final class NotificationChannel implements Parcelable {
|
||||
private static final String ATT_AUDIO_ATTRIBUTES = "audio_attributes";
|
||||
private static final String ATT_SHOW_BADGE = "show_badge";
|
||||
private static final String ATT_USER_LOCKED = "locked";
|
||||
private static final String ATT_ALLOWED = "allowed";
|
||||
private static final String DELIMITER = ",";
|
||||
|
||||
/**
|
||||
@@ -243,18 +242,6 @@ public final class NotificationChannel implements Parcelable {
|
||||
this.mImportance = importance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether notifications are allowed to be posted to this channel.
|
||||
*
|
||||
* Only modifiable by the system and notification ranker.
|
||||
*
|
||||
* @param allowed true if notifications are not allowed from this channel.
|
||||
*/
|
||||
public void setAllowed(boolean allowed) {
|
||||
this.mAllowed = allowed;
|
||||
}
|
||||
|
||||
|
||||
// Modifiable by apps on channel creation.
|
||||
|
||||
/**
|
||||
@@ -406,7 +393,6 @@ public final class NotificationChannel implements Parcelable {
|
||||
enableVibration(safeBool(parser, ATT_VIBRATION_ENABLED, false));
|
||||
setVibrationPattern(safeLongArray(parser, ATT_VIBRATION, null));
|
||||
setShowBadge(safeBool(parser, ATT_SHOW_BADGE, false));
|
||||
setAllowed(safeBool(parser, ATT_ALLOWED, true));
|
||||
lockFields(safeInt(parser, ATT_USER_LOCKED, 0));
|
||||
}
|
||||
|
||||
@@ -448,9 +434,6 @@ public final class NotificationChannel implements Parcelable {
|
||||
if (canShowBadge()) {
|
||||
out.attribute(null, ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
|
||||
}
|
||||
if (!isAllowed()) {
|
||||
out.attribute(null, ATT_ALLOWED, Boolean.toString(isAllowed()));
|
||||
}
|
||||
|
||||
out.endTag(null, TAG_CHANNEL);
|
||||
}
|
||||
@@ -481,8 +464,6 @@ public final class NotificationChannel implements Parcelable {
|
||||
record.put(ATT_USER_LOCKED, Integer.toString(getUserLockedFields()));
|
||||
record.put(ATT_VIBRATION, longArrayToString(getVibrationPattern()));
|
||||
record.put(ATT_SHOW_BADGE, Boolean.toString(canShowBadge()));
|
||||
record.put(ATT_ALLOWED, Boolean.toString(isAllowed()));
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
@@ -1552,7 +1552,7 @@ public class NotificationManagerService extends SystemService {
|
||||
public void updateNotificationChannelForPackage(String pkg, int uid,
|
||||
NotificationChannel channel) {
|
||||
enforceSystemOrSystemUI("Caller not system or systemui");
|
||||
if (!channel.isAllowed()) {
|
||||
if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
|
||||
// cancel
|
||||
cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channel.getId(), 0, 0, true,
|
||||
UserHandle.getUserId(Binder.getCallingUid()), REASON_CHANNEL_BANNED,
|
||||
@@ -2441,7 +2441,7 @@ public class NotificationManagerService extends SystemService {
|
||||
public void updateNotificationChannelFromAssistant(INotificationListener token, String pkg,
|
||||
NotificationChannel channel) throws RemoteException {
|
||||
ManagedServiceInfo info = mNotificationAssistants.checkServiceTokenLocked(token);
|
||||
if (!channel.isAllowed()) {
|
||||
if (channel.getImportance() == NotificationManager.IMPORTANCE_NONE) {
|
||||
// cancel
|
||||
cancelAllNotificationsInt(MY_UID, MY_PID, pkg, channel.getId(), 0, 0, true,
|
||||
info.userid, REASON_CHANNEL_BANNED, null);
|
||||
@@ -2985,7 +2985,7 @@ public class NotificationManagerService extends SystemService {
|
||||
}
|
||||
|
||||
final boolean isBlocked = r.getImportance() == NotificationManager.IMPORTANCE_NONE
|
||||
|| !r.getChannel().isAllowed()
|
||||
|| r.getChannel().getImportance() == NotificationManager.IMPORTANCE_NONE
|
||||
|| !noteNotificationOp(pkg, callingUid);
|
||||
if (isBlocked) {
|
||||
Slog.e(TAG, "Suppressing notification from package by user request.");
|
||||
|
||||
@@ -445,7 +445,6 @@ public class RankingHelper implements RankingConfig {
|
||||
channel.setBypassDnd(r.priority == Notification.PRIORITY_MAX);
|
||||
channel.setLockscreenVisibility(r.visibility);
|
||||
}
|
||||
channel.setAllowed(true);
|
||||
clearLockedFields(channel);
|
||||
if (channel.getLockscreenVisibility() == Notification.VISIBILITY_PUBLIC) {
|
||||
channel.setLockscreenVisibility(Ranking.VISIBILITY_NO_OVERRIDE);
|
||||
@@ -516,9 +515,6 @@ public class RankingHelper implements RankingConfig {
|
||||
channel.setLockscreenVisibility(updatedChannel.getLockscreenVisibility());
|
||||
}
|
||||
}
|
||||
if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_ALLOWED) == 0) {
|
||||
channel.setAllowed(updatedChannel.isAllowed());
|
||||
}
|
||||
if ((channel.getUserLockedFields() & NotificationChannel.USER_LOCKED_SHOW_BADGE) == 0) {
|
||||
channel.setShowBadge(updatedChannel.canShowBadge());
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class NotificationManagerServiceTest {
|
||||
|
||||
NotificationChannel channel = new NotificationChannel("id", "name",
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setAllowed(false);
|
||||
channel.setImportance(NotificationManager.IMPORTANCE_NONE);
|
||||
NotificationRecord r = generateNotificationRecord(channel);
|
||||
NotificationManagerService.EnqueueNotificationRunnable enqueue =
|
||||
mNotificationManagerService.new EnqueueNotificationRunnable(UserHandle.USER_SYSTEM,
|
||||
|
||||
@@ -487,25 +487,6 @@ public class RankingHelperTest {
|
||||
assertEquals(channel, mHelper.getNotificationChannel(pkg, uid, channel.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_userLockedAllowed() throws Exception {
|
||||
final NotificationChannel channel =
|
||||
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
|
||||
channel.setAllowed(true);
|
||||
channel.lockFields(NotificationChannel.USER_LOCKED_ALLOWED);
|
||||
|
||||
mHelper.createNotificationChannel(pkg, uid, channel, false);
|
||||
|
||||
final NotificationChannel channel2 =
|
||||
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_HIGH);
|
||||
channel2.setAllowed(false);
|
||||
|
||||
mHelper.updateNotificationChannelFromAssistant(pkg, uid, channel2);
|
||||
|
||||
// no fields should be changed
|
||||
assertEquals(channel, mHelper.getNotificationChannel(pkg, uid, channel.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate_userLockedBadge() throws Exception {
|
||||
final NotificationChannel channel =
|
||||
@@ -567,7 +548,6 @@ public class RankingHelperTest {
|
||||
channel.setBypassDnd(true);
|
||||
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
channel.setShowBadge(true);
|
||||
channel.setAllowed(false);
|
||||
int lockMask = 0;
|
||||
for (int i = 0; i < NotificationChannel.LOCKABLE_FIELDS.length; i++) {
|
||||
lockMask |= NotificationChannel.LOCKABLE_FIELDS[i];
|
||||
@@ -595,7 +575,6 @@ public class RankingHelperTest {
|
||||
channel.setBypassDnd(true);
|
||||
channel.setLockscreenVisibility(Notification.VISIBILITY_SECRET);
|
||||
channel.setShowBadge(true);
|
||||
channel.setAllowed(false);
|
||||
int lockMask = 0;
|
||||
for (int i = 0; i < NotificationChannel.LOCKABLE_FIELDS.length; i++) {
|
||||
lockMask |= NotificationChannel.LOCKABLE_FIELDS[i];
|
||||
|
||||
Reference in New Issue
Block a user