modify away when locked behaviour to locked || screen off

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.

(cherry picked from commit bf25b24967a90f19999b569d168efdc984061ad5)
This commit is contained in:
Daniel Gultsch 2021-03-13 10:52:02 +01:00 committed by Christian Schneppe
parent ac37054304
commit 1d28363bfe

View file

@ -1184,7 +1184,10 @@ public class XmppConnectionService extends Service {
public boolean isScreenLocked() { public boolean isScreenLocked() {
final KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); 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() { private boolean isPhoneSilenced() {
@ -4735,7 +4738,7 @@ public class XmppConnectionService extends Service {
} }
public void sendPresence(final Account account, final boolean includeIdleTimestamp) { public void sendPresence(final Account account, final boolean includeIdleTimestamp) {
Presence.Status status; final Presence.Status status;
if (manuallyChangePresence()) { if (manuallyChangePresence()) {
status = account.getPresenceStatus(); status = account.getPresenceStatus();
} else { } else {