From 26fe89b6e62030ed5b4c8eb7c07c561b7b77c71a Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 4 Jun 2018 12:25:01 -0700 Subject: Fix assert when disabling VVM The SIM may no longer be valid, but the rest of the deactivation process should still go through. TEST=TAP Bug: 79476712 Test: TAP PiperOrigin-RevId: 199174445 Change-Id: I52d6030320f2675ac74fc06470e3cd8f33b613b8 --- .../voicemail/impl/OmtpVvmCarrierConfigHelper.java | 37 ++++++++++------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'java/com/android/voicemail') diff --git a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java index 4c4df27a7..3b97e3d8e 100644 --- a/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java +++ b/java/com/android/voicemail/impl/OmtpVvmCarrierConfigHelper.java @@ -142,10 +142,14 @@ public class OmtpVvmCarrierConfigHelper { @VisibleForTesting OmtpVvmCarrierConfigHelper( - Context context, PersistableBundle carrierConfig, PersistableBundle telephonyConfig) { + Context context, + PersistableBundle carrierConfig, + PersistableBundle telephonyConfig, + @Nullable PhoneAccountHandle phoneAccountHandle) { this.context = context; this.carrierConfig = carrierConfig; this.telephonyConfig = telephonyConfig; + this.phoneAccountHandle = phoneAccountHandle; overrideConfig = null; vvmType = getVvmType(); protocol = VisualVoicemailProtocolFactory.create(this.context.getResources(), vvmType); @@ -345,7 +349,6 @@ public class OmtpVvmCarrierConfigHelper { } public void startActivation() { - Assert.checkArgument(isValid()); PhoneAccountHandle phoneAccountHandle = getPhoneAccountHandle(); if (phoneAccountHandle == null) { // This should never happen @@ -353,17 +356,12 @@ public class OmtpVvmCarrierConfigHelper { return; } - if (vvmType == null || vvmType.isEmpty()) { - // The VVM type is invalid; we should never have gotten here in the first place since - // this is loaded initially in the constructor, and callers should check isValid() - // before trying to start activation anyways. - VvmLog.e(TAG, "startActivation : vvmType is null or empty for account " + phoneAccountHandle); + if (!isValid()) { + VvmLog.e(TAG, "startActivation : invalid config for account " + phoneAccountHandle); return; } - if (protocol != null) { - ActivationTask.start(context, this.phoneAccountHandle, null); - } + ActivationTask.start(context, this.phoneAccountHandle, null); } public void activateSmsFilter() { @@ -378,17 +376,16 @@ public class OmtpVvmCarrierConfigHelper { } public void startDeactivation() { - Assert.checkArgument(isValid()); VvmLog.i(TAG, "startDeactivation"); - if (!isLegacyModeEnabled()) { - // SMS should still be filtered in legacy mode - context - .getSystemService(TelephonyManager.class) - .createForPhoneAccountHandle(getPhoneAccountHandle()) - .setVisualVoicemailSmsFilterSettings(null); - VvmLog.i(TAG, "filter disabled"); - } - if (protocol != null) { + if (isValid()) { + if (!isLegacyModeEnabled()) { + // SMS should still be filtered in legacy mode + context + .getSystemService(TelephonyManager.class) + .createForPhoneAccountHandle(getPhoneAccountHandle()) + .setVisualVoicemailSmsFilterSettings(null); + VvmLog.i(TAG, "filter disabled"); + } protocol.startDeactivation(this); } VvmAccountManager.removeAccount(context, getPhoneAccountHandle()); -- cgit v1.2.3