Add shell command to toggle DND
adb shell cmd notification set_dnd [type] Where type is one of: none (total silence mode) on (total silence mode) priority (priority only mode) alarms (alarms only mode) all (turn dnd off) off (turn dnd off) Test: manual Fixes: 132901740 Change-Id: I9b634570a0bd6dd0a3277268e39a8ca67e177e89
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
|
||||
package com.android.server.notification;
|
||||
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALARMS;
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_ALL;
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_NONE;
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_PRIORITY;
|
||||
import static android.app.NotificationManager.INTERRUPTION_FILTER_UNKNOWN;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.INotificationManager;
|
||||
import android.app.Notification;
|
||||
@@ -47,13 +53,13 @@ import java.util.Collections;
|
||||
* Implementation of `cmd notification` in NotificationManagerService.
|
||||
*/
|
||||
public class NotificationShellCmd extends ShellCommand {
|
||||
private static final String USAGE =
|
||||
"usage: cmd notification SUBCMD [args]\n\n"
|
||||
private static final String USAGE = "usage: cmd notification SUBCMD [args]\n\n"
|
||||
+ "SUBCMDs:\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"
|
||||
+ " set_dnd [on|none (same as on)|priority|alarms|all|off (same as all)]"
|
||||
+ " 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"
|
||||
@@ -111,6 +117,28 @@ public class NotificationShellCmd extends ShellCommand {
|
||||
final PrintWriter pw = getOutPrintWriter();
|
||||
try {
|
||||
switch (cmd.replace('-', '_')) {
|
||||
case "set_dnd": {
|
||||
String mode = getNextArgRequired();
|
||||
int interruptionFilter = INTERRUPTION_FILTER_UNKNOWN;
|
||||
switch(mode) {
|
||||
case "none":
|
||||
case "on":
|
||||
interruptionFilter = INTERRUPTION_FILTER_NONE;
|
||||
break;
|
||||
case "priority":
|
||||
interruptionFilter = INTERRUPTION_FILTER_PRIORITY;
|
||||
break;
|
||||
case "alarms":
|
||||
interruptionFilter = INTERRUPTION_FILTER_ALARMS;
|
||||
break;
|
||||
case "all":
|
||||
case "off":
|
||||
interruptionFilter = INTERRUPTION_FILTER_ALL;
|
||||
}
|
||||
mBinderService.setInterruptionFilter(
|
||||
mDirectService.getContext().getPackageName(), interruptionFilter);
|
||||
}
|
||||
break;
|
||||
case "allow_dnd": {
|
||||
String packageName = getNextArgRequired();
|
||||
int userId = ActivityManager.getCurrentUser();
|
||||
|
||||
Reference in New Issue
Block a user