summaryrefslogtreecommitdiff
path: root/java/com/android/voicemail
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-09-13 10:37:01 -0700
committerEric Erfanian <erfanian@google.com>2017-09-13 16:40:09 -0700
commit592098024c2f5c7df232c73034b6ae17e8af53a4 (patch)
tree7a2e4ed6af08572dfb400e7d5eeff5c8a40cdc35 /java/com/android/voicemail
parenta23a522125599d99bcad03bc5c999df339538373 (diff)
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
Diffstat (limited to 'java/com/android/voicemail')
-rw-r--r--java/com/android/voicemail/impl/ActivationTask.java21
-rw-r--r--java/com/android/voicemail/impl/settings/VisualVoicemailSettingsUtil.java3
2 files changed, 15 insertions, 9 deletions
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) {