From cb097482c41778c446f66690c10ce06f17463358 Mon Sep 17 00:00:00 2001 From: mdooley Date: Thu, 28 Sep 2017 16:48:08 -0700 Subject: Check for valid phone account before displaying voicemail TOS Project Fi devices crash when declining voicemail TOS because of an invalid PhoneAccountHandle. This cl fixes the problem by not showing the TOS when the PhoneAccountHandle is not valid. Bug: 67001886,66969838 Test: manual and updated unit tests PiperOrigin-RevId: 170418189 Change-Id: I36dd0b10ab7468b0937a81f3f0427a4d64091955 --- .../error/VoicemailTosMessageCreator.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'java') diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java index f5ea95d35..a2b82c0fc 100644 --- a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java +++ b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java @@ -125,6 +125,17 @@ public class VoicemailTosMessageCreator { } private boolean shouldShowTos() { + if (!isValidVoicemailType(status.type)) { + LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "unsupported type: " + status.type); + return false; + } + + if (status.getPhoneAccountHandle() == null + || status.getPhoneAccountHandle().getComponentName() == null) { + LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "invalid phone account"); + return false; + } + if (isVvm3()) { LogUtil.i("VoicemailTosMessageCreator.shouldShowTos", "showing TOS for verizon"); return true; @@ -139,6 +150,20 @@ public class VoicemailTosMessageCreator { return false; } + private static boolean isValidVoicemailType(String type) { + if (type == null) { + return false; + } + switch (type) { + case TelephonyManager.VVM_TYPE_OMTP: + case TelephonyManager.VVM_TYPE_CVVM: + case VisualVoicemailTypeExtensions.VVM_TYPE_VVM3: + return true; + default: + return false; + } + } + private boolean isVoicemailTranscriptionEnabled() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && ConfigProviderBindings.get(context).getBoolean("voicemail_transcription_enabled", false); -- cgit v1.2.3