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
This commit is contained in:
Tyler Gunn
2017-06-16 20:20:34 -07:00
parent 4996a35843
commit 9a351ca849

View File

@@ -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);