Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1244cdae authored by Jeff Brown's avatar Jeff Brown
Browse files

Clean up PowerManager API.

Mostly just moved the code around and improved the docs.

Fixed a minor inefficiency in WakeLock.setWorkSource() where
we would tell the power manager that the work source was changed
even when the old work source and new work source were both null.

Fixed a bug in WakeLock.setWorkSource() where we would not
notify the power manager that the work source was changed if
there was no work source previously specified.

Added synchronized to WakeLock.setReferenceCounted.

Added a checked in WakeLock.acquireLocked() and WakeLock.release()
to check whether the wake lock is actually not held / held
before performing the corresponding operation.  This change avoids
making redundant calls into the power manager service in the
case where the wake lock is not reference counted and acquire()
or release() have been called multiple times.

Made the PowerManager and WakeLock classes final.  They are not
directly instantiable by applications so this change does not
break the API.

Removed a little dead code (one private constructor and an
unused constant).

Change-Id: I4e10cf893506115938a35756136c101256dccf30
parent 880c5f5a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -15962,7 +15962,7 @@ package android.os {
    field public static final int PATTERN_SIMPLE_GLOB = 2; // 0x2
  }
  public class PowerManager {
  public final class PowerManager {
    method public void goToSleep(long);
    method public boolean isScreenOn();
    method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
@@ -15976,7 +15976,7 @@ package android.os {
    field public static final int SCREEN_DIM_WAKE_LOCK = 6; // 0x6
  }
  public class PowerManager.WakeLock {
  public final class PowerManager.WakeLock {
    method public void acquire();
    method public void acquire(long);
    method public boolean isHeld();
+2 −2
Original line number Diff line number Diff line
@@ -15979,7 +15979,7 @@ package android.os {
    field public static final int PATTERN_SIMPLE_GLOB = 2; // 0x2
  }
  public class PowerManager {
  public final class PowerManager {
    method public void goToSleep(long);
    method public boolean isScreenOn();
    method public android.os.PowerManager.WakeLock newWakeLock(int, java.lang.String);
@@ -15993,7 +15993,7 @@ package android.os {
    field public static final int SCREEN_DIM_WAKE_LOCK = 6; // 0x6
  }
  public class PowerManager.WakeLock {
  public final class PowerManager.WakeLock {
    method public void acquire();
    method public void acquire(long);
    method public boolean isHeld();
+399 −324

File changed.

Preview size limit exceeded, changes collapsed.