Support Verizon visual voicemail protocol
The VVM3 implementation differs with existing OMTP and CVVM,
especially it does not have the concept of activation/deactivation. VVM3
is activated once it is provisioned, and can not be turned off from
the client side.
To support none data driven features, We defined the
VisualVoicemailProtocol interface for methods that depends on the
implementation. The protocol will be selected based on the vvm_type_string
in the carrier config.
For VVM3 activation, instead of sending a ACTIVATE SMS which they do
not support, we will send a STATUS SMS to check the provisioning status
and get the server credentials. Provisioning is to be handled in a future
CL.
+ Carrier config values for VZW
+ VVM validity for a carrier is checked by
OmtpVvmCarrierConfigHelper.isValid() instead of getVvmType() matching.
A carrier is valid if a protocol for its' type is implemented.
+ All VVM type dependent code refactored into protocols.
+ StatusMessage.getProvisioningStatus() return unquoted status.
+ Fixed bug in ImapConnection that caused all capability to be rejected
if disabledCapability is null.
Change-Id: I512b954b3260138267cb5eeb2fcc5ae016ec0f2d
Fixes:27817303
Bug:27816386
Bug:28696525
diff --git a/res/xml/vvm_config.xml b/res/xml/vvm_config.xml
index 57a1050..79edaa6 100644
--- a/res/xml/vvm_config.xml
+++ b/res/xml/vvm_config.xml
@@ -20,11 +20,6 @@
<string-array name="mccmnc">
<item value="TEST"/>
</string-array>
-
- <int name="vvm_port_number_int" value="20481"/>
- <string name="vvm_destination_number_string">887</string>
- <string name="vvm_type_string">vvm_type_omtp</string>
- <boolean name="vvm_cellular_data_required_bool" value="true"/>
</pbundle_as_map>
<pbundle_as_map>
@@ -89,4 +84,55 @@
<item value="AUTH=DIGEST-MD5"/>
</string-array>
</pbundle_as_map>
+
+ <pbundle_as_map>
+ <!-- Verizon USA -->
+ <string-array name="mccmnc">
+ <item value="310004"/>
+ <item value="310010"/>
+ <item value="310012"/>
+ <item value="310013"/>
+ <item value="310590"/>
+ <item value="310890"/>
+ <item value="310910"/>
+ <item value="311110"/>
+ <item value="311270"/>
+ <item value="311271"/>
+ <item value="311272"/>
+ <item value="311273"/>
+ <item value="311274"/>
+ <item value="311275"/>
+ <item value="311276"/>
+ <item value="311277"/>
+ <item value="311278"/>
+ <item value="311279"/>
+ <item value="311280"/>
+ <item value="311281"/>
+ <item value="311282"/>
+ <item value="311283"/>
+ <item value="311284"/>
+ <item value="311285"/>
+ <item value="311286"/>
+ <item value="311287"/>
+ <item value="311288"/>
+ <item value="311289"/>
+ <item value="311390"/>
+ <item value="311480"/>
+ <item value="311481"/>
+ <item value="311482"/>
+ <item value="311483"/>
+ <item value="311484"/>
+ <item value="311485"/>
+ <item value="311486"/>
+ <item value="311487"/>
+ <item value="311488"/>
+ <item value="311489"/>
+ </string-array>
+
+ <int name="vvm_port_number_int" value="0"/>
+ <string name="vvm_destination_number_string">900080006200</string>
+ <string name="vvm_type_string">vvm_type_vvm3</string>
+ <string name="vvm_client_prefix_string">//VZWVVM</string>
+ <boolean name="vvm_cellular_data_required_bool" value="true"/>
+ </pbundle_as_map>
</list>
\ No newline at end of file
diff --git a/src/com/android/phone/common/mail/store/ImapConnection.java b/src/com/android/phone/common/mail/store/ImapConnection.java
index 914ab10..ad47acc 100644
--- a/src/com/android/phone/common/mail/store/ImapConnection.java
+++ b/src/com/android/phone/common/mail/store/ImapConnection.java
@@ -260,7 +260,11 @@
}
for (int i = 0; i < response.size(); i++) {
String capability = response.getStringOrEmpty(i).getString();
- if (disabledCapabilities != null && !disabledCapabilities.contains(capability)) {
+ if (disabledCapabilities != null) {
+ if (!disabledCapabilities.contains(capability)) {
+ mCapabilities.add(capability);
+ }
+ } else {
mCapabilities.add(capability);
}
}
diff --git a/src/com/android/phone/settings/VoicemailSettingsActivity.java b/src/com/android/phone/settings/VoicemailSettingsActivity.java
index a08fe30..d403161 100644
--- a/src/com/android/phone/settings/VoicemailSettingsActivity.java
+++ b/src/com/android/phone/settings/VoicemailSettingsActivity.java
@@ -30,7 +30,6 @@
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.provider.ContactsContract.CommonDataKinds;
-import android.telephony.TelephonyManager;
import android.text.BidiFormatter;
import android.text.TextDirectionHeuristics;
import android.text.TextUtils;
@@ -41,10 +40,9 @@
import com.android.internal.telephony.CallForwardInfo;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
-import com.android.phone.R;
import com.android.phone.EditPhoneNumberPreference;
import com.android.phone.PhoneGlobals;
-import com.android.phone.PhoneUtils;
+import com.android.phone.R;
import com.android.phone.SubscriptionInfoHelper;
import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
import com.android.phone.vvm.omtp.sync.OmtpVvmSourceManager;
@@ -261,8 +259,7 @@
mVoicemailVisualVoicemail = (SwitchPreference) findPreference(
getResources().getString(R.string.voicemail_visual_voicemail_key));
- if (TelephonyManager.VVM_TYPE_OMTP.equals(mOmtpVvmCarrierConfigHelper.getVvmType()) ||
- TelephonyManager.VVM_TYPE_CVVM.equals(mOmtpVvmCarrierConfigHelper.getVvmType())) {
+ if (mOmtpVvmCarrierConfigHelper.isValid()) {
mVoicemailVisualVoicemail.setOnPreferenceChangeListener(this);
mVoicemailVisualVoicemail.setChecked(
VisualVoicemailSettingsUtil.isVisualVoicemailEnabled(mPhone));
diff --git a/src/com/android/phone/vvm/omtp/OmtpConstants.java b/src/com/android/phone/vvm/omtp/OmtpConstants.java
index 5fc0317..896ffe0 100644
--- a/src/com/android/phone/vvm/omtp/OmtpConstants.java
+++ b/src/com/android/phone/vvm/omtp/OmtpConstants.java
@@ -136,8 +136,6 @@
* <p>
* Referred by {@link OmtpConstants#PROVISIONING_STATUS}.
*/
- // TODO: As per the spec the code could be either be with or w/o quotes = "N"/N). Currently
- // this only handles the w/o quotes values.
public static final String SUBSCRIBER_NEW = "N";
public static final String SUBSCRIBER_READY = "R";
public static final String SUBSCRIBER_PROVISIONED = "P";
diff --git a/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java b/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
index 7abf299..64e7e31 100644
--- a/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
+++ b/src/com/android/phone/vvm/omtp/OmtpVvmCarrierConfigHelper.java
@@ -18,9 +18,9 @@
import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
import android.os.PersistableBundle;
import android.telephony.CarrierConfigManager;
-import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.VisualVoicemailSmsFilterSettings;
@@ -29,9 +29,8 @@
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.phone.vvm.omtp.sms.OmtpCvvmMessageSender;
-import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
-import com.android.phone.vvm.omtp.sms.OmtpStandardMessageSender;
+import com.android.phone.vvm.omtp.protocol.VisualVoicemailProtocol;
+import com.android.phone.vvm.omtp.protocol.VisualVoicemailProtocolFactory;
import java.util.Arrays;
import java.util.Set;
@@ -88,7 +87,7 @@
private final int mSubId;
private final PersistableBundle mCarrierConfig;
private final String mVvmType;
-
+ private final VisualVoicemailProtocol mProtocol;
private final PersistableBundle mTelephonyConfig;
public OmtpVvmCarrierConfigHelper(Context context, int subId) {
@@ -102,6 +101,7 @@
.getConfig(telephonyManager.getNetworkOperator(subId));
mVvmType = getVvmType();
+ mProtocol = VisualVoicemailProtocolFactory.create(mVvmType);
}
@VisibleForTesting
@@ -112,6 +112,23 @@
mCarrierConfig = carrierConfig;
mTelephonyConfig = telephonyConfig;
mVvmType = getVvmType();
+ mProtocol = VisualVoicemailProtocolFactory.create(mVvmType);
+ }
+
+ public Context getContext() {
+ return mContext;
+ }
+
+ public int getSubId() {
+ return mSubId;
+ }
+
+ /**
+ * return whether the carrier's visual voicemail is supported, with KEY_VVM_TYPE_STRING set as a
+ * known protocol.
+ */
+ public boolean isValid() {
+ return mProtocol != null;
}
@Nullable
@@ -146,11 +163,6 @@
return names;
}
- public boolean isOmtpVvmType() {
- return (TelephonyManager.VVM_TYPE_OMTP.equals(mVvmType) ||
- TelephonyManager.VVM_TYPE_CVVM.equals(mVvmType));
- }
-
/**
* For checking upon sim insertion whether visual voicemail should be enabled. This method does
* so by checking if the carrier's voicemail app is installed.
@@ -172,20 +184,16 @@
}
public boolean isCellularDataRequired() {
- return (boolean) getValue(KEY_VVM_CELLULAR_DATA_REQUIRED_BOOL);
+ return (boolean) getValue(KEY_VVM_CELLULAR_DATA_REQUIRED_BOOL, false);
}
public boolean isPrefetchEnabled() {
- return (boolean) getValue(KEY_VVM_PREFETCH_BOOL);
+ return (boolean) getValue(KEY_VVM_PREFETCH_BOOL, true);
}
public int getApplicationPort() {
- Integer port = (Integer) getValue(KEY_VVM_PORT_NUMBER_INT);
- if (port != null) {
- return port;
- }
- return 0;
+ return (int) getValue(KEY_VVM_PORT_NUMBER_INT, 0);
}
@Nullable
@@ -201,11 +209,7 @@
* TODO: make config public and add to CarrierConfigManager
*/
public int getSslPort() {
- Integer port = (Integer) getValue(KEY_VVM_SSL_PORT_NUMBER_INT);
- if (port != null) {
- return port;
- }
- return 0;
+ return (int) getValue(KEY_VVM_SSL_PORT_NUMBER_INT, 0);
}
/**
@@ -255,20 +259,28 @@
new VisualVoicemailSmsFilterSettings.Builder().setClientPrefix(getClientPrefix())
.build());
- OmtpMessageSender messageSender = getMessageSender();
- if (messageSender != null) {
- Log.i(TAG, "Requesting VVM activation for subId: " + mSubId);
- messageSender.requestVvmActivation(null);
+ if (mProtocol != null) {
+ mProtocol.startActivation(this);
}
}
public void startDeactivation() {
mContext.getSystemService(TelephonyManager.class)
.disableVisualVoicemailSmsFilter(mSubId);
- OmtpMessageSender messageSender = getMessageSender();
- if (messageSender != null) {
- Log.i(TAG, "Requesting VVM deactivation for subId: " + mSubId);
- messageSender.requestVvmDeactivation(null);
+ if (mProtocol != null) {
+ mProtocol.startDeactivation(this);
+ }
+ }
+
+ public void startProvisioning(Bundle data) {
+ if (mProtocol != null) {
+ mProtocol.startProvisioning(this, data);
+ }
+ }
+
+ public void requestStatus() {
+ if (mProtocol != null) {
+ mProtocol.requestStatus(this);
}
}
@@ -295,39 +307,13 @@
return config;
}
- private OmtpMessageSender getMessageSender() {
- if (mCarrierConfig == null && mTelephonyConfig == null) {
- Log.w(TAG, "Empty carrier config.");
- return null;
- }
-
- int applicationPort = getApplicationPort();
- String destinationNumber = getDestinationNumber();
- if (TextUtils.isEmpty(destinationNumber)) {
- Log.w(TAG, "No destination number for this carrier.");
- return null;
- }
-
- OmtpMessageSender messageSender = null;
- SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(mSubId);
- switch (mVvmType) {
- case TelephonyManager.VVM_TYPE_OMTP:
- messageSender = new OmtpStandardMessageSender(smsManager, (short) applicationPort,
- destinationNumber, null, OmtpConstants.PROTOCOL_VERSION1_1, null);
- break;
- case TelephonyManager.VVM_TYPE_CVVM:
- messageSender = new OmtpCvvmMessageSender(smsManager, (short) applicationPort,
- destinationNumber);
- break;
- default:
- Log.w(TAG, "Unexpected visual voicemail type: " + mVvmType);
- }
-
- return messageSender;
+ @Nullable
+ private Object getValue(String key) {
+ return getValue(key, null);
}
@Nullable
- private Object getValue(String key) {
+ private Object getValue(String key, Object defaultValue) {
Object result;
if (mCarrierConfig != null) {
result = mCarrierConfig.get(key);
@@ -341,6 +327,6 @@
return result;
}
}
- return null;
+ return defaultValue;
}
}
\ No newline at end of file
diff --git a/src/com/android/phone/vvm/omtp/SimChangeReceiver.java b/src/com/android/phone/vvm/omtp/SimChangeReceiver.java
index 0a37493..830243a 100644
--- a/src/com/android/phone/vvm/omtp/SimChangeReceiver.java
+++ b/src/com/android/phone/vvm/omtp/SimChangeReceiver.java
@@ -87,7 +87,7 @@
public static void processSubId(Context context, int subId) {
OmtpVvmCarrierConfigHelper carrierConfigHelper =
new OmtpVvmCarrierConfigHelper(context, subId);
- if (carrierConfigHelper.isOmtpVvmType()) {
+ if (carrierConfigHelper.isValid()) {
PhoneAccountHandle phoneAccount = PhoneUtils.makePstnPhoneAccountHandle(
SubscriptionManager.getPhoneId(subId));
diff --git a/src/com/android/phone/vvm/omtp/imap/ImapHelper.java b/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
index 404c771..4c2192e 100644
--- a/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
+++ b/src/com/android/phone/vvm/omtp/imap/ImapHelper.java
@@ -120,8 +120,6 @@
VoicemailContract.Status.QUOTA_UNAVAILABLE);
mQuotaTotal = mPrefs.getInt(getSharedPrefsKey(PREF_KEY_QUOTA_TOTAL),
VoicemailContract.Status.QUOTA_UNAVAILABLE);
-
- Log.v(TAG, "Quota:" + mQuotaOccupied + "/" + mQuotaTotal);
}
/**
diff --git a/src/com/android/phone/vvm/omtp/protocol/CvvmProtocol.java b/src/com/android/phone/vvm/omtp/protocol/CvvmProtocol.java
new file mode 100644
index 0000000..9c4d531
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/CvvmProtocol.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.telephony.SmsManager;
+
+import com.android.phone.vvm.omtp.sms.OmtpCvvmMessageSender;
+import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
+
+/**
+ * A flavor of OMTP protocol with a different mobile originated (MO) format
+ */
+public class CvvmProtocol extends VisualVoicemailProtocol {
+
+ @Override
+ public OmtpMessageSender createMessageSender(SmsManager smsManager, short applicationPort,
+ String destinationNumber) {
+ return new OmtpCvvmMessageSender(smsManager, applicationPort, destinationNumber);
+ }
+}
diff --git a/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java b/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java
new file mode 100644
index 0000000..d002652
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/OmtpProtocol.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.telephony.SmsManager;
+
+import com.android.phone.vvm.omtp.OmtpConstants;
+import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
+import com.android.phone.vvm.omtp.sms.OmtpStandardMessageSender;
+
+public class OmtpProtocol extends VisualVoicemailProtocol {
+
+ @Override
+ public OmtpMessageSender createMessageSender(SmsManager smsManager, short applicationPort,
+ String destinationNumber) {
+ return new OmtpStandardMessageSender(smsManager, applicationPort, destinationNumber,
+ null, OmtpConstants.PROTOCOL_VERSION1_1, null);
+ }
+}
diff --git a/src/com/android/phone/vvm/omtp/protocol/ProtocolHelper.java b/src/com/android/phone/vvm/omtp/protocol/ProtocolHelper.java
new file mode 100644
index 0000000..d265bd0
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/ProtocolHelper.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.telephony.SmsManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
+
+public class ProtocolHelper {
+
+ private static final String TAG = "ProtocolHelper";
+
+ public static OmtpMessageSender getMessageSender(VisualVoicemailProtocol protocol,
+ OmtpVvmCarrierConfigHelper config) {
+
+ int applicationPort = config.getApplicationPort();
+ String destinationNumber = config.getDestinationNumber();
+ if (TextUtils.isEmpty(destinationNumber)) {
+ Log.w(TAG, "No destination number for this carrier.");
+ return null;
+ }
+
+ SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(config.getSubId());
+ return protocol.createMessageSender(smsManager, (short) applicationPort, destinationNumber);
+ }
+}
diff --git a/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocol.java b/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocol.java
new file mode 100644
index 0000000..bc7dc82
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocol.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.os.Bundle;
+import android.telephony.SmsManager;
+
+import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
+
+public abstract class VisualVoicemailProtocol {
+
+ public void startActivation(OmtpVvmCarrierConfigHelper config) {
+ OmtpMessageSender messageSender = ProtocolHelper.getMessageSender(this, config);
+ if (messageSender != null) {
+ messageSender.requestVvmActivation(null);
+ }
+ }
+
+ public void startDeactivation(OmtpVvmCarrierConfigHelper config) {
+ OmtpMessageSender messageSender = ProtocolHelper.getMessageSender(this, config);
+ if (messageSender != null) {
+ messageSender.requestVvmDeactivation(null);
+ }
+ }
+
+ public void startProvisioning(OmtpVvmCarrierConfigHelper config, Bundle data) {
+ // Do nothing
+ }
+
+ public void requestStatus(OmtpVvmCarrierConfigHelper config) {
+ OmtpMessageSender messageSender = ProtocolHelper.getMessageSender(this, config);
+ if (messageSender != null) {
+ messageSender.requestVvmStatus(null);
+ }
+ }
+
+ public abstract OmtpMessageSender createMessageSender(SmsManager smsManager,
+ short applicationPort, String destinationNumber);
+}
diff --git a/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocolFactory.java b/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocolFactory.java
new file mode 100644
index 0000000..dbf38c2
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/VisualVoicemailProtocolFactory.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.annotation.Nullable;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+public class VisualVoicemailProtocolFactory {
+
+ private static final String TAG = "VvmProtocolFactory";
+
+ private static final String VVM_TYPE_VVM3 = "vvm_type_vvm3";
+
+ @Nullable
+ public static VisualVoicemailProtocol create(String type) {
+ if (type == null) {
+ return null;
+ }
+ switch (type) {
+ case TelephonyManager.VVM_TYPE_OMTP:
+ return new OmtpProtocol();
+ case TelephonyManager.VVM_TYPE_CVVM:
+ return new CvvmProtocol();
+ case VVM_TYPE_VVM3:
+ return new Vvm3Protocol();
+ default:
+ Log.e(TAG, "Unexpected visual voicemail type: " + type);
+ }
+ return null;
+ }
+}
diff --git a/src/com/android/phone/vvm/omtp/protocol/Vvm3Protocol.java b/src/com/android/phone/vvm/omtp/protocol/Vvm3Protocol.java
new file mode 100644
index 0000000..f53d270
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/protocol/Vvm3Protocol.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.phone.vvm.omtp.protocol;
+
+import android.os.Bundle;
+import android.telephony.SmsManager;
+import android.util.Log;
+
+import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
+import com.android.phone.vvm.omtp.sms.OmtpMessageSender;
+import com.android.phone.vvm.omtp.sms.Vvm3MessageSender;
+
+/**
+ * A flavor of OMTP protocol with a different provisioning process
+ */
+public class Vvm3Protocol extends VisualVoicemailProtocol {
+
+ private static String TAG = "Vvm3Protocol";
+
+ public Vvm3Protocol() {
+ Log.d(TAG, "Vvm3Protocol created");
+ }
+
+ @Override
+ public void startActivation(OmtpVvmCarrierConfigHelper config) {
+ // VVM3 does not support activation SMS.
+ // Send a status request which will start the provisioning process if the user is not
+ // provisioned.
+ config.requestStatus();
+ }
+
+ @Override
+ public void startDeactivation(OmtpVvmCarrierConfigHelper config) {
+ // VVM3 does not support deactivation.
+ // do nothing.
+ }
+
+ @Override
+ public void startProvisioning(OmtpVvmCarrierConfigHelper config, Bundle data) {
+ Log.d(TAG, "start vvm3 provisioning");
+ // TODO: implement (b/28697797).
+ }
+
+ @Override
+ public OmtpMessageSender createMessageSender(SmsManager smsManager, short applicationPort,
+ String destinationNumber) {
+ return new Vvm3MessageSender(smsManager, applicationPort, destinationNumber);
+ }
+}
diff --git a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
index 67ffef7..f2beabe 100644
--- a/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
+++ b/src/com/android/phone/vvm/omtp/sms/OmtpMessageReceiver.java
@@ -33,6 +33,7 @@
import com.android.phone.settings.VisualVoicemailSettingsUtil;
import com.android.phone.vvm.omtp.LocalLogHelper;
import com.android.phone.vvm.omtp.OmtpConstants;
+import com.android.phone.vvm.omtp.OmtpVvmCarrierConfigHelper;
import com.android.phone.vvm.omtp.sync.OmtpVvmSourceManager;
import com.android.phone.vvm.omtp.sync.OmtpVvmSyncService;
import com.android.phone.vvm.omtp.sync.VoicemailsQueryHelper;
@@ -44,7 +45,6 @@
private static final String TAG = "OmtpMessageReceiver";
private Context mContext;
- private PhoneAccountHandle mPhoneAccount;
@Override
public void onReceive(Context context, Intent intent) {
@@ -55,17 +55,17 @@
}
mContext = context;
- mPhoneAccount = PhoneUtils.makePstnPhoneAccountHandle(
+ PhoneAccountHandle phone = PhoneUtils.makePstnPhoneAccountHandle(
SubscriptionManager.getPhoneId(
intent.getExtras().getInt(VoicemailContract.EXTRA_VOICEMAIL_SMS_SUBID)));
- if (mPhoneAccount == null) {
- Log.w(TAG, "Received message for null phone account");
+ if (phone == null) {
+ Log.i(TAG, "Received message for null phone account");
return;
}
- if (!VisualVoicemailSettingsUtil.isVisualVoicemailEnabled(mContext, mPhoneAccount)) {
- Log.v(TAG, "Received vvm message for disabled vvm source.");
+ if (!VisualVoicemailSettingsUtil.isVisualVoicemailEnabled(mContext, phone)) {
+ Log.i(TAG, "Received vvm message for disabled vvm source.");
return;
}
@@ -76,21 +76,32 @@
if (eventType.equals(OmtpConstants.SYNC_SMS_PREFIX)) {
SyncMessage message = new SyncMessage(data);
- Log.v(TAG, "Received SYNC sms for " + mPhoneAccount.getId() +
+ Log.v(TAG, "Received SYNC sms for " + phone.getId() +
" with event " + message.getSyncTriggerEvent());
- LocalLogHelper.log(TAG, "Received SYNC sms for " + mPhoneAccount.getId() +
+ LocalLogHelper.log(TAG, "Received SYNC sms for " + phone.getId() +
" with event " + message.getSyncTriggerEvent());
- processSync(message);
+ processSync(phone, message);
} else if (eventType.equals(OmtpConstants.STATUS_SMS_PREFIX)) {
- Log.v(TAG, "Received STATUS sms for " + mPhoneAccount.getId());
- LocalLogHelper.log(TAG, "Received Status sms for " + mPhoneAccount.getId());
+ Log.v(TAG, "Received STATUS sms for " + phone.getId());
+ LocalLogHelper.log(TAG, "Received Status sms for " + phone.getId());
StatusMessage message = new StatusMessage(data);
- updateSource(message);
+ if (message.getProvisioningStatus().equals(OmtpConstants.SUBSCRIBER_READY)) {
+ updateSource(phone, message);
+ } else {
+ Log.v(TAG, "Subscriber not ready, start provisioning");
+ startProvisioning(phone, data);
+ }
} else {
Log.e(TAG, "Unknown prefix: " + eventType);
}
}
+ private void startProvisioning(PhoneAccountHandle phone, Bundle data) {
+ OmtpVvmCarrierConfigHelper helper = new OmtpVvmCarrierConfigHelper(mContext,
+ PhoneUtils.getSubIdForPhoneAccountHandle(phone));
+ helper.startProvisioning(data);
+ }
+
/**
* A sync message has two purposes: to signal a new voicemail message, and to indicate the
* voicemails on the server have changed remotely (usually through the TUI). Save the new
@@ -99,13 +110,13 @@
*
* @param message The sync message to extract data from.
*/
- private void processSync(SyncMessage message) {
+ private void processSync(PhoneAccountHandle phone, SyncMessage message) {
Intent serviceIntent = null;
switch (message.getSyncTriggerEvent()) {
case OmtpConstants.NEW_MESSAGE:
Voicemail.Builder builder = Voicemail.createForInsertion(
message.getTimestampMillis(), message.getSender())
- .setPhoneAccount(mPhoneAccount)
+ .setPhoneAccount(phone)
.setSourceData(message.getId())
.setDuration(message.getLength())
.setSourcePackage(mContext.getPackageName());
@@ -116,13 +127,13 @@
Uri uri = VoicemailContract.Voicemails.insert(mContext, voicemail);
voicemail = builder.setId(ContentUris.parseId(uri)).setUri(uri).build();
serviceIntent = OmtpVvmSyncService.getSyncIntent(mContext,
- OmtpVvmSyncService.SYNC_DOWNLOAD_ONE_TRANSCRIPTION, mPhoneAccount,
+ OmtpVvmSyncService.SYNC_DOWNLOAD_ONE_TRANSCRIPTION, phone,
voicemail, true /* firstAttempt */);
}
break;
case OmtpConstants.MAILBOX_UPDATE:
serviceIntent = OmtpVvmSyncService.getSyncIntent(
- mContext, OmtpVvmSyncService.SYNC_DOWNLOAD_ONLY, mPhoneAccount,
+ mContext, OmtpVvmSyncService.SYNC_DOWNLOAD_ONLY, phone,
true /* firstAttempt */);
break;
case OmtpConstants.GREETINGS_UPDATE:
@@ -138,12 +149,12 @@
}
}
- private void updateSource(StatusMessage message) {
+ private void updateSource(PhoneAccountHandle phone, StatusMessage message) {
OmtpVvmSourceManager vvmSourceManager =
OmtpVvmSourceManager.getInstance(mContext);
if (OmtpConstants.SUCCESS.equals(message.getReturnCode())) {
- VoicemailContract.Status.setStatus(mContext, mPhoneAccount,
+ VoicemailContract.Status.setStatus(mContext, phone,
VoicemailContract.Status.CONFIGURATION_STATE_OK,
VoicemailContract.Status.DATA_CHANNEL_STATE_OK,
VoicemailContract.Status.NOTIFICATION_CHANNEL_STATE_OK);
@@ -151,24 +162,24 @@
// Save the IMAP credentials in preferences so they are persistent and can be retrieved.
VisualVoicemailSettingsUtil.setVisualVoicemailCredentialsFromStatusMessage(
mContext,
- mPhoneAccount,
+ phone,
message);
// Add the source to indicate that it is active.
- vvmSourceManager.addSource(mPhoneAccount);
+ vvmSourceManager.addSource(phone);
Intent serviceIntent = OmtpVvmSyncService.getSyncIntent(
- mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, mPhoneAccount,
+ mContext, OmtpVvmSyncService.SYNC_FULL_SYNC, phone,
true /* firstAttempt */);
mContext.startService(serviceIntent);
PhoneGlobals.getInstance().clearMwiIndicator(
- PhoneUtils.getSubIdForPhoneAccountHandle(mPhoneAccount));
+ PhoneUtils.getSubIdForPhoneAccountHandle(phone));
} 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,
+ VisualVoicemailSettingsUtil.setVisualVoicemailEnabled(mContext, phone,
/* isEnabled */ false, /* isUserSet */ true);
}
}
diff --git a/src/com/android/phone/vvm/omtp/sms/StatusMessage.java b/src/com/android/phone/vvm/omtp/sms/StatusMessage.java
index 4d8c815..ee1f07d 100644
--- a/src/com/android/phone/vvm/omtp/sms/StatusMessage.java
+++ b/src/com/android/phone/vvm/omtp/sms/StatusMessage.java
@@ -61,7 +61,7 @@
}
public StatusMessage(Bundle wrappedData) {
- mProvisioningStatus = wrappedData.getString(OmtpConstants.PROVISIONING_STATUS);
+ mProvisioningStatus = unquote(wrappedData.getString(OmtpConstants.PROVISIONING_STATUS));
mStatusReturnCode = wrappedData.getString(OmtpConstants.RETURN_CODE);
mSubscriptionUrl = wrappedData.getString(OmtpConstants.SUBSCRIPTION_URL);
mServerAddress = wrappedData.getString(OmtpConstants.SERVER_ADDRESS);
@@ -76,6 +76,16 @@
mSmtpPassword = wrappedData.getString(OmtpConstants.SMTP_PASSWORD);
}
+ private static String unquote(String string) {
+ if (string.length() < 2) {
+ return string;
+ }
+ if (string.startsWith("\"") && string.endsWith("\"")) {
+ return string.substring(1, string.length() - 1);
+ }
+ return string;
+ }
+
/**
* @return the subscriber's VVM provisioning status.
*/
diff --git a/src/com/android/phone/vvm/omtp/sms/Vvm3MessageSender.java b/src/com/android/phone/vvm/omtp/sms/Vvm3MessageSender.java
new file mode 100644
index 0000000..24c2d03
--- /dev/null
+++ b/src/com/android/phone/vvm/omtp/sms/Vvm3MessageSender.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+package com.android.phone.vvm.omtp.sms;
+
+import android.annotation.Nullable;
+import android.app.PendingIntent;
+import android.telephony.SmsManager;
+
+public class Vvm3MessageSender extends OmtpMessageSender {
+
+ /**
+ * Creates a new instance of Vvm3MessageSender.
+ *
+ * @param smsManager SMS sending library. There is a different SmsManager for each SIM.
+ * @param applicationPort If set to a value > 0 then a binary sms is sent to this port number.
+ * Otherwise, a standard text SMS is sent.
+ */
+ public Vvm3MessageSender(SmsManager smsManager, short applicationPort,
+ String destinationNumber) {
+ super(smsManager, applicationPort, destinationNumber);
+ }
+
+ @Override
+ public void requestVvmActivation(@Nullable PendingIntent sentIntent) {
+ // Activation not supported for VVM3, send a status request instead.
+ requestVvmStatus(sentIntent);
+ }
+
+ @Override
+ public void requestVvmDeactivation(@Nullable PendingIntent sentIntent) {
+ // Deactivation not supported for VVM3, do nothing
+ }
+
+
+ @Override
+ public void requestVvmStatus(@Nullable PendingIntent sentIntent) {
+ // Status message:
+ // STATUS
+ StringBuilder sb = new StringBuilder().append("STATUS");
+ sendSms(sb.toString(), sentIntent);
+ }
+
+}