Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 031eccf

Browse files
committed
[[ Bug 22937 ]] Fix crash where FileProvider projection null
This patch resolves a crash where the `FileProvider` query projection array is `null`. The documentation states: > The list of columns to put into the cursor. If null all columns are included.
1 parent 99a3334 commit 031eccf

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

engine/src/java/com/runrev/android/FileProvider.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ private boolean validField(String p_field)
112112

113113
private boolean validQuery(String[] projection)
114114
{
115+
if (projection == null)
116+
{
117+
return true;
118+
}
119+
115120
boolean t_valid = true;
116121
for (int i = 0; i < projection . length && t_valid; ++i)
117122
{
@@ -173,14 +178,25 @@ public Cursor doQuery(Uri uri, String[] projection, String selection, String[] s
173178
String t_uri_string = uri.toString();
174179
HashMap<String, String> t_infos = m_infos.get(t_uri_string);
175180

176-
String t_values[] = new String[projection.length];
177-
for (int i = 0; i < projection.length; ++i)
178-
t_values[i] = t_infos.get(projection[i]);
181+
String t_values[];
182+
MatrixCursor t_cursor;
183+
if (projection == null)
184+
{
185+
t_values = t_infos.values().toArray(new String[0]);
186+
t_cursor = new MatrixCursor(t_infos.keySet().toArray(new String[0]));
187+
}
188+
else
189+
{
190+
t_values = new String[projection.length];
191+
for (int i = 0; i < projection.length; ++i)
192+
t_values[i] = t_infos.get(projection[i]);
193+
194+
t_cursor = new MatrixCursor(projection);
195+
}
179196
// Log.i("revandroid", "query for " + uri.toString());
180197
// for (int i = 0; i < t_values . length; ++i)
181198
// Log.i("revandroid", "\t" + t_values[i]);
182199

183-
MatrixCursor t_cursor = new MatrixCursor(projection);
184200
t_cursor . addRow(t_values);
185201

186202
return t_cursor;

0 commit comments

Comments
 (0)