use of android.os.PowerManager in project android_frameworks_base by ResurrectionRemix.
the class FingerprintManager method addLockoutResetCallback.
/**
* @hide
*/
public void addLockoutResetCallback(final LockoutResetCallback callback) {
if (mService != null) {
try {
final PowerManager powerManager = mContext.getSystemService(PowerManager.class);
mService.addLockoutResetCallback(new IFingerprintServiceLockoutResetCallback.Stub() {
@Override
public void onLockoutReset(long deviceId) throws RemoteException {
final PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lockoutResetCallback");
wakeLock.acquire();
mHandler.post(new Runnable() {
@Override
public void run() {
try {
callback.onLockoutReset();
} finally {
wakeLock.release();
}
}
});
}
});
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
} else {
Log.w(TAG, "addLockoutResetCallback(): Service not connected!");
}
}
use of android.os.PowerManager in project android_frameworks_base by ResurrectionRemix.
the class GeofenceHardwareImpl method acquireWakeLock.
private void acquireWakeLock() {
if (mWakeLock == null) {
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
}
mWakeLock.acquire();
}
use of android.os.PowerManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatterySaverCondition method refreshState.
@Override
public void refreshState() {
PowerManager powerManager = mManager.getContext().getSystemService(PowerManager.class);
setActive(powerManager.isPowerSaveMode());
}
use of android.os.PowerManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DockEventReceiver method beginStartingService.
/**
* Start the service to process the current event notifications, acquiring
* the wake lock before returning to ensure that the service will run.
*/
private static void beginStartingService(Context context, Intent intent) {
synchronized (sStartingServiceSync) {
if (sStartingService == null) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
sStartingService = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "StartingDockService");
}
sStartingService.acquire();
if (context.startService(intent) == null) {
Log.e(TAG, "Can't start DockService");
}
}
}
use of android.os.PowerManager in project android_frameworks_base by DirtyUnicorns.
the class MediaPlayer method setWakeMode.
/**
* Set the low-level power management behavior for this MediaPlayer. This
* can be used when the MediaPlayer is not playing through a SurfaceHolder
* set with {@link #setDisplay(SurfaceHolder)} and thus can use the
* high-level {@link #setScreenOnWhilePlaying(boolean)} feature.
*
* <p>This function has the MediaPlayer access the low-level power manager
* service to control the device's power usage while playing is occurring.
* The parameter is a combination of {@link android.os.PowerManager} wake flags.
* Use of this method requires {@link android.Manifest.permission#WAKE_LOCK}
* permission.
* By default, no attempt is made to keep the device awake during playback.
*
* @param context the Context to use
* @param mode the power/wake mode to set
* @see android.os.PowerManager
*/
public void setWakeMode(Context context, int mode) {
boolean washeld = false;
/* Disable persistant wakelocks in media player based on property */
if (SystemProperties.getBoolean("audio.offload.ignore_setawake", false) == true) {
Log.w(TAG, "IGNORING setWakeMode " + mode);
return;
}
if (mWakeLock != null) {
if (mWakeLock.isHeld()) {
washeld = true;
mWakeLock.release();
}
mWakeLock = null;
}
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(mode | PowerManager.ON_AFTER_RELEASE, MediaPlayer.class.getName());
mWakeLock.setReferenceCounted(false);
if (washeld) {
mWakeLock.acquire();
}
}
Aggregations