Consolidate subscription ID acquisition.
Update TelephonyConnectionService to use
PhoneUtil.getSubIdForPhoneAccount instead of duplicating the code.
Change-Id: I7fbbc406a45ccea0e7a544d311878697562273b8
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 761d11b..7da2e1f 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -2462,14 +2462,18 @@
}
public static int getSubIdForPhoneAccount(PhoneAccount phoneAccount) {
- if (phoneAccount != null) {
- PhoneAccountHandle handle = phoneAccount.getAccountHandle();
- if (handle != null && handle.getComponentName().equals(getPstnConnectionServiceName()) &&
- phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
- String id = handle.getId();
- if (TextUtils.isDigitsOnly(id)) {
- return Integer.parseInt(id);
- }
+ if (phoneAccount != null
+ && phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
+ return getSubIdForPhoneAccountHandle(phoneAccount.getAccountHandle());
+ }
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+ }
+
+ public static int getSubIdForPhoneAccountHandle(PhoneAccountHandle handle) {
+ if (handle != null && handle.getComponentName().equals(getPstnConnectionServiceName())) {
+ String id = handle.getId();
+ if (TextUtils.isDigitsOnly(id)) {
+ return Integer.parseInt(id);
}
}
return SubscriptionManager.INVALID_SUBSCRIPTION_ID;