diff options
| author | 2019-05-31 11:07:28 -0700 | |
|---|---|---|
| committer | 2019-06-03 21:57:47 +0000 | |
| commit | 895a539d438b6f86d85a3fc2781338c9aee8dfec (patch) | |
| tree | 28b596da3aba8f5934568f26f018d79a093e95e1 | |
| parent | f5671d390d0dfebec37f62bfff7228cd23cd1b59 (diff) | |
Skip legacy-fs-verity setup if file already has it
Test: 1. put com.foo.apk in /system/priv-app
2. adb install-multiple -r -p com.foo split.apk
3. adb install-multiple -r -p com.foo split.apk (second time, only
succeed with this change)
Test: update a priv app (no regression)
Bug: 129509604
Change-Id: I591dd4504e3ba6f1499ebd045dc4f1adbd88d4e3
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 595871515ab4..4a5e61bc7d72 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); } |