Clean dirty state after uploading to server

Previously the dirty state is cleared by marking the voicemail as read
again. This confuses the VoicemailContentProvider. Sending a update
with no values is enough to clean the flag.

The dirty flag is used to track external changes like read flag that
should be uploaded to the server.

+ Reverts ag/1314867, the "new" column is not updatable through the
  VoicemailContentProvider

Change-Id: I17a3c50622d98397fd27dc1097c15219fcd1196c
Fixes: 30105817
diff --git a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
index 3cc25c3..58797de 100644
--- a/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
+++ b/src/com/android/phone/vvm/omtp/sync/OmtpVvmSyncService.java
@@ -188,7 +188,7 @@
 
         if (readVoicemails.size() > 0) {
             if (imapHelper.markMessagesAsRead(readVoicemails)) {
-                mQueryHelper.markReadInDatabase(readVoicemails);
+                mQueryHelper.markCleanInDatabase(readVoicemails);
             } else {
                 success = false;
             }
diff --git a/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java b/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
index 1c71a23..9906386 100644
--- a/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
+++ b/src/com/android/phone/vvm/omtp/sync/VoicemailsQueryHelper.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
-import android.provider.CallLog.Calls;
 import android.provider.VoicemailContract;
 import android.provider.VoicemailContract.Voicemails;
 import android.telecom.PhoneAccountHandle;
@@ -150,15 +149,6 @@
                 new String[] { Long.toString(voicemail.getId()) });
     }
 
-    /**
-     * Sends an update command to the voicemail content provider for a list of voicemails.
-     * From the view of the provider, since the updater is the owner of the entry, a blank
-     * "update" means that the voicemail source is indicating that the server has up-to-date
-     * information on the voicemail. This flips the "dirty" bit to "0".
-     *
-     * @param voicemails The list of voicemails to update
-     * @return The number of voicemails updated
-     */
     public int markReadInDatabase(List<Voicemail> voicemails) {
         int count = voicemails.size();
         for (int i = 0; i < count; i++) {
@@ -174,7 +164,32 @@
         Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
         ContentValues contentValues = new ContentValues();
         contentValues.put(Voicemails.IS_READ, "1");
-        contentValues.put(Calls.NEW, false);
+        mContentResolver.update(uri, contentValues, null, null);
+    }
+
+    /**
+     * Sends an update command to the voicemail content provider for a list of voicemails. From the
+     * view of the provider, since the updater is the owner of the entry, a blank "update" means
+     * that the voicemail source is indicating that the server has up-to-date information on the
+     * voicemail. This flips the "dirty" bit to "0".
+     *
+     * @param voicemails The list of voicemails to update
+     * @return The number of voicemails updated
+     */
+    public int markCleanInDatabase(List<Voicemail> voicemails) {
+        int count = voicemails.size();
+        for (int i = 0; i < count; i++) {
+            markCleanInDatabase(voicemails.get(i));
+        }
+        return count;
+    }
+
+    /**
+     * Utility method to mark single message as clean.
+     */
+    public void markCleanInDatabase(Voicemail voicemail) {
+        Uri uri = ContentUris.withAppendedId(mSourceUri, voicemail.getId());
+        ContentValues contentValues = new ContentValues();
         mContentResolver.update(uri, contentValues, null, null);
     }