From 2e7d80d10acf95076dfb1f2727455432091de65f Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Fri, 30 May 2014 15:38:31 -0700 Subject: [PATCH] Per-app media directories on external storage. This change defines per-app directories on external storage that will be scanned and included in MediaStore. This gives apps a way to write content to secondary shared storage in a way that can easily be surfaced to other apps. Bug: 14382377 Change-Id: I6f03d8076a9391d8b9eb8421ec3fc93669b3ba0d --- sdcard/sdcard.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index 7baad6395..3a164ed62 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -139,6 +139,8 @@ typedef enum { PERM_ANDROID_DATA, /* This node is "/Android/obb" */ PERM_ANDROID_OBB, + /* This node is "/Android/media" */ + PERM_ANDROID_MEDIA, /* This node is "/Android/user" */ PERM_ANDROID_USER, } perm_t; @@ -475,6 +477,10 @@ static void derive_permissions_locked(struct fuse* fuse, struct node *parent, /* Single OBB directory is always shared */ node->graft_path = fuse->obbpath; node->graft_pathlen = strlen(fuse->obbpath); + } else if (!strcasecmp(node->name, "media")) { + /* App-specific directories inside; let anyone traverse */ + node->perm = PERM_ANDROID_MEDIA; + node->mode = 0771; } else if (!strcasecmp(node->name, "user")) { /* User directories must only be accessible to system, protected * by sdcard_all. Zygote will bind mount the appropriate user- @@ -486,6 +492,7 @@ static void derive_permissions_locked(struct fuse* fuse, struct node *parent, break; case PERM_ANDROID_DATA: case PERM_ANDROID_OBB: + case PERM_ANDROID_MEDIA: appid = (appid_t) (uintptr_t) hashmapGet(fuse->package_to_appid, node->name); if (appid != 0) { node->uid = multiuser_get_uid(parent->userid, appid);