null check weak reference value

This commit is contained in:
Daniel Gultsch 2021-03-06 09:45:42 +01:00
parent b8c61b795e
commit b34f6e0720
1 changed files with 7 additions and 4 deletions

View File

@ -149,7 +149,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
@Override @Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) { public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){ if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
if (xmppConnectionService != null) { if (xmppConnectionService != null) {
if (xmppConnectionService.getNotificationService().stopSoundAndVibration()) { if (xmppConnectionService.getNotificationService().stopSoundAndVibration()) {
return true; return true;
@ -489,8 +489,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
return; return;
} }
//TODO apparently this method is not getting called on Android 10 when using the task switcher //TODO apparently this method is not getting called on Android 10 when using the task switcher
final boolean emptyReference = rtpConnectionReference == null || rtpConnectionReference.get() == null; if (emptyReference(rtpConnectionReference) && xmppConnectionService != null) {
if (emptyReference && xmppConnectionService != null) {
retractSessionProposal(); retractSessionProposal();
} }
} }
@ -1077,7 +1076,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
updateRtpSessionProposalState(account, with, state); updateRtpSessionProposalState(account, with, state);
return; return;
} }
if (this.rtpConnectionReference == null) { if (emptyReference(this.rtpConnectionReference)) {
if (END_CARD.contains(state)) { if (END_CARD.contains(state)) {
Log.d(Config.LOGTAG, "not reinitializing session"); Log.d(Config.LOGTAG, "not reinitializing session");
return; return;
@ -1175,4 +1174,8 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
intent.putExtra(EXTRA_LAST_ACTION, media.contains(Media.VIDEO) ? ACTION_MAKE_VIDEO_CALL : ACTION_MAKE_VOICE_CALL); intent.putExtra(EXTRA_LAST_ACTION, media.contains(Media.VIDEO) ? ACTION_MAKE_VIDEO_CALL : ACTION_MAKE_VOICE_CALL);
setIntent(intent); setIntent(intent);
} }
private static boolean emptyReference(final WeakReference<?> weakReference) {
return weakReference == null || weakReference.get() == null;
}
} }