Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c1cb59f authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "Fix Identifier.equals method."

parents 30f0fc7f 19aa9324
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -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();
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
        }
@@ -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));
@@ -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);