Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39de85b9 authored by Victor Hsieh's avatar Victor Hsieh
Browse files

Reland: Enable fs-verity in background thread

The previous attempt was reverted due to CTS failure. The workaround is
implemented in the test since the API contract isn't broken.

In this reland, avoid running a custom thread by leverage the existing
background handler.

Bug: 259179666
Test: on cuttlefish, run ChecksumsTest#testInstallerSignedChecksumsUpdate
Change-Id: Ie88ae3b219e904c0cd9f85b7eb31ac21e56e36d5
parent 627b85d9
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -2259,11 +2259,16 @@ final class InstallPackageHelper {
                incrementalStorages.add(storage);
            }

            // 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 {
                if (!VerityUtils.hasFsverity(pkg.getBaseApkPath())) {
                    VerityUtils.setUpFsverity(pkg.getBaseApkPath(), (byte[]) null);
                }
                for (String path : pkg.getSplitCodePaths()) {
                    for (String path : apkPaths) {
                        if (!VerityUtils.hasFsverity(path)) {
                            VerityUtils.setUpFsverity(path, (byte[]) null);
                        }
@@ -2273,6 +2278,7 @@ final class InstallPackageHelper {
                    // 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);