diff options
author | uabdullah <uabdullah@google.com> | 2018-03-30 02:58:27 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-30 02:58:27 +0000 |
commit | 56d08bca3414d226fca934bfcf376af878bea555 (patch) | |
tree | 2bb34854a35722e852b6e9700a0d2db348425006 | |
parent | 91efee234e0b257e037fa2ba3b403602d9f8c749 (diff) | |
parent | fbf5faff115beb005d5b6138fcd965cf1a606c7e (diff) |
Merge "Use existing transcription from transcription server if available"
am: fbf5faff11
Change-Id: I1878d869e0e07c0007a4b844a51b635b41126f42
3 files changed, 20 insertions, 1 deletions
diff --git a/java/com/android/voicemail/impl/transcribe/GetTranscriptReceiver.java b/java/com/android/voicemail/impl/transcribe/GetTranscriptReceiver.java index cbf165753..5c5bae547 100644 --- a/java/com/android/voicemail/impl/transcribe/GetTranscriptReceiver.java +++ b/java/com/android/voicemail/impl/transcribe/GetTranscriptReceiver.java @@ -295,7 +295,7 @@ public class GetTranscriptReceiver extends BroadcastReceiver { transcriptionClientFactoryForTesting = factory; } - private static TranscriptionClientFactory getTranscriptionClientFactory(Context context) { + static TranscriptionClientFactory getTranscriptionClientFactory(Context context) { if (transcriptionClientFactoryForTesting != null) { return transcriptionClientFactoryForTesting; } diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionTaskAsync.java b/java/com/android/voicemail/impl/transcribe/TranscriptionTaskAsync.java index 60a6811ac..034af6bfc 100644 --- a/java/com/android/voicemail/impl/transcribe/TranscriptionTaskAsync.java +++ b/java/com/android/voicemail/impl/transcribe/TranscriptionTaskAsync.java @@ -83,6 +83,16 @@ public class TranscriptionTaskAsync extends TranscriptionTask { } else if (uploadResponse == null) { VvmLog.i(TAG, "getTranscription, failed to upload voicemail."); return new Pair<>(null, TranscriptionStatus.FAILED_NO_RETRY); + } else if (uploadResponse.isStatusAlreadyExists()) { + VvmLog.i(TAG, "getTranscription, transcription already exists."); + GetTranscriptReceiver.beginPolling( + context, + voicemailUri, + uploadRequest.getTranscriptionId(), + 0, + configProvider, + phoneAccountHandle); + return new Pair<>(null, null); } else if (uploadResponse.getTranscriptionId() == null) { VvmLog.i(TAG, "getTranscription, upload error: " + uploadResponse.status); return new Pair<>(null, TranscriptionStatus.FAILED_NO_RETRY); diff --git a/java/com/android/voicemail/impl/transcribe/grpc/TranscriptionResponse.java b/java/com/android/voicemail/impl/transcribe/grpc/TranscriptionResponse.java index ae4796dea..bd65abe84 100644 --- a/java/com/android/voicemail/impl/transcribe/grpc/TranscriptionResponse.java +++ b/java/com/android/voicemail/impl/transcribe/grpc/TranscriptionResponse.java @@ -18,6 +18,7 @@ package com.android.voicemail.impl.transcribe.grpc; import android.support.annotation.Nullable; import com.android.dialer.common.Assert; import io.grpc.Status; +import io.grpc.Status.Code; /** * Base class for encapulating a voicemail transcription server response. This handles the Grpc @@ -43,6 +44,14 @@ public abstract class TranscriptionResponse { return false; } + public boolean isStatusAlreadyExists() { + if (status != null) { + return status.getCode() == Code.ALREADY_EXISTS; + } + + return false; + } + public boolean hasFatalError() { if (status != null) { return status.getCode() != Status.Code.OK && status.getCode() != Status.Code.UNAVAILABLE; |