diff options
| author | Robert Horvath <robhor@google.com> | 2021-12-06 15:01:29 +0100 |
|---|---|---|
| committer | Robert Horvath <robhor@google.com> | 2022-01-27 23:08:32 +0100 |
| commit | e57eb6d07e403bf4bd0c25d76faacddecbac1e5a (patch) | |
| tree | 4371ecbad4a487972f927098e30c8eb00c384106 /core/java/android/os/PowerManager.java | |
| parent | 4845efb60d530bed74de584c0dfbbb021c71fda0 (diff) | |
Add TestApi to force Low Power Standby to be active
Since Low Power Standby depends on multiple factors to activate,
including the private device configuration for the delay after the
device becomes non-interactive, having this TestApi makes testing
faster and more reliable.
Bug: 190822356
Test: atest LowPowerStandbyTest
Change-Id: I5a16083f996bd7421197b08c6632655c8c3d8c29
Diffstat (limited to 'core/java/android/os/PowerManager.java')
| -rw-r--r-- | core/java/android/os/PowerManager.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index c0d4347e6857..c5e5438c2e63 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -2215,6 +2215,26 @@ public final class PowerManager { } /** + * Force Low Power Standby restrictions to be active. + * Does nothing if Low Power Standby is not supported. + * + * @see #isLowPowerStandbySupported() + * @hide + */ + @TestApi + @RequiresPermission(anyOf = { + android.Manifest.permission.MANAGE_LOW_POWER_STANDBY, + android.Manifest.permission.DEVICE_POWER + }) + public void forceLowPowerStandbyActive(boolean active) { + try { + mService.forceLowPowerStandbyActive(active); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Return whether the given application package name is on the device's power allowlist. * Apps can be placed on the allowlist through the settings UI invoked by * {@link android.provider.Settings#ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS}. |
