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
diff --git a/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java b/java/com/android/dialer/app/voicemail/error/VoicemailTosMessageCreator.java
index f5ea95d..a2b82c0 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 @@
}
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 @@
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);