Loading packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java +22 −9 Original line number Diff line number Diff line Loading @@ -750,7 +750,12 @@ class MtpDatabase { values.putNull(Document.COLUMN_SUMMARY); values.putNull(Document.COLUMN_LAST_MODIFIED); values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp); values.put(Document.COLUMN_FLAGS, 0); values.put(Document.COLUMN_FLAGS, getDocumentFlags( device.operationsSupported, Document.MIME_TYPE_DIR, 0, MtpConstants.PROTECTION_STATUS_NONE, DOCUMENT_TYPE_DEVICE)); values.putNull(Document.COLUMN_SIZE); extraValues.clear(); Loading @@ -765,7 +770,7 @@ class MtpDatabase { * @param values {@link ContentValues} that receives values. * @param extraValues {@link ContentValues} that receives extra values for roots. * @param parentDocumentId Parent document ID. * @param supportedOperations Array of Operation code supported by the device. * @param operationsSupported Array of Operation code supported by the device. * @param root Root to be converted {@link ContentValues}. */ static void getStorageDocumentValues( Loading @@ -786,7 +791,12 @@ class MtpDatabase { values.putNull(Document.COLUMN_SUMMARY); values.putNull(Document.COLUMN_LAST_MODIFIED); values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp); values.put(Document.COLUMN_FLAGS, 0); values.put(Document.COLUMN_FLAGS, getDocumentFlags( operationsSupported, Document.MIME_TYPE_DIR, 0, MtpConstants.PROTECTION_STATUS_NONE, DOCUMENT_TYPE_STORAGE)); values.put(Document.COLUMN_SIZE, root.mMaxCapacity - root.mFreeSpace); extraValues.put(Root.COLUMN_FLAGS, getRootFlags(operationsSupported)); Loading @@ -803,8 +813,8 @@ class MtpDatabase { * @param info MTP object info. */ static void getObjectDocumentValues( ContentValues values, int deviceId, String parentId, int[] operationsSupported, MtpObjectInfo info) { ContentValues values, int deviceId, String parentId, int[] operationsSupported, MtpObjectInfo info) { values.clear(); final String mimeType = getMimeType(info); values.put(COLUMN_DEVICE_ID, deviceId); Loading @@ -822,7 +832,7 @@ class MtpDatabase { values.putNull(Document.COLUMN_ICON); values.put(Document.COLUMN_FLAGS, getDocumentFlags( operationsSupported, mimeType, info.getThumbCompressedSizeLong(), info.getProtectionStatus())); info.getProtectionStatus(), DOCUMENT_TYPE_OBJECT)); values.put(Document.COLUMN_SIZE, info.getCompressedSizeLong()); } Loading Loading @@ -861,16 +871,19 @@ class MtpDatabase { } private static int getDocumentFlags( int[] operationsSupported, String mimeType, long thumbnailSize, int protectionState) { @Nullable int[] operationsSupported, String mimeType, long thumbnailSize, int protectionState, @DocumentType int documentType) { int flag = 0; if (MtpDeviceRecord.isWritingSupported(operationsSupported) && if (!mimeType.equals(Document.MIME_TYPE_DIR) && MtpDeviceRecord.isWritingSupported(operationsSupported) && protectionState == MtpConstants.PROTECTION_STATUS_NONE) { flag |= Document.FLAG_SUPPORTS_WRITE; } if (MtpDeviceRecord.isSupported( operationsSupported, MtpConstants.OPERATION_DELETE_OBJECT) && (protectionState == MtpConstants.PROTECTION_STATUS_NONE || protectionState == MtpConstants.PROTECTION_STATUS_NON_TRANSFERABLE_DATA)) { protectionState == MtpConstants.PROTECTION_STATUS_NON_TRANSFERABLE_DATA) && documentType == DOCUMENT_TYPE_OBJECT) { flag |= Document.FLAG_SUPPORTS_DELETE; } if (mimeType.equals(Document.MIME_TYPE_DIR) && Loading packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDatabaseTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class MtpDatabaseTest extends AndroidTestCase { assertTrue(isNull(cursor, COLUMN_SUMMARY)); assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED)); assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON)); assertEquals(0, getInt(cursor, COLUMN_FLAGS)); assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS)); assertEquals(1000, getInt(cursor, COLUMN_SIZE)); assertEquals( MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE, Loading Loading @@ -165,7 +165,7 @@ public class MtpDatabaseTest extends AndroidTestCase { assertTrue(isNull(cursor, COLUMN_SUMMARY)); assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED)); assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON)); assertEquals(0, getInt(cursor, COLUMN_FLAGS)); assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS)); assertEquals(1000, getInt(cursor, COLUMN_SIZE)); assertEquals( MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE, getInt(cursor, COLUMN_DOCUMENT_TYPE)); Loading packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java +0 −1 Original line number Diff line number Diff line Loading @@ -351,7 +351,6 @@ public class MtpDocumentsProviderTest extends AndroidTestCase { assertEquals(1422716400000L, cursor.getLong(3)); assertEquals( DocumentsContract.Document.FLAG_SUPPORTS_DELETE | DocumentsContract.Document.FLAG_SUPPORTS_WRITE | DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE, cursor.getInt(4)); assertEquals(0, cursor.getInt(5)); Loading Loading
packages/MtpDocumentsProvider/src/com/android/mtp/MtpDatabase.java +22 −9 Original line number Diff line number Diff line Loading @@ -750,7 +750,12 @@ class MtpDatabase { values.putNull(Document.COLUMN_SUMMARY); values.putNull(Document.COLUMN_LAST_MODIFIED); values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp); values.put(Document.COLUMN_FLAGS, 0); values.put(Document.COLUMN_FLAGS, getDocumentFlags( device.operationsSupported, Document.MIME_TYPE_DIR, 0, MtpConstants.PROTECTION_STATUS_NONE, DOCUMENT_TYPE_DEVICE)); values.putNull(Document.COLUMN_SIZE); extraValues.clear(); Loading @@ -765,7 +770,7 @@ class MtpDatabase { * @param values {@link ContentValues} that receives values. * @param extraValues {@link ContentValues} that receives extra values for roots. * @param parentDocumentId Parent document ID. * @param supportedOperations Array of Operation code supported by the device. * @param operationsSupported Array of Operation code supported by the device. * @param root Root to be converted {@link ContentValues}. */ static void getStorageDocumentValues( Loading @@ -786,7 +791,12 @@ class MtpDatabase { values.putNull(Document.COLUMN_SUMMARY); values.putNull(Document.COLUMN_LAST_MODIFIED); values.put(Document.COLUMN_ICON, R.drawable.ic_root_mtp); values.put(Document.COLUMN_FLAGS, 0); values.put(Document.COLUMN_FLAGS, getDocumentFlags( operationsSupported, Document.MIME_TYPE_DIR, 0, MtpConstants.PROTECTION_STATUS_NONE, DOCUMENT_TYPE_STORAGE)); values.put(Document.COLUMN_SIZE, root.mMaxCapacity - root.mFreeSpace); extraValues.put(Root.COLUMN_FLAGS, getRootFlags(operationsSupported)); Loading @@ -803,8 +813,8 @@ class MtpDatabase { * @param info MTP object info. */ static void getObjectDocumentValues( ContentValues values, int deviceId, String parentId, int[] operationsSupported, MtpObjectInfo info) { ContentValues values, int deviceId, String parentId, int[] operationsSupported, MtpObjectInfo info) { values.clear(); final String mimeType = getMimeType(info); values.put(COLUMN_DEVICE_ID, deviceId); Loading @@ -822,7 +832,7 @@ class MtpDatabase { values.putNull(Document.COLUMN_ICON); values.put(Document.COLUMN_FLAGS, getDocumentFlags( operationsSupported, mimeType, info.getThumbCompressedSizeLong(), info.getProtectionStatus())); info.getProtectionStatus(), DOCUMENT_TYPE_OBJECT)); values.put(Document.COLUMN_SIZE, info.getCompressedSizeLong()); } Loading Loading @@ -861,16 +871,19 @@ class MtpDatabase { } private static int getDocumentFlags( int[] operationsSupported, String mimeType, long thumbnailSize, int protectionState) { @Nullable int[] operationsSupported, String mimeType, long thumbnailSize, int protectionState, @DocumentType int documentType) { int flag = 0; if (MtpDeviceRecord.isWritingSupported(operationsSupported) && if (!mimeType.equals(Document.MIME_TYPE_DIR) && MtpDeviceRecord.isWritingSupported(operationsSupported) && protectionState == MtpConstants.PROTECTION_STATUS_NONE) { flag |= Document.FLAG_SUPPORTS_WRITE; } if (MtpDeviceRecord.isSupported( operationsSupported, MtpConstants.OPERATION_DELETE_OBJECT) && (protectionState == MtpConstants.PROTECTION_STATUS_NONE || protectionState == MtpConstants.PROTECTION_STATUS_NON_TRANSFERABLE_DATA)) { protectionState == MtpConstants.PROTECTION_STATUS_NON_TRANSFERABLE_DATA) && documentType == DOCUMENT_TYPE_OBJECT) { flag |= Document.FLAG_SUPPORTS_DELETE; } if (mimeType.equals(Document.MIME_TYPE_DIR) && Loading
packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDatabaseTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -103,7 +103,7 @@ public class MtpDatabaseTest extends AndroidTestCase { assertTrue(isNull(cursor, COLUMN_SUMMARY)); assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED)); assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON)); assertEquals(0, getInt(cursor, COLUMN_FLAGS)); assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS)); assertEquals(1000, getInt(cursor, COLUMN_SIZE)); assertEquals( MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE, Loading Loading @@ -165,7 +165,7 @@ public class MtpDatabaseTest extends AndroidTestCase { assertTrue(isNull(cursor, COLUMN_SUMMARY)); assertTrue(isNull(cursor, COLUMN_LAST_MODIFIED)); assertEquals(R.drawable.ic_root_mtp, getInt(cursor, COLUMN_ICON)); assertEquals(0, getInt(cursor, COLUMN_FLAGS)); assertEquals(Document.FLAG_DIR_SUPPORTS_CREATE, getInt(cursor, COLUMN_FLAGS)); assertEquals(1000, getInt(cursor, COLUMN_SIZE)); assertEquals( MtpDatabaseConstants.DOCUMENT_TYPE_STORAGE, getInt(cursor, COLUMN_DOCUMENT_TYPE)); Loading
packages/MtpDocumentsProvider/tests/src/com/android/mtp/MtpDocumentsProviderTest.java +0 −1 Original line number Diff line number Diff line Loading @@ -351,7 +351,6 @@ public class MtpDocumentsProviderTest extends AndroidTestCase { assertEquals(1422716400000L, cursor.getLong(3)); assertEquals( DocumentsContract.Document.FLAG_SUPPORTS_DELETE | DocumentsContract.Document.FLAG_SUPPORTS_WRITE | DocumentsContract.Document.FLAG_DIR_SUPPORTS_CREATE, cursor.getInt(4)); assertEquals(0, cursor.getInt(5)); Loading