diff options
author | uabdullah <uabdullah@google.com> | 2018-03-27 19:48:20 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-27 19:48:20 +0000 |
commit | ce304fc8c4ee9d25c23e59753ec6c69b1f4648ae (patch) | |
tree | 8237bb4798c453fd1be128665b5204d8a6540da1 | |
parent | 906028950b00093aa624606cccd9a97f4b3dfe92 (diff) | |
parent | 3c733418c83dd4396a32b4f431fcdcef6f5a126e (diff) |
Merge "When transcription setting is enabled, retranscribe voicemails"
am: 3c733418c8
Change-Id: I789c22f7d28dc5d54706bf34ba85356d182a284b
4 files changed, 28 insertions, 4 deletions
diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java index b0881c9a3..187ded932 100644 --- a/java/com/android/voicemail/impl/VoicemailClientImpl.java +++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java @@ -125,6 +125,11 @@ public class VoicemailClientImpl implements VoicemailClient { @Override public boolean isVoicemailTranscriptionAvailable( Context context, PhoneAccountHandle phoneAccountHandle) { + if (phoneAccountHandle == null) { + LogUtil.i( + "VoicemailClientImpl.isVoicemailTranscriptionAvailable", "phone account handle is null"); + } + if (!BuildCompat.isAtLeastO()) { LogUtil.i( "VoicemailClientImpl.isVoicemailTranscriptionAvailable", "not running on O or later"); @@ -198,6 +203,9 @@ public class VoicemailClientImpl implements VoicemailClient { "transcription must be available before enabling/disabling it"); VisualVoicemailSettingsUtil.setVoicemailTranscriptionEnabled( context, phoneAccountHandle, enabled); + if (enabled) { + TranscriptionBackfillService.scheduleTask(context, phoneAccountHandle); + } } @Override diff --git a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java index e7248c40f..3acf60d5f 100644 --- a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java +++ b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java @@ -23,9 +23,11 @@ import android.provider.VoicemailContract.Voicemails; import android.support.annotation.VisibleForTesting; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; +import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.common.database.Selection; +import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.voicemail.VoicemailComponent; import com.android.voicemail.impl.OmtpVvmCarrierConfigHelper; import com.android.voicemail.impl.VisualVoicemailPreferences; @@ -130,6 +132,7 @@ public class VisualVoicemailSettingsUtil { public static boolean isEnabled(Context context, PhoneAccountHandle phoneAccount) { if (phoneAccount == null) { + LogUtil.i("VisualVoicemailSettingsUtil.isEnabled", "phone account is null"); return false; } @@ -213,9 +216,10 @@ public class VisualVoicemailSettingsUtil { @Override public Void doInBackground(Void unused) { - ContentValues contentValues = new ContentValues(); - contentValues.put(Voicemails.TRANSCRIPTION, ""); + contentValues.putNull(Voicemails.TRANSCRIPTION); + contentValues.put( + VoicemailCompat.TRANSCRIPTION_STATE, VoicemailCompat.TRANSCRIPTION_NOT_STARTED); Selection selection = Selection.builder() diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java index 8161e71f7..8fc40ee99 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java @@ -22,6 +22,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Bundle; import android.support.annotation.WorkerThread; import android.support.v4.app.JobIntentService; import android.support.v4.os.BuildCompat; @@ -66,6 +67,10 @@ public class TranscriptionBackfillService extends JobIntentService { protected void onHandleWork(Intent intent) { LogUtil.enterBlock("TranscriptionBackfillService.onHandleWork"); + Bundle bundle = intent.getExtras(); + final PhoneAccountHandle account = + (PhoneAccountHandle) bundle.get(TranscriptionService.EXTRA_ACCOUNT_HANDLE); + TranscriptionDbHelper dbHelper = new TranscriptionDbHelper(this); List<Uri> untranscribed = dbHelper.getUntranscribedVoicemails(); LogUtil.i( @@ -75,7 +80,7 @@ public class TranscriptionBackfillService extends JobIntentService { for (Uri uri : untranscribed) { ThreadUtil.postOnUiThread( () -> { - TranscriptionService.scheduleNewVoicemailTranscriptionJob(this, uri, null, false); + TranscriptionService.scheduleNewVoicemailTranscriptionJob(this, uri, account, false); }); } } diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java b/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java index 24c07cc37..6ffb8485d 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionDbHelper.java @@ -87,7 +87,14 @@ public class TranscriptionDbHelper { Assert.isWorkerThread(); List<Uri> untranscribed = new ArrayList<>(); String whereClause = - Voicemails.TRANSCRIPTION + " is NULL AND " + VoicemailCompat.TRANSCRIPTION_STATE + "=?"; + "(" + + Voicemails.TRANSCRIPTION + + " is NULL OR " + + Voicemails.TRANSCRIPTION + + " = '')" + + " AND " + + VoicemailCompat.TRANSCRIPTION_STATE + + "=?"; String[] whereArgs = {String.valueOf(VoicemailCompat.TRANSCRIPTION_NOT_STARTED)}; try (Cursor cursor = contentResolver.query(uri, PROJECTION, whereClause, whereArgs, null)) { if (cursor == null) { |