retract call when user presses home button or back; not on stop. fixes #3802

This commit is contained in:
Daniel Gultsch 2020-06-22 15:37:22 +02:00
parent 57135e1a59
commit a5430d5ce1

View file

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