add WakeLock#isHeld()

This commit is contained in:
Milos Kozak 2017-08-27 11:57:06 +02:00
parent 1417410dbb
commit 03bf1abdd4

View file

@ -95,9 +95,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (ev.lock) {
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AAPS");
mWakeLock.acquire();
if (!mWakeLock.isHeld())
mWakeLock.acquire();
} else {
if (mWakeLock != null)
if (mWakeLock != null && mWakeLock.isHeld())
mWakeLock.release();
}
}