Some more improvements to fix #325

This commit is contained in:
Sebastián Katzer 2019-02-03 16:17:15 +01:00
parent 6b522e9832
commit 4c157f4509

View File

@ -147,6 +147,7 @@ class BackgroundExt {
Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TOP); Intent.FLAG_ACTIVITY_CLEAR_TOP);
clearSreenAndKeyguardFlags();
app.startActivity(intent); app.startActivity(intent);
} }
@ -244,10 +245,8 @@ class BackgroundExt {
*/ */
private void unlock() private void unlock()
{ {
getApp().runOnUiThread(() -> {
addSreenAndKeyguardFlags(); addSreenAndKeyguardFlags();
getApp().startActivity(getLaunchIntent()); getApp().startActivity(getLaunchIntent());
});
} }
/** /**
@ -287,7 +286,15 @@ class BackgroundExt {
*/ */
private void addSreenAndKeyguardFlags() private void addSreenAndKeyguardFlags()
{ {
getApp().getWindow().addFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD); getApp().runOnUiThread(() -> getApp().getWindow().addFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD));
}
/**
* Clears required flags to the window to unlock/wakeup the device.
*/
private void clearSreenAndKeyguardFlags()
{
getApp().runOnUiThread(() -> getApp().getWindow().clearFlags(FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | FLAG_SHOW_WHEN_LOCKED | FLAG_TURN_SCREEN_ON | FLAG_DISMISS_KEYGUARD));
} }
/** /**