|
|
|
@ -437,7 +437,6 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
registerReceiver(screenactionreceiver, screenactionreceiver.getFilter());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// File path = getApplicationContext().getFilesDir();
|
|
|
|
|
String appPath = buildAppDir(this.getApplicationContext());
|
|
|
|
|
|
|
|
|
@ -482,14 +481,17 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
public void requestWakelock(String name, long timeout) {
|
|
|
|
|
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
|
|
|
|
|
PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, name);
|
|
|
|
|
PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK/* | PowerManager.ON_AFTER_RELEASE*/, name);
|
|
|
|
|
PowerManager.WakeLock wl2 = null;
|
|
|
|
|
synchronized (mWakeLocks) {
|
|
|
|
|
wl2 = mWakeLocks.replace(name, wl);
|
|
|
|
|
wl2 = mWakeLocks.get(name);
|
|
|
|
|
mWakeLocks.put(name, wl);
|
|
|
|
|
}
|
|
|
|
|
if (wl2 != null) {
|
|
|
|
|
Log.i(TAG, "Release same name wakelock:" + name);
|
|
|
|
|
wl2.release();
|
|
|
|
|
}
|
|
|
|
|
Log.i(TAG, "Request wakelock:" + name);
|
|
|
|
|
if (timeout == 0) wl.acquire();
|
|
|
|
|
else wl.acquire(timeout);
|
|
|
|
|
}
|
|
|
|
@ -501,6 +503,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
mWakeLocks.remove(name);
|
|
|
|
|
}
|
|
|
|
|
if (wl != null) {
|
|
|
|
|
Log.i(TAG, "Release wakelock:" + name);
|
|
|
|
|
wl.release();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|