summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Samiul Islam <samiul@google.com> 2022-02-21 15:23:36 +0000
committer Samiul Islam <samiul@google.com> 2022-03-16 11:26:41 +0000
commita0340b3cdd537b30cf5d031ae93b491699d37811 (patch)
tree96c3b461ba0bdf6e0f018cbfb1dea0b6044e2778
parenta90b4e7b44c3043bb1979bb981f65ce36d67222d (diff)
Create sdk directory for an app only if app consumes sdk
Currently, we create sdk directories for all apps. This means during boot time, when we create app data directory for system apps, we are now creating twice the amount of directories as before. This has significant impact on boot time. In order to avoid the regression, we are now limiting the creation to only when app actually consumes an sdk and needs these directories. The PM will be responsible for passing a flag whenever an app consumes sdk. Bug: 220095381 Bug: 217543371 Test: atest installd_service_test Ignore-AOSP-First: Feature is being developed in internal branch Change-Id: I96c19f43f13080b19a80fcb92b22a4042934b785 Merged-In: I96c19f43f13080b19a80fcb92b22a4042934b785 (cherry picked from commit 7d5b1dada05cce59c1dd22f0bc3feab5b6fc6329)
-rw-r--r--cmds/installd/InstalldNativeService.cpp4
-rw-r--r--cmds/installd/binder/android/os/IInstalld.aidl1
-rw-r--r--cmds/installd/tests/installd_service_test.cpp28
3 files changed, 23 insertions, 10 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index b6ebfca2ed..2705505125 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -722,9 +722,7 @@ binder::Status InstalldNativeService::createAppDataLocked(
}
}
- // TODO(b/220095381): Due to boot time regression, we have omitted call to
- // createSdkSandboxDataDirectory from here temporarily (unless it's for testing)
- if (uuid_ != nullptr && strcmp(uuid_, "TEST") == 0) {
+ if (flags & FLAG_STORAGE_SDK) {
auto status = createSdkSandboxDataDirectory(uuid, packageName, userId, appId, previousAppId,
seInfo, flags);
if (!status.isOk()) {
diff --git a/cmds/installd/binder/android/os/IInstalld.aidl b/cmds/installd/binder/android/os/IInstalld.aidl
index f4fd9a94de..1e22f48789 100644
--- a/cmds/installd/binder/android/os/IInstalld.aidl
+++ b/cmds/installd/binder/android/os/IInstalld.aidl
@@ -131,6 +131,7 @@ interface IInstalld {
const int FLAG_STORAGE_DE = 0x1;
const int FLAG_STORAGE_CE = 0x2;
const int FLAG_STORAGE_EXTERNAL = 0x4;
+ const int FLAG_STORAGE_SDK = 0x8;
const int FLAG_CLEAR_CACHE_ONLY = 0x10;
const int FLAG_CLEAR_CODE_CACHE_ONLY = 0x20;
diff --git a/cmds/installd/tests/installd_service_test.cpp b/cmds/installd/tests/installd_service_test.cpp
index 21ab5b87b1..31f5dcef4a 100644
--- a/cmds/installd/tests/installd_service_test.cpp
+++ b/cmds/installd/tests/installd_service_test.cpp
@@ -79,6 +79,7 @@ static constexpr const char* kTestPath = "/data/local/tmp/user/0";
static constexpr const uid_t kSystemUid = 1000;
static constexpr const int32_t kTestUserId = 0;
static constexpr const uid_t kTestAppId = 19999;
+static constexpr const int FLAG_STORAGE_SDK = InstalldNativeService::FLAG_STORAGE_SDK;
const gid_t kTestAppUid = multiuser_get_uid(kTestUserId, kTestAppId);
const uid_t kTestSdkSandboxUid = multiuser_get_sdk_sandbox_uid(kTestUserId, kTestAppId);
@@ -971,7 +972,7 @@ public:
args.userId = kTestUserId;
args.appId = kTestAppId;
args.seInfo = "default";
- args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_DE;
+ args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_DE | FLAG_STORAGE_SDK;
return args;
}
@@ -1006,11 +1007,11 @@ private:
}
};
-TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSupplementalAppData) {
+TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSdkAppLevelData) {
android::os::CreateAppDataResult result;
android::os::CreateAppDataArgs args = createAppDataArgs();
args.packageName = "com.foo";
- args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_DE;
+ args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_DE | FLAG_STORAGE_SDK;
// Create the app user data.
ASSERT_BINDER_SUCCESS(service->createAppData(args, &result));
@@ -1030,11 +1031,24 @@ TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSupplementalAppData) {
S_IFDIR | S_ISGID | 0771);
}
-TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSupplementalAppData_WithoutDeFlag) {
+TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSdkAppLeveleData_WithoutSdkFlag) {
+ android::os::CreateAppDataResult result;
+ android::os::CreateAppDataArgs args = createAppDataArgs();
+ args.packageName = "com.foo";
+ args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_DE;
+
+ // Create the app user data.
+ ASSERT_BINDER_SUCCESS(service->createAppData(args, &result));
+
+ ASSERT_FALSE(exists("/data/local/tmp/misc_ce/0/sdksandbox/com.foo"));
+ ASSERT_FALSE(exists("/data/local/tmp/misc_de/0/sdksandbox/com.foo"));
+}
+
+TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSdkAppLeveleData_WithoutDeFlag) {
android::os::CreateAppDataResult result;
android::os::CreateAppDataArgs args = createAppDataArgs();
args.packageName = "com.foo";
- args.flags = FLAG_STORAGE_CE;
+ args.flags = FLAG_STORAGE_CE | FLAG_STORAGE_SDK;
// Create the app user data.
ASSERT_BINDER_SUCCESS(service->createAppData(args, &result));
@@ -1046,11 +1060,11 @@ TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSupplementalAppData_WithoutDeFla
ASSERT_FALSE(exists("/data/local/tmp/misc_de/0/sdksandbox/com.foo"));
}
-TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSupplementalAppData_WithoutCeFlag) {
+TEST_F(SdkSandboxDataTest, CreateAppData_CreatesSdkAppLeveleData_WithoutCeFlag) {
android::os::CreateAppDataResult result;
android::os::CreateAppDataArgs args = createAppDataArgs();
args.packageName = "com.foo";
- args.flags = FLAG_STORAGE_DE;
+ args.flags = FLAG_STORAGE_DE | FLAG_STORAGE_SDK;
// Create the app user data.
ASSERT_BINDER_SUCCESS(service->createAppData(args, &result));