@Implements(value=android.os.PowerManager.class, looseSignatures=true) public class ShadowPowerManager extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
ShadowPowerManager.ShadowWakeLock |
Constructor | Description |
---|---|
ShadowPowerManager() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
addThermalStatusListener(Object listener) |
This function adds a listener for thermal status change.
|
protected int |
getCurrentThermalStatus() |
This function returns the current thermal status of the device.
|
static PowerManager.WakeLock |
getLatestWakeLock() |
Retrieves the most recent wakelock registered by the application
|
protected int |
getLocationPowerSaveMode() |
Returns how location features should behave when battery saver is on.
|
com.google.common.collect.ImmutableList<String> |
getRebootReasons() |
Returns the list of reasons for each reboot, in chronological order.
|
int |
getTimesRebooted() |
Returns the number of times
reboot(String) was called. |
protected boolean |
isAmbientDisplayAvailable() |
Returns true by default, or the value specified via
setAmbientDisplayAvailable(boolean) . |
protected boolean |
isAmbientDisplaySuppressed() |
Returns true if
suppressAmbientDisplay(String, boolean) has been called with any
token. |
protected boolean |
isDeviceIdleMode() |
|
protected boolean |
isIgnoringBatteryOptimizations(String packageName) |
|
protected boolean |
isInteractive() |
|
protected boolean |
isLightDeviceIdleMode() |
|
protected boolean |
isPowerSaveMode() |
|
protected boolean |
isRebootingUserspaceSupported() |
Returns last value specified in
setIsRebootingUserspaceSupported(boolean) or
false by default. |
protected boolean |
isScreenOn() |
|
protected boolean |
isWakeLockLevelSupported(int level) |
|
protected PowerManager.WakeLock |
newWakeLock(int flags,
String tag) |
|
protected void |
reboot(String reason) |
|
protected void |
removeThermalStatusListener(Object listener) |
This function removes a listener for thermal status change.
|
static void |
reset() |
Discards the most recent
PowerManager.WakeLock s |
void |
setAmbientDisplayAvailable(boolean available) |
Sets the value returned by
isAmbientDisplayAvailable() . |
void |
setCurrentThermalStatus(int thermalStatus) |
Sets the value returned by
getCurrentThermalStatus() . |
void |
setIgnoringBatteryOptimizations(String packageName,
boolean value) |
|
void |
setIsDeviceIdleMode(boolean isDeviceIdleMode) |
Sets the value returned by
isDeviceIdleMode() . |
void |
setIsInteractive(boolean interactive) |
|
void |
setIsLightDeviceIdleMode(boolean lightDeviceIdleMode) |
Sets the value returned by
isLightDeviceIdleMode() . |
void |
setIsPowerSaveMode(boolean powerSaveMode) |
|
void |
setIsRebootingUserspaceSupported(boolean supported) |
Sets the value returned by
isRebootingUserspaceSupported() . |
void |
setIsScreenOn(boolean screenOn) |
|
void |
setIsWakeLockLevelSupported(int level,
boolean supported) |
|
void |
setLocationPowerSaveMode(int locationMode) |
Sets the value returned by
getLocationPowerSaveMode() when battery saver is on. |
protected void |
suppressAmbientDisplay(String token,
boolean suppress) |
If true, suppress the device's ambient display.
|
@Implementation protected PowerManager.WakeLock newWakeLock(int flags, String tag)
@Implementation protected boolean isScreenOn()
public void setIsScreenOn(boolean screenOn)
@Implementation(minSdk=21) protected boolean isInteractive()
public void setIsInteractive(boolean interactive)
@Implementation(minSdk=21) protected boolean isPowerSaveMode()
public void setIsPowerSaveMode(boolean powerSaveMode)
@Implementation(minSdk=21) protected boolean isWakeLockLevelSupported(int level)
public void setIsWakeLockLevelSupported(int level, boolean supported)
@Implementation(minSdk=23) protected boolean isDeviceIdleMode()
setIsDeviceIdleMode(boolean)
public void setIsDeviceIdleMode(boolean isDeviceIdleMode)
isDeviceIdleMode()
.@Implementation(minSdk=24) protected boolean isLightDeviceIdleMode()
setIsLightDeviceIdleMode(boolean)
public void setIsLightDeviceIdleMode(boolean lightDeviceIdleMode)
isLightDeviceIdleMode()
.@Implementation(minSdk=28) protected int getLocationPowerSaveMode()
#LOCATION_MODE_NO_CHANGE
.public void setLocationPowerSaveMode(int locationMode)
getLocationPowerSaveMode()
when battery saver is on.@Implementation(minSdk=29) protected int getCurrentThermalStatus()
@Implementation(minSdk=29) protected void addThermalStatusListener(Object listener)
@Implementation(minSdk=29) protected void removeThermalStatusListener(Object listener)
public void setCurrentThermalStatus(int thermalStatus)
getCurrentThermalStatus()
.@Resetter public static void reset()
PowerManager.WakeLock
spublic static PowerManager.WakeLock getLatestWakeLock()
@Implementation(minSdk=23) protected boolean isIgnoringBatteryOptimizations(String packageName)
public void setIgnoringBatteryOptimizations(String packageName, boolean value)
@Implementation protected void reboot(String reason)
public int getTimesRebooted()
reboot(String)
was called.public com.google.common.collect.ImmutableList<String> getRebootReasons()
public void setAmbientDisplayAvailable(boolean available)
isAmbientDisplayAvailable()
.public void setIsRebootingUserspaceSupported(boolean supported)
isRebootingUserspaceSupported()
.@Implementation(minSdk=30) protected boolean isAmbientDisplayAvailable()
setAmbientDisplayAvailable(boolean)
.@Implementation(minSdk=30) protected void suppressAmbientDisplay(String token, boolean suppress)
PowerManager.isInteractive()
is false.token
- An identifier for the ambient display suppression.suppress
- If true
, suppresses the ambient display. Otherwise, unsuppresses the
ambient display for the given token.@Implementation(minSdk=30) protected boolean isAmbientDisplaySuppressed()
suppressAmbientDisplay(String, boolean)
has been called with any
token.@Implementation(minSdk=30) protected boolean isRebootingUserspaceSupported()
setIsRebootingUserspaceSupported(boolean)
or
false
by default.