Merge "Don't map root documents in DocumentLoader." into nyc-dev

This commit is contained in:
Daichi Hirono
2016-03-22 04:47:55 +00:00
committed by Android (Google) Code Review
3 changed files with 11 additions and 3 deletions

View File

@@ -9,5 +9,10 @@ LOCAL_PRIVILEGED_MODULE := true
LOCAL_JNI_SHARED_LIBRARIES := libappfuse_jni
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
# Only enable asserts on userdebug/eng builds
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
LOCAL_JACK_FLAGS += -D jack.assert.policy=enable
endif
include $(BUILD_PACKAGE)
include $(call all-makefiles-under, $(LOCAL_PATH))

View File

@@ -69,7 +69,8 @@ class DocumentLoader implements AutoCloseable {
*/
synchronized Cursor queryChildDocuments(String[] columnNames, Identifier parent)
throws IOException {
Preconditions.checkArgument(parent.mDeviceId == mDevice.deviceId);
assert parent.mDeviceId == mDevice.deviceId;
LoaderTask task = mTaskList.findTask(parent);
if (task == null) {
if (parent.mDocumentId == null) {
@@ -256,7 +257,8 @@ class DocumentLoader implements AutoCloseable {
LoaderTask(MtpManager manager, MtpDatabase database, int[] operationsSupported,
Identifier identifier) {
Preconditions.checkNotNull(operationsSupported);
assert operationsSupported != null;
assert identifier.mDocumentType != MtpDatabaseConstants.DOCUMENT_TYPE_DEVICE;
mManager = manager;
mDatabase = database;
mOperationsSupported = operationsSupported;

View File

@@ -617,6 +617,7 @@ class MtpDatabase {
final String whereClosure =
"parent." + COLUMN_DEVICE_ID + " = ? AND " +
"parent." + COLUMN_ROW_STATE + " IN (?, ?) AND " +
"parent." + COLUMN_DOCUMENT_TYPE + " != ? AND " +
"child." + COLUMN_ROW_STATE + " = ?";
try (final Cursor cursor = mDatabase.query(
fromClosure,
@@ -626,7 +627,7 @@ class MtpDatabase {
"parent." + Document.COLUMN_DOCUMENT_ID,
"parent." + COLUMN_DOCUMENT_TYPE),
whereClosure,
strings(deviceId, ROW_STATE_VALID, ROW_STATE_INVALIDATED,
strings(deviceId, ROW_STATE_VALID, ROW_STATE_INVALIDATED, DOCUMENT_TYPE_DEVICE,
ROW_STATE_DISCONNECTED),
null,
null,