Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -33616,6 +33616,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; } api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -35753,6 +35753,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; } api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -33630,6 +33630,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; } core/java/android/service/notification/NotificationAssistantService.java +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ public abstract class NotificationAssistantService extends NotificationListenerS /** Notification was canceled because it was an invisible member of a group. */ public static final int REASON_GROUP_OPTIMIZATION = 13; /** Notification was canceled by the user banning the topic. */ public static final int REASON_TOPIC_BANNED = 14; public class Adjustment { int mImportance; CharSequence mExplanation; Loading services/core/java/com/android/server/notification/NotificationManagerService.java +19 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static android.service.notification.NotificationAssistantService.REASON_L import static android.service.notification.NotificationAssistantService.REASON_LISTENER_CANCEL_ALL; import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_BANNED; import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_CHANGED; import static android.service.notification.NotificationAssistantService.REASON_TOPIC_BANNED; import static android.service.notification.NotificationAssistantService.REASON_USER_STOPPED; import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS; import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH; Loading Loading @@ -741,7 +742,7 @@ public class NotificationManagerService extends SystemService { for (String pkgName : pkgList) { if (cancelNotifications) { cancelAllNotificationsInt(MY_UID, MY_PID, pkgName, 0, 0, !queryRestart, changeUserId, REASON_PACKAGE_CHANGED, null); changeUserId, REASON_PACKAGE_CHANGED, null, null); } } } Loading Loading @@ -774,7 +775,7 @@ public class NotificationManagerService extends SystemService { int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); if (userHandle >= 0) { cancelAllNotificationsInt(MY_UID, MY_PID, null, 0, 0, true, userHandle, REASON_USER_STOPPED, null); REASON_USER_STOPPED, null, null); } } else if (action.equals(Intent.ACTION_USER_PRESENT)) { // turn off LED when user passes through lock screen Loading Loading @@ -1051,7 +1052,7 @@ public class NotificationManagerService extends SystemService { // Now, cancel any outstanding notifications that are part of a just-disabled app if (ENABLE_BLOCKED_NOTIFICATIONS && !enabled) { cancelAllNotificationsInt(MY_UID, MY_PID, pkg, 0, 0, true, UserHandle.getUserId(uid), REASON_PACKAGE_BANNED, null); REASON_PACKAGE_BANNED, null, null); } } Loading Loading @@ -1209,7 +1210,7 @@ public class NotificationManagerService extends SystemService { // running foreground services. cancelAllNotificationsInt(Binder.getCallingUid(), Binder.getCallingPid(), pkg, 0, Notification.FLAG_FOREGROUND_SERVICE, true, userId, REASON_APP_CANCEL_ALL, null); REASON_APP_CANCEL_ALL, null, null); } @Override Loading Loading @@ -1266,6 +1267,11 @@ public class NotificationManagerService extends SystemService { public void setTopicImportance(String pkg, int uid, Notification.Topic topic, int importance) { enforceSystemOrSystemUI("Caller not system or systemui"); if (NotificationListenerService.Ranking.IMPORTANCE_NONE == importance) { cancelAllNotificationsInt(MY_UID, MY_PID, pkg, 0, 0, true, UserHandle.getUserId(uid), REASON_TOPIC_BANNED, topic, null); } mRankingHelper.setTopicImportance(pkg, uid, topic, importance); savePolicyFile(); } Loading Loading @@ -2284,8 +2290,9 @@ public class NotificationManagerService extends SystemService { mRankingHelper.extractSignals(r); savePolicyFile(); // blocked apps if (ENABLE_BLOCKED_NOTIFICATIONS && !noteNotificationOp(pkg, callingUid)) { // blocked apps/topics if (r.getImportance() == NotificationListenerService.Ranking.IMPORTANCE_NONE || !noteNotificationOp(pkg, callingUid)) { if (!isSystemNotification) { Slog.e(TAG, "Suppressing notification from package " + pkg + " by user request."); Loading Loading @@ -3067,11 +3074,11 @@ public class NotificationManagerService extends SystemService { } /** * Cancels all notifications from a given package that have all of the * Cancels all notifications from a given package or topic that have all of the * {@code mustHaveFlags}. */ boolean cancelAllNotificationsInt(int callingUid, int callingPid, String pkg, int mustHaveFlags, int mustNotHaveFlags, boolean doit, int userId, int reason, int mustNotHaveFlags, boolean doit, int userId, int reason, Notification.Topic topic, ManagedServiceInfo listener) { String listenerName = listener == null ? null : listener.component.toShortString(); EventLogTags.writeNotificationCancelAll(callingUid, callingPid, Loading Loading @@ -3099,6 +3106,10 @@ public class NotificationManagerService extends SystemService { if (pkg != null && !r.sbn.getPackageName().equals(pkg)) { continue; } if (topic != null && !topic.getId().equals(r.getNotification().getTopic().getId())) { continue; } if (canceledNotifications == null) { canceledNotifications = new ArrayList<>(); } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -33616,6 +33616,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; }
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -35753,6 +35753,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; }
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -33630,6 +33630,7 @@ package android.service.notification { field public static final int REASON_LISTENER_CANCEL_ALL = 11; // 0xb field public static final int REASON_PACKAGE_BANNED = 7; // 0x7 field public static final int REASON_PACKAGE_CHANGED = 5; // 0x5 field public static final int REASON_TOPIC_BANNED = 14; // 0xe field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationAssistantService"; }
core/java/android/service/notification/NotificationAssistantService.java +3 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,9 @@ public abstract class NotificationAssistantService extends NotificationListenerS /** Notification was canceled because it was an invisible member of a group. */ public static final int REASON_GROUP_OPTIMIZATION = 13; /** Notification was canceled by the user banning the topic. */ public static final int REASON_TOPIC_BANNED = 14; public class Adjustment { int mImportance; CharSequence mExplanation; Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +19 −8 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static android.service.notification.NotificationAssistantService.REASON_L import static android.service.notification.NotificationAssistantService.REASON_LISTENER_CANCEL_ALL; import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_BANNED; import static android.service.notification.NotificationAssistantService.REASON_PACKAGE_CHANGED; import static android.service.notification.NotificationAssistantService.REASON_TOPIC_BANNED; import static android.service.notification.NotificationAssistantService.REASON_USER_STOPPED; import static android.service.notification.NotificationListenerService.HINT_HOST_DISABLE_EFFECTS; import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_HIGH; Loading Loading @@ -741,7 +742,7 @@ public class NotificationManagerService extends SystemService { for (String pkgName : pkgList) { if (cancelNotifications) { cancelAllNotificationsInt(MY_UID, MY_PID, pkgName, 0, 0, !queryRestart, changeUserId, REASON_PACKAGE_CHANGED, null); changeUserId, REASON_PACKAGE_CHANGED, null, null); } } } Loading Loading @@ -774,7 +775,7 @@ public class NotificationManagerService extends SystemService { int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); if (userHandle >= 0) { cancelAllNotificationsInt(MY_UID, MY_PID, null, 0, 0, true, userHandle, REASON_USER_STOPPED, null); REASON_USER_STOPPED, null, null); } } else if (action.equals(Intent.ACTION_USER_PRESENT)) { // turn off LED when user passes through lock screen Loading Loading @@ -1051,7 +1052,7 @@ public class NotificationManagerService extends SystemService { // Now, cancel any outstanding notifications that are part of a just-disabled app if (ENABLE_BLOCKED_NOTIFICATIONS && !enabled) { cancelAllNotificationsInt(MY_UID, MY_PID, pkg, 0, 0, true, UserHandle.getUserId(uid), REASON_PACKAGE_BANNED, null); REASON_PACKAGE_BANNED, null, null); } } Loading Loading @@ -1209,7 +1210,7 @@ public class NotificationManagerService extends SystemService { // running foreground services. cancelAllNotificationsInt(Binder.getCallingUid(), Binder.getCallingPid(), pkg, 0, Notification.FLAG_FOREGROUND_SERVICE, true, userId, REASON_APP_CANCEL_ALL, null); REASON_APP_CANCEL_ALL, null, null); } @Override Loading Loading @@ -1266,6 +1267,11 @@ public class NotificationManagerService extends SystemService { public void setTopicImportance(String pkg, int uid, Notification.Topic topic, int importance) { enforceSystemOrSystemUI("Caller not system or systemui"); if (NotificationListenerService.Ranking.IMPORTANCE_NONE == importance) { cancelAllNotificationsInt(MY_UID, MY_PID, pkg, 0, 0, true, UserHandle.getUserId(uid), REASON_TOPIC_BANNED, topic, null); } mRankingHelper.setTopicImportance(pkg, uid, topic, importance); savePolicyFile(); } Loading Loading @@ -2284,8 +2290,9 @@ public class NotificationManagerService extends SystemService { mRankingHelper.extractSignals(r); savePolicyFile(); // blocked apps if (ENABLE_BLOCKED_NOTIFICATIONS && !noteNotificationOp(pkg, callingUid)) { // blocked apps/topics if (r.getImportance() == NotificationListenerService.Ranking.IMPORTANCE_NONE || !noteNotificationOp(pkg, callingUid)) { if (!isSystemNotification) { Slog.e(TAG, "Suppressing notification from package " + pkg + " by user request."); Loading Loading @@ -3067,11 +3074,11 @@ public class NotificationManagerService extends SystemService { } /** * Cancels all notifications from a given package that have all of the * Cancels all notifications from a given package or topic that have all of the * {@code mustHaveFlags}. */ boolean cancelAllNotificationsInt(int callingUid, int callingPid, String pkg, int mustHaveFlags, int mustNotHaveFlags, boolean doit, int userId, int reason, int mustNotHaveFlags, boolean doit, int userId, int reason, Notification.Topic topic, ManagedServiceInfo listener) { String listenerName = listener == null ? null : listener.component.toShortString(); EventLogTags.writeNotificationCancelAll(callingUid, callingPid, Loading Loading @@ -3099,6 +3106,10 @@ public class NotificationManagerService extends SystemService { if (pkg != null && !r.sbn.getPackageName().equals(pkg)) { continue; } if (topic != null && !topic.getId().equals(r.getNotification().getTopic().getId())) { continue; } if (canceledNotifications == null) { canceledNotifications = new ArrayList<>(); } Loading