diff options
author | 2023-04-18 16:54:52 -0700 | |
---|---|---|
committer | 2023-04-19 10:44:05 -0700 | |
commit | 6e377858ffbce87b84d74322cb6e6a710ef26ab8 (patch) | |
tree | 7c37f6b9c9e58b6ff1ab5ee32b1af5bfbf29fb33 | |
parent | 9bf704091b787c3b1879003eca6b46d859c50c26 (diff) |
ignore call streaming msgs if the adapter is destroyed/not set
The D2DI team hit an NPE while testing out the call transfer/streaming
stuff. The NPE arises in StreamingCall whenever a call streaming changed
msg comes in and the StreamingCallAdapter is null.
Ideally, we should be wrapping any adapter request with an NPE check and
ignoring messages if the adapter is destroyed or not set.
bug: 277119309
Test: manual
Change-Id: I90a5c1dc16dfda9f3c92316b2f4f1655166a59b9
-rw-r--r-- | telecomm/java/android/telecom/CallStreamingService.java | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/telecomm/java/android/telecom/CallStreamingService.java b/telecomm/java/android/telecom/CallStreamingService.java index 3f538a7f262d..df48cd6a16e2 100644 --- a/telecomm/java/android/telecom/CallStreamingService.java +++ b/telecomm/java/android/telecom/CallStreamingService.java @@ -52,6 +52,7 @@ import java.lang.annotation.RetentionPolicy; * </service> * } * </pre> + * * @hide */ @SystemApi @@ -65,7 +66,7 @@ public abstract class CallStreamingService extends Service { private static final int MSG_SET_STREAMING_CALL_ADAPTER = 1; private static final int MSG_CALL_STREAMING_STARTED = 2; private static final int MSG_CALL_STREAMING_STOPPED = 3; - private static final int MSG_CALL_STREAMING_CHANGED_CHANGED = 4; + private static final int MSG_CALL_STREAMING_STATE_CHANGED = 4; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -77,8 +78,10 @@ public abstract class CallStreamingService extends Service { switch (msg.what) { case MSG_SET_STREAMING_CALL_ADAPTER: - mStreamingCallAdapter = new StreamingCallAdapter( - (IStreamingCallAdapter) msg.obj); + if (msg.obj != null) { + mStreamingCallAdapter = new StreamingCallAdapter( + (IStreamingCallAdapter) msg.obj); + } break; case MSG_CALL_STREAMING_STARTED: mCall = (StreamingCall) msg.obj; @@ -90,10 +93,12 @@ public abstract class CallStreamingService extends Service { mStreamingCallAdapter = null; CallStreamingService.this.onCallStreamingStopped(); break; - case MSG_CALL_STREAMING_CHANGED_CHANGED: + case MSG_CALL_STREAMING_STATE_CHANGED: int state = (int) msg.obj; - mCall.requestStreamingState(state); - CallStreamingService.this.onCallStreamingStateChanged(state); + if (mStreamingCallAdapter != null) { + mCall.requestStreamingState(state); + CallStreamingService.this.onCallStreamingStateChanged(state); + } break; default: break; @@ -128,7 +133,7 @@ public abstract class CallStreamingService extends Service { @Override public void onCallStreamingStateChanged(int state) throws RemoteException { - mHandler.obtainMessage(MSG_CALL_STREAMING_CHANGED_CHANGED, state).sendToTarget(); + mHandler.obtainMessage(MSG_CALL_STREAMING_STATE_CHANGED, state).sendToTarget(); } } @@ -173,9 +178,12 @@ public abstract class CallStreamingService extends Service { STREAMING_FAILED_ALREADY_STREAMING, STREAMING_FAILED_NO_SENDER, STREAMING_FAILED_SENDER_BINDING_ERROR - }) + }) @Retention(RetentionPolicy.SOURCE) - public @interface StreamingFailedReason {}; + public @interface StreamingFailedReason { + } + + ; /** * Called when a {@code StreamingCall} has been added to this call streaming session. The call |