Disable visual voicemail if STATUS sms returns with error.
If the server returns a STATUS sms with an error, we want to disable
visual voicemail.
Bug: 22119548
Change-Id: I7d7203e8392addc66208f21ad4517a04dded7bb0
diff --git a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
index 6c8106b..d768e17 100644
--- a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
+++ b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
@@ -121,23 +121,32 @@
private void updateSource(StatusMessage message) {
OmtpVvmSourceManager vvmSourceManager =
OmtpVvmSourceManager.getInstance(mContext);
- VoicemailContract.Status.setStatus(mContext, mPhoneAccount,
- VoicemailContract.Status.CONFIGURATION_STATE_OK,
- VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
- VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
- // Save the IMAP credentials in preferences so they are persistent and can be retrieved.
- VisualVoicemailSettingsUtil.setVisualVoicemailCredentialsFromStatusMessage(
- mContext,
- mPhoneAccount,
- message);
+ if (OmtpConstants.SUCCESS.equals(message.getReturnCode())) {
+ VoicemailContract.Status.setStatus(mContext, mPhoneAccount,
+ VoicemailContract.Status.CONFIGURATION_STATE_OK,
+ VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
+ VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
- // Add the source to indicate that it is active.
- vvmSourceManager.addSource(mPhoneAccount);
+ // Save the IMAP credentials in preferences so they are persistent and can be retrieved.
+ VisualVoicemailSettingsUtil.setVisualVoicemailCredentialsFromStatusMessage(
+ mContext,
+ mPhoneAccount,
+ message);
- Intent serviceIntent = OmtpVvmSyncService.getSyncIntent(
- mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
- true /* firstAttempt */);
- mContext.startService(serviceIntent);
+ // Add the source to indicate that it is active.
+ vvmSourceManager.addSource(mPhoneAccount);
+
+ Intent serviceIntent = OmtpVvmSyncService.getSyncIntent(
+ mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
+ true /* firstAttempt */);
+ mContext.startService(serviceIntent);
+ } else {
+ Log.w(TAG, "Visual voicemail not available for subscriber.");
+ // Override default isEnabled setting to false since visual voicemail is unable to
+ // be accessed for some reason.
+ VisualVoicemailSettingsUtil.setVisualVoicemailEnabled(mContext, mPhoneAccount,
+ /* isEnabled */ false, /* isUserSet */ true);
+ }
}
}
\ No newline at end of file