diff options
| author | Nikita Ioffe <ioffe@google.com> | 2020-04-09 00:47:33 +0100 |
|---|---|---|
| committer | Nikita Ioffe <ioffe@google.com> | 2020-04-09 14:07:22 +0100 |
| commit | 57300d9057fae45decaa7dcfc7dad0b31d710a92 (patch) | |
| tree | 9360e0c1c45fb60452e43e3a93476be8ff58aa5b /core/java/android/os/PowerManager.java | |
| parent | 9b82cceb5997fcbbf8021b6f326de9ad83673c4f (diff) | |
Introduce static @hide PowerManager.isRebootingUserspaceSupportedImpl()
This method consolidates logic of testing whenever rebooting userspace
is supported in a place that can be used both from
PowerMager.isRebootingUserspaceSupported() API and from
PowerManagerService.reboot() implementation.
Consequently, this makes `adb shell svc power reboot userspace` also
benefit from that check, and fail userspace reboot on devices that don't
support it.
Also tweaked logic of ignoring RemoteException to take into account
userspace reboot.
Test: adb root
Test: adb shell setprop init.userspace_reboot.is_supported 0
Test: adb shell svc power reboot userspace & verified error message
Test: adb shell setprop init.userspace_reboot.is_supported 1
Test: adb shell svc power reboot userspace & verified no error message
Test: atest PowerManagerTest
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152803929
Change-Id: I2d3a8e0ae1320c408a838c5c5fdf4cd977b167b3
Diffstat (limited to 'core/java/android/os/PowerManager.java')
| -rw-r--r-- | core/java/android/os/PowerManager.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index b8e1aa88c3a3..be2de0edda2d 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -1483,12 +1483,25 @@ public final class PowerManager { return mInteractiveCache.query(null); } + + /** + * 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(); } /** |
