aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortonyzhu <tonyzhu@google.com>2018-10-22 18:57:02 +0800
committertonyzhu <tonyzhu@google.com>2018-11-08 11:24:56 +0800
commit51a3712e2a54da95245e596b7d63f9de7949f7b8 (patch)
tree1dc8828d228aaca88a0d2a2525f9c65162fdc929
parent043bc0d9be0730863b212a7285b487f70e723f3a (diff)
downloadContactsProvider-51a3712e2a54da95245e596b7d63f9de7949f7b8.tar.gz
[Call Screening]Logging of calls blocked by call blocking feature, call screening app.
Add CALL_SCREENING_COMPONENT_NAME, CALL_SCREENING_APP_NAME, BLOCK_REASON columns to the call log database that identify the reason a call was blocked and which app was responsible for. Bug: 113243596 Test: run CallLogProviderTest Change-Id: I95786b109b66cff188560570a456201083b09001
-rw-r--r--src/com/android/providers/contacts/CallLogDatabaseHelper.java20
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java4
-rw-r--r--tests/src/com/android/providers/contacts/CallLogProviderTest.java2
3 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/providers/contacts/CallLogDatabaseHelper.java b/src/com/android/providers/contacts/CallLogDatabaseHelper.java
index 736d6657..9aed6d0a 100644
--- a/src/com/android/providers/contacts/CallLogDatabaseHelper.java
+++ b/src/com/android/providers/contacts/CallLogDatabaseHelper.java
@@ -39,7 +39,7 @@ import com.android.providers.contacts.util.PropertyUtils;
public class CallLogDatabaseHelper {
private static final String TAG = "CallLogDatabaseHelper";
- private static final int DATABASE_VERSION = 5;
+ private static final int DATABASE_VERSION = 6;
private static final boolean DEBUG = false; // DON'T SUBMIT WITH TRUE
@@ -149,6 +149,9 @@ public class CallLogDatabaseHelper {
Calls.CACHED_FORMATTED_NUMBER + " TEXT," +
Calls.ADD_FOR_ALL_USERS + " INTEGER NOT NULL DEFAULT 1," +
Calls.LAST_MODIFIED + " INTEGER DEFAULT 0," +
+ Calls.CALL_SCREENING_COMPONENT_NAME + " TEXT," +
+ Calls.CALL_SCREENING_APP_NAME + " TEXT," +
+ Calls.BLOCK_REASON + " INTEGER NOT NULL DEFAULT 0," +
Voicemails._DATA + " TEXT," +
Voicemails.HAS_CONTENT + " INTEGER," +
Voicemails.MIME_TYPE + " TEXT," +
@@ -204,6 +207,10 @@ public class CallLogDatabaseHelper {
if (oldVersion < 5) {
upgradeToVersion5(db);
}
+
+ if (oldVersion < 6) {
+ upgradeToVersion6(db);
+ }
}
}
@@ -280,6 +287,17 @@ public class CallLogDatabaseHelper {
}
/**
+ * Add {@link CallLog.Calls#CALL_SCREENING_COMPONENT_NAME}
+ * {@link CallLog.Calls#CALL_SCREENING_APP_NAME}
+ * {@link CallLog.Calls#BLOCK_REASON} column to the CallLog database.
+ */
+ private void upgradeToVersion6(SQLiteDatabase db) {
+ db.execSQL("ALTER TABLE calls ADD call_screening_component_name TEXT");
+ db.execSQL("ALTER TABLE calls ADD call_screening_app_name TEXT");
+ db.execSQL("ALTER TABLE calls ADD block_reason INTEGER NOT NULL DEFAULT 0");
+ }
+
+ /**
* Perform the migration from the contacts2.db (of the latest version) to the current calllog/
* voicemail status tables.
*/
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index f71a7503..ff3e65c6 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -157,6 +157,10 @@ public class CallLogProvider extends ContentProvider {
sCallsProjectionMap.put(Calls.CACHED_FORMATTED_NUMBER, Calls.CACHED_FORMATTED_NUMBER);
sCallsProjectionMap.put(Calls.ADD_FOR_ALL_USERS, Calls.ADD_FOR_ALL_USERS);
sCallsProjectionMap.put(Calls.LAST_MODIFIED, Calls.LAST_MODIFIED);
+ sCallsProjectionMap
+ .put(Calls.CALL_SCREENING_COMPONENT_NAME, Calls.CALL_SCREENING_COMPONENT_NAME);
+ sCallsProjectionMap.put(Calls.CALL_SCREENING_APP_NAME, Calls.CALL_SCREENING_APP_NAME);
+ sCallsProjectionMap.put(Calls.BLOCK_REASON, Calls.BLOCK_REASON);
}
private static final String ALLOWED_PACKAGE_FOR_TESTING = "com.android.providers.contacts";
diff --git a/tests/src/com/android/providers/contacts/CallLogProviderTest.java b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
index f6078464..babfaff7 100644
--- a/tests/src/com/android/providers/contacts/CallLogProviderTest.java
+++ b/tests/src/com/android/providers/contacts/CallLogProviderTest.java
@@ -61,7 +61,7 @@ public class CallLogProviderTest extends BaseContactsProvider2Test {
Voicemails.DIRTY,
Voicemails.DELETED};
/** Total number of columns exposed by call_log provider. */
- private static final int NUM_CALLLOG_FIELDS = 31;
+ private static final int NUM_CALLLOG_FIELDS = 34;
private CallLogProviderTestable mCallLogProvider;