diff options
author | Guang Zhu <guangzhu@google.com> | 2013-03-19 01:56:33 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-19 01:56:33 +0000 |
commit | 12220c789ceb26aa79cd7586f77792d9fad614d7 (patch) | |
tree | 375748f09ea78a856801c9d319f57d043aa7365c | |
parent | 8c2267d471fc9dc457077ad2e700db1bd01addb9 (diff) | |
parent | f21d2fd5fb034a93e1df17538a753ab9e52ac965 (diff) | |
download | frameworks_base-12220c789ceb26aa79cd7586f77792d9fad614d7.zip frameworks_base-12220c789ceb26aa79cd7586f77792d9fad614d7.tar.gz frameworks_base-12220c789ceb26aa79cd7586f77792d9fad614d7.tar.bz2 |
am f21d2fd5: am a35d380b: Merge "add reboot and shutdown to `svc power` command" into jb-mr2-dev
* commit 'f21d2fd5fb034a93e1df17538a753ab9e52ac965':
add reboot and shutdown to `svc power` command
-rw-r--r-- | cmds/svc/src/com/android/commands/svc/PowerCommand.java | 30 |
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; } } } |