diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java | 8 | ||||
-rw-r--r-- | java/com/android/voicemail/impl/transcribe/TranscriptionService.java | 7 |
2 files changed, 14 insertions, 1 deletions
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java index d6e362014..f3c6e64f4 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionBackfillService.java @@ -22,9 +22,11 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.support.annotation.WorkerThread; import android.support.v4.app.JobIntentService; import android.support.v4.os.BuildCompat; import com.android.dialer.common.LogUtil; +import com.android.dialer.common.concurrent.ThreadUtil; import com.android.dialer.constants.ScheduledJobIds; import java.util.List; @@ -57,6 +59,7 @@ public class TranscriptionBackfillService extends JobIntentService { } @Override + @WorkerThread protected void onHandleWork(Intent intent) { LogUtil.enterBlock("TranscriptionBackfillService.onHandleWork"); @@ -67,7 +70,10 @@ public class TranscriptionBackfillService extends JobIntentService { "found " + untranscribed.size() + " untranscribed voicemails"); // TODO(mdooley): Consider doing the actual transcriptions here instead of scheduling jobs. for (Uri uri : untranscribed) { - TranscriptionService.scheduleNewVoicemailTranscriptionJob(this, uri, false); + ThreadUtil.postOnUiThread( + () -> { + TranscriptionService.scheduleNewVoicemailTranscriptionJob(this, uri, false); + }); } } diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java index 509f25bed..2ca16fbf2 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java @@ -57,6 +57,7 @@ public class TranscriptionService extends JobService { // Schedule a task to transcribe the indicated voicemail, return true if transcription task was // scheduled. + @MainThread public static boolean scheduleNewVoicemailTranscriptionJob( Context context, Uri voicemailUri, boolean highPriority) { Assert.isMainThread(); @@ -86,6 +87,7 @@ public class TranscriptionService extends JobService { } // Cancel all transcription tasks + @MainThread public static void cancelTranscriptions(Context context) { Assert.isMainThread(); LogUtil.enterBlock("TranscriptionService.cancelTranscriptions"); @@ -93,6 +95,7 @@ public class TranscriptionService extends JobService { scheduler.cancel(ScheduledJobIds.VVM_TRANSCRIPTION_JOB); } + @MainThread public TranscriptionService() { Assert.isMainThread(); } @@ -108,6 +111,7 @@ public class TranscriptionService extends JobService { } @Override + @MainThread public boolean onStartJob(JobParameters params) { Assert.isMainThread(); LogUtil.enterBlock("TranscriptionService.onStartJob"); @@ -127,6 +131,7 @@ public class TranscriptionService extends JobService { } @Override + @MainThread public boolean onStopJob(JobParameters params) { Assert.isMainThread(); LogUtil.enterBlock("TranscriptionService.onStopJob"); @@ -135,6 +140,7 @@ public class TranscriptionService extends JobService { } @Override + @MainThread public void onDestroy() { Assert.isMainThread(); LogUtil.enterBlock("TranscriptionService.onDestroy"); @@ -186,6 +192,7 @@ public class TranscriptionService extends JobService { private class Callback implements JobCallback { @Override + @MainThread public void onWorkCompleted(JobWorkItem completedWorkItem) { Assert.isMainThread(); LogUtil.i("TranscriptionService.Callback.onWorkCompleted", completedWorkItem.toString()); |