Call "createConnectionComplete" callback in Telecom.

When done creating a connection in Telecom, call createConnectionComplete.
Note: Checks the serviceinterface for null since in the case of a
"null connection" from the ConnectionService we'll be unbound by
the time we get here.

Test: Manual
Bug: 33272455
Change-Id: Ic23f6ad65d49d2a8c70ac4d35d53feb0dd5e34bb
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index f269cdf..6ae7261 100644
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -77,6 +77,15 @@
                     logIncoming("handleCreateConnectionComplete %s", callId);
                     ConnectionServiceWrapper.this
                             .handleCreateConnectionComplete(callId, request, connection);
+
+                    if (mServiceInterface != null) {
+                        logOutgoing("createConnectionComplete %s", callId);
+                        try {
+                            mServiceInterface.createConnectionComplete(callId,
+                                    Log.getExternalSession());
+                        } catch (RemoteException e) {
+                        }
+                    }
                 }
             } finally {
                 Binder.restoreCallingIdentity(token);
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
index f053a99..e815b5c 100644
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
@@ -117,6 +117,10 @@
         }
 
         @Override
+        public void onCreateConnectionComplete(Connection connection) {
+        }
+
+        @Override
         public void onConference(Connection cxn1, Connection cxn2) {
             if (((FakeConnection) cxn1).getIsConferenceCreated()) {
                 // Usually, this is implemented by something in Telephony, which does a bunch of
@@ -240,6 +244,11 @@
         }
 
         @Override
+        public void createConnectionComplete(String id, Session.Info info) throws RemoteException {
+            mConnectionServiceDelegateAdapter.createConnectionComplete(id, null /*Session.Info*/);
+        }
+
+        @Override
         public void createConnectionFailed(PhoneAccountHandle connectionManagerPhoneAccount,
                 String callId, ConnectionRequest request, boolean isIncoming,
                 Session.Info sessionInfo) throws RemoteException {
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index 1c81fec..1f7a7de 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -720,6 +720,10 @@
         // Wait for the callback in ConnectionService#onAdapterAttached to execute.
         waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
 
+        // Ensure callback to CS on successful creation happened.
+        verify(connectionServiceFixture.getTestDouble(), timeout(TEST_TIMEOUT))
+                .createConnectionComplete(anyString(), any());
+
         assertEquals(startingNumCalls + 1, mInCallServiceFixtureX.mCallById.size());
         assertEquals(startingNumCalls + 1, mInCallServiceFixtureY.mCallById.size());
 
@@ -767,6 +771,12 @@
 
         // Wait for the handler to start the CallerInfo lookup
         waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
+
+        // Ensure callback to CS on successful creation happened.
+        verify(connectionServiceFixture.getTestDouble(), timeout(TEST_TIMEOUT))
+                .createConnectionComplete(anyString(), any());
+
+
         // Process the CallerInfo lookup reply
         mCallerInfoAsyncQueryFactoryFixture.mRequests.forEach(
                 CallerInfoAsyncQueryFactoryFixture.Request::reply);