From 5dcad7edd3ca8a052f888a7bb7cb73c4d1524d05 Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 11 Jun 2018 14:32:23 -0700 Subject: Handle alternative form VVM SMS as legacy notification if the account is not activated yet. On VVM3 if subscription failed, the alternative form SMS will still be sent by the carrier. In this state dialer should fallback to legacy voicemail notification. TEST=manual - disable auto subscription in code, check legacy voicemail notification functionality. Bug: 109896901 Test: manual - disable auto subscription in code, check legacy voicemail notification functionality. PiperOrigin-RevId: 200113818 Change-Id: I55b70e7a8b2cd3d8b40864fa03b2ba209037f4e8 --- java/com/android/voicemail/impl/OmtpConstants.java | 5 +++++ .../com/android/voicemail/impl/sms/LegacyModeSmsHandler.java | 12 +++++++++++- java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/java/com/android/voicemail/impl/OmtpConstants.java b/java/com/android/voicemail/impl/OmtpConstants.java index d94e36138..c04f5e23d 100644 --- a/java/com/android/voicemail/impl/OmtpConstants.java +++ b/java/com/android/voicemail/impl/OmtpConstants.java @@ -244,4 +244,9 @@ public class OmtpConstants { private static final String truncate(String string, int length) { return string.substring(0, Math.min(length, string.length())); } + + // Alternative form of sync message: MBOXUPDATE?m=;=; + + public static final String ALTERNATIVE_MAILBOX_UPDATE = "MBOXUPDATE"; + public static final String ALTERNATIVE_NUM_MESSAGE_COUNT = "m"; } diff --git a/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java b/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java index 3608c3602..29d376b35 100644 --- a/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java +++ b/java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java @@ -62,11 +62,21 @@ public class LegacyModeSmsHandler { case OmtpConstants.NEW_MESSAGE: case OmtpConstants.MAILBOX_UPDATE: sendLegacyVoicemailNotification(context, handle, message.getNewMessageCount()); - break; default: break; } + } else if (OmtpConstants.ALTERNATIVE_MAILBOX_UPDATE.equals(eventType)) { + VvmLog.w(TAG, "receiving alternative VVM SMS on non-activated account"); + int messageCount = 0; + try { + messageCount = + Integer.parseInt( + sms.getFields().getString(OmtpConstants.ALTERNATIVE_NUM_MESSAGE_COUNT)); + } catch (NumberFormatException e) { + VvmLog.e(TAG, "missing message count"); + } + sendLegacyVoicemailNotification(context, handle, messageCount); } } diff --git a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java index eae990ab0..0f22c3d62 100644 --- a/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java +++ b/java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java @@ -38,6 +38,7 @@ import com.android.voicemail.impl.settings.VisualVoicemailSettingsUtil; import com.android.voicemail.impl.sync.SyncOneTask; import com.android.voicemail.impl.sync.SyncTask; import com.android.voicemail.impl.sync.VoicemailsQueryHelper; +import com.android.voicemail.impl.sync.VvmAccountManager; import com.android.voicemail.impl.utils.VoicemailDatabaseUtil; /** Receive SMS messages and send for processing by the OMTP visual voicemail source. */ @@ -69,6 +70,12 @@ public class OmtpMessageReceiver extends BroadcastReceiver { return; } + if (!VvmAccountManager.isAccountActivated(context, phone)) { + VvmLog.i(TAG, "Received message on non-activated account"); + LegacyModeSmsHandler.handle(context, sms); + return; + } + OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(this.context, phone); if (!helper.isValid()) { VvmLog.e(TAG, "vvm config no longer valid"); -- cgit v1.2.3