diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 595871515ab43..4a5e61bc7d728 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -18050,9 +18050,15 @@ public class PackageManagerService extends IPackageManager.Stub if (Build.IS_DEBUGGABLE) Slog.i(TAG, "Enabling verity to " + filePath); final FileDescriptor fd = result.getUnownedFileDescriptor(); try { - mInstaller.installApkVerity(filePath, fd, result.getContentSize()); final byte[] rootHash = VerityUtils.generateApkVerityRootHash(filePath); - mInstaller.assertFsverityRootHashMatches(filePath, rootHash); + try { + // A file may already have fs-verity, e.g. when reused during a split + // install. If the measurement succeeds, no need to attempt to set up. + mInstaller.assertFsverityRootHashMatches(filePath, rootHash); + } catch (InstallerException e) { + mInstaller.installApkVerity(filePath, fd, result.getContentSize()); + mInstaller.assertFsverityRootHashMatches(filePath, rootHash); + } } finally { IoUtils.closeQuietly(fd); }