summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-09-24 18:34:07 -0700
committerJeff Sharkey <jsharkey@android.com>2012-09-25 17:34:48 -0700
commit4fbbda4cecb078bd3867f416b02cc75f5455284f (patch)
treee4d988ec4be9e86e7fa5a2cfb1e20ecb1342ce72 /native
parent5e21bf934b2a71b595deb9856a2044eea4dbce86 (diff)
downloadframeworks_base-4fbbda4cecb078bd3867f416b02cc75f5455284f.zip
frameworks_base-4fbbda4cecb078bd3867f416b02cc75f5455284f.tar.gz
frameworks_base-4fbbda4cecb078bd3867f416b02cc75f5455284f.tar.bz2
Handle multi-user mountObb() requests.
Since emulated external storage paths differ based on execution context, carefully fix up paths for various use-cases: 1. When sending paths to DefaultContainerService, always scope OBB paths as belonging to USER_OWNER. 2. When sending paths to vold, always build emulated storage paths visible to root. 3. Always use the original untouched path when talking with apps. Mount OBB containers using shared app GID, so that an app can read the mount point across users. Handle legacy paths like "/sdcard" by resolving the canonical path before sending to MountService. Move tests to servicestests, and add tests for new path generation logic. Bug: 7212801 Change-Id: I078c52879cd08d9c8a52cc8c83ac7ced1e8035e7
Diffstat (limited to 'native')
-rw-r--r--native/android/storage_manager.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/native/android/storage_manager.cpp b/native/android/storage_manager.cpp
index f2f36b62..399f1ff 100644
--- a/native/android/storage_manager.cpp
+++ b/native/android/storage_manager.cpp
@@ -125,11 +125,20 @@ public:
}
}
- void mountObb(const char* filename, const char* key, AStorageManager_obbCallbackFunc func, void* data) {
+ void mountObb(const char* rawPath, const char* key, AStorageManager_obbCallbackFunc func,
+ void* data) {
+ // Resolve path before sending to MountService
+ char canonicalPath[PATH_MAX];
+ if (realpath(rawPath, canonicalPath) == NULL) {
+ ALOGE("mountObb failed to resolve path %s: %s", rawPath, strerror(errno));
+ return;
+ }
+
ObbCallback* cb = registerObbCallback(func, data);
- String16 filename16(filename);
+ String16 rawPath16(rawPath);
+ String16 canonicalPath16(canonicalPath);
String16 key16(key);
- mMountService->mountObb(filename16, key16, mObbActionListener, cb->nonce);
+ mMountService->mountObb(rawPath16, canonicalPath16, key16, mObbActionListener, cb->nonce);
}
void unmountObb(const char* filename, const bool force, AStorageManager_obbCallbackFunc func, void* data) {