summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--api/test-current.txt1
-rw-r--r--core/java/android/app/NotificationChannel.java19
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java6
-rw-r--r--services/core/java/com/android/server/notification/RankingHelper.java4
-rw-r--r--services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java2
-rw-r--r--services/tests/notification/src/com/android/server/notification/RankingHelperTest.java21
8 files changed, 4 insertions, 51 deletions
diff --git a/api/current.txt b/api/current.txt
index b1ba9c85059e..00bd41f7328c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -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);
diff --git a/api/system-current.txt b/api/system-current.txt
index 92b437d7eda9..c25c84c1af04 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -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);
diff --git a/api/test-current.txt b/api/test-current.txt
index 9b8e87ce61db..3637897a712f 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -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);
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java
index 627391764069..bdccb8a9620c 100644
--- a/core/java/android/app/NotificationChannel.java
+++ b/core/java/android/app/NotificationChannel.java
@@ -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;
}
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 4d8e26f6955b..dffe86ab47b4 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -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.");
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 0c9e4b82189e..598ac2edf5b1 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -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());
}
diff --git a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
index e1c0166ee39b..ef61ec242a4c 100644
--- a/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -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,
diff --git a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
index eb1021d9b6f3..f8061f6feb00 100644
--- a/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
+++ b/services/tests/notification/src/com/android/server/notification/RankingHelperTest.java
@@ -488,25 +488,6 @@ public class RankingHelperTest {
}
@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 =
new NotificationChannel("id2", "name2", NotificationManager.IMPORTANCE_LOW);
@@ -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];