summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2018-03-30 03:03:03 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-03-30 03:03:03 +0000
commit2f7fe1ec8b810818743f0f930f187b2d09b1ddf6 (patch)
treec504143cbbefcd6adc5ccfe6b397a6b8faa4de15
parente7afa7b0222b6aa8f79573f617b4c91a49ffd92f (diff)
parent56d08bca3414d226fca934bfcf376af878bea555 (diff)
Merge "Use existing transcription from transcription server if available" am: fbf5faff11
am: 56d08bca34 Change-Id: I70b50d5af7131dc4e2dded5b70c2e5aadb3fab6d
-rw-r--r--java/com/android/voicemail/impl/transcribe/GetTranscriptReceiver.java2
-rw-r--r--java/com/android/voicemail/impl/transcribe/TranscriptionTaskAsync.java10
-rw-r--r--java/com/android/voicemail/impl/transcribe/grpc/TranscriptionResponse.java9
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;