Merge "Remove hasColumn() and use isInProjection() instead."
diff --git a/src/com/android/providers/contacts/ContactsDatabaseHelper.java b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
index b1e5b6d..01c62d3 100644
--- a/src/com/android/providers/contacts/ContactsDatabaseHelper.java
+++ b/src/com/android/providers/contacts/ContactsDatabaseHelper.java
@@ -4359,21 +4359,31 @@
}
/**
+ * Test if the given column appears in the given projection.
+ */
+ public static boolean isInProjection(String[] projection, String column) {
+ if (projection == null) {
+ return true; // Null means "all columns". We can't really tell if it's in there...
+ }
+ for (String test : projection) {
+ if (column.equals(test)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Test if any of the columns appear in the given projection.
*/
- public boolean isInProjection(String[] projection, String... columns) {
+ public static boolean isInProjection(String[] projection, String... columns) {
if (projection == null) {
return true;
}
// Optimized for a single-column test
if (columns.length == 1) {
- String column = columns[0];
- for (String test : projection) {
- if (column.equals(test)) {
- return true;
- }
- }
+ return isInProjection(projection, columns[0]);
} else {
for (String test : projection) {
for (String column : columns) {
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 0f5aa3c..46e4061 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -4980,17 +4980,6 @@
}
}
- private boolean hasColumn(String[] projection, String column) {
- if (projection == null) {
- return true; // Null projection means "all columns".
- }
-
- for (int i = 0; i < projection.length; i++) {
- if (column.equalsIgnoreCase(projection[i])) return true;
- }
- return false;
- }
-
protected Cursor queryLocal(Uri uri, String[] projection, String selection,
String[] selectionArgs, String sortOrder, long directoryId) {
if (VERBOSE_LOGGING) {
@@ -5859,7 +5848,7 @@
readBooleanQueryParameter(uri, Groups.PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT,
false);
String tables = Views.GROUPS + " AS " + Tables.GROUPS;
- if (hasColumn(projection, Groups.SUMMARY_COUNT)) {
+ if (ContactsDatabaseHelper.isInProjection(projection, Groups.SUMMARY_COUNT)) {
tables = tables + Joins.GROUP_MEMBER_COUNT;
}
qb.setTables(tables);
@@ -8084,6 +8073,6 @@
* @return a boolean indicating if a snippet is needed or not.
*/
private boolean snippetNeeded(String [] projection) {
- return mDbHelper.get().isInProjection(projection, SearchSnippetColumns.SNIPPET);
+ return ContactsDatabaseHelper.isInProjection(projection, SearchSnippetColumns.SNIPPET);
}
}