diff options
author | Sarmad Hashmi <mhashmi@google.com> | 2016-03-04 19:54:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-04 19:54:45 +0000 |
commit | 49204f165c06b7cc3ebbdfbebcdda0950c2875a0 (patch) | |
tree | 6fc41ba1e6c44a8262ad1737df79631002583c0d /src/com/android/dialer/calllog | |
parent | 9912a31b59e1120612807d963d890e83c29b94d7 (diff) | |
parent | af04b7b8d5bad8998f875ee0a28df36d5b6e97c5 (diff) |
Merge "Add files for voicemail archive tab." into nyc-dev am: ee8f5a3c0d
am: af04b7b8d5
* commit 'af04b7b8d5bad8998f875ee0a28df36d5b6e97c5':
Add files for voicemail archive tab.
Diffstat (limited to 'src/com/android/dialer/calllog')
-rw-r--r-- | src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java index f331dd008..3a60a39c2 100644 --- a/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java +++ b/src/com/android/dialer/calllog/CallLogAsyncTaskUtil.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog; +import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; @@ -32,6 +33,7 @@ import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PermissionsUtil; import com.android.dialer.DialtactsActivity; import com.android.dialer.PhoneCallDetails; +import com.android.dialer.database.VoicemailArchiveContract; import com.android.dialer.util.AppCompatConstants; import com.android.dialer.util.AsyncTaskExecutor; import com.android.dialer.util.AsyncTaskExecutors; @@ -416,16 +418,16 @@ public class CallLogAsyncTaskUtil { /** - * Updates the duration of a voicemail call log entry. + * Updates the duration of a voicemail call log entry if the duration given is greater than 0, + * and if if the duration currently in the database is less than or equal to 0 (non-existent). */ public static void updateVoicemailDuration( final Context context, final Uri voicemailUri, - final int duration) { - if (!PermissionsUtil.hasPhonePermissions(context)) { + final long duration) { + if (duration <= 0 || !PermissionsUtil.hasPhonePermissions(context)) { return; } - if (sAsyncTaskExecutor == null) { initTaskExecutor(); } @@ -433,9 +435,18 @@ public class CallLogAsyncTaskUtil { 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); + ContentResolver contentResolver = context.getContentResolver(); + Cursor cursor = contentResolver.query( + voicemailUri, + new String[] { VoicemailArchiveContract.VoicemailArchive.DURATION }, + null, null, null); + if (cursor != null && cursor.moveToFirst() && cursor.getInt( + cursor.getColumnIndex( + VoicemailArchiveContract.VoicemailArchive.DURATION)) <= 0) { + ContentValues values = new ContentValues(1); + values.put(CallLog.Calls.DURATION, duration); + context.getContentResolver().update(voicemailUri, values, null, null); + } return null; } }); |