Merge "Pop-up a video call welcome dialog upon the dialer" into atel.lnx.2.0-dev
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java
index 666535f..60bc42e 100644
--- a/InCallUI/src/com/android/incallui/Call.java
+++ b/InCallUI/src/com/android/incallui/Call.java
@@ -20,6 +20,7 @@
 import android.hardware.camera2.CameraCharacteristics;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.SystemClock;
 import android.os.Trace;
 import android.os.RemoteException;
 import android.telecom.Call.Details;
@@ -391,6 +392,7 @@
     private String mLastForwardedNumber;
     private String mCallSubject;
     private PhoneAccountHandle mPhoneAccountHandle;
+    private long mBaseChronometerTime = 0;
 
     /**
      * Indicates whether the phone account associated with this call supports specifying a call
@@ -1026,4 +1028,13 @@
                 extras.getInt(QtiCallConstants.VOWIFI_CALL_QUALITY_EXTRA_KEY,
                 QtiCallConstants.VOWIFI_QUALITY_NONE);
     }
+
+    public void triggerCalcBaseChronometerTime() {
+        mBaseChronometerTime = getConnectTimeMillis() - System.currentTimeMillis()
+                + SystemClock.elapsedRealtime();
+    }
+
+    public long getCallDuration() {
+        return SystemClock.elapsedRealtime() - mBaseChronometerTime;
+    }
 }
diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java
index 4434335..70da98a 100644
--- a/InCallUI/src/com/android/incallui/CallCardPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java
@@ -321,6 +321,7 @@
         // Start/stop timers.
         if (isPrimaryCallActive()) {
             Log.d(this, "Starting the calltime timer");
+            mPrimary.triggerCalcBaseChronometerTime();
             mCallTimer.start(CALL_TIME_UPDATE_INTERVAL_MS);
         } else {
             Log.d(this, "Canceling the calltime timer");
@@ -561,9 +562,7 @@
             ui.setPrimaryCallElapsedTime(false, 0);
             mCallTimer.cancel();
         } else {
-            final long callStart = mPrimary.getConnectTimeMillis();
-            final long duration = System.currentTimeMillis() - callStart;
-            ui.setPrimaryCallElapsedTime(true, duration);
+            ui.setPrimaryCallElapsedTime(true, mPrimary.getCallDuration());
         }
     }