From 592098024c2f5c7df232c73034b6ae17e8af53a4 Mon Sep 17 00:00:00 2001 From: twyen Date: Wed, 13 Sep 2017 10:37:01 -0700 Subject: Setup SMS filter even if VVM is already activated VVM can be "activated" through restoring shared preferences from another device. In this case the SMS filter in telephony is still not configured, and needs to be set up. Bug: 65542413 Test: ActivationTaskTest PiperOrigin-RevId: 168560153 Change-Id: I46dd9b31e43899d8d567e7e6baebf06559548525 --- java/com/android/voicemail/impl/ActivationTask.java | 21 +++++++++++++-------- .../impl/settings/VisualVoicemailSettingsUtil.java | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'java/com/android/voicemail') diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java index d7a122ce3..29c91e01e 100644 --- a/java/com/android/voicemail/impl/ActivationTask.java +++ b/java/com/android/voicemail/impl/ActivationTask.java @@ -170,7 +170,9 @@ public class ActivationTask extends BaseTask { if (VvmAccountManager.isAccountActivated(getContext(), phoneAccountHandle)) { VvmLog.i(TAG, "Account is already activated"); - onSuccess(getContext(), phoneAccountHandle); + // The activated state might come from restored data, the filter still needs to be set up. + helper.activateSmsFilter(); + onSuccess(getContext(), phoneAccountHandle, helper); return; } helper.handleEvent( @@ -230,7 +232,7 @@ public class ActivationTask extends BaseTask { + message.getReturnCode()); if (message.getProvisioningStatus().equals(OmtpConstants.SUBSCRIBER_READY)) { VvmLog.d(TAG, "subscriber ready, no activation required"); - updateSource(getContext(), phoneAccountHandle, message); + updateSource(getContext(), phoneAccountHandle, message, helper); } else { if (helper.supportsProvisioning()) { VvmLog.i(TAG, "Subscriber not ready, start provisioning"); @@ -240,7 +242,7 @@ public class ActivationTask extends BaseTask { VvmLog.i(TAG, "Subscriber new but provisioning is not supported"); // Ignore the non-ready state and attempt to use the provided info as is. // This is probably caused by not completing the new user tutorial. - updateSource(getContext(), phoneAccountHandle, message); + updateSource(getContext(), phoneAccountHandle, message, helper); } else { VvmLog.i(TAG, "Subscriber not ready but provisioning is not supported"); helper.handleEvent(status, OmtpEvents.CONFIG_SERVICE_NOT_AVAILABLE); @@ -251,20 +253,23 @@ public class ActivationTask extends BaseTask { } private static void updateSource( - Context context, PhoneAccountHandle phone, StatusMessage message) { + Context context, + PhoneAccountHandle phone, + StatusMessage message, + OmtpVvmCarrierConfigHelper config) { if (OmtpConstants.SUCCESS.equals(message.getReturnCode())) { // Save the IMAP credentials in preferences so they are persistent and can be retrieved. VvmAccountManager.addAccount(context, phone, message); - onSuccess(context, phone); + onSuccess(context, phone, config); } else { VvmLog.e(TAG, "Visual voicemail not available for subscriber."); } } - private static void onSuccess(Context context, PhoneAccountHandle phoneAccountHandle) { - OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(context, phoneAccountHandle); - helper.handleEvent( + private static void onSuccess( + Context context, PhoneAccountHandle phoneAccountHandle, OmtpVvmCarrierConfigHelper config) { + config.handleEvent( VoicemailStatus.edit(context, phoneAccountHandle), OmtpEvents.CONFIG_REQUEST_STATUS_SUCCESS); clearLegacyVoicemailNotification(context, phoneAccountHandle); diff --git a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java index 9ce32a97c..ae526d168 100644 --- a/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java +++ b/java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java @@ -16,6 +16,7 @@ package com.android.voicemail.impl.settings; import android.content.Context; +import android.support.annotation.VisibleForTesting; import android.telecom.PhoneAccountHandle; import com.android.dialer.common.Assert; import com.android.voicemail.VoicemailComponent; @@ -28,7 +29,7 @@ import com.android.voicemail.impl.sync.VvmAccountManager; /** Save whether or not a particular account is enabled in shared to be retrieved later. */ public class VisualVoicemailSettingsUtil { - private static final String IS_ENABLED_KEY = "is_enabled"; + @VisibleForTesting public static final String IS_ENABLED_KEY = "is_enabled"; public static void setEnabled( Context context, PhoneAccountHandle phoneAccount, boolean isEnabled) { -- cgit v1.2.3