diff options
author | Keun-young Park <keunyoung@google.com> | 2017-04-07 09:31:01 -0700 |
---|---|---|
committer | Keun-young Park <keunyoung@google.com> | 2017-04-10 20:55:03 +0000 |
commit | b706bb7e52a43ce79bc348bc19354c904dfe7d31 (patch) | |
tree | dc63d1696b569f33ada102b22c11d3d465a211e4 /cmds/svc/src | |
parent | 4a306894145340a4fe08b70b569eaa31641b38e6 (diff) |
ignore RemoteException from pm if shutdown is already on-going
- In new shutdown flow, adb is guaranteed to be alive while system server
is alive.
- power manager can be killed before system server is killed.
- This leads into RemoteException for shutdown request to power manager.
- If shutdown is already on-going (=sys.powerctl set), the RemoteException
should be ignored.
bug: 37096155
Test: adb shell svc power reboot|shutdown and check output to adb
Change-Id: Ia90a900d55123bd7c1bf57c90c49d35332ebfdf5
Diffstat (limited to 'cmds/svc/src')
-rw-r--r-- | cmds/svc/src/com/android/commands/svc/PowerCommand.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cmds/svc/src/com/android/commands/svc/PowerCommand.java b/cmds/svc/src/com/android/commands/svc/PowerCommand.java index 6ce29cb24bc6..920a52dad641 100644 --- a/cmds/svc/src/com/android/commands/svc/PowerCommand.java +++ b/cmds/svc/src/com/android/commands/svc/PowerCommand.java @@ -22,6 +22,7 @@ import android.os.IPowerManager; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; +import android.os.SystemProperties; public class PowerCommand extends Svc.Command { public PowerCommand() { @@ -87,7 +88,7 @@ public class PowerCommand extends Svc.Command { // no confirm, wait till device is rebooted pm.reboot(false, mode, true); } catch (RemoteException e) { - System.err.println("Failed to reboot."); + maybeLogRemoteException("Failed to reboot."); } return; } else if ("shutdown".equals(args[1])) { @@ -95,7 +96,7 @@ public class PowerCommand extends Svc.Command { // no confirm, wait till device is off pm.shutdown(false, null, true); } catch (RemoteException e) { - System.err.println("Failed to shutdown."); + maybeLogRemoteException("Failed to shutdown."); } return; } @@ -103,4 +104,14 @@ public class PowerCommand extends Svc.Command { } System.err.println(longHelp()); } + + // Check if remote exception is benign during shutdown. Pm can be killed + // before system server during shutdown, so remote exception can be ignored + // if it is already in shutdown flow. + private void maybeLogRemoteException(String msg) { + String powerProp = SystemProperties.get("sys.powerctl"); + if (powerProp.isEmpty()) { + System.err.println(msg); + } + } } |