diff options
author | inshik <inshik.shin@samsung.com> | 2011-08-12 13:52:46 +0900 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2011-08-15 17:05:25 -0700 |
commit | 4eb45cc98bdcee575cc21f5ad5754cde57197a81 (patch) | |
tree | 85d89006d06545d00bdade209567d4b78e8f6835 /telephony/java | |
parent | 89d55ad781c6f1eba77342c89136dce41a7de72a (diff) | |
download | frameworks_base-4eb45cc98bdcee575cc21f5ad5754cde57197a81.zip frameworks_base-4eb45cc98bdcee575cc21f5ad5754cde57197a81.tar.gz frameworks_base-4eb45cc98bdcee575cc21f5ad5754cde57197a81.tar.bz2 |
Add utility functions for pause and tonewait pause.
Add a function that converts a string with RFC3601 defintion
of pause and wait into android representation.
Change-Id: Id8a17c3a166422d62247acb227506549990ace12
Diffstat (limited to 'telephony/java')
-rw-r--r-- | telephony/java/android/telephony/PhoneNumberUtils.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java index c1713a5..51922da 100644 --- a/telephony/java/android/telephony/PhoneNumberUtils.java +++ b/telephony/java/android/telephony/PhoneNumberUtils.java @@ -122,6 +122,17 @@ public class PhoneNumberUtils return c == PAUSE || c == WAIT; } + private static boolean + isPause (char c){ + return c == 'p'||c == 'P'; + } + + private static boolean + isToneWait (char c){ + return c == 'w'||c == 'W'; + } + + /** Returns true if ch is not dialable or alpha char */ private static boolean isSeparator(char ch) { return !isDialable(ch) && !(('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')); @@ -278,6 +289,32 @@ public class PhoneNumberUtils return ret.toString(); } + /** + * Converts pause and tonewait pause characters + * to Android representation. + * RFC 3601 says pause is 'p' and tonewait is 'w'. + * @hide + */ + public static String convertPreDial(String phoneNumber) { + if (phoneNumber == null) { + return null; + } + int len = phoneNumber.length(); + StringBuilder ret = new StringBuilder(len); + + for (int i = 0; i < len; i++) { + char c = phoneNumber.charAt(i); + + if (isPause(c)) { + c = PAUSE; + } else if (isToneWait(c)) { + c = WAIT; + } + ret.append(c); + } + return ret.toString(); + } + /** or -1 if both are negative */ static private int minPositive (int a, int b) { |