summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-06-11 23:49:27 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-06-11 23:49:27 +0000
commit1ffc9adf373b588505c9749f4db3f83098559f40 (patch)
tree97c4a98be8c0c203f58ca475321d7983333d188d
parent564c41f33b05262610ef171008a15957fb99878d (diff)
parent5dcad7edd3ca8a052f888a7bb7cb73c4d1524d05 (diff)
Merge "Handle alternative form VVM SMS as legacy notification if the account is not activated yet."
-rw-r--r--java/com/android/voicemail/impl/OmtpConstants.java5
-rw-r--r--java/com/android/voicemail/impl/sms/LegacyModeSmsHandler.java12
-rw-r--r--java/com/android/voicemail/impl/sms/OmtpMessageReceiver.java7
3 files changed, 23 insertions, 1 deletions
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=<new_message_count>;<key>=<value>;
+
+ 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");