Track conference start in system elapsed time.

This is important so that Telecom can track the duration of the call,
which is tracked using wall clock time.

Test: Manual, unit test
Bug: 64068300
Change-Id: If642d282cd8134060acf6ffe8d81215c394d800c
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 7d2f5c8..63772a1 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -20,7 +20,6 @@
 import com.android.internal.telecom.IVideoCallback;
 import com.android.internal.telecom.IVideoProvider;
 
-import android.annotation.IntDef;
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.annotation.SystemApi;
@@ -37,14 +36,13 @@
 import android.os.Message;
 import android.os.ParcelFileDescriptor;
 import android.os.RemoteException;
+import android.os.SystemClock;
 import android.util.ArraySet;
 import android.view.Surface;
 
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -1678,6 +1676,7 @@
     private VideoProvider mVideoProvider;
     private boolean mAudioModeIsVoip;
     private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
+    private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
     private StatusHints mStatusHints;
     private int mVideoState;
     private DisconnectCause mDisconnectCause;
@@ -1822,6 +1821,22 @@
     }
 
     /**
+     * Retrieves the connection start time of the {@link Connection}, if specified.  A value of
+     * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
+     * start time of the conference.
+     *
+     * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
+     * changes do not impact the call duration.
+     *
+     * @return The time at which the {@link Connection} was connected.
+     *
+     * @hide
+     */
+    public final long getConnectElapsedTimeMillis() {
+        return mConnectElapsedTimeMillis;
+    }
+
+    /**
      * @return The status hints for this connection.
      */
     public final StatusHints getStatusHints() {
@@ -2232,7 +2247,8 @@
      * 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.
+     * @param connectTimeMillis The connection time, in milliseconds.  Should be set using a value
+     *                          obtained from {@link System#currentTimeMillis()}.
      *
      * @hide
      */
@@ -2241,6 +2257,19 @@
     }
 
     /**
+     * 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 connectElapsedTimeMillis The connection time, in milliseconds.  Stored in the format
+     *                              {@link SystemClock#elapsedRealtime()}.
+     *
+     * @hide
+     */
+    public final void setConnectElapsedTimeMillis(long connectElapsedTimeMillis) {
+        mConnectElapsedTimeMillis = connectElapsedTimeMillis;
+    }
+
+    /**
      * Sets the label and icon status to display in the in-call UI.
      *
      * @param statusHints The status label and icon to set.