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/Conference.java b/telecomm/java/android/telecom/Conference.java
index 177759e..e79d841 100644
--- a/telecomm/java/android/telecom/Conference.java
+++ b/telecomm/java/android/telecom/Conference.java
@@ -20,6 +20,7 @@
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Bundle;
+import android.os.SystemClock;
import android.telecom.Connection.VideoProvider;
import android.util.ArraySet;
@@ -81,6 +82,7 @@
private int mConnectionProperties;
private String mDisconnectMessage;
private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
+ private long mConnectElapsedTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
private StatusHints mStatusHints;
private Bundle mExtras;
private Set<String> mPreviousExtraKeys;
@@ -586,7 +588,11 @@
}
/**
- * Sets the connection start time of the {@code Conference}.
+ * Sets the connection start time of the {@code Conference}. Should be specified in wall-clock
+ * time returned by {@link System#currentTimeMillis()}.
+ * <p>
+ * When setting the connection time, you should always set the connection elapsed time via
+ * {@link #setConnectionElapsedTime(long)}.
*
* @param connectionTimeMillis The connection time, in milliseconds.
*/
@@ -595,6 +601,20 @@
}
/**
+ * Sets the elapsed time since system boot when the {@link Conference} was connected.
+ * This is used to determine the duration of the {@link Conference}.
+ * <p>
+ * When setting the connection elapsed time, you should always set the connection time via
+ * {@link #setConnectionTime(long)}.
+ *
+ * @param connectionElapsedTime The connection time, as measured by
+ * {@link SystemClock#elapsedRealtime()}.
+ */
+ public final void setConnectionElapsedTime(long connectionElapsedTime) {
+ mConnectElapsedTimeMillis = connectionElapsedTime;
+ }
+
+ /**
* @hide
* @deprecated Use {@link #getConnectionTime}.
*/
@@ -616,6 +636,21 @@
}
/**
+ * Retrieves the connection start time of the {@link Conference}, if specified. A value of
+ * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time
+ * of the conference.
+ *
+ * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not
+ * impacted by wall clock changes (user initiated, network initiated, time zone change, etc).
+ *
+ * @return The elapsed time at which the {@link Conference} was connected.
+ * @hide
+ */
+ public final long getConnectElapsedTime() {
+ return mConnectElapsedTimeMillis;
+ }
+
+ /**
* Inform this Conference that the state of its audio output has been changed externally.
*
* @param state The new audio state.