From 3fea8d1042a81ee45e5a2eb658dc504586246fba Mon Sep 17 00:00:00 2001 From: Andrew Solovay Date: Thu, 5 Dec 2019 13:05:38 -0800 Subject: docs: Removing most of the intro to PowerManager API The intro text says PowerManager is discouraged, and almost all the available wakelock options have long been deprecated. Given that, I think it makes sense to remove most of that intro and just point devs to FLAG_KEEP_SCREEN_ON instead. Staged to: go/dac-stage/reference/android/os/PowerManager Test: make ds-docs Bug: 145699347 Change-Id: I517366903f3d9743166d7edaddc08471af0803d9 --- core/java/android/os/PowerManager.java | 69 +++------------------------------- 1 file changed, 5 insertions(+), 64 deletions(-) (limited to 'core/java/android/os/PowerManager.java') diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 2fff595d7150..45e777c7d01b 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -44,70 +44,10 @@ import java.util.concurrent.Executor; *

* Device battery life will be significantly affected by the use of this API. * Do not acquire {@link WakeLock}s unless you really need them, use the minimum levels - * possible, and be sure to release them as soon as possible. - *

- * The primary API you'll use is {@link #newWakeLock(int, String) newWakeLock()}. - * This will create a {@link PowerManager.WakeLock} object. You can then use methods - * on the wake lock object to control the power state of the device. - *

- * In practice it's quite simple: - * {@samplecode - * PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); - * PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag"); - * wl.acquire(); - * ..screen will stay on during this section.. - * wl.release(); - * } - *

- * The following wake lock levels are defined, with varying effects on system power. - * These levels are mutually exclusive - you may only specify one of them. + * possible, and be sure to release them as soon as possible. In most cases, + * you'll want to use + * {@link android.view.WindowManager.LayoutParams#FLAG_KEEP_SCREEN_ON} instead. * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Flag ValueCPU Screen Keyboard
{@link #PARTIAL_WAKE_LOCK}On* Off Off
{@link #SCREEN_DIM_WAKE_LOCK}On Dim Off
{@link #SCREEN_BRIGHT_WAKE_LOCK}On Bright Off
{@link #FULL_WAKE_LOCK}On Bright Bright
- *

- * *If you hold a partial wake lock, the CPU will continue to run, regardless of any - * display timeouts or the state of the screen and even after the user presses the power button. - * In all other wake locks, the CPU will run, but the user can still put the device to sleep - * using the power button. - *

- * In addition, you can add two more flags, which affect behavior of the screen only. - * These flags have no effect when combined with a {@link #PARTIAL_WAKE_LOCK}.

- * - * - * - * - * - * - * - * - * - * - * - *
Flag Value Description
{@link #ACQUIRE_CAUSES_WAKEUP}Normal wake locks don't actually turn on the illumination. Instead, they cause - * the illumination to remain on once it turns on (e.g. from user activity). This flag - * will force the screen and/or keyboard to turn on immediately, when the WakeLock is - * acquired. A typical use would be for notifications which are important for the user to - * see immediately.
{@link #ON_AFTER_RELEASE}If this flag is set, the user activity timer will be reset when the WakeLock is - * released, causing the illumination to remain on a bit longer. This can be used to - * reduce flicker if you are cycling between wake lock conditions.
*

* Any application using a WakeLock must request the {@code android.permission.WAKE_LOCK} * permission in an {@code } element of the application's manifest. @@ -914,7 +854,8 @@ public final class PowerManager { * {@link #FULL_WAKE_LOCK}, {@link #SCREEN_DIM_WAKE_LOCK} * and {@link #SCREEN_BRIGHT_WAKE_LOCK}. Exactly one wake lock level must be * specified as part of the {@code levelAndFlags} parameter. - *

+ *

+ *

* The wake lock flags are: {@link #ACQUIRE_CAUSES_WAKEUP} * and {@link #ON_AFTER_RELEASE}. Multiple flags can be combined as part of the * {@code levelAndFlags} parameters. -- cgit v1.2.3