summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2018-02-12 07:51:54 -0800
committerCopybara-Service <copybara-piper@google.com>2018-02-12 11:43:26 -0800
commitc2aac15c07ba83cb9dac5dd05f805628ad395449 (patch)
tree3ed7e1570969ebdab63d13b5a7e64c7baf7bf145
parent814a5b4894426eea6d178018df767c22a5453c4d (diff)
Delete and upload voicemail as deleted on the VM server
When a voicemail is deleted we mark it as deleted in the database. However to ensure that a voicemail gets deleted on the server, we need to upload it as well by forcing a upload sync, which we do after a successful marking it as deleted. Bug: 73087132 Test: N/A PiperOrigin-RevId: 185377828 Change-Id: Ia023cd7c5c283034c78022bcb6d4ce78e410de76
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java32
1 files changed, 20 insertions, 12 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
index 044d8df6d..07a37c3cc 100644
--- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
+++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java
@@ -16,13 +16,16 @@
package com.android.dialer.voicemail.listui;
import android.app.FragmentManager;
+import android.content.ContentValues;
import android.content.Context;
+import android.content.Intent;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
+import android.provider.VoicemailContract.Voicemails;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
@@ -37,7 +40,6 @@ import android.view.ViewGroup;
import com.android.dialer.calllogutils.CallLogDates;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
-import com.android.dialer.common.concurrent.DialerExecutor.SuccessListener;
import com.android.dialer.common.concurrent.DialerExecutor.Worker;
import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.common.concurrent.ThreadUtil;
@@ -48,6 +50,7 @@ import com.android.dialer.voicemail.listui.error.VoicemailErrorMessage;
import com.android.dialer.voicemail.listui.error.VoicemailErrorMessageCreator;
import com.android.dialer.voicemail.listui.error.VoicemailStatus;
import com.android.dialer.voicemail.model.VoicemailEntry;
+import com.android.voicemail.VoicemailClient;
import com.google.common.collect.ImmutableList;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -637,32 +640,37 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder>
collapseExpandedViewHolder(expandedViewHolder);
- Worker<Pair<Context, Uri>, Integer> deleteVoicemail = this::deleteVoicemail;
- SuccessListener<Integer> deleteVoicemailCallBack = this::onVoicemailDeleted;
+ Worker<Pair<Context, Uri>, Void> deleteVoicemail = this::deleteVoicemail;
DialerExecutorComponent.get(context)
.dialerExecutorFactory()
- .createUiTaskBuilder(fragmentManager, "delete_voicemail", deleteVoicemail)
- .onSuccess(deleteVoicemailCallBack)
+ .createNonUiTaskBuilder(deleteVoicemail)
.build()
.executeSerial(new Pair<>(context, voicemailUri));
notifyItemRemoved(expandedViewHolder.getAdapterPosition());
}
- private void onVoicemailDeleted(Integer integer) {
- LogUtil.i("NewVoicemailAdapter.onVoicemailDeleted", "return value:%d", integer);
- Assert.checkArgument(integer == 1, "voicemail delete was not successful");
- }
-
@WorkerThread
- private Integer deleteVoicemail(Pair<Context, Uri> contextUriPair) {
+ private Void deleteVoicemail(Pair<Context, Uri> contextUriPair) {
Assert.isWorkerThread();
LogUtil.enterBlock("NewVoicemailAdapter.deleteVoicemail");
+
Context context = contextUriPair.first;
Uri uri = contextUriPair.second;
LogUtil.i("NewVoicemailAdapter.deleteVoicemail", "deleting uri:%s", String.valueOf(uri));
- return context.getContentResolver().delete(uri, null, null);
+ ContentValues values = new ContentValues();
+ values.put(Voicemails.DELETED, "1");
+
+ int numRowsUpdated = context.getContentResolver().update(uri, values, null, null);
+
+ LogUtil.i("NewVoicemailAdapter.onVoicemailDeleted", "return value:%d", numRowsUpdated);
+ Assert.checkArgument(numRowsUpdated == 1, "voicemail delete was not successful");
+
+ Intent intent = new Intent(VoicemailClient.ACTION_UPLOAD);
+ intent.setPackage(context.getPackageName());
+ context.sendBroadcast(intent);
+ return null;
}
/**