From 3e6a328d51c8022daff8134bcf022c5de7e7aa1e Mon Sep 17 00:00:00 2001 From: Stephen Bird Date: Mon, 31 Aug 2015 16:18:48 -0700 Subject: CallLog: initial adding of new plugin columns Change-Id: I4f1f08ccf40e1042ae343f8b27becdd23f0e8cf8 --- Android.mk | 5 +++ AndroidManifest.xml | 2 + .../providers/contacts/CallLogProvider.java | 50 ++++++++++++++++++++-- .../providers/contacts/ContactsDatabaseHelper.java | 21 ++++++++- 4 files changed, 74 insertions(+), 4 deletions(-) diff --git a/Android.mk b/Android.mk index 1698686..ab46567 100644 --- a/Android.mk +++ b/Android.mk @@ -10,6 +10,7 @@ LOCAL_SRC_FILES += \ LOCAL_JAVA_LIBRARIES := ext telephony-common +LOCAL_STATIC_JAVA_AAR_LIBRARIES := ambientsdk LOCAL_STATIC_JAVA_LIBRARIES += android-common com.android.vcard guava # The Emma tool analyzes code coverage when running unit tests on the @@ -26,6 +27,10 @@ LOCAL_EMMA_COVERAGE_FILTER := +com.android.providers.contacts.* # production builds. LOCAL_EMMA_COVERAGE_FILTER := +com.android.providers.contacts.* +LOCAL_AAPT_FLAGS := \ + --auto-add-overlay \ + --extra-packages com.cyanogen.ambient + LOCAL_PACKAGE_NAME := ContactsProvider LOCAL_CERTIFICATE := shared LOCAL_PRIVILEGED_MODULE := true diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4e035f9..cbea921 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -20,6 +20,8 @@ android:label="Broadcast that a change happened to the call log." android:protectionLevel="signature|system"/> + + 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 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 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); } diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java index 12a6f56..24ad862 100644 --- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java +++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java @@ -92,6 +92,9 @@ import com.google.common.annotations.VisibleForTesting; import libcore.icu.ICU; +import com.cyanogen.ambient.incall.CallLogConstants; + +import java.util.HashMap; import java.util.Locale; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -121,7 +124,7 @@ public class ContactsDatabaseHelper extends SQLiteOpenHelper { * 1000-1099 M * */ - static final int DATABASE_VERSION = 1012; + static final int DATABASE_VERSION = 1013; public interface Tables { public static final String CONTACTS = "contacts"; @@ -1532,6 +1535,8 @@ public class ContactsDatabaseHelper extends SQLiteOpenHelper { Calls.CACHED_PHOTO_URI + " TEXT," + Calls.CACHED_FORMATTED_NUMBER + " TEXT," + CallColumns.ORIGIN + " TEXT," + + CallLogConstants.PLUGIN_NAME + " TEXT DEFAULT NULL," + + CallLogConstants.PLUGIN_USER_HANDLE + " TEXT DEFAULT NULL," + Voicemails._DATA + " TEXT," + Voicemails.HAS_CONTENT + " INTEGER," + Voicemails.MIME_TYPE + " TEXT," + @@ -2925,6 +2930,11 @@ public class ContactsDatabaseHelper extends SQLiteOpenHelper { oldVersion = 1012; } + if (oldVersion < 1013) { + upgradeToVersion1013(db); + oldVersion = 1013; + } + if (upgradeViewsAndTriggers) { createContactsViews(db); createGroupsView(db); @@ -4480,6 +4490,15 @@ public class ContactsDatabaseHelper extends SQLiteOpenHelper { + " TEXT DEFAULT NULL;"); } + // Add Plugin name and User handle for incall api plugins. + private void upgradeToVersion1013(SQLiteDatabase db) { + db.execSQL("ALTER TABLE " + Tables.CALLS + " ADD " + CallLogConstants.PLUGIN_NAME + + " TEXT DEFAULT NULL;"); + + db.execSQL("ALTER TABLE " + Tables.CALLS + " ADD " + CallLogConstants.PLUGIN_USER_HANDLE + + " TEXT DEFAULT NULL;"); + } + public String extractHandleFromEmailAddress(String email) { Rfc822Token[] tokens = Rfc822Tokenizer.tokenize(email); if (tokens.length == 0) { -- cgit v1.1