17e53f20c835ae2614c92717a6fc222b345c75036Jason Monk/* 27e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * Copyright (C) 2016 The Android Open Source Project 37e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * 47e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 57e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * except in compliance with the License. You may obtain a copy of the License at 67e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * 77e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * http://www.apache.org/licenses/LICENSE-2.0 87e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * 97e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * Unless required by applicable law or agreed to in writing, software distributed under the 107e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 117e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * KIND, either express or implied. See the License for the specific language governing 127e53f20c835ae2614c92717a6fc222b345c75036Jason Monk * permissions and limitations under the License. 137e53f20c835ae2614c92717a6fc222b345c75036Jason Monk */ 147e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 157e53f20c835ae2614c92717a6fc222b345c75036Jason Monkpackage com.android.server.statusbar; 167e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 177e53f20c835ae2614c92717a6fc222b345c75036Jason Monkimport android.content.ComponentName; 187e53f20c835ae2614c92717a6fc222b345c75036Jason Monkimport android.os.RemoteException; 197e53f20c835ae2614c92717a6fc222b345c75036Jason Monkimport android.os.ShellCommand; 207e53f20c835ae2614c92717a6fc222b345c75036Jason Monkimport com.android.internal.statusbar.IStatusBarService; 217e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 227e53f20c835ae2614c92717a6fc222b345c75036Jason Monkimport java.io.PrintWriter; 237e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 247e53f20c835ae2614c92717a6fc222b345c75036Jason Monkpublic class StatusBarShellCommand extends ShellCommand { 257e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 267e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private final IStatusBarService mInterface; 277e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 287e53f20c835ae2614c92717a6fc222b345c75036Jason Monk public StatusBarShellCommand(StatusBarManagerService service) { 297e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface = service; 307e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 317e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 327e53f20c835ae2614c92717a6fc222b345c75036Jason Monk @Override 337e53f20c835ae2614c92717a6fc222b345c75036Jason Monk public int onCommand(String cmd) { 347e53f20c835ae2614c92717a6fc222b345c75036Jason Monk if (cmd == null) { 357e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return handleDefaultCommands(cmd); 367e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 377e53f20c835ae2614c92717a6fc222b345c75036Jason Monk try { 387e53f20c835ae2614c92717a6fc222b345c75036Jason Monk switch (cmd) { 397e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "expand-notifications": 407e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runExpandNotifications(); 417e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "expand-settings": 427e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runExpandSettings(); 437e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "collapse": 447e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runCollapse(); 457e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "add-tile": 467e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runAddTile(); 477e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "remove-tile": 487e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runRemoveTile(); 497e53f20c835ae2614c92717a6fc222b345c75036Jason Monk case "click-tile": 507e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return runClickTile(); 517e53f20c835ae2614c92717a6fc222b345c75036Jason Monk default: 527e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return handleDefaultCommands(cmd); 537e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 547e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } catch (RemoteException e) { 557e53f20c835ae2614c92717a6fc222b345c75036Jason Monk final PrintWriter pw = getOutPrintWriter(); 567e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println("Remote exception: " + e); 577e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 587e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return -1; 597e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 607e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 617e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runAddTile() throws RemoteException { 627e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.addTile(ComponentName.unflattenFromString(getNextArgRequired())); 637e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 647e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 657e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 667e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runRemoveTile() throws RemoteException { 677e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.remTile(ComponentName.unflattenFromString(getNextArgRequired())); 687e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 697e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 707e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 717e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runClickTile() throws RemoteException { 727e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.clickTile(ComponentName.unflattenFromString(getNextArgRequired())); 737e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 747e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 757e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 767e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runCollapse() throws RemoteException { 777e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.collapsePanels(); 787e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 797e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 807e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 817e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runExpandSettings() throws RemoteException { 827e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.expandSettingsPanel(null); 837e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 847e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 857e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 867e53f20c835ae2614c92717a6fc222b345c75036Jason Monk private int runExpandNotifications() throws RemoteException { 877e53f20c835ae2614c92717a6fc222b345c75036Jason Monk mInterface.expandNotificationsPanel(); 887e53f20c835ae2614c92717a6fc222b345c75036Jason Monk return 0; 897e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 907e53f20c835ae2614c92717a6fc222b345c75036Jason Monk 917e53f20c835ae2614c92717a6fc222b345c75036Jason Monk @Override 927e53f20c835ae2614c92717a6fc222b345c75036Jason Monk public void onHelp() { 937e53f20c835ae2614c92717a6fc222b345c75036Jason Monk final PrintWriter pw = getOutPrintWriter(); 947e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println("Status bar commands:"); 957e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" help"); 967e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Print this help text."); 977e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 987e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" expand-notifications"); 997e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Open the notifications panel."); 1007e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1017e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" expand-settings"); 1027e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Open the notifications panel and expand quick settings if present."); 1037e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1047e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" collapse"); 1057e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Collapse the notifications and settings panel."); 1067e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1077e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" add-tile COMPONENT"); 1087e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Add a TileService of the specified component"); 1097e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1107e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" remove-tile COMPONENT"); 1117e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Remove a TileService of the specified component"); 1127e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1137e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" click-tile COMPONENT"); 1147e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(" Click on a TileService of the specified component"); 1157e53f20c835ae2614c92717a6fc222b345c75036Jason Monk pw.println(""); 1167e53f20c835ae2614c92717a6fc222b345c75036Jason Monk } 1177e53f20c835ae2614c92717a6fc222b345c75036Jason Monk} 118