Merge pull request #937 from jtrax/bugfixes
Fixed turn on the screen algorithm
This commit is contained in:
commit
9539a10d24
1 changed files with 19 additions and 20 deletions
|
@ -112,10 +112,9 @@ public class MapActivity extends AccessibleActivity implements
|
||||||
private StateChangedListener<ApplicationMode> applicationModeListener;
|
private StateChangedListener<ApplicationMode> applicationModeListener;
|
||||||
private FrameLayout lockView;
|
private FrameLayout lockView;
|
||||||
private GpxImportHelper gpxImportHelper;
|
private GpxImportHelper gpxImportHelper;
|
||||||
private Long lastWakeOnTime = 0l;
|
|
||||||
private PowerManager.WakeLock wakeLock = null;
|
private PowerManager.WakeLock wakeLock = null;
|
||||||
private KeyguardManager.KeyguardLock keyguardLock = null;
|
private KeyguardManager.KeyguardLock keyguardLock = null;
|
||||||
|
private ReleaseWakeLocksRunnable releaseWakeLocksRunnable = new ReleaseWakeLocksRunnable();
|
||||||
|
|
||||||
private Notification getNotification() {
|
private Notification getNotification() {
|
||||||
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
|
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
|
||||||
|
@ -783,7 +782,8 @@ public class MapActivity extends AccessibleActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void onVoiceMessage() {
|
public void onVoiceMessage() {
|
||||||
if (settings.WAKE_ON_VOICE.get()) {
|
if (settings.WAKE_ON_VOICE.get()) {
|
||||||
lastWakeOnTime = System.currentTimeMillis();
|
uiHandler.removeCallbacks(releaseWakeLocksRunnable);
|
||||||
|
|
||||||
if (wakeLock == null) {
|
if (wakeLock == null) {
|
||||||
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
|
wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK
|
||||||
|
@ -797,27 +797,26 @@ public class MapActivity extends AccessibleActivity implements
|
||||||
keyguardLock.disableKeyguard();
|
keyguardLock.disableKeyguard();
|
||||||
}
|
}
|
||||||
|
|
||||||
uiHandler.postDelayed(new Runnable() {
|
uiHandler.postDelayed(releaseWakeLocksRunnable, WAKE_ON_VOICE_INTERVAL);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
releaseWakeLocks();
|
|
||||||
}
|
|
||||||
}, WAKE_ON_VOICE_INTERVAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseWakeLocks() {
|
private void releaseWakeLocks() {
|
||||||
long now = System.currentTimeMillis();
|
if (keyguardLock != null) {
|
||||||
if (now >= lastWakeOnTime) {
|
keyguardLock.reenableKeyguard();
|
||||||
if (keyguardLock != null) {
|
keyguardLock = null;
|
||||||
keyguardLock.reenableKeyguard();
|
}
|
||||||
keyguardLock = null;
|
if (wakeLock != null) {
|
||||||
}
|
wakeLock.release();
|
||||||
if (wakeLock != null) {
|
wakeLock = null;
|
||||||
wakeLock.release();
|
}
|
||||||
wakeLock = null;
|
}
|
||||||
}
|
|
||||||
|
private class ReleaseWakeLocksRunnable implements Runnable {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
releaseWakeLocks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue