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

Commit e611ad41 authored by Mike Lockwood's avatar Mike Lockwood Committed by Android (Google) Code Review
Browse files

Merge "Use separate Uris for MTP to the media provider files table"

parents cad0cffe 8490e66f
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -273,7 +273,9 @@ public final class MediaStore {
     }

    /**
     * Media provider interface used by MTP implementation.
     * Media provider table containing an index of all files in the storage.
     * This can be used by applications to find all documents of a particular type
     * and is also used internally by the device side MTP implementation.
     * @hide
     */
    public static final class Files {
@@ -289,11 +291,22 @@ public final class MediaStore {
                    + "/file/" + fileId);
        }

        // used for MTP GetObjectReferences and SetObjectReferences
        public static final Uri getReferencesUri(String volumeName,
        public static Uri getMtpObjectsUri(String volumeName) {
            return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName +
                    "/object");
        }

        public static final Uri getMtpObjectsUri(String volumeName,
                long fileId) {
            return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName
                    + "/object/" + fileId);
        }

        // Used to implement the MTP GetObjectReferences and SetObjectReferences commands.
        public static final Uri getMtpReferencesUri(String volumeName,
                long fileId) {
            return Uri.parse(CONTENT_AUTHORITY_SLASH + volumeName
                    + "/file/" + fileId + "/references");
                    + "/object/" + fileId + "/references");
        }

        /**
+4 −4
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ public class MtpDatabase {
        mContext = context;
        mMediaProvider = context.getContentResolver().acquireProvider("media");
        mVolumeName = volumeName;
        mObjectsUri = Files.getContentUri(volumeName);
        mObjectsUri = Files.getMtpObjectsUri(volumeName);
        mMediaScanner = new MediaScanner(context);
        openDevicePropertiesDatabase(context);
    }
@@ -481,7 +481,7 @@ public class MtpDatabase {
    private int deleteFile(int handle) {
        Log.d(TAG, "deleteFile: " + handle);
        mDatabaseModified = true;
        Uri uri = Files.getContentUri(mVolumeName, handle);
        Uri uri = Files.getMtpObjectsUri(mVolumeName, handle);
        try {
            if (mMediaProvider.delete(uri, null, null) == 1) {
                return MtpConstants.RESPONSE_OK;
@@ -496,7 +496,7 @@ public class MtpDatabase {

    private int[] getObjectReferences(int handle) {
        Log.d(TAG, "getObjectReferences for: " + handle);
        Uri uri = Files.getReferencesUri(mVolumeName, handle);
        Uri uri = Files.getMtpReferencesUri(mVolumeName, handle);
        Cursor c = null;
        try {
            c = mMediaProvider.query(uri, ID_PROJECTION, null, null, null);
@@ -524,7 +524,7 @@ public class MtpDatabase {

    private int setObjectReferences(int handle, int[] references) {
        mDatabaseModified = true;
        Uri uri = Files.getReferencesUri(mVolumeName, handle);
        Uri uri = Files.getMtpReferencesUri(mVolumeName, handle);
        int count = references.length;
        ContentValues[] valuesList = new ContentValues[count];
        for (int i = 0; i < count; i++) {