Skip to content

Commit c31ed39

Browse files
committed
Send accessibility notification events only for the current user.
1. The notification manager service is firing accessibility events for notification for a background user. Events for the current user's notifications should be sent. bug:7326302 Change-Id: I00665385ba2106f161928dad1b76536c93c17f27
1 parent 9617921 commit c31ed39

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

services/java/com/android/server/NotificationManagerService.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,14 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
991991
| Notification.FLAG_NO_CLEAR;
992992
}
993993

994+
final int currentUser;
995+
final long token = Binder.clearCallingIdentity();
996+
try {
997+
currentUser = ActivityManager.getCurrentUser();
998+
} finally {
999+
Binder.restoreCallingIdentity(token);
1000+
}
1001+
9941002
if (notification.icon != 0) {
9951003
final StatusBarNotification n = new StatusBarNotification(
9961004
pkg, id, tag, r.uid, r.initialPid, score, notification, user);
@@ -1015,7 +1023,10 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
10151023
Binder.restoreCallingIdentity(identity);
10161024
}
10171025
}
1018-
sendAccessibilityEvent(notification, pkg);
1026+
// Send accessibility events only for the current user.
1027+
if (currentUser == userId) {
1028+
sendAccessibilityEvent(notification, pkg);
1029+
}
10191030
} else {
10201031
Slog.e(TAG, "Ignoring notification with icon==0: " + notification);
10211032
if (old != null && old.statusBarKey != null) {
@@ -1029,14 +1040,6 @@ public void enqueueNotificationInternal(String pkg, int callingUid, int callingP
10291040
}
10301041
}
10311042

1032-
final int currentUser;
1033-
final long token = Binder.clearCallingIdentity();
1034-
try {
1035-
currentUser = ActivityManager.getCurrentUser();
1036-
} finally {
1037-
Binder.restoreCallingIdentity(token);
1038-
}
1039-
10401043
// If we're not supposed to beep, vibrate, etc. then don't.
10411044
if (((mDisabledNotifications & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) == 0)
10421045
&& (!(old != null

0 commit comments

Comments
 (0)