summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2019-02-22 20:42:47 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-02-22 20:42:47 +0000
commita71a8036e35fbf59a3e4dfd58b2fd5c78264cad9 (patch)
treeacff4d9ca42b80f268b0b78d3b7aeb97e6f997e3
parentccac0718279e08e26b4f26bbc978ed336581ae3b (diff)
parent2dcd5e87d38b41fa67a1b2a36be2cd8190600ef0 (diff)
Merge "Default cmd notification commands to current user."
-rw-r--r--services/core/java/com/android/server/notification/NotificationShellCmd.java64
1 files changed, 40 insertions, 24 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationShellCmd.java b/services/core/java/com/android/server/notification/NotificationShellCmd.java
index 2aaa1edcfad9..26cc0c10ccb3 100644
--- a/services/core/java/com/android/server/notification/NotificationShellCmd.java
+++ b/services/core/java/com/android/server/notification/NotificationShellCmd.java
@@ -16,6 +16,7 @@
package com.android.server.notification;
+import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.Notification;
import android.app.NotificationChannel;
@@ -49,12 +50,12 @@ public class NotificationShellCmd extends ShellCommand {
private static final String USAGE =
"usage: cmd notification SUBCMD [args]\n\n"
+ "SUBCMDs:\n"
- + " allow_listener COMPONENT [user_id]\n"
- + " disallow_listener COMPONENT [user_id]\n"
- + " allow_assistant COMPONENT\n"
- + " remove_assistant COMPONENT\n"
- + " allow_dnd PACKAGE\n"
- + " disallow_dnd PACKAGE\n"
+ + " allow_listener COMPONENT [user_id (current user if not specified)]\n"
+ + " disallow_listener COMPONENT [user_id (current user if not specified)]\n"
+ + " allow_assistant COMPONENT [user_id (current user if not specified)]\n"
+ + " remove_assistant COMPONENT [user_id (current user if not specified)]\n"
+ + " allow_dnd PACKAGE [user_id (current user if not specified)]\n"
+ + " disallow_dnd PACKAGE [user_id (current user if not specified)]\n"
+ " suspend_package PACKAGE\n"
+ " unsuspend_package PACKAGE\n"
+ " post [--help | flags] TAG TEXT";
@@ -109,14 +110,24 @@ public class NotificationShellCmd extends ShellCommand {
try {
switch (cmd.replace('-', '_')) {
case "allow_dnd": {
- mBinderService.setNotificationPolicyAccessGranted(
- getNextArgRequired(), true);
+ String packageName = getNextArgRequired();
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
+ }
+ mBinderService.setNotificationPolicyAccessGrantedForUser(
+ packageName, userId, true);
}
break;
case "disallow_dnd": {
- mBinderService.setNotificationPolicyAccessGranted(
- getNextArgRequired(), false);
+ String packageName = getNextArgRequired();
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
+ }
+ mBinderService.setNotificationPolicyAccessGrantedForUser(
+ packageName, userId, false);
}
break;
case "allow_listener": {
@@ -125,13 +136,11 @@ public class NotificationShellCmd extends ShellCommand {
pw.println("Invalid listener - must be a ComponentName");
return -1;
}
- String userId = getNextArg();
- if (userId == null) {
- mBinderService.setNotificationListenerAccessGranted(cn, true);
- } else {
- mBinderService.setNotificationListenerAccessGrantedForUser(
- cn, Integer.parseInt(userId), true);
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
}
+ mBinderService.setNotificationListenerAccessGrantedForUser(cn, userId, true);
}
break;
case "disallow_listener": {
@@ -140,13 +149,11 @@ public class NotificationShellCmd extends ShellCommand {
pw.println("Invalid listener - must be a ComponentName");
return -1;
}
- String userId = getNextArg();
- if (userId == null) {
- mBinderService.setNotificationListenerAccessGranted(cn, false);
- } else {
- mBinderService.setNotificationListenerAccessGrantedForUser(
- cn, Integer.parseInt(userId), false);
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
}
+ mBinderService.setNotificationListenerAccessGrantedForUser(cn, userId, false);
}
break;
case "allow_assistant": {
@@ -155,7 +162,11 @@ public class NotificationShellCmd extends ShellCommand {
pw.println("Invalid assistant - must be a ComponentName");
return -1;
}
- mBinderService.setNotificationAssistantAccessGranted(cn, true);
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
+ }
+ mBinderService.setNotificationAssistantAccessGrantedForUser(cn, userId, true);
}
break;
case "disallow_assistant": {
@@ -164,7 +175,11 @@ public class NotificationShellCmd extends ShellCommand {
pw.println("Invalid assistant - must be a ComponentName");
return -1;
}
- mBinderService.setNotificationAssistantAccessGranted(cn, false);
+ int userId = ActivityManager.getCurrentUser();
+ if (peekNextArg() != null) {
+ userId = Integer.parseInt(getNextArgRequired());
+ }
+ mBinderService.setNotificationAssistantAccessGrantedForUser(cn, userId, false);
}
break;
case "suspend_package": {
@@ -176,6 +191,7 @@ public class NotificationShellCmd extends ShellCommand {
// only use for testing
mDirectService.simulatePackageSuspendBroadcast(false, getNextArgRequired());
}
+ break;
case "distract_package": {
// only use for testing
// Flag values are in