From b34f6e072014d0cf2385a7a32a466478266c651b Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 6 Mar 2021 09:45:42 +0100 Subject: [PATCH] null check weak reference value --- .../eu/siacs/conversations/ui/RtpSessionActivity.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java index 56839d501..7f046def8 100644 --- a/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/RtpSessionActivity.java @@ -149,7 +149,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe @Override 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.getNotificationService().stopSoundAndVibration()) { return true; @@ -489,8 +489,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe return; } //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 && xmppConnectionService != null) { + if (emptyReference(rtpConnectionReference) && xmppConnectionService != null) { retractSessionProposal(); } } @@ -1077,7 +1076,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe updateRtpSessionProposalState(account, with, state); return; } - if (this.rtpConnectionReference == null) { + if (emptyReference(this.rtpConnectionReference)) { if (END_CARD.contains(state)) { Log.d(Config.LOGTAG, "not reinitializing session"); 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); setIntent(intent); } + + private static boolean emptyReference(final WeakReference weakReference) { + return weakReference == null || weakReference.get() == null; + } }