summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail/impl/transcribe
diff options
context:
space:
mode:
authormdooley <mdooley@google.com>2017-11-17 11:02:48 -0800
committerzachh <zachh@google.com>2017-11-18 07:35:27 +0000
commit7e1a0d155eecc8a407e11f91605db135911c8eb6 (patch)
treed6eb3002e4a9753b9c82bfe3df4ea689d4da01a0 /java/com/android/voicemail/impl/transcribe
parent6a63e8d6830ff6e01454ee116c6df36294818cdb (diff)
Refactoring and adding TOS check before transcribing
This cl just adds a check before starting a transcription job to verify that the user has accepted the appropriate TOS. Its a rather big cl just because it had to expose some TOS acceptance details that were previously encapsulated in the VoicemailTosMessageCreator. Bug: 69267260 Test: manual and unit tests PiperOrigin-RevId: 176132370 Change-Id: Ic28fb197a07f9df7a9b5f1729c84566cba0890fc
Diffstat (limited to 'java/com/android/voicemail/impl/transcribe')
-rw-r--r--java/com/android/voicemail/impl/transcribe/TranscriptionService.java30
1 files changed, 17 insertions, 13 deletions
diff --git a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
index 33c9676a4..a19ab6208 100644
--- a/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
+++ b/java/com/android/voicemail/impl/transcribe/TranscriptionService.java
@@ -69,15 +69,7 @@ public class TranscriptionService extends JobService {
public static boolean scheduleNewVoicemailTranscriptionJob(
Context context, Uri voicemailUri, PhoneAccountHandle account, boolean highPriority) {
Assert.isMainThread();
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- LogUtil.i(
- "TranscriptionService.scheduleNewVoicemailTranscriptionJob", "not supported by sdk");
- return false;
- }
- if (!carrierAllowsOttTranscription(context, account)) {
- LogUtil.i(
- "TranscriptionService.scheduleNewVoicemailTranscriptionJob",
- "carrier doesn't allow transcription");
+ if (!canTranscribeVoicemail(context, account)) {
return false;
}
@@ -101,12 +93,24 @@ public class TranscriptionService extends JobService {
return scheduler.enqueue(builder.build(), workItem) == JobScheduler.RESULT_SUCCESS;
}
- private static boolean carrierAllowsOttTranscription(
- Context context, PhoneAccountHandle account) {
+ private static boolean canTranscribeVoicemail(Context context, PhoneAccountHandle account) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ LogUtil.i("TranscriptionService.canTranscribeVoicemail", "not supported by sdk");
+ return false;
+ }
VoicemailClient client = VoicemailComponent.get(context).getVoicemailClient();
- return Boolean.parseBoolean(
+ if (!client.hasAcceptedTos(context, account)) {
+ LogUtil.i("TranscriptionService.canTranscribeVoicemail", "hasn't accepted TOS");
+ return false;
+ }
+ if (!Boolean.parseBoolean(
client.getCarrierConfigString(
- context, account, CarrierConfigKeys.VVM_CARRIER_ALLOWS_OTT_TRANSCRIPTION_STRING));
+ context, account, CarrierConfigKeys.VVM_CARRIER_ALLOWS_OTT_TRANSCRIPTION_STRING))) {
+ LogUtil.i(
+ "TranscriptionService.canTranscribeVoicemail", "carrier doesn't allow transcription");
+ return false;
+ }
+ return true;
}
// Cancel all transcription tasks