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

Commit c3dac2ed authored by Victor Hsieh's avatar Victor Hsieh
Browse files

Move fs-verity check into DexMetadataHelper

Bug: 180414192
Test: CtsDexMetadataHostTestCases (with pm.dexopt.dm.require_fsverity
      true/false)
Change-Id: I91924fc92afd53bf7a276fa9ee62a7ce82d4e6b1
parent 167dea12
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.util.Log;
import android.util.jar.StrictJarFile;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.security.VerityUtils;

import java.io.File;
import java.io.IOException;
@@ -76,7 +77,8 @@ public class DexMetadataHelper {
     * Returns whether fs-verity is required to install a dex metadata
     */
    public static boolean isFsVerityRequired() {
        return SystemProperties.getBoolean(PROPERTY_DM_FSVERITY_REQUIRED, false);
        return VerityUtils.isFsVeritySupported()
                && SystemProperties.getBoolean(PROPERTY_DM_FSVERITY_REQUIRED, false);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -3060,7 +3060,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
        // Also stage .dm.fsv_sig. .dm may be required to install with fs-verity signature on
        // supported on older devices.
        maybeStageFsveritySignatureLocked(dexMetadataFile, targetDexMetadataFile,
                VerityUtils.isFsVeritySupported() && DexMetadataHelper.isFsVerityRequired());
                DexMetadataHelper.isFsVerityRequired());
    }

    private void storeBytesToInstallationFile(final String localPath, final String absolutePath,