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
diff --git a/java/com/android/voicemail/impl/ActivationTask.java b/java/com/android/voicemail/impl/ActivationTask.java
index 320ea2a..d7a122c 100644
--- a/java/com/android/voicemail/impl/ActivationTask.java
+++ b/java/com/android/voicemail/impl/ActivationTask.java
@@ -23,6 +23,7 @@
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 @@
private final RetryPolicy mRetryPolicy;
+ @Nullable private OmtpVvmCarrierConfigHelper configForTest;
+
private Bundle mMessageData;
public ActivationTask() {
@@ -132,19 +135,27 @@
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 @@
.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 bbdca8c..773d026 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.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 @@
@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";