Merge "Skip legacy-fs-verity setup if file already has it" into qt-dev am: 4fd5870662

am: 6ebd3bf5e8

Change-Id: Ie135ad897405c56175719d722bd29a963e778830
This commit is contained in:
Victor Hsieh
2019-06-04 19:05:54 -07:00
committed by android-build-merger

View File

@@ -18051,9 +18051,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);
}