Fix for call timer resetting when starting IMS conference call. 4/4

- Added support in Conference for specifying the connect time when the
conference is created.

Bug: 18959443
Change-Id: I7a0b9e65b955c53314f6b23a5543e0e161998da5
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 82d2d78..8bf516d 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -334,13 +334,6 @@
             boolean isIncoming,
             boolean isConference) {
         mState = isConference ? CallState.ACTIVE : CallState.NEW;
-
-        // Conference calls are considered connected upon adding to Telecom, so set the connect
-        // time now.
-        if (isConference) {
-            mConnectTimeMillis = System.currentTimeMillis();
-        }
-
         mContext = context;
         mRepository = repository;
         setHandle(handle);
@@ -353,6 +346,37 @@
         maybeLoadCannedSmsResponses();
     }
 
+    /**
+     * Persists the specified parameters and initializes the new instance.
+     *
+     * @param context The context.
+     * @param repository The connection service repository.
+     * @param handle The handle to dial.
+     * @param gatewayInfo Gateway information to use for the call.
+     * @param connectionManagerPhoneAccountHandle Account to use for the service managing the call.
+     *         This account must be one that was registered with the
+     *         {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER} flag.
+     * @param targetPhoneAccountHandle Account information to use for the call. This account must be
+     *         one that was registered with the {@link PhoneAccount#CAPABILITY_CALL_PROVIDER} flag.
+     * @param isIncoming True if this is an incoming call.
+     * @param connectTimeMillis The connection time of the call.
+     */
+    Call(
+            Context context,
+            ConnectionServiceRepository repository,
+            Uri handle,
+            GatewayInfo gatewayInfo,
+            PhoneAccountHandle connectionManagerPhoneAccountHandle,
+            PhoneAccountHandle targetPhoneAccountHandle,
+            boolean isIncoming,
+            boolean isConference,
+            long connectTimeMillis) {
+        this(context, repository, handle, gatewayInfo, connectionManagerPhoneAccountHandle,
+                targetPhoneAccountHandle, isIncoming, isConference);
+
+        mConnectTimeMillis = connectTimeMillis;
+    }
+
     void addListener(Listener listener) {
         mListeners.add(listener);
     }
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index c7d821e..3732a4f 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -24,6 +24,7 @@
 import android.provider.CallLog.Calls;
 import android.telecom.AudioState;
 import android.telecom.CallState;
+import android.telecom.Conference;
 import android.telecom.Connection;
 import android.telecom.DisconnectCause;
 import android.telecom.GatewayInfo;
@@ -1039,6 +1040,14 @@
     Call createConferenceCall(
             PhoneAccountHandle phoneAccount,
             ParcelableConference parcelableConference) {
+
+        // If the parceled conference specifies a connect time, use it; otherwise default to 0,
+        // which is the default value for new Calls.
+        long connectTime =
+                parcelableConference.getConnectTimeMillis() ==
+                        Conference.CONNECT_TIME_NOT_SPECIFIED ? 0 :
+                        parcelableConference.getConnectTimeMillis();
+
         Call call = new Call(
                 mContext,
                 mConnectionServiceRepository,
@@ -1047,7 +1056,8 @@
                 null /* connectionManagerPhoneAccount */,
                 phoneAccount,
                 false /* isIncoming */,
-                true /* isConference */);
+                true /* isConference */,
+                connectTime);
 
         setCallState(call, Call.getStateFromConnectionState(parcelableConference.getState()));
         call.setConnectionCapabilities(parcelableConference.getConnectionCapabilities());