Add isWpsCall System API in PhoneNumberUtils class.
Bug: 266175810
Test: atest FrameworksTelephonyTests
Change-Id: Ifef13a8bb867b402efc5eafa9ac40f77e1def019
diff --git a/core/api/current.txt b/core/api/current.txt
index 12d55f4..779c778 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -44938,6 +44938,7 @@
method public static final boolean isStartsPostDial(char);
method public static boolean isVoiceMailNumber(String);
method public static boolean isWellFormedSmsAddress(String);
+ method public static boolean isWpsCallNumber(@Nullable String);
method public static byte[] networkPortionToCalledPartyBCD(String);
method public static byte[] networkPortionToCalledPartyBCDWithLength(String);
method public static String normalizeNumber(String);
diff --git a/telephony/java/android/telephony/PhoneNumberUtils.java b/telephony/java/android/telephony/PhoneNumberUtils.java
index cf0561d..cee2efb 100644
--- a/telephony/java/android/telephony/PhoneNumberUtils.java
+++ b/telephony/java/android/telephony/PhoneNumberUtils.java
@@ -111,6 +111,14 @@
private static final String BCD_EF_ADN_EXTENDED = "*#,N;";
private static final String BCD_CALLED_PARTY_EXTENDED = "*#abc";
+ private static final String PREFIX_WPS = "*272";
+
+ // WPS prefix when CLIR is being activated for the call.
+ private static final String PREFIX_WPS_CLIR_ACTIVATE = "*31#*272";
+
+ // WPS prefix when CLIR is being deactivated for the call.
+ private static final String PREFIX_WPS_CLIR_DEACTIVATE = "#31#*272";
+
/*
* global-phone-number = ["+"] 1*( DIGIT / written-sep )
* written-sep = ("-"/".")
@@ -2943,4 +2951,15 @@
return false;
}
}
+
+ /**
+ * Check if the number is for Wireless Priority Service call.
+ * @param number The phone number used for WPS call.
+ * @return {@code true} if number matches WPS pattern and {@code false} otherwise.
+ */
+ public static boolean isWpsCallNumber(@Nullable String number) {
+ return (number != null) && (number.startsWith(PREFIX_WPS)
+ || number.startsWith(PREFIX_WPS_CLIR_ACTIVATE)
+ || number.startsWith(PREFIX_WPS_CLIR_DEACTIVATE));
+ }
}