From 9a351ca849b0f74e407fa1b7fb7ce10c63d878d6 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 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 e3b027abdb5d1..f78e427663c6a 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -1440,6 +1440,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")); } @@ -2166,7 +2172,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);