summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java28
-rw-r--r--src/com/android/dialer/calllog/PhoneCallDetailsHelper.java2
-rw-r--r--src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java7
3 files changed, 36 insertions, 1 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
index 5bcfa6bd5..f331dd008 100644
--- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
+++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java
@@ -54,6 +54,7 @@ public class CallLogAsyncTaskUtil {
MARK_VOICEMAIL_READ,
MARK_CALL_READ,
GET_CALL_DETAILS,
+ UPDATE_DURATION
}
private static final class CallDetailQuery {
@@ -413,6 +414,33 @@ public class CallLogAsyncTaskUtil {
});
}
+
+ /**
+ * Updates the duration of a voicemail call log entry.
+ */
+ public static void updateVoicemailDuration(
+ final Context context,
+ final Uri voicemailUri,
+ final int duration) {
+ if (!PermissionsUtil.hasPhonePermissions(context)) {
+ return;
+ }
+
+ if (sAsyncTaskExecutor == null) {
+ initTaskExecutor();
+ }
+
+ sAsyncTaskExecutor.submit(Tasks.UPDATE_DURATION, new AsyncTask<Void, Void, Void>() {
+ @Override
+ public Void doInBackground(Void... params) {
+ ContentValues values = new ContentValues(1);
+ values.put(CallLog.Calls.DURATION, duration);
+ context.getContentResolver().update(voicemailUri, values, null, null);
+ return null;
+ }
+ });
+ }
+
@VisibleForTesting
public static void resetForTest() {
sAsyncTaskExecutor = null;
diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
index be02e4c1b..7b149e24e 100644
--- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java
@@ -326,7 +326,7 @@ public class PhoneCallDetailsHelper {
text = dateText;
}
- if (details.callTypes[0] == Calls.VOICEMAIL_TYPE) {
+ if (details.callTypes[0] == Calls.VOICEMAIL_TYPE && details.duration > 0) {
views.callLocationAndDate.setText(mResources.getString(
R.string.voicemailCallLogDateTimeFormatWithDuration, text,
getVoicemailDuration(details)));
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
index 93ff00270..2bb4de932 100644
--- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
+++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java
@@ -36,6 +36,7 @@ import android.view.WindowManager.LayoutParams;
import android.widget.SeekBar;
import com.android.dialer.R;
+import com.android.dialer.calllog.CallLogAsyncTaskUtil;
import com.android.dialer.util.AsyncTaskExecutor;
import com.android.dialer.util.AsyncTaskExecutors;
import com.android.common.io.MoreCloseables;
@@ -557,6 +558,12 @@ public class VoicemailPlaybackPresenter implements MediaPlayer.OnPreparedListene
Log.d(TAG, "onPrepared");
mIsPrepared = true;
+ // Update the duration in the database if it was not previously retrieved
+ if (mDuration.get() == 0) {
+ CallLogAsyncTaskUtil.updateVoicemailDuration(mContext, mVoicemailUri,
+ mMediaPlayer.getDuration() / 1000);
+ }
+
mDuration.set(mMediaPlayer.getDuration());
Log.d(TAG, "onPrepared: mPosition=" + mPosition);