Merge "Fix Identifier.equals method."

This commit is contained in:
Daichi Hirono
2016-02-04 06:06:18 +00:00
committed by Android (Google) Code Review
2 changed files with 39 additions and 1 deletions

View File

@@ -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();
}
}

View File

@@ -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);