summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengjun Leng <mengju@codeaurora.org>2015-01-21 10:54:55 +0800
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:20:57 -0600
commitb4bcebba5d50374a0a159fb2614591edde31b3a5 (patch)
treee0cc065140edab9b5f59ec201377cb36a2afba96
parent2ee5f83ac01578015488794fc609f152567f55f8 (diff)
downloadpackages_apps_InCallUI-b4bcebba5d50374a0a159fb2614591edde31b3a5.tar.gz
packages_apps_InCallUI-b4bcebba5d50374a0a159fb2614591edde31b3a5.tar.bz2
packages_apps_InCallUI-b4bcebba5d50374a0a159fb2614591edde31b3a5.zip
Fix incorrect call duration after system time changes
Currently, using system time to calculate elapsed time for call duration. If we change system time, it will lead to calculate duration incorrectly. To fix it, using elapsed real time to calculate the duration instead of the current system time. CRs-Fixed: 767005 Change-Id: Ie3725b87bf9aad747f81c1703343b60f5af8dcb8
-rw-r--r--src/com/android/incallui/CallCardPresenter.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/incallui/CallCardPresenter.java b/src/com/android/incallui/CallCardPresenter.java
index 6262deae..8a6e435c 100644
--- a/src/com/android/incallui/CallCardPresenter.java
+++ b/src/com/android/incallui/CallCardPresenter.java
@@ -27,6 +27,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.telecom.Call.Details;
+import android.os.SystemClock;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
@@ -76,6 +77,7 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
private Context mContext;
private boolean mSpinnerShowing = false;
private boolean mIsFullscreen = false;
+ private long mBaseChronometerTime = 0;
public static class ContactLookupCallback implements ContactInfoCacheCallback {
private final WeakReference<CallCardPresenter> mCallCardPresenter;
@@ -250,10 +252,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
// Start/stop timers.
if (isPrimaryCallActive()) {
Log.d(this, "Starting the calltime timer");
+ mBaseChronometerTime = mPrimary.getConnectTimeMillis() - System.currentTimeMillis()
+ + SystemClock.elapsedRealtime();
mCallTimer.start(CALL_TIME_UPDATE_INTERVAL_MS);
} else {
Log.d(this, "Canceling the calltime timer");
mCallTimer.cancel();
+ mBaseChronometerTime = 0;
ui.setPrimaryCallElapsedTime(false, 0);
}
@@ -437,9 +442,9 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi>
} else if (!isPrimaryCallActive()) {
ui.setPrimaryCallElapsedTime(false, 0);
mCallTimer.cancel();
- } else {
- final long callStart = mPrimary.getConnectTimeMillis();
- final long duration = System.currentTimeMillis() - callStart;
+ mBaseChronometerTime = 0;
+ } else if (mBaseChronometerTime > 0) {
+ final long duration = SystemClock.elapsedRealtime() - mBaseChronometerTime;
ui.setPrimaryCallElapsedTime(true, duration);
}
}