More robust createAppData() batching.
The perf team noticed that createAppData() is pretty slow, holding up
typical device boot timings because it loops over all installed apps
twice (once for DE, once for CE storage), making blocking installd
calls for each individual app.
There was a createAppDataBatched() method added awhile back, but it
was only wired up for multi-user initialization, and it was fragile
because any failure in the batch would leave the device in a
non-deterministic state.
This change rewrites the installd batch call to return a unique
result object for each request, allowing us to share both detailed
success (returning CE inode values) and detailed error messages,
instead of failing the entire batch request.
On the framework side, we use CompletableFuture to collect multiple
requests for batching, while also allowing "chaining" of follow-up
work, which PackageManagerService heavily relies upon. (For example,
when a specific package fails, we might want to try destroying and
recreating its data directories.)
Bug: 163861619
Test: atest FrameworksServicesTests:com.android.server.pm
Test: atest android.appsecurity.cts.DirectBootHostTest
Change-Id: Ib903dbbbe98fa453c8a3500338824064ae64f80f
diff --git a/cmds/installd/InstalldNativeService.h b/cmds/installd/InstalldNativeService.h
index 9819327..4966b96 100644
--- a/cmds/installd/InstalldNativeService.h
+++ b/cmds/installd/InstalldNativeService.h
@@ -44,15 +44,18 @@
int32_t userSerial, int32_t flags);
binder::Status destroyUserData(const std::optional<std::string>& uuid, int32_t userId,
int32_t flags);
- binder::Status createAppDataBatched(
- const std::optional<std::vector<std::optional<std::string>>>& uuids,
- const std::optional<std::vector<std::optional<std::string>>>& packageNames,
- int32_t userId, int32_t flags, const std::vector<int32_t>& appIds,
- const std::vector<std::string>& seInfos, const std::vector<int32_t>& targetSdkVersions,
- int64_t* _aidl_return);
+
binder::Status createAppData(const std::optional<std::string>& uuid,
const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
const std::string& seInfo, int32_t targetSdkVersion, int64_t* _aidl_return);
+
+ binder::Status createAppData(
+ const android::os::CreateAppDataArgs& args,
+ android::os::CreateAppDataResult* _aidl_return);
+ binder::Status createAppDataBatched(
+ const std::vector<android::os::CreateAppDataArgs>& args,
+ std::vector<android::os::CreateAppDataResult>* _aidl_return);
+
binder::Status restoreconAppData(const std::optional<std::string>& uuid,
const std::string& packageName, int32_t userId, int32_t flags, int32_t appId,
const std::string& seInfo);