summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-05-02 12:24:03 -0700
committerWeijia Xu <weijiaxu@google.com>2018-05-04 06:15:37 +0000
commit9c70e4ca34c2f3f0c5d48b549602603eed7a6c2e (patch)
tree7b3d14d7b346dc1028ff2933904599dc3c556abb /java
parentf16da49791f0af08ec0260d4e5b7c2ec6d6947c8 (diff)
Add column for call mapping id to AnnotatedCallLog database.
This will ensure call mapping used by RTT etc. won't break when migrating to new way to generate the call mapping id since they are stored in the database already. Bug: 77717594 Test: unit tests PiperOrigin-RevId: 195132562 Change-Id: Ieb52489b19b37ac2701967eb570a96457ceed4c0
Diffstat (limited to 'java')
-rw-r--r--java/com/android/dialer/calldetails/CallDetailsCursorLoader.java8
-rw-r--r--java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java26
-rw-r--r--java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java11
-rw-r--r--java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java3
4 files changed, 41 insertions, 7 deletions
diff --git a/java/com/android/dialer/calldetails/CallDetailsCursorLoader.java b/java/com/android/dialer/calldetails/CallDetailsCursorLoader.java
index c22ec7318..a7e17717f 100644
--- a/java/com/android/dialer/calldetails/CallDetailsCursorLoader.java
+++ b/java/com/android/dialer/calldetails/CallDetailsCursorLoader.java
@@ -42,7 +42,8 @@ public final class CallDetailsCursorLoader extends CursorLoader {
AnnotatedCallLog.TIMESTAMP,
AnnotatedCallLog.DURATION,
AnnotatedCallLog.DATA_USAGE,
- AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME
+ AnnotatedCallLog.PHONE_ACCOUNT_COMPONENT_NAME,
+ AnnotatedCallLog.CALL_MAPPING_ID
};
// Indexes for COLUMNS_FOR_CALL_DETAILS
@@ -53,6 +54,7 @@ public final class CallDetailsCursorLoader extends CursorLoader {
private static final int DURATION = 4;
private static final int DATA_USAGE = 5;
private static final int PHONE_ACCOUNT_COMPONENT_NAME = 6;
+ private static final int CALL_MAPPING_ID = 7;
CallDetailsCursorLoader(Context context, CoalescedIds coalescedIds) {
super(
@@ -140,9 +142,7 @@ public final class CallDetailsCursorLoader extends CursorLoader {
.setDate(cursor.getLong(TIMESTAMP))
.setDuration(cursor.getLong(DURATION))
.setDataUsage(cursor.getLong(DATA_USAGE))
-
- .setCallMappingId(String.valueOf(cursor.getLong(TIMESTAMP)));
-
+ .setCallMappingId(cursor.getString(CALL_MAPPING_ID));
String phoneAccountComponentName = cursor.getString(PHONE_ACCOUNT_COMPONENT_NAME);
entry.setIsDuoCall(
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
index 61f7debf7..32f303fb4 100644
--- a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
+++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
@@ -45,7 +45,7 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
@ApplicationContext Context appContext,
@AnnotatedCallLogMaxRows int maxRows,
@BackgroundExecutor ListeningExecutorService backgroundExecutor) {
- super(appContext, FILENAME, null, 1);
+ super(appContext, FILENAME, null, 2);
this.appContext = appContext;
this.maxRows = maxRows;
@@ -75,9 +75,24 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
+ (AnnotatedCallLog.NUMBER_ATTRIBUTES + " blob, ")
+ (AnnotatedCallLog.IS_VOICEMAIL_CALL + " integer, ")
+ (AnnotatedCallLog.VOICEMAIL_CALL_TAG + " text, ")
- + (AnnotatedCallLog.TRANSCRIPTION_STATE + " integer")
+ + (AnnotatedCallLog.TRANSCRIPTION_STATE + " integer, ")
+ + (AnnotatedCallLog.CALL_MAPPING_ID + " text")
+ ");";
+ private static final String ALTER_TABLE_SQL_ADD_CALL_MAPPING_ID_COLUMN =
+ "alter table "
+ + AnnotatedCallLog.TABLE
+ + " add column "
+ + AnnotatedCallLog.CALL_MAPPING_ID
+ + " text;";
+ private static final String UPDATE_CALL_MAPPING_ID_COLUMN =
+ "update "
+ + AnnotatedCallLog.TABLE
+ + " set "
+ + AnnotatedCallLog.CALL_MAPPING_ID
+ + " = "
+ + AnnotatedCallLog.TIMESTAMP;
+
/**
* Deletes all but the first maxRows rows (by timestamp, excluding voicemails) to keep the table a
* manageable size.
@@ -143,7 +158,12 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
}
@Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+ if (oldVersion == 1 && newVersion == 2) {
+ db.execSQL(ALTER_TABLE_SQL_ADD_CALL_MAPPING_ID_COLUMN);
+ db.execSQL(UPDATE_CALL_MAPPING_ID_COLUMN);
+ }
+ }
/** Closes the database and deletes it. */
public ListenableFuture<Void> delete() {
diff --git a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
index 5e4e4afd3..ee888d196 100644
--- a/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
+++ b/java/com/android/dialer/calllog/database/contract/AnnotatedCallLogContract.java
@@ -221,6 +221,17 @@ public class AnnotatedCallLogContract {
* <p>TYPE: TEXT
*/
public static final String VOICEMAIL_URI = "voicemail_uri";
+
+ /**
+ * An unique id to associate this call log row to a {@link android.telecom.Call}.
+ *
+ * <p>For pre-Q device, this is same as {@link TIMESTAMP}.
+ *
+ * <p>For Q+ device, this will be copied from {@link android.provider.CallLog.Calls}.
+ *
+ * <p>Type: TEXT
+ */
+ public static final String CALL_MAPPING_ID = "call_mapping_id";
}
/**
diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
index 661b2495b..fb18e8927 100644
--- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
+++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java
@@ -367,6 +367,9 @@ public class SystemCallLogDataSource implements CallLogDataSource {
contentValues.put(AnnotatedCallLog.DATA_USAGE, dataUsage);
contentValues.put(AnnotatedCallLog.TRANSCRIPTION, transcription);
contentValues.put(AnnotatedCallLog.VOICEMAIL_URI, voicemailUri);
+
+ contentValues.put(AnnotatedCallLog.CALL_MAPPING_ID, String.valueOf(date));
+
setTranscriptionState(cursor, contentValues);
if (existingAnnotatedCallLogIds.contains(id)) {