From 0a88f2e21b3e3ed8a3a953e572a1eea6b572cb3e Mon Sep 17 00:00:00 2001 From: Tyler Gunn Date: Fri, 16 Jun 2017 20:20:34 -0700 Subject: [PATCH] Ensure CallId is not null when connection creation is complete. When calling "get" on the mConnectoinById map, a null callId will result in an NPE. In findConnectionForAction, defaulting to returning the "null" connection which is the same behavior as if it isn't found. In notifyCreateConnectionComplete, specifically checking if the callId is null and skipping the onCreateConnectionComplete callback. This scenario is possible if the connection is remove from the ConnectionService before the connection complete callback comes back from Telecom. Test: Manual Fixes: 62588734 Merged-In: I1de7a0a4cc9c630019e38b8154bfc1d470f56ae3 Change-Id: Ie610c51155ed417e0f916000fe20e4484bdb6603 --- telecomm/java/android/telecom/ConnectionService.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index 6f970fa8e0b5c..a81fba95c4ed2 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -1449,6 +1449,12 @@ public abstract class ConnectionService extends Service { */ private void notifyCreateConnectionComplete(final String callId) { Log.i(this, "notifyCreateConnectionComplete %s", callId); + if (callId == null) { + // This could happen if the connection fails quickly and is removed from the + // ConnectionService before Telecom sends the create connection complete callback. + Log.w(this, "notifyCreateConnectionComplete: callId is null."); + return; + } onCreateConnectionComplete(findConnectionForAction(callId, "notifyCreateConnectionComplete")); } @@ -2177,7 +2183,7 @@ public abstract class ConnectionService extends Service { } private Connection findConnectionForAction(String callId, String action) { - if (mConnectionById.containsKey(callId)) { + if (callId != null && mConnectionById.containsKey(callId)) { return mConnectionById.get(callId); } Log.w(this, "%s - Cannot find Connection %s", action, callId);