Loading packages/MtpDocumentsProvider/src/com/android/mtp/Identifier.java +28 −1 Original line number Diff line number Diff line Loading @@ -44,11 +44,38 @@ class Identifier { return false; final Identifier other = (Identifier) obj; return mDeviceId == other.mDeviceId && mStorageId == other.mStorageId && mObjectHandle == other.mObjectHandle && mDocumentId == other.mDocumentId; mObjectHandle == other.mObjectHandle && mDocumentId.equals(other.mDocumentId); } @Override public int hashCode() { return Objects.hash(mDeviceId, mStorageId, mObjectHandle, mDocumentId); } @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("Identifier { "); builder.append("mDeviceId: "); builder.append(mDeviceId); builder.append(", "); builder.append("mStorageId: "); builder.append(mStorageId); builder.append(", "); builder.append("mObjectHandle: "); builder.append(mObjectHandle); builder.append(", "); builder.append("mDocumentId: "); builder.append(mDocumentId); builder.append(", "); builder.append("mDocumentType: "); builder.append(mDocumentType); builder.append(" }"); return builder.toString(); } } packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java +11 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ public class MtpDocumentsProvider extends DocumentsProvider { Document.COLUMN_FLAGS, Document.COLUMN_SIZE, }; static final boolean DEBUG = true; private final Object mDeviceListLock = new Object(); private static MtpDocumentsProvider sSingleton; Loading Loading @@ -151,6 +153,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { @Override public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException { if (DEBUG) { Log.d(TAG, "queryChildDocuments: " + parentDocumentId); } if (projection == null) { projection = MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION; } Loading Loading @@ -298,6 +303,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { if (mDeviceToolkits.containsKey(deviceId)) { return; } if (DEBUG) { Log.d(TAG, "Open device " + deviceId); } mMtpManager.openDevice(deviceId); mDeviceToolkits.put( deviceId, new DeviceToolkit(mMtpManager, mResolver, mDatabase)); Loading Loading @@ -384,6 +392,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { if (!mDeviceToolkits.containsKey(deviceId)) { return; } if (DEBUG) { Log.d(TAG, "Close device " + deviceId); } getDeviceToolkit(deviceId).mDocumentLoader.clearTasks(); mDeviceToolkits.remove(deviceId); mMtpManager.closeDevice(deviceId); Loading Loading
packages/MtpDocumentsProvider/src/com/android/mtp/Identifier.java +28 −1 Original line number Diff line number Diff line Loading @@ -44,11 +44,38 @@ class Identifier { return false; final Identifier other = (Identifier) obj; return mDeviceId == other.mDeviceId && mStorageId == other.mStorageId && mObjectHandle == other.mObjectHandle && mDocumentId == other.mDocumentId; mObjectHandle == other.mObjectHandle && mDocumentId.equals(other.mDocumentId); } @Override public int hashCode() { return Objects.hash(mDeviceId, mStorageId, mObjectHandle, mDocumentId); } @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append("Identifier { "); builder.append("mDeviceId: "); builder.append(mDeviceId); builder.append(", "); builder.append("mStorageId: "); builder.append(mStorageId); builder.append(", "); builder.append("mObjectHandle: "); builder.append(mObjectHandle); builder.append(", "); builder.append("mDocumentId: "); builder.append(mDocumentId); builder.append(", "); builder.append("mDocumentType: "); builder.append(mDocumentType); builder.append(" }"); return builder.toString(); } }
packages/MtpDocumentsProvider/src/com/android/mtp/MtpDocumentsProvider.java +11 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ public class MtpDocumentsProvider extends DocumentsProvider { Document.COLUMN_FLAGS, Document.COLUMN_SIZE, }; static final boolean DEBUG = true; private final Object mDeviceListLock = new Object(); private static MtpDocumentsProvider sSingleton; Loading Loading @@ -151,6 +153,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { @Override public Cursor queryChildDocuments(String parentDocumentId, String[] projection, String sortOrder) throws FileNotFoundException { if (DEBUG) { Log.d(TAG, "queryChildDocuments: " + parentDocumentId); } if (projection == null) { projection = MtpDocumentsProvider.DEFAULT_DOCUMENT_PROJECTION; } Loading Loading @@ -298,6 +303,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { if (mDeviceToolkits.containsKey(deviceId)) { return; } if (DEBUG) { Log.d(TAG, "Open device " + deviceId); } mMtpManager.openDevice(deviceId); mDeviceToolkits.put( deviceId, new DeviceToolkit(mMtpManager, mResolver, mDatabase)); Loading Loading @@ -384,6 +392,9 @@ public class MtpDocumentsProvider extends DocumentsProvider { if (!mDeviceToolkits.containsKey(deviceId)) { return; } if (DEBUG) { Log.d(TAG, "Close device " + deviceId); } getDeviceToolkit(deviceId).mDocumentLoader.clearTasks(); mDeviceToolkits.remove(deviceId); mMtpManager.closeDevice(deviceId); Loading