Remove carrier id in URL_SIM_APN_LIST
In Q, query current sim APN based on {mcc, mnc, mvno}, but in the
future query based on carrier id.
Bug: 115709816
Test: run TelephonyProvider test.
Change-Id: I152d81c7d5ee015f6a2da8e6879c46a2b4b3c519
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 94ab534..098e058 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -2777,12 +2777,12 @@
}
/**
- * To find the current sim APN.
+ * To find the current sim APN. Query APN based on {MCC, MNC, MVNO} to support backward
+ * compatibility but will move to carrier id in the future.
*
* There has three steps:
- * 1. Query the APN based on carrier ID and fall back to query { MCC, MNC, MVNO }.
- * 2. If can't find the current APN, then query the parent APN. Query based on
- * MNO carrier id and { MCC, MNC }.
+ * 1. Query the APN based on { MCC, MNC, MVNO }.
+ * 2. If can't find the current APN, then query the parent APN. Query based on { MCC, MNC }.
* 3. else return empty cursor
*
*/
@@ -2794,18 +2794,12 @@
getContext().getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(subId);
SQLiteDatabase db = getReadableDatabase();
-
String mccmnc = tm.getSimOperator();
- String carrierId = String.valueOf(tm.getSimCarrierId());
- String mnoCarrierId = String.valueOf(tm.getSimMNOCarrierId());
// For query db one time, append step 1 and step 2 condition in one selection and
// separate results after the query is completed. Because IMSI has special match rule,
// so just query the MCC / MNC and filter the MVNO by ourselves
- String carrierIDSelection = CARRIER_ID + " = '" + carrierId + "' OR " +
- NUMERIC + " = '" + mccmnc + "' OR " +
- CARRIER_ID + " = '" + mnoCarrierId + "' ";
- qb.appendWhereStandalone(carrierIDSelection);
+ qb.appendWhereStandalone(NUMERIC + " = '" + mccmnc + "' ");
ret = qb.query(db, null, selection, selectionArgs, null, null, sort);
@@ -2815,7 +2809,6 @@
MatrixCursor currentCursor = new MatrixCursor(coulmnNames);
MatrixCursor parentCursor = new MatrixCursor(coulmnNames);
- int carrierIdIndex = ret.getColumnIndex(CARRIER_ID);
int numericIndex = ret.getColumnIndex(NUMERIC);
int mvnoIndex = ret.getColumnIndex(MVNO_TYPE);
int mvnoDataIndex = ret.getColumnIndex(MVNO_MATCH_DATA);
@@ -2829,24 +2822,15 @@
data.add(ret.getString(ret.getColumnIndex(column)));
}
- if (ret.getString(carrierIdIndex).equals(carrierId)) {
- // 1. APN query result based on SIM carrier id
- currentCursor.addRow(data);
- } else if (!TextUtils.isEmpty(ret.getString(numericIndex)) &&
+ if (!TextUtils.isEmpty(ret.getString(numericIndex)) &&
ApnSettingUtils.mvnoMatches(iccRecords,
ApnSetting.getMvnoTypeIntFromString(ret.getString(mvnoIndex)),
ret.getString(mvnoDataIndex))) {
- // 1. APN query result based on legacy SIM MCC/MCC and MVNO in case APN carrier id
- // migration is not 100%. some APNSettings can not find match id.
- // TODO: remove legacy {mcc,mnc, mvno} support in the future.
+ // 1. APN query result based on legacy SIM MCC/MCC and MVNO
currentCursor.addRow(data);
- } else if (ret.getString(carrierIdIndex).equals(mnoCarrierId)) {
- // 2. APN query result based on SIM MNO carrier id in case no APN found from
- // exact carrier id fallback to query the MNO carrier id
- parentCursor.addRow(data);
- } else if (!TextUtils.isEmpty(ret.getString(numericIndex))) {
+ } else if (!TextUtils.isEmpty(ret.getString(numericIndex)) &&
+ TextUtils.isEmpty(ret.getString(mvnoIndex))) {
// 2. APN query result based on SIM MCC/MNC
- // TODO: remove legacy {mcc, mnc} support in the future.
parentCursor.addRow(data);
}
}
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index 91a7a46..f9acd48 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -1447,46 +1447,8 @@
@Test
@SmallTest
- public void testSIMAPNLIST_APNMatchTheCarrierID() {
- // Test on getCurrentAPNList() step 1
- TelephonyManager telephonyManager =
- ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
- doReturn(telephonyManager).when(telephonyManager).createForSubscriptionId(anyInt());
-
- final String apnName = "apnName";
- final String carrierName = "name";
- final int carrierID = 100;
- final String numeric = TEST_OPERATOR;
- doReturn(carrierID).when(telephonyManager).getSimCarrierId();
- doReturn(numeric).when(telephonyManager).getSimOperator();
-
- // Insert the APN
- ContentValues contentValues = new ContentValues();
- contentValues.put(Carriers.APN, apnName);
- contentValues.put(Carriers.NAME, carrierName);
- contentValues.put(Carriers.CARRIER_ID, carrierID);
- mContentResolver.insert(Carriers.CONTENT_URI, contentValues);
-
- // Query DB
- final String[] testProjection =
- {
- Carriers.APN,
- Carriers.NAME,
- Carriers.CARRIER_ID,
- };
- Cursor cursor = mContentResolver.query(URL_SIM_APN_LIST,
- testProjection, null, null, null);
-
- cursor.moveToFirst();
- assertEquals(apnName, cursor.getString(0));
- assertEquals(carrierName, cursor.getString(1));
- assertEquals(String.valueOf(carrierID), cursor.getString(2));
- }
-
- @Test
- @SmallTest
public void testSIMAPNLIST_APNMatchTheMCCMNCAndMVNO() {
- // Test on getCurrentAPNList() step 2
+ // Test on getCurrentAPNList() step 1
TelephonyManager telephonyManager =
((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
doReturn(telephonyManager).when(telephonyManager).createForSubscriptionId(anyInt());
@@ -1529,48 +1491,8 @@
@Test
@SmallTest
- public void testSIMAPNLIST_APNMatchTheMNOCarrierID() {
- // Test on getCurrentAPNList() step 3
- TelephonyManager telephonyManager =
- ((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
- doReturn(telephonyManager).when(telephonyManager).createForSubscriptionId(anyInt());
-
- final String apnName = "apnName";
- final String carrierName = "name";
- final int carrierId = 100;
- final int mnoCarrierId = 101;
- final String numeric = TEST_OPERATOR;
- doReturn(carrierId).when(telephonyManager).getSimCarrierId();
- doReturn(mnoCarrierId).when(telephonyManager).getSimMNOCarrierId();
- doReturn(numeric).when(telephonyManager).getSimOperator();
-
- // Insert the APN and DB only have the MNO carrier id APN
- ContentValues contentValues = new ContentValues();
- contentValues.put(Carriers.APN, apnName);
- contentValues.put(Carriers.NAME, carrierName);
- contentValues.put(Carriers.CARRIER_ID, mnoCarrierId);
- mContentResolver.insert(Carriers.CONTENT_URI, contentValues);
-
- // Query DB
- final String[] testProjection =
- {
- Carriers.APN,
- Carriers.NAME,
- Carriers.CARRIER_ID,
- };
- Cursor cursor = mContentResolver.query(URL_SIM_APN_LIST,
- testProjection, null, null, null);
-
- cursor.moveToFirst();
- assertEquals(apnName, cursor.getString(0));
- assertEquals(carrierName, cursor.getString(1));
- assertEquals(String.valueOf(mnoCarrierId), cursor.getString(2));
- }
-
- @Test
- @SmallTest
public void testSIMAPNLIST_APNMatchTheParentMCCMNC() {
- // Test on getCurrentAPNList() step 4
+ // Test on getCurrentAPNList() step 2
TelephonyManager telephonyManager =
((TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE));
doReturn(telephonyManager).when(telephonyManager).createForSubscriptionId(anyInt());