summaryrefslogtreecommitdiffstats
path: root/cmds/svc
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2013-03-14 01:11:53 -0700
committerGuang Zhu <guangzhu@google.com>2013-03-18 18:22:30 -0700
commit62aad7f66fcd673831029eb96dd49c95f76b17bd (patch)
treeda743e86cd8cfe6f1c8a61fbce544f271c7e63b9 /cmds/svc
parente4c9ac2df26f640fa9aeab5928e82bcc59a33da2 (diff)
downloadframeworks_base-62aad7f66fcd673831029eb96dd49c95f76b17bd.zip
frameworks_base-62aad7f66fcd673831029eb96dd49c95f76b17bd.tar.gz
frameworks_base-62aad7f66fcd673831029eb96dd49c95f76b17bd.tar.bz2
add reboot and shutdown to `svc power` command
a runtime shutdown will be performed first, then device will reboot with the provided reason or power off. Change-Id: I44cfbae19626c46147fad3bc8e91434970daa5d5
Diffstat (limited to 'cmds/svc')
-rw-r--r--cmds/svc/src/com/android/commands/svc/PowerCommand.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
index 58105fa..da8586c 100644
--- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java
+++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java
@@ -36,12 +36,18 @@ public class PowerCommand extends Svc.Command {
return shortHelp() + "\n"
+ "\n"
+ "usage: svc power stayon [true|false|usb|ac|wireless]\n"
- + " Set the 'keep awake while plugged in' setting.\n";
+ + " Set the 'keep awake while plugged in' setting.\n"
+ + " svc power reboot [reason]\n"
+ + " Perform a runtime shutdown and reboot device with specified reason.\n"
+ + " svc power shutdown\n"
+ + " Perform a runtime shutdown and power off the device.\n";
}
public void run(String[] args) {
fail: {
if (args.length >= 2) {
+ IPowerManager pm = IPowerManager.Stub.asInterface(
+ ServiceManager.getService(Context.POWER_SERVICE));
if ("stayon".equals(args[1]) && args.length == 3) {
int val;
if ("true".equals(args[2])) {
@@ -60,8 +66,6 @@ public class PowerCommand extends Svc.Command {
} else {
break fail;
}
- IPowerManager pm
- = IPowerManager.Stub.asInterface(ServiceManager.getService(Context.POWER_SERVICE));
try {
if (val != 0) {
// if the request is not to set it to false, wake up the screen so that
@@ -74,6 +78,26 @@ public class PowerCommand extends Svc.Command {
System.err.println("Faild to set setting: " + e);
}
return;
+ } else if ("reboot".equals(args[1])) {
+ String mode = null;
+ if (args.length == 3) {
+ mode = args[2];
+ }
+ try {
+ // no confirm, wait till device is rebooted
+ pm.reboot(false, mode, true);
+ } catch (RemoteException e) {
+ System.err.println("Failed to reboot.");
+ }
+ return;
+ } else if ("shutdown".equals(args[1])) {
+ try {
+ // no confirm, wait till device is off
+ pm.shutdown(false, true);
+ } catch (RemoteException e) {
+ System.err.println("Failed to shutdown.");
+ }
+ return;
}
}
}