From 3c45c4c96939be65055ce518dc65d9f7ff479edf Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Thu, 21 Sep 2017 23:32:11 +0900 Subject: [PATCH] Add multiuser support for enabling notification listener Bug: 66504373 Bug: 65566927 Test: run CtsMediaHostTestCases Change-Id: I7f22a3849a0dc298b8a6358327125d966068a09d --- .../NotificationManagerService.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 92b360bdf8f79..c83d57935975d 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -5816,8 +5816,8 @@ public class NotificationManagerService extends SystemService { private class ShellCmd extends ShellCommand { public static final String USAGE = "help\n" - + "allow_listener COMPONENT\n" - + "disallow_listener COMPONENT\n" + + "allow_listener COMPONENT [user_id]\n" + + "disallow_listener COMPONENT [user_id]\n" + "set_assistant COMPONENT\n" + "remove_assistant COMPONENT\n" + "allow_dnd PACKAGE\n" @@ -5848,7 +5848,13 @@ public class NotificationManagerService extends SystemService { pw.println("Invalid listener - must be a ComponentName"); return -1; } - getBinderService().setNotificationListenerAccessGranted(cn, true); + String userId = getNextArg(); + if (userId == null) { + getBinderService().setNotificationListenerAccessGranted(cn, true); + } else { + getBinderService().setNotificationListenerAccessGrantedForUser( + cn, Integer.parseInt(userId), true); + } } break; case "disallow_listener": { @@ -5857,7 +5863,13 @@ public class NotificationManagerService extends SystemService { pw.println("Invalid listener - must be a ComponentName"); return -1; } - getBinderService().setNotificationListenerAccessGranted(cn, false); + String userId = getNextArg(); + if (userId == null) { + getBinderService().setNotificationListenerAccessGranted(cn, false); + } else { + getBinderService().setNotificationListenerAccessGrantedForUser( + cn, Integer.parseInt(userId), false); + } } break; case "allow_assistant": {