From 7e1a0d155eecc8a407e11f91605db135911c8eb6 Mon Sep 17 00:00:00 2001 From: mdooley Date: Fri, 17 Nov 2017 11:02:48 -0800 Subject: 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 --- .../android/voicemail/impl/VoicemailClientImpl.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'java/com/android/voicemail/impl/VoicemailClientImpl.java') diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java index 330543837..60fc80692 100644 --- a/java/com/android/voicemail/impl/VoicemailClientImpl.java +++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java @@ -16,8 +16,10 @@ package com.android.voicemail.impl; import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Build.VERSION_CODES; import android.os.PersistableBundle; +import android.preference.PreferenceManager; import android.provider.VoicemailContract.Status; import android.provider.VoicemailContract.Voicemails; import android.support.annotation.MainThread; @@ -32,6 +34,7 @@ import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.voicemail.PinChanger; import com.android.voicemail.VisualVoicemailTypeExtensions; import com.android.voicemail.VoicemailClient; +import com.android.voicemail.VoicemailVersionConstants; import com.android.voicemail.impl.configui.VoicemailSecretCodeActivity; import com.android.voicemail.impl.settings.VisualVoicemailSettingsUtil; import com.android.voicemail.impl.sync.VvmAccountManager; @@ -291,6 +294,21 @@ public class VoicemailClientImpl implements VoicemailClient { TranscriptionBackfillService.scheduleTask(context, account); } + @Override + public boolean hasAcceptedTos(Context context, PhoneAccountHandle phoneAccountHandle) { + SharedPreferences preferences = + PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()); + OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle); + boolean isVvm3 = VisualVoicemailTypeExtensions.VVM_TYPE_VVM3.equals(helper.getVvmType()); + if (isVvm3) { + return preferences.getInt(VoicemailVersionConstants.PREF_VVM3_TOS_VERSION_ACCEPTED_KEY, 0) + >= VoicemailVersionConstants.CURRENT_VVM3_TOS_VERSION; + } else { + return preferences.getInt(VoicemailVersionConstants.PREF_DIALER_TOS_VERSION_ACCEPTED_KEY, 0) + >= VoicemailVersionConstants.CURRENT_DIALER_TOS_VERSION; + } + } + @Override @Nullable public String getCarrierConfigString(Context context, PhoneAccountHandle account, String key) { -- cgit v1.2.3