~singpolyma/cheogram-android

38450896d19b72bf198c7b2ff044bbbe0646c2b5 — Stephen Paul Weber 10 months ago 4d01101 2.10.3-2
Fix NPE when answering a call that has already gone away
1 files changed, 17 insertions(+), 6 deletions(-)

M src/cheogram/java/com/cheogram/android/ConnectionService.java
M src/cheogram/java/com/cheogram/android/ConnectionService.java => src/cheogram/java/com/cheogram/android/ConnectionService.java +17 -6
@@ 220,7 220,7 @@ public class ConnectionService extends android.telecom.ConnectionService {
			if (sessionId == null || !sessionId.equals(this.sessionId)) return;
			if (rtpConnection == null) {
				this.with = with; // Store full JID of connection
				rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
				findRtpConnection();
			}

			setStatusHints(new StatusHints(null, gatewayIcon, null));


@@ 269,15 269,20 @@ public class ConnectionService extends android.telecom.ConnectionService {
		public void onAnswer() {
			// For incoming calls, a connection update may not have been triggered before answering
			// so we have to acquire the rtp connection object here
			this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);

			rtpConnection.get().acceptCall();
			findRtpConnection();
			if (rtpConnection == null || rtpConnection.get() == null) {
				close(new DisconnectCause(DisconnectCause.CANCELED));
			} else {
				rtpConnection.get().acceptCall();
			}
		}

		@Override
		public void onReject() {
			this.rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
			rtpConnection.get().rejectCall();
			findRtpConnection();
			if (rtpConnection != null && rtpConnection.get() != null) {
				rtpConnection.get().rejectCall();
			}
			close(new DisconnectCause(DisconnectCause.LOCAL));
		}



@@ 316,6 321,12 @@ public class ConnectionService extends android.telecom.ConnectionService {
			if (c) postDial();
		}

		protected void findRtpConnection() {
			if (rtpConnection != null) return;

			rtpConnection = xmppConnectionService.getJingleConnectionManager().findJingleRtpConnection(account, with, sessionId);
		}

		protected void sleep(int ms) {
			try {
				Thread.sleep(ms);