am 19949b9d: Merge "Guard against missing document columns." into klp-dev

* commit '19949b9d3de584b283fa9d1ef2489d3e97a3b41a':
  Guard against missing document columns.
This commit is contained in:
Jeff Sharkey
2013-10-29 11:56:27 -07:00
committed by Android Git Automerger
3 changed files with 16 additions and 11 deletions

View File

@ -17,6 +17,8 @@
package com.android.documentsui; package com.android.documentsui;
import static com.android.documentsui.DocumentsActivity.TAG; import static com.android.documentsui.DocumentsActivity.TAG;
import static com.android.documentsui.model.DocumentInfo.getCursorLong;
import static com.android.documentsui.model.DocumentInfo.getCursorString;
import android.database.AbstractCursor; import android.database.AbstractCursor;
import android.database.Cursor; import android.database.Cursor;
@ -50,10 +52,8 @@ public class FilteringCursorWrapper extends AbstractCursor {
cursor.moveToPosition(-1); cursor.moveToPosition(-1);
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
final String mimeType = cursor.getString( final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
cursor.getColumnIndex(Document.COLUMN_MIME_TYPE)); final long lastModified = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
final long lastModified = cursor.getLong(
cursor.getColumnIndex(Document.COLUMN_LAST_MODIFIED));
if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) { if (rejectMimes != null && MimePredicate.mimeMatches(rejectMimes, mimeType)) {
continue; continue;
} }

View File

@ -19,6 +19,8 @@ package com.android.documentsui;
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_DISPLAY_NAME; import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_DISPLAY_NAME;
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_LAST_MODIFIED; import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_LAST_MODIFIED;
import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_SIZE; import static com.android.documentsui.DocumentsActivity.State.SORT_ORDER_SIZE;
import static com.android.documentsui.model.DocumentInfo.getCursorLong;
import static com.android.documentsui.model.DocumentInfo.getCursorString;
import android.database.AbstractCursor; import android.database.AbstractCursor;
import android.database.Cursor; import android.database.Cursor;
@ -62,10 +64,9 @@ public class SortingCursorWrapper extends AbstractCursor {
switch (sortOrder) { switch (sortOrder) {
case SORT_ORDER_DISPLAY_NAME: case SORT_ORDER_DISPLAY_NAME:
final String mimeType = cursor.getString( final String mimeType = getCursorString(cursor, Document.COLUMN_MIME_TYPE);
cursor.getColumnIndex(Document.COLUMN_MIME_TYPE)); final String displayName = getCursorString(
final String displayName = cursor.getString( cursor, Document.COLUMN_DISPLAY_NAME);
cursor.getColumnIndex(Document.COLUMN_DISPLAY_NAME));
if (Document.MIME_TYPE_DIR.equals(mimeType)) { if (Document.MIME_TYPE_DIR.equals(mimeType)) {
mValueString[i] = '\001' + displayName; mValueString[i] = '\001' + displayName;
} else { } else {
@ -73,11 +74,10 @@ public class SortingCursorWrapper extends AbstractCursor {
} }
break; break;
case SORT_ORDER_LAST_MODIFIED: case SORT_ORDER_LAST_MODIFIED:
mValueLong[i] = cursor.getLong( mValueLong[i] = getCursorLong(cursor, Document.COLUMN_LAST_MODIFIED);
cursor.getColumnIndex(Document.COLUMN_LAST_MODIFIED));
break; break;
case SORT_ORDER_SIZE: case SORT_ORDER_SIZE:
mValueLong[i] = cursor.getLong(cursor.getColumnIndex(Document.COLUMN_SIZE)); mValueLong[i] = getCursorLong(cursor, Document.COLUMN_SIZE);
break; break;
} }
} }

View File

@ -57,6 +57,9 @@ public class TestDocumentsProvider extends DocumentsProvider {
private static final boolean LAG = false; private static final boolean LAG = false;
private static final boolean ROOT_LAME_PROJECTION = false;
private static final boolean DOCUMENT_LAME_PROJECTION = false;
private static final boolean ROOTS_WEDGE = false; private static final boolean ROOTS_WEDGE = false;
private static final boolean ROOTS_CRASH = false; private static final boolean ROOTS_CRASH = false;
private static final boolean ROOTS_REFRESH = false; private static final boolean ROOTS_REFRESH = false;
@ -88,10 +91,12 @@ public class TestDocumentsProvider extends DocumentsProvider {
}; };
private static String[] resolveRootProjection(String[] projection) { private static String[] resolveRootProjection(String[] projection) {
if (ROOT_LAME_PROJECTION) return new String[0];
return projection != null ? projection : DEFAULT_ROOT_PROJECTION; return projection != null ? projection : DEFAULT_ROOT_PROJECTION;
} }
private static String[] resolveDocumentProjection(String[] projection) { private static String[] resolveDocumentProjection(String[] projection) {
if (DOCUMENT_LAME_PROJECTION) return new String[0];
return projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION; return projection != null ? projection : DEFAULT_DOCUMENT_PROJECTION;
} }