Merge "Update sandbox structure for apps with sharedUserIds."
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index c3ad2dc..8445cd8 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -193,8 +193,8 @@
// sandboxId will be in either the format shared:<shared-user-id> or <package-name>
// and <shared-user-id> name has same requirements as <package-name>.
std::size_t nameStartIndex = 0;
- if (sandboxId.find("shared:") == 0) {
- nameStartIndex = 7; // len("shared:")
+ if (android::base::StartsWith(sandboxId, "shared:")) {
+ nameStartIndex = 7; // len("shared:")
}
return checkArgumentPackageName(sandboxId.substr(nameStartIndex));
}
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 2a8e8b7..594fcde 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -358,7 +358,24 @@
return -errno;
}
}
- return mountSandboxesForPrimaryVol(source, userId, packageNames, isPrimaryEmulated);
+ if (mountSandboxesForPrimaryVol(source, userId, packageNames, isPrimaryEmulated) != 0) {
+ return -errno;
+ }
+ // Keep /sdcard working for shell process
+ std::string primarySource(mPrimary->getPath());
+ if (isPrimaryEmulated) {
+ StringAppendF(&primarySource, "/%d", userId);
+ }
+ std::string target(StringPrintf("/mnt/user/%d/primary", userId));
+ if (TEMP_FAILURE_RETRY(unlink(target.c_str()))) {
+ if (errno != ENOENT) {
+ PLOG(WARNING) << "Failed to unlink " << target;
+ }
+ }
+ if (TEMP_FAILURE_RETRY(symlink(primarySource.c_str(), target.c_str()))) {
+ PLOG(WARNING) << "Failed to link " << primarySource << " at " << target;
+ return -errno;
+ }
} else {
std::string source(mPrimary->getPath());
if (mPrimary->getType() == android::vold::VolumeBase::Type::kEmulated) {
@@ -403,10 +420,14 @@
return -errno;
}
- std::string segment = StringPrintf("%d/package/", userId);
- std::string mntTargetRoot = prepareSubDirs("/mnt/user", segment.c_str(),
- 0700, AID_ROOT, AID_ROOT);
- if (mntTargetRoot.empty()) {
+ std::string mntTargetRoot = StringPrintf("/mnt/user/%d", userId);
+ if (fs_prepare_dir(mntTargetRoot.c_str(), 0751, AID_ROOT, AID_ROOT) != 0) {
+ PLOG(ERROR) << "fs_prepare_dir failed on " << mntTargetRoot;
+ return -errno;
+ }
+ mntTargetRoot.append("/package");
+ if (fs_prepare_dir(mntTargetRoot.c_str(), 0700, AID_ROOT, AID_ROOT) != 0) {
+ PLOG(ERROR) << "fs_prepare_dir failed on " << mntTargetRoot;
return -errno;
}
diff --git a/cryptfs.cpp b/cryptfs.cpp
index 16c589e..c4274ed 100644
--- a/cryptfs.cpp
+++ b/cryptfs.cpp
@@ -322,10 +322,6 @@
constexpr CryptoType supported_crypto_types[] = {
default_crypto_type,
- CryptoType()
- .set_property_name("Speck128/128-XTS")
- .set_crypto_name("speck128-xts-plain64")
- .set_keysize(32),
// Add new CryptoTypes here. Order is not important.
};