summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/contacts/CallLogProvider.java
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2015-08-31 16:18:48 -0700
committerRichard MacGregor <rmacgregor@cyngn.com>2016-04-07 13:33:40 -0700
commit3e6a328d51c8022daff8134bcf022c5de7e7aa1e (patch)
treec85a3b94809ed5e35e225fecd14cdf06b0982031 /src/com/android/providers/contacts/CallLogProvider.java
parent01c7baf0157231d9231853ea812d97646c779e5b (diff)
downloadpackages_providers_ContactsProvider-3e6a328d51c8022daff8134bcf022c5de7e7aa1e.zip
packages_providers_ContactsProvider-3e6a328d51c8022daff8134bcf022c5de7e7aa1e.tar.gz
packages_providers_ContactsProvider-3e6a328d51c8022daff8134bcf022c5de7e7aa1e.tar.bz2
CallLog: initial adding of new plugin columns
Change-Id: I4f1f08ccf40e1042ae343f8b27becdd23f0e8cf8
Diffstat (limited to 'src/com/android/providers/contacts/CallLogProvider.java')
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java50
1 files changed, 47 insertions, 3 deletions
diff --git a/src/com/android/providers/contacts/CallLogProvider.java b/src/com/android/providers/contacts/CallLogProvider.java
index 1443247..b8dfcfb 100644
--- a/src/com/android/providers/contacts/CallLogProvider.java
+++ b/src/com/android/providers/contacts/CallLogProvider.java
@@ -52,6 +52,8 @@ import com.android.providers.contacts.util.UserUtils;
import com.google.common.annotations.VisibleForTesting;
+import com.cyanogen.ambient.incall.CallLogConstants;
+
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -85,7 +87,9 @@ public class CallLogProvider extends ContentProvider {
Calls.DATA_USAGE,
Calls.PHONE_ACCOUNT_COMPONENT_NAME,
Calls.PHONE_ACCOUNT_ID,
- ContactsDatabaseHelper.CallColumns.ORIGIN
+ ContactsDatabaseHelper.CallColumns.ORIGIN,
+ CallLogConstants.PLUGIN_NAME,
+ CallLogConstants.PLUGIN_USER_HANDLE
};
static final String[] MINIMAL_PROJECTION = new String[] { Calls._ID };
@@ -96,6 +100,13 @@ public class CallLogProvider extends ContentProvider {
private static final int CALLS_FILTER = 3;
+ private static final int CALLS_PLUGIN = 4;
+
+ /** Path Segments */
+ private static final int ALL_CALL_LOGS_PATH = 2;
+ private static final int PLUGIN_NAME_PATH = 2;
+ private static final int PLUGIN_USER_NAME_PATH = 3;
+
private static final String UNHIDE_BY_PHONE_ACCOUNT_QUERY =
"UPDATE " + Tables.CALLS + " SET " + Calls.PHONE_ACCOUNT_HIDDEN + "=0 WHERE " +
Calls.PHONE_ACCOUNT_COMPONENT_NAME + "=? AND " + Calls.PHONE_ACCOUNT_ID + "=?;";
@@ -108,7 +119,11 @@ public class CallLogProvider extends ContentProvider {
static {
sURIMatcher.addURI(CallLog.AUTHORITY, "calls", CALLS);
sURIMatcher.addURI(CallLog.AUTHORITY, "calls/#", CALLS_ID);
+ sURIMatcher.addURI(CallLog.AUTHORITY, "calls/all", CALLS);
sURIMatcher.addURI(CallLog.AUTHORITY, "calls/filter/*", CALLS_FILTER);
+ sURIMatcher.addURI(CallLog.AUTHORITY, "calls/plugin", CALLS_PLUGIN);
+ sURIMatcher.addURI(CallLog.AUTHORITY, "calls/plugin/*", CALLS_PLUGIN);
+ sURIMatcher.addURI(CallLog.AUTHORITY, "calls/plugin/*/*", CALLS_PLUGIN);
}
private static final HashMap<String, String> sCallsProjectionMap;
@@ -144,6 +159,9 @@ public class CallLogProvider extends ContentProvider {
sCallsProjectionMap.put(Calls.CACHED_FORMATTED_NUMBER, Calls.CACHED_FORMATTED_NUMBER);
sCallsProjectionMap.put(ContactsDatabaseHelper.CallColumns.ORIGIN,
ContactsDatabaseHelper.CallColumns.ORIGIN);
+ sCallsProjectionMap.put(CallLogConstants.PLUGIN_NAME, CallLogConstants.PLUGIN_NAME);
+ sCallsProjectionMap.put(CallLogConstants.PLUGIN_USER_HANDLE,
+ CallLogConstants.PLUGIN_USER_HANDLE);
}
private HandlerThread mBackgroundThread;
@@ -214,9 +232,15 @@ public class CallLogProvider extends ContentProvider {
selectionBuilder.addClause(EXCLUDE_HIDDEN_SELECTION);
final int match = sURIMatcher.match(uri);
+ List<String> pathSegments = uri.getPathSegments();
+
switch (match) {
- case CALLS:
+ case CALLS: {
+ if (pathSegments.size() < ALL_CALL_LOGS_PATH) {
+ qb.appendWhere(CallLogConstants.PLUGIN_NAME + " IS NULL ");
+ }
break;
+ }
case CALLS_ID: {
selectionBuilder.addClause(getEqualityClause(Calls._ID,
@@ -225,7 +249,6 @@ public class CallLogProvider extends ContentProvider {
}
case CALLS_FILTER: {
- List<String> pathSegments = uri.getPathSegments();
String phoneNumber = pathSegments.size() >= 2 ? pathSegments.get(2) : null;
if (!TextUtils.isEmpty(phoneNumber)) {
qb.appendWhere("PHONE_NUMBERS_EQUAL(number, ");
@@ -238,6 +261,25 @@ public class CallLogProvider extends ContentProvider {
break;
}
+ case CALLS_PLUGIN: {
+ String pluginName = pathSegments.size() >= PLUGIN_NAME_PATH ?
+ pathSegments.get(PLUGIN_NAME_PATH) : null;
+ if (!TextUtils.isEmpty(pluginName)) {
+ qb.appendWhere(CallLogConstants.PLUGIN_NAME + " == ");
+ qb.appendWhereEscapeString(pluginName);
+ if (pathSegments.size() >= PLUGIN_USER_NAME_PATH) {
+ String pluginUserName = pathSegments.get(PLUGIN_USER_NAME_PATH);
+ if (!TextUtils.isEmpty(pluginUserName)) {
+ qb.appendWhere(" AND " + CallLogConstants.PLUGIN_USER_HANDLE + " == ");
+ qb.appendWhereEscapeString(pluginUserName);
+ }
+ }
+ } else {
+ qb.appendWhere(CallLogConstants.PLUGIN_NAME + " IS NOT NULL");
+ }
+ break;
+ }
+
default:
throw new IllegalArgumentException("Unknown URL " + uri);
}
@@ -293,6 +335,8 @@ public class CallLogProvider extends ContentProvider {
return Calls.CONTENT_ITEM_TYPE;
case CALLS_FILTER:
return Calls.CONTENT_TYPE;
+ case CALLS_PLUGIN:
+ return Calls.CONTENT_TYPE;
default:
throw new IllegalArgumentException("Unknown URI: " + uri);
}