From 1a4970fbbc23111502d859e3d69cff96f1f21fab Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Jun 2020 15:43:53 +0300 Subject: [PATCH 1/4] Fix turn screen on --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 3 ++- OsmAnd/src/net/osmand/plus/helpers/LockHelper.java | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index e19af7c3e5..c39309b99e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1977,10 +1977,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (enable) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + setKeepScreenOn(true); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + setKeepScreenOn(forceKeepScreenOn); } - setKeepScreenOn(forceKeepScreenOn); } @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index a7dcf6b011..9502c17401 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -118,11 +118,8 @@ public class LockHelper implements SensorEventListener { private void lock() { releaseWakeLocks(); - int unlockTime = turnScreenOnTime.get(); - if (lockUIAdapter != null) { - if (!(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get()) && unlockTime != 0) { - lockUIAdapter.lock(); - } + if (lockUIAdapter != null && !(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get())) { + lockUIAdapter.lock(); } } From b92c91c31e1de4df3b5c9cfdc4d82e61fee1965a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Jun 2020 15:53:01 +0300 Subject: [PATCH 2/4] Remove unnecessary changes --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 5 ++--- OsmAnd/src/net/osmand/plus/helpers/LockHelper.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index c39309b99e..3e94bae493 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1977,11 +1977,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (enable) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); - setKeepScreenOn(true); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); - setKeepScreenOn(forceKeepScreenOn); } + setKeepScreenOn(forceKeepScreenOn); } @Override @@ -1991,7 +1990,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void unlock() { - changeKeyguardFlags(true, false); + changeKeyguardFlags(true, true); } @Override diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index 9502c17401..d58bbd104c 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -118,7 +118,7 @@ public class LockHelper implements SensorEventListener { private void lock() { releaseWakeLocks(); - if (lockUIAdapter != null && !(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get())) { + if (lockUIAdapter != null) { lockUIAdapter.lock(); } } From 96bccff5159c6072f0d5f041dadeb76c11fb11d4 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Jun 2020 16:09:05 +0300 Subject: [PATCH 3/4] Remove unnecessary changes for power button --- OsmAnd/src/net/osmand/plus/helpers/LockHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index d58bbd104c..9502c17401 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -118,7 +118,7 @@ public class LockHelper implements SensorEventListener { private void lock() { releaseWakeLocks(); - if (lockUIAdapter != null) { + if (lockUIAdapter != null && !(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get())) { lockUIAdapter.lock(); } } From c69e1104c31bf624cd9a9981c16dc94adf39b8d0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Jun 2020 16:41:51 +0300 Subject: [PATCH 4/4] Fix power button for keep screen on --- OsmAnd/src/net/osmand/plus/helpers/LockHelper.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index 9502c17401..9bf628803a 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -118,8 +118,13 @@ public class LockHelper implements SensorEventListener { private void lock() { releaseWakeLocks(); - if (lockUIAdapter != null && !(useSystemScreenTimeout.get() && turnScreenOnPowerButton.get())) { - lockUIAdapter.lock(); + if (lockUIAdapter != null) { + boolean useSystemTimeout = useSystemScreenTimeout.get(); + boolean usePowerButton = useSystemTimeout && turnScreenOnPowerButton.get() + || !useSystemTimeout && turnScreenOnTime.get() == 0 && turnScreenOnPowerButton.get(); + if (!usePowerButton) { + lockUIAdapter.lock(); + } } }