@@ -54,6 +54,12 @@ public class PhoneNumberUtils
5454 public static final char WAIT = ';' ;
5555 public static final char WILD = 'N' ;
5656
57+ /*
58+ * Calling Line Identification Restriction (CLIR)
59+ */
60+ private static final String CLIR_ON = "*31#+" ;
61+ private static final String CLIR_OFF = "#31#+" ;
62+
5763 /*
5864 * TOA = TON + NPI
5965 * See TS 24.008 section 10.5.4.7 for details.
@@ -179,8 +185,6 @@ public static String getNumberFromIntent(Intent intent, Context context) {
179185 * Please note that the GSM wild character is allowed in the result.
180186 * This must be resolved before dialing.
181187 *
182- * Allows + only in the first position in the result string.
183- *
184188 * Returns null if phoneNumber == null
185189 */
186190 public static String
@@ -203,6 +207,11 @@ public static String getNumberFromIntent(Intent intent, Context context) {
203207 }
204208 }
205209
210+ int pos = addPlusChar (phoneNumber );
211+ if (pos >= 0 && ret .length () > pos ) {
212+ ret .insert (pos , '+' );
213+ }
214+
206215 return ret .toString ();
207216 }
208217
@@ -304,6 +313,28 @@ private static void log(String msg) {
304313 }
305314 }
306315
316+ /** GSM codes
317+ * Finds if a GSM code includes the international prefix (+).
318+ *
319+ * @param number the number to dial.
320+ *
321+ * @return the position where the + char will be inserted, -1 if the GSM code was not found.
322+ */
323+ private static int
324+ addPlusChar (String number ) {
325+ int pos = -1 ;
326+
327+ if (number .startsWith (CLIR_OFF )) {
328+ pos = CLIR_OFF .length () - 1 ;
329+ }
330+
331+ if (number .startsWith (CLIR_ON )) {
332+ pos = CLIR_ON .length () - 1 ;
333+ }
334+
335+ return pos ;
336+ }
337+
307338 /**
308339 * Extracts the post-dial sequence of DTMF control digits, pauses, and
309340 * waits. Strips separators. This string may be empty, but will not be null
0 commit comments