Remove usage of hidden API TelephonyManager.getLine1Number(int)
This CL creats subscription specific telephony manager instance
and then invokes getLine1Number() API.
Bug: 140908357
Test: Build
Change-Id: Ib49098dcf3a0718d498d829765ba7f52d9a1de09
diff --git a/telephony/common/com/google/android/mms/pdu/PduPersister.java b/telephony/common/com/google/android/mms/pdu/PduPersister.java
index 95ae409..b237705 100755
--- a/telephony/common/com/google/android/mms/pdu/PduPersister.java
+++ b/telephony/common/com/google/android/mms/pdu/PduPersister.java
@@ -291,15 +291,11 @@
@UnsupportedAppUsage
private final ContentResolver mContentResolver;
private final DrmManagerClient mDrmManagerClient;
- @UnsupportedAppUsage
- private final TelephonyManager mTelephonyManager;
private PduPersister(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
mDrmManagerClient = new DrmManagerClient(context);
- mTelephonyManager = (TelephonyManager)context
- .getSystemService(Context.TELEPHONY_SERVICE);
}
/** Get(or create if not exist) an instance of PduPersister */
@@ -1453,7 +1449,8 @@
if (excludeMyNumber) {
// Build a list of my phone numbers from the various sims.
for (int subid : subscriptionManager.getActiveSubscriptionIdList()) {
- final String myNumber = mTelephonyManager.getLine1Number(subid);
+ final String myNumber = mContext.getSystemService(TelephonyManager.class).
+ createForSubscriptionId(subid).getLine1Number();
if (myNumber != null) {
myPhoneNumbers.add(myNumber);
}