Skip to content

Commit a6d9d77

Browse files
woongki minPMS22
authored andcommitted
Need to check current user when triggering notification lights
Notification Lights also requires user check like sound and vibration. Otherwise, lights can occur without notifications. Test: runtest BuzzBeepBlinkTest Change-Id: I625db35796b7a479283ce51973ad2350559bd47f
1 parent 46ee92d commit a6d9d77

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6150,6 +6150,10 @@ boolean canShowLightsLocked(final NotificationRecord record, boolean aboveThresh
61506150
if (record.sbn.isGroup() && record.getNotification().suppressAlertingDueToGrouping()) {
61516151
return false;
61526152
}
6153+
// check current user
6154+
if (!isNotificationForCurrentUser(record)) {
6155+
return false;
6156+
}
61536157

61546158
return true;
61556159
}

services/tests/uiservicestests/src/com/android/server/notification/BuzzBeepBlinkTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,22 @@ public void testGroupAlertAllLightsGroup() {
12911291
assertEquals(-1, group.getLastAudiblyAlertedMs());
12921292
}
12931293

1294+
@Test
1295+
public void testLightsCheckCurrentUser() {
1296+
final Notification n = new Builder(getContext(), "test")
1297+
.setSmallIcon(android.R.drawable.sym_def_app_icon).build();
1298+
int userId = mUser.getIdentifier() + 10;
1299+
StatusBarNotification sbn = new StatusBarNotification(mPkg, mPkg, 0, mTag, mUid,
1300+
mPid, n, UserHandle.of(userId), null, System.currentTimeMillis());
1301+
NotificationRecord r = new NotificationRecord(getContext(), sbn,
1302+
new NotificationChannel("test", "test", IMPORTANCE_HIGH));
1303+
1304+
mService.buzzBeepBlinkLocked(r);
1305+
verifyNeverLights();
1306+
assertFalse(r.isInterruptive());
1307+
assertEquals(-1, r.getLastAudiblyAlertedMs());
1308+
}
1309+
12941310
@Test
12951311
public void testListenerHintCall() throws Exception {
12961312
NotificationRecord r = getCallRecord(1, true);

0 commit comments

Comments
 (0)