From ba93c4fe5016341d06be1ce47410885522e09a58 Mon Sep 17 00:00:00 2001 From: twyen Date: Fri, 29 Jun 2018 13:05:50 -0700 Subject: Strip +1 when subscribing to VVM3 The self provisioning gateway expects 10 digit US national number. TEST=manual, VVM subscription cannot be automated. Bug: 110390254 Test: manual, VVM subscription cannot be automated. PiperOrigin-RevId: 202695056 Change-Id: I9368a4e04d50f4a402d994f7bef3fb1e4b654940 --- .../voicemail/impl/protocol/Vvm3Subscriber.java | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'java/com') diff --git a/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java b/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java index 3bbda4797..41598e047 100644 --- a/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java +++ b/java/com/android/voicemail/impl/protocol/Vvm3Subscriber.java @@ -89,7 +89,7 @@ public class Vvm3Subscriber { private static final String OPERATION_GET_SPG_URL = "retrieveSPGURL"; private static final String SPG_URL_TAG = "spgurl"; private static final String TRANSACTION_ID_TAG = "transactionid"; - //language=XML + // language=XML private static final String VMG_XML_REQUEST_FORMAT = "" + "" @@ -159,6 +159,7 @@ public class Vvm3Subscriber { } @WorkerThread + @SuppressWarnings("missingPermission") public Vvm3Subscriber( ActivationTask task, PhoneAccountHandle handle, @@ -175,11 +176,23 @@ public class Vvm3Subscriber { // Assuming getLine1Number() will work with VVM3. For unprovisioned users the IMAP username // is not included in the status SMS, thus no other way to get the current phone number. number = - this.helper - .getContext() - .getSystemService(TelephonyManager.class) - .createForPhoneAccountHandle(this.handle) - .getLine1Number(); + stripInternational( + this.helper + .getContext() + .getSystemService(TelephonyManager.class) + .createForPhoneAccountHandle(this.handle) + .getLine1Number()); + } + + /** + * Self provisioning gateway expects 10 digit national format, but {@link + * TelephonyManager#getLine1Number()} might return e164 with "+1" at front. + */ + private static String stripInternational(String number) { + if (number.startsWith("+1")) { + number = number.substring(2); + } + return number; } @WorkerThread -- cgit v1.2.3