Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa683ea2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add shell command to toggle DND"

parents e61a0cd2 08d381b8
Loading
Loading
Loading
Loading
+30 −2
Original line number Diff line number Diff line
@@ -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();