From f370b7dc3b7218c20fc55d08902869be31d3cab6 Mon Sep 17 00:00:00 2001 From: twyen Date: Thu, 31 Aug 2017 15:19:52 -0700 Subject: Setup SMS filter during activation if legacy mode is used If the user disabled VVM on pre-O devices then upgrade to O, dialer will not setup the filter because VVM is disabled. The legacy mode which translate VVM SMS into traditional notifications needs the filter to operate. This CL sets up the filter if legacy mode is used. Bug: 65050952 Test: ActivationTaskTest PiperOrigin-RevId: 167199492 Change-Id: I2c77f0c6964b157d36bfa2adde7169b9ac6ccc3a --- .../com/android/voicemail/impl/ActivationTask.java | 28 +++++++++++++++++----- .../voicemail/impl/scheduling/BaseTask.java | 4 +++- 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'java') diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java index 320ea2aaa..d7a122ce3 100644 --- a/java/com/android/voicemail/impl/ActivationTask.java +++ b/java/com/android/voicemail/impl/ActivationTask.java @@ -23,6 +23,7 @@ import android.os.Build.VERSION_CODES; import android.os.Bundle; import android.provider.Settings; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import android.telephony.ServiceState; @@ -64,6 +65,8 @@ public class ActivationTask extends BaseTask { private final RetryPolicy mRetryPolicy; + @Nullable private OmtpVvmCarrierConfigHelper configForTest; + private Bundle mMessageData; public ActivationTask() { @@ -132,19 +135,27 @@ public class ActivationTask extends BaseTask { PreOMigrationHandler.migrate(getContext(), phoneAccountHandle); - if (!VisualVoicemailSettingsUtil.isEnabled(getContext(), phoneAccountHandle)) { - VvmLog.i(TAG, "VVM is disabled"); - return; + OmtpVvmCarrierConfigHelper helper; + if (configForTest != null) { + helper = configForTest; + } else { + helper = new OmtpVvmCarrierConfigHelper(getContext(), phoneAccountHandle); } - - OmtpVvmCarrierConfigHelper helper = - new OmtpVvmCarrierConfigHelper(getContext(), phoneAccountHandle); if (!helper.isValid()) { VvmLog.i(TAG, "VVM not supported on phoneAccountHandle " + phoneAccountHandle); VvmAccountManager.removeAccount(getContext(), phoneAccountHandle); return; } + if (!VisualVoicemailSettingsUtil.isEnabled(getContext(), phoneAccountHandle)) { + if (helper.isLegacyModeEnabled()) { + VvmLog.i(TAG, "Setting up filter for legacy mode"); + helper.activateSmsFilter(); + } + VvmLog.i(TAG, "VVM is disabled"); + return; + } + // OmtpVvmCarrierConfigHelper can start the activation process; it will pass in a vvm // content provider URI which we will use. On some occasions, setting that URI will // fail, so we will perform a few attempts to ensure that the vvm content provider has @@ -278,4 +289,9 @@ public class ActivationTask extends BaseTask { .createForPhoneAccountHandle(phoneAccountHandle); return telephonyManager.getServiceState().getState() == ServiceState.STATE_IN_SERVICE; } + + @VisibleForTesting + void setConfigForTest(OmtpVvmCarrierConfigHelper config) { + configForTest = config; + } } diff --git a/java/com/android/voicemail/impl/scheduling/BaseTask.java b/java/com/android/voicemail/impl/scheduling/BaseTask.java index bbdca8c88..773d026bf 100644 --- a/java/com/android/voicemail/impl/scheduling/BaseTask.java +++ b/java/com/android/voicemail/impl/scheduling/BaseTask.java @@ -23,6 +23,7 @@ import android.os.SystemClock; import android.support.annotation.CallSuper; import android.support.annotation.MainThread; import android.support.annotation.NonNull; +import android.support.annotation.VisibleForTesting; import android.support.annotation.WorkerThread; import android.telecom.PhoneAccountHandle; import com.android.dialer.proguard.UsedByReflection; @@ -38,7 +39,8 @@ import java.util.List; @UsedByReflection(value = "Tasks.java") public abstract class BaseTask implements Task { - private static final String EXTRA_PHONE_ACCOUNT_HANDLE = "extra_phone_account_handle"; + @VisibleForTesting + public static final String EXTRA_PHONE_ACCOUNT_HANDLE = "extra_phone_account_handle"; private static final String EXTRA_EXECUTION_TIME = "extra_execution_time"; -- cgit v1.2.3