2012-09-17 15:13:50 +00:00
|
|
|
package com.dougkeen.bart;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.PowerManager;
|
|
|
|
|
|
|
|
import com.dougkeen.bart.model.Constants;
|
|
|
|
|
|
|
|
public abstract class WakeLocker {
|
|
|
|
private static PowerManager.WakeLock wakeLock;
|
|
|
|
|
|
|
|
public static void acquire(Context ctx) {
|
|
|
|
if (wakeLock != null)
|
|
|
|
wakeLock.release();
|
|
|
|
|
|
|
|
PowerManager pm = (PowerManager) ctx
|
|
|
|
.getSystemService(Context.POWER_SERVICE);
|
|
|
|
wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
|
|
|
|
| PowerManager.ACQUIRE_CAUSES_WAKEUP
|
2012-09-17 15:51:16 +00:00
|
|
|
| PowerManager.ON_AFTER_RELEASE, Constants.TAG);
|
2012-09-17 15:13:50 +00:00
|
|
|
wakeLock.acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void release() {
|
|
|
|
if (wakeLock != null)
|
|
|
|
wakeLock.release();
|
|
|
|
wakeLock = null;
|
|
|
|
}
|
|
|
|
}
|