Update Telecom to use getSubId* method
Remove custom code to convert PhoneAccount to sub-id from telecom and
start using the TelephonyManager version.
Change-Id: If324b4e577e4c0a43f93dd43e833d48a65e949cd
diff --git a/src/com/android/server/telecom/PhoneAccountRegistrar.java b/src/com/android/server/telecom/PhoneAccountRegistrar.java
index eb3248e..bd6e2d2 100644
--- a/src/com/android/server/telecom/PhoneAccountRegistrar.java
+++ b/src/com/android/server/telecom/PhoneAccountRegistrar.java
@@ -36,11 +36,13 @@
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.AtomicFile;
import android.util.Base64;
import android.util.Xml;
+
// TODO: Needed for move to system service: import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.FastXmlSerializer;
@@ -136,15 +138,15 @@
*/
public int getSubscriptionIdForPhoneAccount(PhoneAccountHandle accountHandle) {
PhoneAccount account = getPhoneAccountInternal(accountHandle);
- if (account == null
- || !account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
- || !TextUtils.isDigitsOnly(accountHandle.getId())
- || !isVisibleForUser(accountHandle)) {
- // Since no decimals or negative numbers can be valid subscription ids, only a string of
- // numbers can be subscription id
- return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
+
+ if (account != null
+ && account.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)
+ && isVisibleForUser(accountHandle)) {
+ TelephonyManager tm =
+ (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ return tm.getSubIdForPhoneAccount(account);
}
- return Integer.parseInt(accountHandle.getId());
+ return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
}
/**