Loading cmds/svc/src/com/android/commands/svc/PowerCommand.java +6 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; import android.sysprop.InitProperties; public class PowerCommand extends Svc.Command { private static final int FORCE_SUSPEND_DELAY_DEFAULT_MILLIS = 0; Loading Loading @@ -103,6 +104,8 @@ public class PowerCommand extends Svc.Command { pm.reboot(false, mode, true); } catch (RemoteException e) { maybeLogRemoteException("Failed to reboot."); } catch (Exception e) { System.err.println("Failed to reboot: " + e.getMessage()); } return; } else if ("shutdown".equals(args[1])) { Loading Loading @@ -138,7 +141,9 @@ public class PowerCommand extends Svc.Command { // if it is already in shutdown flow. private void maybeLogRemoteException(String msg) { String powerProp = SystemProperties.get("sys.powerctl"); if (powerProp.isEmpty()) { // Also check if userspace reboot is ongoing, since in case of userspace reboot value of the // sys.powerctl property will be reset. if (powerProp.isEmpty() && !InitProperties.userspace_reboot_in_progress().orElse(false)) { System.err.println(msg); } } Loading core/java/android/os/PowerManager.java +14 −1 Original line number Diff line number Diff line Loading @@ -1332,12 +1332,25 @@ public final class PowerManager { } } /** * Returns {@code true} if this device supports rebooting userspace. * * <p>This method exists solely for the sake of re-using same logic between {@code PowerManager} * and {@code PowerManagerService}. * * @hide */ public static boolean isRebootingUserspaceSupportedImpl() { return InitProperties.is_userspace_reboot_supported().orElse(false); } /** * Returns {@code true} if this device supports rebooting userspace. */ // TODO(b/138605180): add link to documentation once it's ready. public boolean isRebootingUserspaceSupported() { return InitProperties.is_userspace_reboot_supported().orElse(false); return isRebootingUserspaceSupportedImpl(); } /** Loading services/core/java/com/android/server/power/PowerManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -2838,6 +2838,10 @@ public final class PowerManagerService extends SystemService private void shutdownOrRebootInternal(final @HaltMode int haltMode, final boolean confirm, @Nullable final String reason, boolean wait) { if (PowerManager.REBOOT_USERSPACE.equals(reason)) { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { throw new UnsupportedOperationException( "Attempted userspace reboot on a device that doesn't support it"); } UserspaceRebootLogger.noteUserspaceRebootWasRequested(); } if (mHandler == null || !mSystemReady) { Loading Loading
cmds/svc/src/com/android/commands/svc/PowerCommand.java +6 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; import android.sysprop.InitProperties; public class PowerCommand extends Svc.Command { private static final int FORCE_SUSPEND_DELAY_DEFAULT_MILLIS = 0; Loading Loading @@ -103,6 +104,8 @@ public class PowerCommand extends Svc.Command { pm.reboot(false, mode, true); } catch (RemoteException e) { maybeLogRemoteException("Failed to reboot."); } catch (Exception e) { System.err.println("Failed to reboot: " + e.getMessage()); } return; } else if ("shutdown".equals(args[1])) { Loading Loading @@ -138,7 +141,9 @@ public class PowerCommand extends Svc.Command { // if it is already in shutdown flow. private void maybeLogRemoteException(String msg) { String powerProp = SystemProperties.get("sys.powerctl"); if (powerProp.isEmpty()) { // Also check if userspace reboot is ongoing, since in case of userspace reboot value of the // sys.powerctl property will be reset. if (powerProp.isEmpty() && !InitProperties.userspace_reboot_in_progress().orElse(false)) { System.err.println(msg); } } Loading
core/java/android/os/PowerManager.java +14 −1 Original line number Diff line number Diff line Loading @@ -1332,12 +1332,25 @@ public final class PowerManager { } } /** * Returns {@code true} if this device supports rebooting userspace. * * <p>This method exists solely for the sake of re-using same logic between {@code PowerManager} * and {@code PowerManagerService}. * * @hide */ public static boolean isRebootingUserspaceSupportedImpl() { return InitProperties.is_userspace_reboot_supported().orElse(false); } /** * Returns {@code true} if this device supports rebooting userspace. */ // TODO(b/138605180): add link to documentation once it's ready. public boolean isRebootingUserspaceSupported() { return InitProperties.is_userspace_reboot_supported().orElse(false); return isRebootingUserspaceSupportedImpl(); } /** Loading
services/core/java/com/android/server/power/PowerManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -2838,6 +2838,10 @@ public final class PowerManagerService extends SystemService private void shutdownOrRebootInternal(final @HaltMode int haltMode, final boolean confirm, @Nullable final String reason, boolean wait) { if (PowerManager.REBOOT_USERSPACE.equals(reason)) { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { throw new UnsupportedOperationException( "Attempted userspace reboot on a device that doesn't support it"); } UserspaceRebootLogger.noteUserspaceRebootWasRequested(); } if (mHandler == null || !mSystemReady) { Loading