From bf25b24967a90f19999b569d168efdc984061ad5 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 13 Mar 2021 10:52:02 +0100 Subject: [PATCH] modify away when locked behaviour to locked || screen off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this new behaviour still takes care of not going online when quickly checking for the time but it also includes systems that don’t have a lock screen or incorrectly report being unlocked. --- .../conversations/services/XmppConnectionService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 5880dfa56..3256d2c15 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -999,7 +999,10 @@ public class XmppConnectionService extends Service { public boolean isScreenLocked() { final KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); - return keyguardManager != null && keyguardManager.inKeyguardRestrictedInputMode(); + final PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); + final boolean locked = keyguardManager != null && keyguardManager.isKeyguardLocked(); + final boolean interactive = powerManager != null && powerManager.isInteractive(); + return locked || !interactive; } private boolean isPhoneSilenced() { @@ -4346,7 +4349,7 @@ public class XmppConnectionService extends Service { } private void sendPresence(final Account account, final boolean includeIdleTimestamp) { - Presence.Status status; + final Presence.Status status; if (manuallyChangePresence()) { status = account.getPresenceStatus(); } else {