add WakeLock#isHeld()
This commit is contained in:
parent
1417410dbb
commit
03bf1abdd4
1 changed files with 3 additions and 2 deletions
|
@ -95,9 +95,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
||||||
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
|
||||||
if (ev.lock) {
|
if (ev.lock) {
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AAPS");
|
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "AAPS");
|
||||||
mWakeLock.acquire();
|
if (!mWakeLock.isHeld())
|
||||||
|
mWakeLock.acquire();
|
||||||
} else {
|
} else {
|
||||||
if (mWakeLock != null)
|
if (mWakeLock != null && mWakeLock.isHeld())
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue