summaryrefslogtreecommitdiff
path: root/java/com
diff options
context:
space:
mode:
authorlinyuh <linyuh@google.com>2018-06-11 16:37:22 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-11 16:41:14 -0700
commit8a90a0ac4898f5c575cbd22e8edb54f838edd9ea (patch)
treeee82633b11b2372a45d152eb90a2a66be3b03763 /java/com
parent443dcfbb54648034f58e1accecb54589cd0c5833 (diff)
Default column IS_VOICEMAIL_CALL to 0 in the annotated call log.
Test: AnnotatedCallLogDatabaseHelperTest PiperOrigin-RevId: 200134473 Change-Id: I1d3f43630b6cd7753ef8b72a7a02d119c8ab75cc
Diffstat (limited to 'java/com')
-rw-r--r--java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java57
-rw-r--r--java/com/android/dialer/calllog/database/Coalescer.java9
2 files changed, 41 insertions, 25 deletions
diff --git a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
index 32f303fb4..8fc80a62d 100644
--- a/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
+++ b/java/com/android/dialer/calllog/database/AnnotatedCallLogDatabaseHelper.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.CallLog.Calls;
+import android.support.annotation.VisibleForTesting;
import com.android.dialer.calllog.database.contract.AnnotatedCallLogContract.AnnotatedCallLog;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor;
@@ -34,6 +35,8 @@ import javax.inject.Singleton;
@Singleton
public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
+ @VisibleForTesting static final int VERSION = 3;
+
private static final String FILENAME = "annotated_call_log.db";
private final Context appContext;
@@ -45,7 +48,7 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
@ApplicationContext Context appContext,
@AnnotatedCallLogMaxRows int maxRows,
@BackgroundExecutor ListeningExecutorService backgroundExecutor) {
- super(appContext, FILENAME, null, 2);
+ super(appContext, FILENAME, null, VERSION);
this.appContext = appContext;
this.maxRows = maxRows;
@@ -73,26 +76,12 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
+ (AnnotatedCallLog.VOICEMAIL_URI + " text, ")
+ (AnnotatedCallLog.CALL_TYPE + " integer not null, ")
+ (AnnotatedCallLog.NUMBER_ATTRIBUTES + " blob, ")
- + (AnnotatedCallLog.IS_VOICEMAIL_CALL + " integer, ")
+ + (AnnotatedCallLog.IS_VOICEMAIL_CALL + " integer default 0, ")
+ (AnnotatedCallLog.VOICEMAIL_CALL_TAG + " text, ")
+ (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.
@@ -159,12 +148,42 @@ public class AnnotatedCallLogDatabaseHelper extends SQLiteOpenHelper {
@Override
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);
+ if (oldVersion < 2) {
+ upgradeToV2(db);
+ }
+ if (oldVersion < 3) {
+ upgradeToV3(db);
}
}
+ private static void upgradeToV2(SQLiteDatabase db) {
+ db.execSQL(
+ "alter table "
+ + AnnotatedCallLog.TABLE
+ + " add column "
+ + AnnotatedCallLog.CALL_MAPPING_ID
+ + " text;");
+ db.execSQL(
+ "update "
+ + AnnotatedCallLog.TABLE
+ + " set "
+ + AnnotatedCallLog.CALL_MAPPING_ID
+ + " = "
+ + AnnotatedCallLog.TIMESTAMP);
+ }
+
+ private static void upgradeToV3(SQLiteDatabase db) {
+ db.execSQL(
+ "update "
+ + AnnotatedCallLog.TABLE
+ + " set "
+ + AnnotatedCallLog.IS_VOICEMAIL_CALL
+ + " = 0 "
+ + "where "
+ + AnnotatedCallLog.IS_VOICEMAIL_CALL
+ + " is null");
+ }
+
/** Closes the database and deletes it. */
public ListenableFuture<Void> delete() {
return backgroundExecutor.submit(
diff --git a/java/com/android/dialer/calllog/database/Coalescer.java b/java/com/android/dialer/calllog/database/Coalescer.java
index 36df87c06..903b7e26e 100644
--- a/java/com/android/dialer/calllog/database/Coalescer.java
+++ b/java/com/android/dialer/calllog/database/Coalescer.java
@@ -321,14 +321,11 @@ public class Coalescer {
.setFeatures(coalescedContentValues.getAsInteger(CoalescedAnnotatedCallLog.FEATURES))
.setCallType(coalescedContentValues.getAsInteger(CoalescedAnnotatedCallLog.CALL_TYPE))
.setNumberAttributes(numberAttributes)
+ .setIsVoicemailCall(
+ coalescedContentValues.getAsInteger(CoalescedAnnotatedCallLog.IS_VOICEMAIL_CALL)
+ == 1)
.setCoalescedIds(coalescedIds);
- // TODO(linyuh): none of the boolean columns in the annotated call log should be null.
- // This is a bug in VoicemailDataSource, but we should also fix the database constraints.
- Integer isVoicemailCall =
- coalescedContentValues.getAsInteger(CoalescedAnnotatedCallLog.IS_VOICEMAIL_CALL);
- coalescedRowBuilder.setIsVoicemailCall(isVoicemailCall != null && isVoicemailCall == 1);
-
String formattedNumber =
coalescedContentValues.getAsString(CoalescedAnnotatedCallLog.FORMATTED_NUMBER);
if (!TextUtils.isEmpty(formattedNumber)) {