From 609120c0d88c2848960435d1841085815e4bba2c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 11 Apr 2020 19:47:30 +0200 Subject: [PATCH] only ever create one wake lock in rtpsessionactivity --- .../conversations/services/NotificationService.java | 4 ---- .../conversations/services/XmppConnectionService.java | 2 +- .../eu/siacs/conversations/ui/RtpSessionActivity.java | 11 ++++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 75097a4ae..c2665ea8b 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -1105,10 +1105,6 @@ public class NotificationService { notify(FOREGROUND_NOTIFICATION_ID, notification); } - void dismissForcedForegroundNotification() { - cancel(FOREGROUND_NOTIFICATION_ID); - } - private void notify(String tag, int id, Notification notification) { final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mXmppConnectionService); try { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 2ad2c49f3..24c80713c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1273,7 +1273,7 @@ public class XmppConnectionService extends Service { } public boolean foregroundNotificationNeedsUpdatingWhenErrorStateChanges() { - return !mForceForegroundService.get() && Compatibility.keepForegroundService(this) && hasEnabledAccounts(); + return !mForceForegroundService.get() && ongoingCall.get() == null && Compatibility.keepForegroundService(this) && hasEnabledAccounts(); } @Override diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index c98d55cb6..73c066eec 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -115,7 +115,9 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - this.mProximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, PROXIMITY_WAKE_LOCK_TAG); + if (this.mProximityWakeLock == null) { + this.mProximityWakeLock = powerManager.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, PROXIMITY_WAKE_LOCK_TAG); + } if (!this.mProximityWakeLock.isHeld()) { Log.d(Config.LOGTAG, "acquiring wake lock"); this.mProximityWakeLock.acquire(); @@ -139,6 +141,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe @Override public void onNewIntent(final Intent intent) { super.onNewIntent(intent); + //TODO. deal with 'pending intent' in case background service isn’t here yet. final Account account = extractAccount(intent); final Jid with = Jid.of(intent.getStringExtra(EXTRA_WITH)); final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID); @@ -211,10 +214,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe @Override public void onStop() { - if (!isChangingConfigurations()) { - releaseWakeLock(); - //TODO maybe we want to finish if call had ended - } + releaseWakeLock(); + //TODO maybe we want to finish if call had ended super.onStop(); }