diff options
author | mdooley <mdooley@google.com> | 2017-11-29 08:53:31 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-11-29 11:50:44 -0800 |
commit | b9ca335dbbc3325643549f6fbf2dac06a5502d26 (patch) | |
tree | 0145604277fbcf00e8bf48b835a5a9d7fb922e40 /java/com/android/voicemail/impl/settings | |
parent | 00d18e0efe89d7bbd4c69de6988ef6f9a62df782 (diff) |
Delete voicemails when disabling visual voicemail
For privacy reasons we now delete all voicemails and transcriptions when
the user disables visual voicemail, (after confirming that they want to do this
via a dialog).
Note: we only delete voicemails whose source package is the google dialer.
Note: the voicemails will be re-downloaded and re-transcribed if the user re-enables visual voicemail
Bug: 69323147
Test: manual and unit test
PiperOrigin-RevId: 177315139
Change-Id: Ie04496dc5960b485794733fbf74f7f704e806023
Diffstat (limited to 'java/com/android/voicemail/impl/settings')
-rw-r--r-- | java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java index 61d76194c..e42d56938 100644 --- a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java +++ b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java @@ -19,11 +19,14 @@ import android.content.Context; import android.support.annotation.VisibleForTesting; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; +import com.android.dialer.common.concurrent.DialerExecutor.Worker; +import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.voicemail.VoicemailComponent; import com.android.voicemail.impl.OmtpVvmCarrierConfigHelper; import com.android.voicemail.impl.VisualVoicemailPreferences; import com.android.voicemail.impl.VvmLog; import com.android.voicemail.impl.sync.VvmAccountManager; +import com.android.voicemail.impl.utils.VoicemailDatabaseUtil; /** Save whether or not a particular account is enabled in shared to be retrieved later. */ public class VisualVoicemailSettingsUtil { @@ -45,9 +48,40 @@ public class VisualVoicemailSettingsUtil { } else { VvmAccountManager.removeAccount(context, phoneAccount); config.startDeactivation(); + // Remove all voicemails from the database + DialerExecutorComponent.get(context) + .dialerExecutorFactory() + .createNonUiTaskBuilder(new VoicemailDeleteWorker(context)) + .onSuccess(VisualVoicemailSettingsUtil::onSuccess) + .onFailure(VisualVoicemailSettingsUtil::onFailure) + .build() + .executeParallel(null); } } + private static class VoicemailDeleteWorker implements Worker<Void, Void> { + private final Context context; + + VoicemailDeleteWorker(Context context) { + this.context = context; + } + + @Override + public Void doInBackground(Void unused) { + int deleted = VoicemailDatabaseUtil.deleteAll(context); + VvmLog.i("VisualVoicemailSettingsUtil.doInBackground", "deleted " + deleted + " voicemails"); + return null; + } + } + + private static void onSuccess(Void unused) { + VvmLog.i("VisualVoicemailSettingsUtil.onSuccess", "delete voicemails"); + } + + private static void onFailure(Throwable t) { + VvmLog.e("VisualVoicemailSettingsUtil.onFailure", "delete voicemails", t); + } + public static void setArchiveEnabled( Context context, PhoneAccountHandle phoneAccount, boolean isEnabled) { Assert.checkArgument( |