summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorSvet Ganov <svetoslavganov@google.com>2015-04-28 16:03:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-04-28 16:03:54 +0000
commit340b198ccbd1a05e67d586c345139617d4b84ce0 (patch)
treeb83cffe49b69be45ed169001f456211e181045b2 /core/java/android
parent2301174eb3598a3290b5c56aae36b19b2c6743ac (diff)
parenta2147ec975016f2aa1e44e5ed6c754a36ce1a074 (diff)
downloadframeworks_base-340b198ccbd1a05e67d586c345139617d4b84ce0.zip
frameworks_base-340b198ccbd1a05e67d586c345139617d4b84ce0.tar.gz
frameworks_base-340b198ccbd1a05e67d586c345139617d4b84ce0.tar.bz2
Merge "Handle null projection properly if provider app op is not enabled." into mnc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/ContentProvider.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/core/java/android/content/ContentProvider.java b/core/java/android/content/ContentProvider.java
index fd65d56..72e701d 100644
--- a/core/java/android/content/ContentProvider.java
+++ b/core/java/android/content/ContentProvider.java
@@ -211,7 +211,27 @@ public abstract class ContentProvider implements ComponentCallbacks2 {
// We do not call ContentProvider#query with a modified where clause since
// the implementation is not guaranteed to be backed by a SQL database, hence
// it may not handle properly the tautology where clause we would have created.
- return new MatrixCursor(projection, 0);
+ if (projection != null) {
+ return new MatrixCursor(projection, 0);
+ }
+
+ // Null projection means all columns but we have no idea which they are.
+ // However, the caller may be expecting to access them my index. Hence,
+ // we have to execute the query as if allowed to get a cursor with the
+ // columns. We then use the column names to return an empty cursor.
+ Cursor cursor = ContentProvider.this.query(uri, projection, selection,
+ selectionArgs, sortOrder, CancellationSignal.fromTransport(
+ cancellationSignal));
+
+ // Create a projection for all columns.
+ final int columnCount = cursor.getCount();
+ String[] allColumns = new String[columnCount];
+ for (int i = 0; i < columnCount; i++) {
+ allColumns[i] = cursor.getColumnName(i);
+ }
+
+ // Return an empty cursor for all columns.
+ return new MatrixCursor(allColumns, 0);
}
final String original = setCallingPackage(callingPkg);
try {