Skip to content

Commit

Permalink
Fix bugs regarding system app cannot write visible path
Browse files Browse the repository at this point in the history
1. some system app by OEM can not write file to sdcard through visible
path("/storage/[UUID]") despite it has WRITE_MEDIA_STORAGE.

2. Google photo can't open and delete file which transferred from PC to
SDcard by MTP. (http://b/116332048)

Test: Check system app which has sdcard_rw permission writes file to sdcard("/storage/[UUID]").

Change-Id: Id38bd7c4753a38b6c61fff512821becfbcd9215a
Signed-off-by: Sangho Yoon <sangho.yoon@lge.com>
  • Loading branch information
sangho.yoon authored and adithya2306 committed Nov 7, 2019
1 parent 79723e2 commit a0311b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/etc/platform.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

<permission name="android.permission.WRITE_MEDIA_STORAGE" >
<group gid="media_rw" />
<group gid="sdcard_rw" />
</permission>

<permission name="android.permission.ACCESS_MTP" >
Expand Down
2 changes: 1 addition & 1 deletion media/java/android/mtp/MtpStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class MtpStorage {

public MtpStorage(StorageVolume volume, int storageId) {
mStorageId = storageId;
mPath = volume.getInternalPath();
mPath = volume.getPath();
mDescription = volume.getDescription(null);
mRemovable = volume.isRemovable();
mMaxFileSize = volume.getMaxFileSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static android.Manifest.permission.REQUEST_DELETE_PACKAGES;
import static android.Manifest.permission.SET_HARMFUL_APP_WARNINGS;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.Manifest.permission.WRITE_MEDIA_STORAGE;
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_DEFAULT;
import static android.content.Intent.CATEGORY_HOME;
Expand Down Expand Up @@ -21691,6 +21692,9 @@ public int getMountMode(int uid, String packageName) {
if (Process.isIsolated(uid)) {
return Zygote.MOUNT_EXTERNAL_NONE;
}
if (checkUidPermission(WRITE_MEDIA_STORAGE, uid) == PERMISSION_GRANTED) {
return Zygote.MOUNT_EXTERNAL_DEFAULT;
}
if (checkUidPermission(READ_EXTERNAL_STORAGE, uid) == PERMISSION_DENIED) {
return Zygote.MOUNT_EXTERNAL_DEFAULT;
}
Expand Down

0 comments on commit a0311b6

Please sign in to comment.