Check whether dialable only

It allows to call to any sender such as *20(Voice Mail Number for
Chile Claro).

Test: Manual

Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
Change-Id: Ifca83c5f05018de627fa38318fd4b6db20370910
This commit is contained in:
Taesu Lee
2020-05-25 14:30:02 +09:00
parent eb1e0417eb
commit dbc43316cf
2 changed files with 17 additions and 9 deletions

View File

@@ -700,7 +700,7 @@ public class ConversationData extends BindableData {
final ParticipantData participant = this.getOtherParticipant(); final ParticipantData participant = this.getOtherParticipant();
if (participant != null) { if (participant != null) {
final String phoneNumber = participant.getSendDestination(); final String phoneNumber = participant.getSendDestination();
if (!TextUtils.isEmpty(phoneNumber) && MmsSmsUtils.isPhoneNumber(phoneNumber)) { if (!TextUtils.isEmpty(phoneNumber) && MmsSmsUtils.isDialable(phoneNumber)) {
return phoneNumber; return phoneNumber;
} }
} }

View File

@@ -100,19 +100,27 @@ public class MmsSmsUtils {
return match.matches(); return match.matches();
} }
/** True if c is ISO-LATIN characters 0-9, *, # , + */
public static final boolean isDialable(char c) {
return (c >= '0' && c <= '9') || c == '*' || c == '#' || c == '+';
}
/** /**
* Returns true if the number is a Phone number * Returns true if the address is a dialable phone number.
* *
* @param number the input number to be tested * @param address the input address to be tested
* @return true if number is a Phone number * @return true if address is a dialable phone number
*/ */
public static boolean isPhoneNumber(final String number) { public static boolean isDialable(final String address) {
if (TextUtils.isEmpty(number)) { if (TextUtils.isEmpty(address)) {
return false; return false;
} }
for (int i = 0, count = address.length(); i < count; i++) {
final Matcher match = Patterns.PHONE.matcher(number); if (!isDialable(address.charAt(i))) {
return match.matches(); return false;
}
}
return true;
} }
/** /**