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

Commit 19fd3c80 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Restrict access_mtp permission access to Android/"

parents 4784d2c0 36e16b2e
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -3942,9 +3942,13 @@ class StorageManagerService extends IStorageManager.Stub
            final boolean hasMtp = mIPackageManager.checkUidPermission(ACCESS_MTP, uid) ==
            final boolean hasMtp = mIPackageManager.checkUidPermission(ACCESS_MTP, uid) ==
                    PERMISSION_GRANTED;
                    PERMISSION_GRANTED;
            if (mIsFuseEnabled && hasMtp) {
            if (mIsFuseEnabled && hasMtp) {
                // The process hosting the MTP server should be able to write in Android/
                ApplicationInfo ai = mIPackageManager.getApplicationInfo(packageName,
                        0, UserHandle.getUserId(uid));
                if (ai.isSignedWithPlatformKey()) {
                    // Platform processes hosting the MTP server should be able to write in Android/
                    return Zygote.MOUNT_EXTERNAL_ANDROID_WRITABLE;
                    return Zygote.MOUNT_EXTERNAL_ANDROID_WRITABLE;
                }
                }
            }


            // Determine if caller is holding runtime permission
            // Determine if caller is holding runtime permission
            final boolean hasRead = StorageManager.checkPermissionAndCheckOp(mContext, false, 0,
            final boolean hasRead = StorageManager.checkPermissionAndCheckOp(mContext, false, 0,