diff --git a/core/java/android/os/incremental/IncrementalManager.java b/core/java/android/os/incremental/IncrementalManager.java index 592e98abae638..87dced8a34370 100644 --- a/core/java/android/os/incremental/IncrementalManager.java +++ b/core/java/android/os/incremental/IncrementalManager.java @@ -155,22 +155,21 @@ public final class IncrementalManager { } /** - * Set up an app's code path. The expected outcome of this method is: + * Link an app's files from the stage dir to the final installation location. + * The expected outcome of this method is: * 1) The actual apk directory under /data/incremental is bind-mounted to the parent directory * of {@code afterCodeFile}. * 2) All the files under {@code beforeCodeFile} will show up under {@code afterCodeFile}. * * @param beforeCodeFile Path that is currently bind-mounted and have APKs under it. - * Should no longer have any APKs after this method is called. * Example: /data/app/vmdl*tmp * @param afterCodeFile Path that should will have APKs after this method is called. Its parent * directory should be bind-mounted to a directory under /data/incremental. * Example: /data/app/~~[randomStringA]/[packageName]-[randomStringB] * @throws IllegalArgumentException * @throws IOException - * TODO(b/147371381): add unit tests */ - public void renameCodePath(File beforeCodeFile, File afterCodeFile) + public void linkCodePath(File beforeCodeFile, File afterCodeFile) throws IllegalArgumentException, IOException { final File beforeCodeAbsolute = beforeCodeFile.getAbsoluteFile(); final IncrementalStorage apkStorage = openStorage(beforeCodeAbsolute.toString()); @@ -188,7 +187,6 @@ public final class IncrementalManager { try { final String afterCodePathName = afterCodeFile.getName(); linkFiles(apkStorage, beforeCodeAbsolute, "", linkedApkStorage, afterCodePathName); - apkStorage.unBind(beforeCodeAbsolute.toString()); } catch (Exception e) { linkedApkStorage.unBind(targetStorageDir); throw e; diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index e3f925a97ddaa..82778778a27f8 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -17985,7 +17985,9 @@ public class PackageManagerService extends IPackageManager.Stub try { makeDirRecursive(afterCodeFile.getParentFile(), 0775); if (onIncremental) { - mIncrementalManager.renameCodePath(beforeCodeFile, afterCodeFile); + // Just link files here. The stage dir will be removed when the installation + // session is completed. + mIncrementalManager.linkCodePath(beforeCodeFile, afterCodeFile); } else { Os.rename(beforeCodeFile.getAbsolutePath(), afterCodeFile.getAbsolutePath()); } @@ -17994,7 +17996,6 @@ public class PackageManagerService extends IPackageManager.Stub return false; } - //TODO(b/136132412): enable selinux restorecon for incremental directories if (!onIncremental && !SELinux.restoreconRecursive(afterCodeFile)) { Slog.w(TAG, "Failed to restorecon"); return false;