Added nr advanced calling settings support
Added a telephony provider entry for storing the
user's settings.
Bug: 202150953
Test: atest
Change-Id: Ifaaf4174c7dc0bdb72fabc9117207edc206c07fb
Merged-In: Ifaaf4174c7dc0bdb72fabc9117207edc206c07fb
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 0ff9fc6..0638461 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -155,7 +155,7 @@
private static final boolean DBG = true;
private static final boolean VDBG = false; // STOPSHIP if true
- private static final int DATABASE_VERSION = 51 << 16;
+ private static final int DATABASE_VERSION = 52 << 16;
private static final int URL_UNKNOWN = 0;
private static final int URL_TELEPHONY = 1;
private static final int URL_CURRENT = 2;
@@ -439,7 +439,8 @@
SIM_INFO_COLUMNS_TO_BACKUP.put(
Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
Cursor.FIELD_TYPE_STRING);
-
+ SIM_INFO_COLUMNS_TO_BACKUP.put(
+ Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED, Cursor.FIELD_TYPE_INTEGER);
}
@VisibleForTesting
@@ -564,7 +565,8 @@
+ Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT,"
+ Telephony.SimInfo.COLUMN_VOIMS_OPT_IN_STATUS + " INTEGER DEFAULT 0,"
+ Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING + " INTEGER DEFAULT 0,"
- + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS + " TEXT"
+ + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS + " TEXT,"
+ + Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED + " INTEGER DEFAULT -1"
+ ");";
}
@@ -1688,6 +1690,21 @@
}
oldVersion = 51 << 16 | 6;
}
+
+ if (oldVersion < (52 << 16 | 6)) {
+ try {
+ // Try to update the siminfo table. It might not be there.
+ db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+ + Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED
+ + " INTEGER DEFAULT -1;");
+ } catch (SQLiteException e) {
+ if (DBG) {
+ log("onUpgrade skipping " + SIMINFO_TABLE + " upgrade. " +
+ "The table will get created in onOpen.");
+ }
+ }
+ oldVersion = 52 << 16 | 6;
+ }
if (DBG) {
log("dbh.onUpgrade:- db=" + db + " oldV=" + oldVersion + " newV=" + newVersion);
}
@@ -3492,7 +3509,7 @@
PersistableBundle backedUpSimInfoEntry, int backupDataFormatVersion,
String isoCountryCodeFromDb,
List<String> wfcRestoreBlockedCountries) {
- if (DATABASE_VERSION != 51 << 16) {
+ if (DATABASE_VERSION != 52 << 16) {
throw new AssertionError("The database schema has been updated which might make "
+ "the format of #BACKED_UP_SIM_SPECIFIC_SETTINGS_FILE outdated. Make sure to "
+ "1) review whether any of the columns in #SIM_INFO_COLUMNS_TO_BACKUP have "
@@ -3534,6 +3551,12 @@
* Also make sure to add necessary removal of sensitive settings in
* polishContentValues(ContentValues contentValues).
*/
+ if (backupDataFormatVersion >= 52 << 16) {
+ contentValues.put(Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
+ backedUpSimInfoEntry.getInt(
+ Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED,
+ DEFAULT_INT_COLUMN_VALUE));
+ }
if (backupDataFormatVersion >= 51 << 16) {
contentValues.put(Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
backedUpSimInfoEntry.getString(
@@ -4747,6 +4770,12 @@
Telephony.SimInfo.COLUMN_VOIMS_OPT_IN_STATUS),
usingSubId, subId), null, true, UserHandle.USER_ALL);
}
+ if (values.containsKey(Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED)) {
+ getContext().getContentResolver().notifyChange(getNotifyContentUri(
+ Uri.withAppendedPath(Telephony.SimInfo.CONTENT_URI,
+ Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED),
+ usingSubId, subId), null, true, UserHandle.USER_ALL);
+ }
break;
default:
getContext().getContentResolver().notifyChange(
diff --git a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
index 6f3f842..eb03443 100644
--- a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
@@ -266,6 +266,23 @@
Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS));
}
+ @Test
+ public void databaseHelperOnUpgrade_hasNrAdvancedCallingEnabledField() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasNrAdvancedCallingEnabledField");
+ // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+ SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+ mHelper.onUpgrade(db, (4 << 16), TelephonyProvider.getVersion(mContext));
+
+ // the upgraded db must have the
+ // Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED field
+ Cursor cursor = db.query("siminfo", null, null, null, null, null, null);
+ String[] upgradedColumns = cursor.getColumnNames();
+ Log.d(TAG, "siminfo columns: " + Arrays.toString(upgradedColumns));
+
+ assertTrue(Arrays.asList(upgradedColumns).contains(
+ Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED));
+ }
+
/**
* Helper for an in memory DB used to test the TelephonyProvider#DatabaseHelper.
*
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
index 1a9b46c..b1cb97e 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -213,6 +213,7 @@
contentValues.put(Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING, arbitraryIntVal);
contentValues.put(Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING_SELECTED_CONTACTS,
arbitraryStringVal);
+ contentValues.put(Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED, arbitraryIntVal);
if (isoCountryCode != null) {
contentValues.put(Telephony.SimInfo.COLUMN_ISO_COUNTRY_CODE, isoCountryCode);
}
@@ -790,7 +791,10 @@
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_MODE));
assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_ROAMING_MODE));
-
+ assertEquals(
+ ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+ getIntValueFromCursor(
+ cursor, Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED));
assertRestoredSubIdIsRemembered();
}
@@ -831,7 +835,10 @@
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_MODE));
assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_2,
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_ROAMING_MODE));
-
+ assertEquals(
+ ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_2,
+ getIntValueFromCursor(
+ cursor, Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED));
assertRestoredSubIdIsRemembered();
}
@@ -872,7 +879,10 @@
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_MODE));
assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_3,
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_ROAMING_MODE));
-
+ assertEquals(
+ ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_3,
+ getIntValueFromCursor(
+ cursor, Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED));
assertRestoredSubIdIsRemembered();
}
@@ -914,7 +924,10 @@
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_MODE));
assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
getIntValueFromCursor(cursor, Telephony.SimInfo.COLUMN_WFC_IMS_ROAMING_MODE));
-
+ assertEquals(
+ ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+ getIntValueFromCursor(
+ cursor, Telephony.SimInfo.COLUMN_NR_ADVANCED_CALLING_ENABLED));
assertRestoredSubIdIsRemembered();
}