diff options
Diffstat (limited to 'java/com/android/voicemail/impl/VoicemailClientImpl.java')
-rw-r--r-- | java/com/android/voicemail/impl/VoicemailClientImpl.java | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/java/com/android/voicemail/impl/VoicemailClientImpl.java b/java/com/android/voicemail/impl/VoicemailClientImpl.java index 993594eb3..b0881c9a3 100644 --- a/java/com/android/voicemail/impl/VoicemailClientImpl.java +++ b/java/com/android/voicemail/impl/VoicemailClientImpl.java @@ -123,13 +123,28 @@ public class VoicemailClientImpl implements VoicemailClient { } @Override - public boolean isVoicemailTranscriptionAvailable(Context context) { + public boolean isVoicemailTranscriptionAvailable( + Context context, PhoneAccountHandle phoneAccountHandle) { if (!BuildCompat.isAtLeastO()) { LogUtil.i( "VoicemailClientImpl.isVoicemailTranscriptionAvailable", "not running on O or later"); return false; } + if (!isVoicemailEnabled(context, phoneAccountHandle)) { + LogUtil.i( + "VoicemailClientImpl.isVoicemailTranscriptionAvailable", + "visual voicemail is not enabled"); + return false; + } + + if (!isActivated(context, phoneAccountHandle)) { + LogUtil.i( + "VoicemailClientImpl.isVoicemailTranscriptionAvailable", + "visual voicemail is not activated"); + return false; + } + TranscriptionConfigProvider provider = new TranscriptionConfigProvider(context); if (!provider.isVoicemailTranscriptionAvailable()) { LogUtil.i( @@ -141,12 +156,24 @@ public class VoicemailClientImpl implements VoicemailClient { } @Override - public boolean isVoicemailDonationAvailable(Context context) { - if (!isVoicemailTranscriptionAvailable(context)) { + public boolean isVoicemailTranscriptionEnabled(Context context, PhoneAccountHandle account) { + return isVoicemailTranscriptionAvailable(context, account) + && VisualVoicemailSettingsUtil.isVoicemailTranscriptionEnabled(context, account); + } + + @Override + public boolean isVoicemailDonationAvailable( + Context context, PhoneAccountHandle phoneAccountHandle) { + if (!isVoicemailTranscriptionAvailable(context, phoneAccountHandle)) { LogUtil.i("VoicemailClientImpl.isVoicemailDonationAvailable", "transcription not available"); return false; } + if (!isVoicemailTranscriptionEnabled(context, phoneAccountHandle)) { + LogUtil.i("VoicemailClientImpl.isVoicemailDonationAvailable", "transcription not enabled"); + return false; + } + TranscriptionConfigProvider provider = new TranscriptionConfigProvider(context); if (!provider.isVoicemailDonationAvailable()) { LogUtil.i("VoicemailClientImpl.isVoicemailDonationAvailable", "feature disabled by config"); @@ -158,13 +185,34 @@ public class VoicemailClientImpl implements VoicemailClient { @Override public boolean isVoicemailDonationEnabled(Context context, PhoneAccountHandle account) { - return isVoicemailTranscriptionAvailable(context) + return isVoicemailTranscriptionEnabled(context, account) + && isVoicemailDonationAvailable(context, account) && VisualVoicemailSettingsUtil.isVoicemailDonationEnabled(context, account); } @Override + public void setVoicemailTranscriptionEnabled( + Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled) { + Assert.checkArgument( + isVoicemailTranscriptionAvailable(context, phoneAccountHandle), + "transcription must be available before enabling/disabling it"); + VisualVoicemailSettingsUtil.setVoicemailTranscriptionEnabled( + context, phoneAccountHandle, enabled); + } + + @Override public void setVoicemailDonationEnabled( Context context, PhoneAccountHandle phoneAccountHandle, boolean enabled) { + if (enabled) { + Assert.checkArgument( + isVoicemailTranscriptionAvailable(context, phoneAccountHandle) + && isVoicemailTranscriptionEnabled(context, phoneAccountHandle), + "should not be able to enable donation without transcription " + + "available(value: %b) and enabled (value:%b) for account:%s", + isVoicemailTranscriptionAvailable(context, phoneAccountHandle), + isVoicemailTranscriptionEnabled(context, phoneAccountHandle), + phoneAccountHandle.toString()); + } VisualVoicemailSettingsUtil.setVoicemailDonationEnabled(context, phoneAccountHandle, enabled); } |