summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk5
-rw-r--r--AndroidManifest.xml2
-rw-r--r--src/com/android/providers/contacts/CallLogProvider.java50
-rw-r--r--src/com/android/providers/contacts/ContactsDatabaseHelper.java21
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"/>
+ <uses-sdk android:minSdkVersion="21" />
+
<application android:process="android.process.acore"
android:label="@string/app_label"
android:icon="@drawable/app_icon"
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);
}
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
* </pre>
*/
- 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) {