diff options
| author | 2022-12-03 04:22:13 +0000 | |
|---|---|---|
| committer | 2022-12-03 04:22:13 +0000 | |
| commit | 81f3552c083157c13aeb93c701470b3f5d1f0cd6 (patch) | |
| tree | 53a24d3e169a92ed14a886431f7a8a5cf2d3cec2 | |
| parent | 70dfdac01315d320f47ec8865fb0fa28b065cff2 (diff) | |
| parent | 39de85b953d3264de774db5690c4ef630b0ecf20 (diff) | |
Merge "Reland: Enable fs-verity in background thread"
| -rw-r--r-- | services/core/java/com/android/server/pm/InstallPackageHelper.java | 30 |
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); |