Merge Android 14 QPR3 to AOSP main
Bug: 346855327
Merged-In: I9868dac19bb470e16e0d843650e4c9505b552bd8
Change-Id: I11de4984276f441b165f57291cd22c79e1182432
diff --git a/src/com/android/providers/telephony/ProviderUtil.java b/src/com/android/providers/telephony/ProviderUtil.java
index ac6e5f7..79e7cc8 100644
--- a/src/com/android/providers/telephony/ProviderUtil.java
+++ b/src/com/android/providers/telephony/ProviderUtil.java
@@ -237,7 +237,7 @@
emergencyNumberList = tm.getEmergencyNumberList();
}
} catch (Exception e) {
- Log.e(TAG, "Cannot get emergency number list: " + e);
+ Log.e(TAG, "Cannot get emergency number list", e);
}
String selectionByEmergencyNumber = null;
@@ -287,7 +287,18 @@
}
ActivityManager am = context.getSystemService(ActivityManager.class);
+ if (am == null) {
+ Log.d(TAG, "logRunningTelephonyProviderProcesses: ActivityManager service is not"
+ + " available");
+ return;
+ }
+
List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
+ if (processInfos == null) {
+ Log.d(TAG, "logRunningTelephonyProviderProcesses: processInfos is null");
+ return;
+ }
+
StringBuilder sb = new StringBuilder();
for (ActivityManager.RunningAppProcessInfo processInfo : processInfos) {
if (Arrays.asList(processInfo.pkgList).contains(TELEPHONY_PROVIDER_PACKAGE)
diff --git a/src/com/android/providers/telephony/SmsProvider.java b/src/com/android/providers/telephony/SmsProvider.java
index 0819e29..c00e0c8 100644
--- a/src/com/android/providers/telephony/SmsProvider.java
+++ b/src/com/android/providers/telephony/SmsProvider.java
@@ -26,6 +26,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.UriMatcher;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.MatrixCursor;
@@ -119,6 +120,11 @@
return true;
}
+ private boolean hasCalling() {
+ return getContext().getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_TELEPHONY_CALLING);
+ }
+
/**
* Return the proper view of "sms" table for the current access status.
*
@@ -350,7 +356,7 @@
// Filter SMS based on subId and emergency numbers.
selectionBySubIds = ProviderUtil.getSelectionBySubIds(getContext(),
callerUserHandle);
- if (qb.getTables().equals(smsTable)) {
+ if (hasCalling() && qb.getTables().equals(smsTable)) {
selectionByEmergencyNumbers = ProviderUtil
.getSelectionByEmergencyNumbers(getContext());
}
diff --git a/src/com/android/providers/telephony/TelephonyProvider.java b/src/com/android/providers/telephony/TelephonyProvider.java
index 4fbeed4..4ecf6b0 100644
--- a/src/com/android/providers/telephony/TelephonyProvider.java
+++ b/src/com/android/providers/telephony/TelephonyProvider.java
@@ -164,7 +164,7 @@
private static final boolean DBG = true;
private static final boolean VDBG = false; // STOPSHIP if true
- private static final int DATABASE_VERSION = 67 << 16;
+ private static final int DATABASE_VERSION = 71 << 16;
private static final int URL_UNKNOWN = 0;
private static final int URL_TELEPHONY = 1;
private static final int URL_CURRENT = 2;
@@ -286,6 +286,14 @@
private boolean mManagedApnEnforced;
+ /**
+ * Lazy tracking SubscriptionManager#getDefaultSubscriptionId for db operation to prevent race
+ * condition.
+ * Make sure the call is outside of instance synchronization to prevent dead lock between
+ * SubscriptionManager lock and telephony provider lock.
+ */
+ private int mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+
private final LocalLog mLocalLog = new LocalLog(128);
/**
@@ -464,6 +472,13 @@
Cursor.FIELD_TYPE_INTEGER);
SIM_INFO_COLUMNS_TO_BACKUP.put(
Telephony.SimInfo.COLUMN_IS_NTN, Cursor.FIELD_TYPE_INTEGER);
+ SIM_INFO_COLUMNS_TO_BACKUP.put(
+ Telephony.SimInfo.COLUMN_TRANSFER_STATUS, Cursor.FIELD_TYPE_INTEGER);
+ SIM_INFO_COLUMNS_TO_BACKUP.put(
+ Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS, Cursor.FIELD_TYPE_INTEGER);
+ SIM_INFO_COLUMNS_TO_BACKUP.put(
+ Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
+ Cursor.FIELD_TYPE_STRING);
}
@VisibleForTesting
@@ -608,8 +623,13 @@
+ UserHandle.USER_NULL + ","
+ Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT 0,"
+ Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
- + " INTEGER DEFAULT 0, "
- + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0"
+ + " INTEGER DEFAULT 1, "
+ + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0, "
+ + Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES + " INTEGER DEFAULT "
+ + SubscriptionManager.getAllServiceCapabilityBitmasks() + ","
+ + Telephony.SimInfo.COLUMN_TRANSFER_STATUS + " INTEGER DEFAULT 0,"
+ + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS + " INTEGER DEFAULT 0,"
+ + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS + " TEXT"
+ ");";
}
@@ -715,10 +735,15 @@
}
}
- static public ContentValues setDefaultValue(ContentValues values) {
+
+ /**
+ * Put the default subscription Id into the provided convent values.
+ * @param values The content values to populate.
+ * @return The populated content values.
+ */
+ public ContentValues setDefaultValue(ContentValues values) {
if (!values.containsKey(SUBSCRIPTION_ID)) {
- int subId = SubscriptionManager.getDefaultSubscriptionId();
- values.put(SUBSCRIPTION_ID, subId);
+ values.put(SUBSCRIPTION_ID, mDefaultSubId);
}
return values;
@@ -878,11 +903,7 @@
long oldChecksum = getApnConfChecksum();
if (DBG) log("newChecksum: " + newChecksum);
if (DBG) log("oldChecksum: " + oldChecksum);
- if (newChecksum == oldChecksum) {
- return false;
- } else {
- return true;
- }
+ return newChecksum != oldChecksum;
}
/**
@@ -2015,6 +2036,71 @@
oldVersion = 67 << 16 | 6;
}
+ if (oldVersion < (68 << 16 | 6)) {
+ try {
+ db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+ + Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES
+ + " INTEGER DEFAULT 7;");
+ } catch (SQLiteException e) {
+ if (DBG) {
+ log("onUpgrade failed to update " + SIMINFO_TABLE
+ + " to add cellular service capabilities");
+ }
+
+ }
+ oldVersion = 68 << 16 | 6;
+ }
+
+ if (oldVersion < (69 << 16 | 6)) {
+ try {
+ // If default value of COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER column is
+ // set to 0, then update it to 1
+ db.execSQL("UPDATE " + SIMINFO_TABLE + " SET "
+ + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER + "=1"
+ + " WHERE "
+ + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+ + "=0;");
+ } catch (SQLiteException e) {
+ if (DBG) {
+ log("onUpgrade failed to update " + SIMINFO_TABLE
+ + " to add cellular service capabilities");
+ }
+ }
+ oldVersion = 69 << 16 | 6;
+ }
+ if (oldVersion < (70 << 16 | 6)) {
+ try {
+ db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+ + Telephony.SimInfo.COLUMN_TRANSFER_STATUS
+ + " INTEGER DEFAULT 0;");
+ } catch (SQLiteException e) {
+ if (DBG) {
+ log("onUpgrade failed to update " + SIMINFO_TABLE
+ + " to add transfer status");
+ }
+
+ }
+ oldVersion = 70 << 16 | 6;
+ }
+
+ if (oldVersion < (71 << 16 | 6)) {
+ try {
+ // Try to update the siminfo table with new columns.
+ db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+ + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS
+ + " INTEGER DEFAULT 0;");
+ db.execSQL("ALTER TABLE " + SIMINFO_TABLE + " ADD COLUMN "
+ + Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS
+ + " TEXT DEFAULT '';");
+ } catch (SQLiteException e) {
+ if (DBG) {
+ log("onUpgrade failed to update " + SIMINFO_TABLE
+ + " to add satellite entitlement status and plmns");
+ }
+ }
+ oldVersion = 71 << 16 | 6;
+ }
+
if (DBG) {
log("dbh.onUpgrade:- db=" + db + " oldV=" + oldVersion + " newV=" + newVersion);
}
@@ -3247,6 +3333,7 @@
@Override
public boolean onCreate() {
mOpenHelper = new DatabaseHelper(getContext());
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
boolean isNewBuild = false;
String newBuildId = SystemProperties.get("ro.build.id", null);
SharedPreferences sp = getContext().getSharedPreferences(BUILD_ID_FILE,
@@ -3888,7 +3975,7 @@
PersistableBundle backedUpSimInfoEntry, int backupDataFormatVersion,
String isoCountryCodeFromDb,
List<String> wfcRestoreBlockedCountries) {
- if (DATABASE_VERSION != 67 << 16) {
+ if (DATABASE_VERSION != 71 << 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 "
@@ -3930,6 +4017,21 @@
* Also make sure to add necessary removal of sensitive settings in
* polishContentValues(ContentValues contentValues).
*/
+ if (backupDataFormatVersion >= 71 << 16) {
+ contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
+ backedUpSimInfoEntry.getInt(
+ Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS,
+ DEFAULT_INT_COLUMN_VALUE));
+ contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
+ backedUpSimInfoEntry.getString(
+ Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS,
+ DEFAULT_STRING_COLUMN_VALUE));
+ }
+ if (backupDataFormatVersion >= 70 << 16) {
+ contentValues.put(Telephony.SimInfo.COLUMN_TRANSFER_STATUS,
+ backedUpSimInfoEntry.getInt(Telephony.SimInfo.COLUMN_TRANSFER_STATUS,
+ DEFAULT_INT_COLUMN_VALUE));
+ }
if (backupDataFormatVersion >= 64 << 16) {
contentValues.put(Telephony.SimInfo.COLUMN_IS_NTN,
backedUpSimInfoEntry.getInt(Telephony.SimInfo.COLUMN_IS_NTN,
@@ -4101,12 +4203,20 @@
int match = s_urlMatcher.match(url);
checkPermissionCompat(match, projectionIn);
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
return queryInternal(url, projectionIn, selection, selectionArgs, sort);
}
- private synchronized Cursor queryInternal(Uri url, String[] projectionIn, String selection,
+ /**
+ * Internally queries the database.
+ *
+ * Things to keep in mind when writing code for this function:
+ * - Must be wrapped in synchronized before quering database.
+ * - Please call external APIs, that use locks, outside of synchronized.
+ */
+ private Cursor queryInternal(Uri url, String[] projectionIn, String selection,
String[] selectionArgs, String sort) {
- int subId = SubscriptionManager.getDefaultSubscriptionId();
+ int subId = mDefaultSubId;
String subIdString;
SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
qb.setStrict(true); // a little protection from injection attacks
@@ -4125,7 +4235,6 @@
loge("NumberFormatException" + e);
return null;
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
qb.appendWhereStandalone(IS_NOT_OWNED_BY_DPC);
return getSubscriptionMatchingAPNList(qb, projectionIn, selection, selectionArgs,
sort, subId);
@@ -4146,7 +4255,6 @@
loge("NumberFormatException" + e);
return null;
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
// TODO b/74213956 turn this back on once insertion includes correct sub id
// constraints.add(SUBSCRIPTION_ID + "=" + subIdString);
}
@@ -4174,7 +4282,6 @@
loge("NumberFormatException" + e);
return null;
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
// TODO b/74213956 turn this back on once insertion includes correct sub id
// constraints.add(SUBSCRIPTION_ID + "=" + subIdString);
}
@@ -4193,7 +4300,6 @@
loge("NumberFormatException" + e);
return null;
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
// TODO b/74213956 turn this back on once insertion includes correct sub id
// constraints.add(SUBSCRIPTION_ID + "=" + subIdString);
}
@@ -4312,29 +4418,32 @@
qb.appendWhere(TextUtils.join(" AND ", constraints));
}
- SQLiteDatabase db = getReadableDatabase();
- Cursor ret = null;
- try {
- // Exclude entries marked deleted
- if (CARRIERS_TABLE.equals(qb.getTables())) {
- if (TextUtils.isEmpty(selection)) {
- selection = "";
- } else {
- selection += " and ";
+ synchronized (this) {
+ SQLiteDatabase db = getReadableDatabase();
+ Cursor ret = null;
+ try {
+ // Exclude entries marked deleted
+ if (CARRIERS_TABLE.equals(qb.getTables())) {
+ if (TextUtils.isEmpty(selection)) {
+ selection = "";
+ } else {
+ selection += " and ";
+ }
+ selection += IS_NOT_USER_DELETED + " and "
+ + IS_NOT_USER_DELETED_BUT_PRESENT_IN_XML + " and "
+ + IS_NOT_CARRIER_DELETED + " and "
+ + IS_NOT_CARRIER_DELETED_BUT_PRESENT_IN_XML;
+ if (VDBG) log("query: selection modified to " + selection);
}
- selection += IS_NOT_USER_DELETED + " and " +
- IS_NOT_USER_DELETED_BUT_PRESENT_IN_XML + " and " +
- IS_NOT_CARRIER_DELETED + " and " +
- IS_NOT_CARRIER_DELETED_BUT_PRESENT_IN_XML;
- if (VDBG) log("query: selection modified to " + selection);
+ ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
+ } catch (SQLException e) {
+ loge("got exception when querying: " + e);
}
- ret = qb.query(db, projectionIn, selection, selectionArgs, null, null, sort);
- } catch (SQLException e) {
- loge("got exception when querying: " + e);
+ if (ret != null) {
+ ret.setNotificationUri(getContext().getContentResolver(), url);
+ }
+ return ret;
}
- if (ret != null)
- ret.setNotificationUri(getContext().getContentResolver(), url);
- return ret;
}
/**
@@ -4373,14 +4482,25 @@
*/
private Cursor getSubscriptionMatchingAPNList(SQLiteQueryBuilder qb, String[] projectionIn,
String selection, String[] selectionArgs, String sort, int subId) {
- Cursor ret;
Context context = getContext();
- SubscriptionManager subscriptionManager = (SubscriptionManager) context
+
+ // The SubscriptionManager can use the lock to query tables such as sim_info again, so
+ // calling subscriptionManager should be performed outside of synchronized.
+ final SubscriptionManager subscriptionManager = (SubscriptionManager) context
.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
if (!subscriptionManager.isActiveSubscriptionId(subId)) {
return null;
}
+ return getSubscriptionMatchingAPNListSynchronized(qb, projectionIn, selection,
+ selectionArgs, sort, subId);
+ }
+
+ private synchronized Cursor getSubscriptionMatchingAPNListSynchronized(
+ SQLiteQueryBuilder qb, String[] projectionIn, String selection, String[] selectionArgs,
+ String sort, int subId) {
+ Cursor ret;
+ Context context = getContext();
final TelephonyManager tm = ((TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE))
.createForSubscriptionId(subId);
@@ -4540,8 +4660,11 @@
* Insert an array of ContentValues and call notifyChange at the end.
*/
@Override
- public synchronized int bulkInsert(Uri url, ContentValues[] values) {
- return unsynchronizedBulkInsert(url, values);
+ public int bulkInsert(Uri url, ContentValues[] values) {
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+ synchronized (this) {
+ return unsynchronizedBulkInsert(url, values);
+ }
}
/**
@@ -4568,7 +4691,12 @@
}
@Override
- public synchronized Uri insert(Uri url, ContentValues initialValues) {
+ public Uri insert(Uri url, ContentValues initialValues) {
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+ return insertSynchronized(url, initialValues);
+ }
+
+ private synchronized Uri insertSynchronized(Uri url, ContentValues initialValues) {
Pair<Uri, Boolean> rowAndNotify = insertSingleRow(url, initialValues);
if (rowAndNotify.second) {
getContext().getContentResolver().notifyChange(CONTENT_URI, null,
@@ -4582,7 +4710,7 @@
*
* @param values the value that caller wants to insert
* @return a pair in which the first element refers to the Uri for the row inserted, the second
- * element refers to whether sends out nofitication.
+ * element refers to whether sends out notification.
*/
private Pair<Uri, Boolean> insertRowWithValue(ContentValues values) {
Uri result = null;
@@ -4597,7 +4725,7 @@
result = ContentUris.withAppendedId(CONTENT_URI, rowID);
notify = true;
}
- if (VDBG) log("insert: inserted " + values.toString() + " rowID = " + rowID);
+ if (DBG) log("insert: inserted " + values + ", rowID = " + rowID);
} catch (SQLException e) {
log("insert: exception " + e);
// Insertion failed which could be due to a conflict. Check if that is the case
@@ -4616,7 +4744,7 @@
private Pair<Uri, Boolean> insertSingleRow(Uri url, ContentValues initialValues) {
Uri result = null;
- int subId = SubscriptionManager.getDefaultSubscriptionId();
+ int subId = mDefaultSubId;
int match = s_urlMatcher.match(url);
checkPermission(match);
@@ -4628,14 +4756,7 @@
{
case URL_TELEPHONY_USING_SUBID:
{
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- return Pair.create(result, notify);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
+ loge("insert carriers/subId/* is not supported, treat as carriers");
}
//intentional fall through from above case
@@ -4663,15 +4784,7 @@
case URL_CURRENT_USING_SUBID:
{
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- return Pair.create(result, notify);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- // FIXME use subId in the query
+ loge("insert carriers/current/subId/* is not supported, treat as carriers/current");
}
//intentional fall through from above case
@@ -4705,7 +4818,6 @@
loge("NumberFormatException" + e);
return Pair.create(result, notify);
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
}
//intentional fall through from above case
@@ -4758,9 +4870,14 @@
}
@Override
- public synchronized int delete(Uri url, String where, String[] whereArgs) {
+ public int delete(Uri url, String where, String[] whereArgs) {
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+ return deleteSynchronized(url, where, whereArgs);
+ }
+
+ private synchronized int deleteSynchronized(Uri url, String where, String[] whereArgs) {
int count = 0;
- int subId = SubscriptionManager.getDefaultSubscriptionId();
+ int subId = mDefaultSubId;
String userOrCarrierEdited = ") and (" +
IS_USER_EDITED + " or " +
IS_CARRIER_EDITED + ")";
@@ -4789,15 +4906,7 @@
case URL_TELEPHONY_USING_SUBID:
{
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- throw new IllegalArgumentException("Invalid subId " + url);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- // FIXME use subId in query
+ loge("delete carriers/subId/* is not supported, treat as carriers");
}
//intentional fall through from above case
@@ -4813,15 +4922,7 @@
}
case URL_CURRENT_USING_SUBID: {
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- throw new IllegalArgumentException("Invalid subId " + url);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- // FIXME use subId in query
+ loge("delete carriers/current/subId/* is not supported, treat as carriers/current");
}
//intentional fall through from above case
@@ -4859,7 +4960,6 @@
loge("NumberFormatException" + e);
throw new IllegalArgumentException("Invalid subId " + url);
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
}
// intentional fall through from above case
@@ -4881,7 +4981,6 @@
loge("NumberFormatException" + e);
throw new IllegalArgumentException("Invalid subId " + url);
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
}
//intentional fall through from above case
@@ -4927,11 +5026,17 @@
}
@Override
- public synchronized int update(Uri url, ContentValues values, String where, String[] whereArgs)
+ public int update(Uri url, ContentValues values, String where, String[] whereArgs)
{
+ mDefaultSubId = SubscriptionManager.getDefaultSubscriptionId();
+ return updateSynchronized(url, values, where, whereArgs);
+ }
+
+ private synchronized int updateSynchronized(Uri url, ContentValues values, String where,
+ String[] whereArgs) {
int count = 0;
int uriType = URL_UNKNOWN;
- int subId = SubscriptionManager.getDefaultSubscriptionId();
+ int subId = mDefaultSubId;
int match = s_urlMatcher.match(url);
checkPermission(match);
@@ -4942,15 +5047,7 @@
{
case URL_TELEPHONY_USING_SUBID:
{
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- throw new IllegalArgumentException("Invalid subId " + url);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- //FIXME use subId in the query
+ loge("insert carriers/subId/* is not supported, treat as carriers");
}
//intentional fall through from above case
@@ -4971,15 +5068,7 @@
case URL_CURRENT_USING_SUBID:
{
- String subIdString = url.getLastPathSegment();
- try {
- subId = Integer.parseInt(subIdString);
- } catch (NumberFormatException e) {
- loge("NumberFormatException" + e);
- throw new IllegalArgumentException("Invalid subId " + url);
- }
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
- //FIXME use subId in the query
+ loge("insert carriers/current/subId/* is not supported, treat as carriers/current");
}
//intentional fall through from above case
@@ -5010,7 +5099,7 @@
try {
count = db.updateWithOnConflict(CARRIERS_TABLE, values, _ID + "=?" + " and " +
- IS_NOT_OWNED_BY_DPC, new String[] { rowID },
+ IS_NOT_OWNED_BY_DPC, new String[] { rowID },
SQLiteDatabase.CONFLICT_ABORT);
} catch (SQLException e) {
// Update failed which could be due to a conflict. Check if that is
@@ -5039,7 +5128,6 @@
loge("NumberFormatException" + e);
throw new IllegalArgumentException("Invalid subId " + url);
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
}
case URL_PREFERAPN:
@@ -5091,7 +5179,6 @@
loge("NumberFormatException" + e);
throw new IllegalArgumentException("Invalid subId " + url);
}
- if (DBG) log("subIdString = " + subIdString + " subId = " + subId);
if (where != null || whereArgs != null) {
throw new UnsupportedOperationException(
"Cannot update URL " + url + " with a where clause");
@@ -5189,9 +5276,9 @@
}
if (values.containsKey(Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED)) {
getContext().getContentResolver().notifyChange(getNotifyContentUri(
- Uri.withAppendedPath(Telephony.SimInfo.CONTENT_URI,
- Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED), usingSubId, subId),
- null, true, UserHandle.USER_ALL);
+ Uri.withAppendedPath(Telephony.SimInfo.CONTENT_URI,
+ Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED),
+ usingSubId, subId), null, true, UserHandle.USER_ALL);
}
if (values.containsKey(Telephony.SimInfo.COLUMN_CROSS_SIM_CALLING_ENABLED)) {
getContext().getContentResolver().notifyChange(getNotifyContentUri(
@@ -5223,6 +5310,20 @@
Telephony.SimInfo.COLUMN_ENABLED_MOBILE_DATA_POLICIES),
usingSubId, subId), null, true, UserHandle.USER_ALL);
}
+ if (values.containsKey(
+ Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES)) {
+ getContext().getContentResolver().notifyChange(getNotifyContentUri(
+ Uri.withAppendedPath(Telephony.SimInfo.CONTENT_URI,
+ Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES),
+ usingSubId, subId), null, true, UserHandle.USER_ALL);
+ }
+ if (values.containsKey(
+ Telephony.SimInfo.COLUMN_TRANSFER_STATUS)) {
+ getContext().getContentResolver().notifyChange(getNotifyContentUri(
+ Uri.withAppendedPath(Telephony.SimInfo.CONTENT_URI,
+ Telephony.SimInfo.COLUMN_TRANSFER_STATUS),
+ usingSubId, subId), null, true, UserHandle.USER_ALL);
+ }
break;
default:
getContext().getContentResolver().notifyChange(
diff --git a/tests/src/com/android/providers/telephony/CarrierProviderTest.java b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
index d329002..488ddf8 100644
--- a/tests/src/com/android/providers/telephony/CarrierProviderTest.java
+++ b/tests/src/com/android/providers/telephony/CarrierProviderTest.java
@@ -25,15 +25,15 @@
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContext;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils;
import android.util.Log;
+import androidx.test.filters.SmallTest;
+
import junit.framework.TestCase;
import org.junit.Test;
-
/**
* Tests for testing CRUD operations of CarrierProvider.
* Uses TelephonyProviderTestable to set up in-memory database
diff --git a/tests/src/com/android/providers/telephony/SmsProviderTest.java b/tests/src/com/android/providers/telephony/SmsProviderTest.java
index 37bbb29..3381400 100644
--- a/tests/src/com/android/providers/telephony/SmsProviderTest.java
+++ b/tests/src/com/android/providers/telephony/SmsProviderTest.java
@@ -20,11 +20,10 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
import android.app.AppOpsManager;
-import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -33,8 +32,6 @@
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Build;
-import android.os.Process;
import android.os.UserHandle;
import android.provider.Telephony;
import android.telephony.SmsManager;
@@ -42,19 +39,15 @@
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
-import android.test.mock.MockContext;
-import android.test.suitebuilder.annotation.SmallTest;
import android.util.Log;
-
import androidx.test.core.app.ApplicationProvider;
-import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
import junit.framework.TestCase;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.util.ArrayList;
diff --git a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
index 8ca3cd5..1d0e3e8 100644
--- a/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyDatabaseHelperTest.java
@@ -593,6 +593,128 @@
assertEquals(expectedInfrastructureBitmask, infrastructureBitmask);
}
+ @Test
+ public void databaseHelperOnUpgrade_hasServiceCapabilitiesFields() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasServiceCapabilitiesFields");
+ // (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 fields
+ // Telephony.SimInfo.COLUMN_CELLULAR_SERVICE_CAPABILITIES
+ Cursor cursor = db.query("siminfo", null, null, null, null, null, null);
+ String[] columns = cursor.getColumnNames();
+ Log.d(TAG, "siminfo columns: " + Arrays.toString(columns));
+
+ assertTrue(Arrays.asList(columns).contains(Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES));
+ }
+
+ @Test
+ public void databaseHelperOnUpgrade_hasSatelliteAttachEnabledForCarrierField_updateValue() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasSatelliteAttachEnabledForCarrierField_updateValue");
+ // (5 << 16 | 6) is the first upgrade trigger in onUpgrade
+ SQLiteDatabase db = mInMemoryDbHelper.getWritableDatabase();
+ // SATELLITE_ATTACH_ENABLED_FOR_CARRIER default value is set to 0 in version 64.
+ mHelper.onUpgrade(db, (4 << 16), 64);
+
+ // The upgraded db must have Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
+ 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_SATELLITE_ATTACH_ENABLED_FOR_CARRIER));
+
+ // Insert test contentValues into db.
+ final int insertSubId = 1;
+ int expectSatelliteAttachEnabledForCarrier = 0;
+ ContentValues contentValues = new ContentValues();
+ // Set SATELLITE_ATTACH_ENABLED_FOR_CARRIER to 0 (disabled).
+ contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
+ expectSatelliteAttachEnabledForCarrier);
+ contentValues.put(Telephony.SimInfo.COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID, insertSubId);
+ // Populate NON NULL columns.
+ contentValues.put(Telephony.SimInfo.COLUMN_ICC_ID, "123");
+ contentValues.put(Telephony.SimInfo.COLUMN_DISPLAY_NUMBER_FORMAT, 0);
+ contentValues.put(Telephony.SimInfo.COLUMN_CARD_ID, "123");
+ db.insert("siminfo", null, contentValues);
+
+ // Query SATELLITE_ATTACH_ENABLED_FOR_CARRIER value from db which should be equal to 0.
+ final String[] testProjection =
+ {Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER};
+ final String selection = Telephony.SimInfo.COLUMN_UNIQUE_KEY_SUBSCRIPTION_ID + "=?";
+ String[] selectionArgs = {Integer.toString(insertSubId)};
+ cursor = db.query("siminfo", testProjection, selection, selectionArgs,
+ null, null, null);
+ assertNotNull(cursor);
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ int satelliteAttachEnabledForCarrier = cursor.getInt(0);
+ assertEquals(expectSatelliteAttachEnabledForCarrier, satelliteAttachEnabledForCarrier);
+
+ // Upgrade db from version 64 to version 69.
+ mHelper.onUpgrade(db, (64 << 16), 69);
+
+ // Query SATELLITE_ATTACH_ENABLED_FOR_CARRIER value from db which should be equal to 1
+ // (enabled) after db upgrade.
+ expectSatelliteAttachEnabledForCarrier = 1;
+ cursor = db.query("siminfo", testProjection, selection, selectionArgs,
+ null, null, null);
+ assertNotNull(cursor);
+ assertEquals(1, cursor.getCount());
+ cursor.moveToFirst();
+ satelliteAttachEnabledForCarrier = cursor.getInt(0);
+ assertEquals(expectSatelliteAttachEnabledForCarrier, satelliteAttachEnabledForCarrier);
+ }
+
+ @Test
+ public void databaseHelperOnUpgrade_hasTransferStatusFields() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasTransferStatusFields");
+ // (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 fields
+ // Telephony.SimInfo.COLUMN_TRANSFER_STATUS
+ Cursor cursor = db.query("siminfo", null, null, null, null, null, null);
+ String[] columns = cursor.getColumnNames();
+ Log.d(TAG, "siminfo columns: " + Arrays.toString(columns));
+
+ assertTrue(Arrays.asList(columns).contains(Telephony.SimInfo.COLUMN_TRANSFER_STATUS));
+ }
+
+ @Test
+ public void databaseHelperOnUpgrade_hasSatelliteEntitlementStatusFields() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasSatelliteEntitlementStatusFields");
+ // (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 Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS
+ 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_SATELLITE_ENTITLEMENT_STATUS));
+ }
+
+ @Test
+ public void databaseHelperOnUpgrade_hasSatelliteEntitlementPlmnsFields() {
+ Log.d(TAG, "databaseHelperOnUpgrade_hasSatelliteEntitlementPlmnsFields");
+ // (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 Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS
+ 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_SATELLITE_ENTITLEMENT_PLMNS));
+ }
+
/**
* 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 9ec340b..02d573f 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTest.java
@@ -21,7 +21,7 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
-
+import static org.mockito.Mockito.when;
import android.Manifest;
import android.content.ContentUris;
@@ -34,8 +34,8 @@
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
-import android.os.Environment;
import android.os.Bundle;
+import android.os.Environment;
import android.os.PersistableBundle;
import android.os.Process;
import android.provider.Telephony;
@@ -45,20 +45,20 @@
import android.telephony.TelephonyManager;
import android.test.mock.MockContentResolver;
import android.test.mock.MockContext;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils;
import android.util.Log;
-import com.android.internal.telephony.LocalLog;
+
import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+
+import com.android.internal.telephony.LocalLog;
+import com.android.internal.telephony.PhoneFactory;
import junit.framework.TestCase;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
import org.mockito.Mock;
-import static org.mockito.Mockito.when;
-
-import com.android.internal.telephony.PhoneFactory;
+import org.mockito.MockitoAnnotations;
import java.io.File;
import java.io.FileInputStream;
@@ -223,6 +223,10 @@
contentValues.put(Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
arbitraryIntVal);
contentValues.put(SimInfo.COLUMN_IS_NTN, arbitraryIntVal);
+ contentValues.put(SimInfo.COLUMN_SERVICE_CAPABILITIES, arbitraryIntVal);
+ contentValues.put(SimInfo.COLUMN_TRANSFER_STATUS, arbitraryIntVal);
+ contentValues.put(SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS, arbitraryIntVal);
+ contentValues.put(SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS, arbitraryStringVal);
if (isoCountryCode != null) {
contentValues.put(Telephony.SimInfo.COLUMN_ISO_COUNTRY_CODE, isoCountryCode);
}
@@ -723,6 +727,11 @@
final int insertSatelliteEnabled = 1;
final int insertSatelliteAttachEnabledForCarrier = 1;
final int insertSatelliteIsNtn = 1;
+ final int insertCellularService =
+ SubscriptionManager.SERVICE_CAPABILITY_DATA_BITMASK;
+ final int insertTransferStatus = 1;
+ final int insertSatelliteEntitlementStatus = 1;
+ final String insertSatelliteEntitlementPlmns = "examplePlmns";
contentValues.put(SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID, insertSubId);
contentValues.put(SubscriptionManager.DISPLAY_NAME, insertDisplayName);
contentValues.put(SubscriptionManager.CARRIER_NAME, insertCarrierName);
@@ -735,6 +744,12 @@
contentValues.put(SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
insertSatelliteAttachEnabledForCarrier);
contentValues.put(SubscriptionManager.IS_NTN, insertSatelliteIsNtn);
+ contentValues.put(SubscriptionManager.SERVICE_CAPABILITIES, insertCellularService);
+ contentValues.put(SubscriptionManager.TRANSFER_STATUS, insertTransferStatus);
+ contentValues.put(SubscriptionManager.SATELLITE_ENTITLEMENT_STATUS,
+ insertSatelliteEntitlementStatus);
+ contentValues.put(SubscriptionManager.SATELLITE_ENTITLEMENT_PLMNS,
+ insertSatelliteEntitlementPlmns);
Log.d(TAG, "testSimTable Inserting contentValues: " + contentValues);
mContentResolver.insert(SimInfo.CONTENT_URI, contentValues);
@@ -751,6 +766,10 @@
SubscriptionManager.SATELLITE_ENABLED,
SubscriptionManager.SATELLITE_ATTACH_ENABLED_FOR_CARRIER,
SubscriptionManager.IS_NTN,
+ SubscriptionManager.SERVICE_CAPABILITIES,
+ SubscriptionManager.TRANSFER_STATUS,
+ SubscriptionManager.SATELLITE_ENTITLEMENT_STATUS,
+ SubscriptionManager.SATELLITE_ENTITLEMENT_PLMNS,
};
final String selection = SubscriptionManager.DISPLAY_NAME + "=?";
String[] selectionArgs = { insertDisplayName };
@@ -772,6 +791,10 @@
final int resultSatelliteEnabled = cursor.getInt(6);
final int resultCarrierHandoverToSatelliteEnabledByUser = cursor.getInt(7);
final int resultSatelliteIsNtn = cursor.getInt(8);
+ final int resultCellularService = cursor.getInt(9);
+ final int resultTransferStatus = cursor.getInt(10);
+ final int resultSatelliteEntitlementStatus = cursor.getInt(11);
+ final String resultSatelliteEntitlementPlmns = cursor.getString(12);
assertEquals(insertSubId, resultSubId);
assertEquals(insertCarrierName, resultCarrierName);
assertEquals(insertCardId, resultCardId);
@@ -781,6 +804,10 @@
assertEquals(insertSatelliteAttachEnabledForCarrier,
resultCarrierHandoverToSatelliteEnabledByUser);
assertEquals(insertSatelliteIsNtn, resultSatelliteIsNtn);
+ assertEquals(insertCellularService, resultCellularService);
+ assertEquals(insertTransferStatus, resultTransferStatus);
+ assertEquals(insertSatelliteEntitlementStatus, resultSatelliteEntitlementStatus);
+ assertEquals(insertSatelliteEntitlementPlmns, resultSatelliteEntitlementPlmns);
// delete test content
final String selectionToDelete = SubscriptionManager.DISPLAY_NAME + "=?";
@@ -849,6 +876,14 @@
Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER));
assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
getIntValueFromCursor(cursor, SimInfo.COLUMN_IS_NTN));
+ assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+ getIntValueFromCursor(cursor, SimInfo.COLUMN_TRANSFER_STATUS));
+ assertEquals(ARBITRARY_SIMINFO_DB_TEST_INT_VALUE_1,
+ getIntValueFromCursor(cursor,
+ Telephony.SimInfo.COLUMN_SATELLITE_ENTITLEMENT_STATUS));
+ assertEquals(ARBITRARY_SIMINFO_DB_TEST_STRING_VALUE_1,
+ getStringValueFromCursor(cursor,
+ SimInfo.COLUMN_SATELLITE_ENTITLEMENT_PLMNS));
assertRestoredSubIdIsRemembered();
}
diff --git a/tests/src/com/android/providers/telephony/TelephonyProviderTestable.java b/tests/src/com/android/providers/telephony/TelephonyProviderTestable.java
index eca7830..5ce3bc1 100644
--- a/tests/src/com/android/providers/telephony/TelephonyProviderTestable.java
+++ b/tests/src/com/android/providers/telephony/TelephonyProviderTestable.java
@@ -15,11 +15,6 @@
*/
package com.android.providers.telephony;
-import static android.provider.Telephony.Carriers.*;
-
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
@@ -27,7 +22,6 @@
import androidx.test.InstrumentationRegistry;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.providers.telephony.TelephonyProvider;
/**
* A subclass of TelephonyProvider used for testing on an in-memory database