summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-12-03 04:22:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-12-03 04:22:13 +0000
commit81f3552c083157c13aeb93c701470b3f5d1f0cd6 (patch)
tree53a24d3e169a92ed14a886431f7a8a5cf2d3cec2
parent70dfdac01315d320f47ec8865fb0fa28b065cff2 (diff)
parent39de85b953d3264de774db5690c4ef630b0ecf20 (diff)
Merge "Reland: Enable fs-verity in background thread"
-rw-r--r--services/core/java/com/android/server/pm/InstallPackageHelper.java30
1 files changed, 18 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index 5d01aebab29b..7553370bf4c6 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -2259,20 +2259,26 @@ final class InstallPackageHelper {
incrementalStorages.add(storage);
}
- try {
- if (!VerityUtils.hasFsverity(pkg.getBaseApkPath())) {
- VerityUtils.setUpFsverity(pkg.getBaseApkPath(), (byte[]) null);
- }
- for (String path : pkg.getSplitCodePaths()) {
- if (!VerityUtils.hasFsverity(path)) {
- VerityUtils.setUpFsverity(path, (byte[]) null);
+ // Enabling fs-verity is a blocking operation. To reduce the impact to the install time,
+ // run in a background thread.
+ final ArrayList<String> apkPaths = new ArrayList<>();
+ apkPaths.add(pkg.getBaseApkPath());
+ if (pkg.getSplitCodePaths() != null) {
+ Collections.addAll(apkPaths, pkg.getSplitCodePaths());
+ }
+ mInjector.getBackgroundHandler().post(() -> {
+ try {
+ for (String path : apkPaths) {
+ if (!VerityUtils.hasFsverity(path)) {
+ VerityUtils.setUpFsverity(path, (byte[]) null);
+ }
}
+ } catch (IOException e) {
+ // There's nothing we can do if the setup failed. Since fs-verity is
+ // optional, just ignore the error for now.
+ Slog.e(TAG, "Failed to fully enable fs-verity to " + packageName);
}
- } catch (IOException e) {
- // There's nothing we can do if the setup failed. Since fs-verity is
- // optional, just ignore the error for now.
- Slog.e(TAG, "Failed to fully enable fs-verity to " + packageName);
- }
+ });
// Hardcode previousAppId to 0 to disable any data migration (http://b/221088088)
mAppDataHelper.prepareAppDataPostCommitLIF(pkg, 0);