diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index ddd198b83..5db8dfc6d 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -276,11 +276,15 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe private void releaseProximityWakeLock() { if (this.mProximityWakeLock != null && mProximityWakeLock.isHeld()) { Log.d(Config.LOGTAG, "releasing proximity wake lock"); - this.mProximityWakeLock.release(PowerManager.RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + this.mProximityWakeLock.release(PowerManager.RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY); + } else { + this.mProximityWakeLock.release(); + } this.mProximityWakeLock = null; } } - + private void putProximityWakeLockInProperState(final AppRTCAudioManager.AudioDevice audioDevice) { if (audioDevice == AppRTCAudioManager.AudioDevice.EARPIECE) { acquireProximityWakeLock(); @@ -402,10 +406,6 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe final JingleRtpConnection jingleRtpConnection = weakReference == null ? null : weakReference.get(); if (jingleRtpConnection != null) { releaseVideoTracks(jingleRtpConnection); - } else if (!isChangingConfigurations()) { - if (xmppConnectionService != null) { - retractSessionProposal(); - } } releaseProximityWakeLock(); super.onStop(); @@ -424,17 +424,20 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe @Override public void onBackPressed() { - endCall(); super.onBackPressed(); + endCall(); } @Override public void onUserLeaveHint() { + super.onUserLeaveHint(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && deviceSupportsPictureInPicture()) { if (shouldBePictureInPicture()) { startPictureInPicture(); + return; } } + retractSessionProposal(); } @RequiresApi(api = Build.VERSION_CODES.O) @@ -445,7 +448,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe .setAspectRatio(new Rational(10, 16)) .build() ); - } catch (IllegalStateException e) { + } catch (final IllegalStateException e) { //this sometimes happens on Samsung phones (possibly when Knox is enabled) Log.w(Config.LOGTAG, "unable to enter picture in picture mode", e); } @@ -467,7 +470,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe RtpEndUserState.CONNECTING, RtpEndUserState.CONNECTED ).contains(rtpConnection.getEndUserState()); - } catch (IllegalStateException e) { + } catch (final IllegalStateException e) { return false; } }