Maintain call time across SRVCC (2/3).

When an IMS conference call encounters an SRVCC event requiring a
fallback to GSM/CDMA, we need to maintain the call time for the
conference host across this fallback. So, adding a connectTime attribute
in the underlying conference host's connection object which can be used
to account for the call time from the now inactive conference call into
the new call created.

BUG: 21918593
Change-Id: I13e7ae6e31f004e798776c02ac7a6ac09a10f0bd
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 58fb088..bf78712 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -1050,6 +1050,7 @@
     private int mConnectionCapabilities;
     private VideoProvider mVideoProvider;
     private boolean mAudioModeIsVoip;
+    private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     private StatusHints mStatusHints;
     private int mVideoState;
     private DisconnectCause mDisconnectCause;
@@ -1162,6 +1163,19 @@
     }
 
     /**
+     * Retrieves the connection start time of the {@code Connnection}, if specified.  A value of
+     * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
+     * start time of the conference.
+     *
+     * @return The time at which the {@code Connnection} was connected.
+     *
+     * @hide
+     */
+    public final long getConnectTimeMillis() {
+        return mConnectTimeMillis;
+    }
+
+    /**
      * @return The status hints for this connection.
      */
     public final StatusHints getStatusHints() {
@@ -1476,6 +1490,18 @@
     }
 
     /**
+     * Sets the time at which a call became active on this Connection. This is set only
+     * when a conference call becomes active on this connection.
+     *
+     * @param connectionTimeMillis The connection time, in milliseconds.
+     *
+     * @hide
+     */
+    public final void setConnectTimeMillis(long connectTimeMillis) {
+        mConnectTimeMillis = connectTimeMillis;
+    }
+
+    /**
      * Sets the label and icon status to display in the in-call UI.
      *
      * @param statusHints The status label and icon to set.
diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java
index d2e7a74..96f44b9 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -651,6 +651,7 @@
                         connection.getVideoState(),
                         connection.isRingbackRequested(),
                         connection.getAudioModeIsVoip(),
+                        connection.getConnectTimeMillis(),
                         connection.getStatusHints(),
                         connection.getDisconnectCause(),
                         createIdList(connection.getConferenceables()),
@@ -979,6 +980,7 @@
                     connection.getVideoState(),
                     connection.isRingbackRequested(),
                     connection.getAudioModeIsVoip(),
+                    connection.getConnectTimeMillis(),
                     connection.getStatusHints(),
                     connection.getDisconnectCause(),
                     emptyList,
diff --git a/telecomm/java/android/telecom/ParcelableConnection.java b/telecomm/java/android/telecom/ParcelableConnection.java
index 683ab6a..fe0a4d8 100644
--- a/telecomm/java/android/telecom/ParcelableConnection.java
+++ b/telecomm/java/android/telecom/ParcelableConnection.java
@@ -44,6 +44,7 @@
     private final int mVideoState;
     private final boolean mRingbackRequested;
     private final boolean mIsVoipAudioMode;
+    private final long mConnectTimeMillis;
     private final StatusHints mStatusHints;
     private final DisconnectCause mDisconnectCause;
     private final List<String> mConferenceableConnectionIds;
@@ -62,6 +63,7 @@
             int videoState,
             boolean ringbackRequested,
             boolean isVoipAudioMode,
+            long connectTimeMillis,
             StatusHints statusHints,
             DisconnectCause disconnectCause,
             List<String> conferenceableConnectionIds,
@@ -77,6 +79,7 @@
         mVideoState = videoState;
         mRingbackRequested = ringbackRequested;
         mIsVoipAudioMode = isVoipAudioMode;
+        mConnectTimeMillis = connectTimeMillis;
         mStatusHints = statusHints;
         mDisconnectCause = disconnectCause;
         mConferenceableConnectionIds = conferenceableConnectionIds;
@@ -128,6 +131,10 @@
         return mIsVoipAudioMode;
     }
 
+    public long getConnectTimeMillis() {
+        return mConnectTimeMillis;
+    }
+
     public final StatusHints getStatusHints() {
         return mStatusHints;
     }
@@ -176,6 +183,7 @@
             int videoState = source.readInt();
             boolean ringbackRequested = source.readByte() == 1;
             boolean audioModeIsVoip = source.readByte() == 1;
+            long connectTimeMillis = source.readLong();
             StatusHints statusHints = source.readParcelable(classLoader);
             DisconnectCause disconnectCause = source.readParcelable(classLoader);
             List<String> conferenceableConnectionIds = new ArrayList<>();
@@ -194,6 +202,7 @@
                     videoState,
                     ringbackRequested,
                     audioModeIsVoip,
+                    connectTimeMillis,
                     statusHints,
                     disconnectCause,
                     conferenceableConnectionIds,
@@ -227,6 +236,7 @@
         destination.writeInt(mVideoState);
         destination.writeByte((byte) (mRingbackRequested ? 1 : 0));
         destination.writeByte((byte) (mIsVoipAudioMode ? 1 : 0));
+        destination.writeLong(mConnectTimeMillis);
         destination.writeParcelable(mStatusHints, 0);
         destination.writeParcelable(mDisconnectCause, 0);
         destination.writeStringList(mConferenceableConnectionIds);