blob: 4e20f0177b35a2eb84f6adea40dbac635947d595 [file] [log] [blame]
Jason Monk7e53f202016-01-28 10:40:20 -05001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.server.statusbar;
16
17import android.content.ComponentName;
18import android.os.RemoteException;
19import android.os.ShellCommand;
Jason Monk213eb4f2017-03-31 09:26:27 -040020import android.service.quicksettings.TileService;
21
Jason Monk7e53f202016-01-28 10:40:20 -050022import com.android.internal.statusbar.IStatusBarService;
23
24import java.io.PrintWriter;
25
26public class StatusBarShellCommand extends ShellCommand {
27
Jason Monkf8c2f7b2017-09-06 09:22:29 -040028 private final StatusBarManagerService mInterface;
Jason Monk7e53f202016-01-28 10:40:20 -050029
30 public StatusBarShellCommand(StatusBarManagerService service) {
31 mInterface = service;
32 }
33
34 @Override
35 public int onCommand(String cmd) {
36 if (cmd == null) {
37 return handleDefaultCommands(cmd);
38 }
39 try {
40 switch (cmd) {
41 case "expand-notifications":
42 return runExpandNotifications();
43 case "expand-settings":
44 return runExpandSettings();
45 case "collapse":
46 return runCollapse();
47 case "add-tile":
48 return runAddTile();
49 case "remove-tile":
50 return runRemoveTile();
51 case "click-tile":
52 return runClickTile();
Jason Monk213eb4f2017-03-31 09:26:27 -040053 case "check-support":
54 final PrintWriter pw = getOutPrintWriter();
55 pw.println(String.valueOf(TileService.isQuickSettingsSupported()));
56 return 0;
Jason Monkf8c2f7b2017-09-06 09:22:29 -040057 case "get-status-icons":
58 return runGetStatusIcons();
Jason Monk7e53f202016-01-28 10:40:20 -050059 default:
60 return handleDefaultCommands(cmd);
61 }
62 } catch (RemoteException e) {
63 final PrintWriter pw = getOutPrintWriter();
64 pw.println("Remote exception: " + e);
65 }
66 return -1;
67 }
68
69 private int runAddTile() throws RemoteException {
70 mInterface.addTile(ComponentName.unflattenFromString(getNextArgRequired()));
71 return 0;
72 }
73
74 private int runRemoveTile() throws RemoteException {
75 mInterface.remTile(ComponentName.unflattenFromString(getNextArgRequired()));
76 return 0;
77 }
78
79 private int runClickTile() throws RemoteException {
80 mInterface.clickTile(ComponentName.unflattenFromString(getNextArgRequired()));
81 return 0;
82 }
83
84 private int runCollapse() throws RemoteException {
85 mInterface.collapsePanels();
86 return 0;
87 }
88
89 private int runExpandSettings() throws RemoteException {
90 mInterface.expandSettingsPanel(null);
91 return 0;
92 }
93
94 private int runExpandNotifications() throws RemoteException {
95 mInterface.expandNotificationsPanel();
96 return 0;
97 }
98
Jason Monkf8c2f7b2017-09-06 09:22:29 -040099 private int runGetStatusIcons() {
100 final PrintWriter pw = getOutPrintWriter();
101 for (String icon : mInterface.getStatusBarIcons()) {
102 pw.println(icon);
103 }
104 return 0;
105 }
106
Jason Monk7e53f202016-01-28 10:40:20 -0500107 @Override
108 public void onHelp() {
109 final PrintWriter pw = getOutPrintWriter();
110 pw.println("Status bar commands:");
111 pw.println(" help");
112 pw.println(" Print this help text.");
113 pw.println("");
114 pw.println(" expand-notifications");
115 pw.println(" Open the notifications panel.");
116 pw.println("");
117 pw.println(" expand-settings");
118 pw.println(" Open the notifications panel and expand quick settings if present.");
119 pw.println("");
120 pw.println(" collapse");
121 pw.println(" Collapse the notifications and settings panel.");
122 pw.println("");
123 pw.println(" add-tile COMPONENT");
124 pw.println(" Add a TileService of the specified component");
125 pw.println("");
126 pw.println(" remove-tile COMPONENT");
127 pw.println(" Remove a TileService of the specified component");
128 pw.println("");
129 pw.println(" click-tile COMPONENT");
130 pw.println(" Click on a TileService of the specified component");
131 pw.println("");
Jason Monk213eb4f2017-03-31 09:26:27 -0400132 pw.println(" check-support");
133 pw.println(" Check if this device supports QS + APIs");
134 pw.println("");
Jason Monkf8c2f7b2017-09-06 09:22:29 -0400135 pw.println(" get-status-icons");
136 pw.println(" Print the list of status bar icons and the order they appear in");
137 pw.println("");
Jason Monk7e53f202016-01-28 10:40:20 -0500138 }
139}