[Telephony Mainline] Use new method for mainline
- TelephonyBackupAgent.getActiveSubscriptionInfoList(boolean)
-> getActiveAndHiddenSubscriptionInfoList()
- TelephonyProvider
- TelephonyManager.from -> getSystemService
- TelephonyManager.getSimOperator(int) -> getSimOperator()
Bug: 144972924
Test: make & atest TelephonyProviderTest/TelephonyBackupAgentTest
Change-Id: I9998906fa258632bb4e780fae80aa5bf89d28226
Merged-In: I9998906fa258632bb4e780fae80aa5bf89d28226
diff --git a/src/com/android/providers/telephony/TelephonyBackupAgent.java b/src/com/android/providers/telephony/TelephonyBackupAgent.java
index 437b5a2..b3c0d99 100644
--- a/src/com/android/providers/telephony/TelephonyBackupAgent.java
+++ b/src/com/android/providers/telephony/TelephonyBackupAgent.java
@@ -319,7 +319,7 @@
final SubscriptionManager subscriptionManager = SubscriptionManager.from(this);
if (subscriptionManager != null) {
final List<SubscriptionInfo> subInfo =
- subscriptionManager.getActiveSubscriptionInfoList(/* userVisibleonly */false);
+ subscriptionManager.getActiveAndHiddenSubscriptionInfoList();
if (subInfo != null) {
for (SubscriptionInfo sub : subInfo) {
final String phoneNumber = getNormalizedNumber(sub);
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index f90c216..74bca16 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -2797,8 +2797,6 @@
String[] selectionArgs, String sort) {
if (VDBG) log("query: url=" + url + ", projectionIn=" + projectionIn + ", selection="
+ selection + "selectionArgs=" + selectionArgs + ", sort=" + sort);
- TelephonyManager mTelephonyManager =
- (TelephonyManager)getContext().getSystemService(Context.TELEPHONY_SERVICE);
int subId = SubscriptionManager.getDefaultSubscriptionId();
String subIdString;
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
@@ -2819,7 +2817,9 @@
return null;
}
if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- constraints.add(NUMERIC + " = '" + mTelephonyManager.getSimOperator(subId) + "'");
+ TelephonyManager telephonyManager = getContext()
+ .getSystemService(TelephonyManager.class).createForSubscriptionId(subId);
+ constraints.add(NUMERIC + " = '" + telephonyManager.getSimOperator() + "'");
// TODO b/74213956 turn this back on once insertion includes correct sub id
// constraints.add(SUBSCRIPTION_ID + "=" + subIdString);
}
@@ -3842,8 +3842,8 @@
return null;
}
TelephonyManager telephonyManager =
- (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
- String simOperator = telephonyManager.getSimOperator(subId);
+ getContext().getSystemService(TelephonyManager.class).createForSubscriptionId(subId);
+ String simOperator = telephonyManager.getSimOperator();
Cursor cursor = db.query(CARRIERS_TABLE, new String[] {MVNO_TYPE, MVNO_MATCH_DATA},
NUMERIC + "='" + simOperator + "'", null, null, null, DEFAULT_SORT_ORDER);
String where = null;
@@ -3878,7 +3878,7 @@
@VisibleForTesting
IccRecords getIccRecords(int subId) {
TelephonyManager telephonyManager =
- TelephonyManager.from(getContext()).createForSubscriptionId(subId);
+ getContext().getSystemService(TelephonyManager.class).createForSubscriptionId(subId);
int family = telephonyManager.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM ?
UiccController.APP_FAM_3GPP : UiccController.APP_FAM_3GPP2;
return UiccController.getInstance().getIccRecords(
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index 47c1dc6..a644534 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -183,6 +183,16 @@
}
@Override
+ public String getSystemServiceName(Class<?> serviceClass) {
+ if (serviceClass.equals(TelephonyManager.class)) {
+ return Context.TELEPHONY_SERVICE;
+ } else {
+ Log.d(TAG, "getSystemServiceName: returning null");
+ return null;
+ }
+ }
+
+ @Override
public Resources getResources() {
Log.d(TAG, "getResources: returning null");
return null;