From c69e1104c31bf624cd9a9981c16dc94adf39b8d0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 3 Jun 2020 16:41:51 +0300 Subject: [PATCH] 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(); + } } }