Redefine query columns in provider
Bug: 135956699
Test: manual and atest CellBroadcastServiceTests
Merged-In: I5d3d99d4c85086c246490abc00a82d267a43cf1e
Change-Id: I5d3d99d4c85086c246490abc00a82d267a43cf1e
(cherry picked from commit b51f693e7bbcb6fb6487be1b2170d3275ad7d0a0)
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index cc0aba4..8966417 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -322,10 +322,7 @@
List<SmsCbMessage> cbMessages = new ArrayList<>();
try (Cursor cursor = mContext.getContentResolver().query(CellBroadcasts.CONTENT_URI,
- // TODO: QUERY_COLUMNS_FWK is a hidden API, since we are going to move
- // CellBroadcastProvider to this module we can define those COLUMNS in side
- // CellBroadcastProvider and reference from there.
- CellBroadcasts.QUERY_COLUMNS_FWK,
+ CellBroadcastProvider.QUERY_COLUMNS,
where,
new String[] {Long.toString(dupCheckTime)},
null)) {
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastProvider.java b/src/com/android/cellbroadcastservice/CellBroadcastProvider.java
index 8b1a747..c32f764 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastProvider.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastProvider.java
@@ -98,6 +98,43 @@
/** Content uri of this provider. */
public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
+ /**
+ * Local definition of the subId column name.
+ * The value should match CellBroadcasts.SUB_ID, but we don't use it here because it's hidden
+ * and deprecated, and slot_index should be enough in the future.
+ */
+ private static final String SUB_ID = "sub_id";
+
+ /**
+ * Local definition of the query columns for instantiating
+ * {@link android.telephony.SmsCbMessage} objects.
+ */
+ public static final String[] QUERY_COLUMNS = {
+ CellBroadcasts._ID,
+ CellBroadcasts.SLOT_INDEX,
+ CellBroadcasts.GEOGRAPHICAL_SCOPE,
+ CellBroadcasts.PLMN,
+ CellBroadcasts.LAC,
+ CellBroadcasts.CID,
+ CellBroadcasts.SERIAL_NUMBER,
+ CellBroadcasts.SERVICE_CATEGORY,
+ CellBroadcasts.LANGUAGE_CODE,
+ CellBroadcasts.MESSAGE_BODY,
+ CellBroadcasts.MESSAGE_FORMAT,
+ CellBroadcasts.MESSAGE_PRIORITY,
+ CellBroadcasts.ETWS_WARNING_TYPE,
+ CellBroadcasts.CMAS_MESSAGE_CLASS,
+ CellBroadcasts.CMAS_CATEGORY,
+ CellBroadcasts.CMAS_RESPONSE_TYPE,
+ CellBroadcasts.CMAS_SEVERITY,
+ CellBroadcasts.CMAS_URGENCY,
+ CellBroadcasts.CMAS_CERTAINTY,
+ CellBroadcasts.RECEIVED_TIME,
+ CellBroadcasts.MESSAGE_BROADCASTED,
+ CellBroadcasts.GEOMETRIES,
+ CellBroadcasts.MAXIMUM_WAIT_TIME
+ };
+
@VisibleForTesting
public PermissionChecker mPermissionChecker;
@@ -270,7 +307,7 @@
public static String getStringForCellBroadcastTableCreation(String tableName) {
return "CREATE TABLE " + tableName + " ("
+ CellBroadcasts._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
- + CellBroadcasts.SUB_ID + " INTEGER,"
+ + SUB_ID + " INTEGER,"
+ CellBroadcasts.SLOT_INDEX + " INTEGER DEFAULT 0,"
+ CellBroadcasts.GEOGRAPHICAL_SCOPE + " INTEGER,"
+ CellBroadcasts.PLMN + " TEXT,"
diff --git a/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java b/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
index 2f16555..637edd4 100644
--- a/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/GsmCellBroadcastHandler.java
@@ -131,7 +131,7 @@
ContentResolver resolver = mContext.getContentResolver();
for (CellBroadcastIdentity identity : geoFencingTriggerMessage.cbIdentifiers) {
try (Cursor cursor = resolver.query(CellBroadcasts.CONTENT_URI,
- CellBroadcasts.QUERY_COLUMNS_FWK,
+ CellBroadcastProvider.QUERY_COLUMNS,
where,
new String[] { Integer.toString(identity.messageIdentifier),
Integer.toString(identity.serialNumber), MESSAGE_NOT_BROADCASTED,