Merge "[pm/incremental] minor fix for unbind timing" into sc-dev

This commit is contained in:
Songchun Fan
2021-03-02 22:55:06 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 7 deletions

View File

@@ -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 * 1) The actual apk directory under /data/incremental is bind-mounted to the parent directory
* of {@code afterCodeFile}. * of {@code afterCodeFile}.
* 2) All the files under {@code beforeCodeFile} will show up under {@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. * @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 * Example: /data/app/vmdl*tmp
* @param afterCodeFile Path that should will have APKs after this method is called. Its parent * @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. * directory should be bind-mounted to a directory under /data/incremental.
* Example: /data/app/~~[randomStringA]/[packageName]-[randomStringB] * Example: /data/app/~~[randomStringA]/[packageName]-[randomStringB]
* @throws IllegalArgumentException * @throws IllegalArgumentException
* @throws IOException * @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 { throws IllegalArgumentException, IOException {
final File beforeCodeAbsolute = beforeCodeFile.getAbsoluteFile(); final File beforeCodeAbsolute = beforeCodeFile.getAbsoluteFile();
final IncrementalStorage apkStorage = openStorage(beforeCodeAbsolute.toString()); final IncrementalStorage apkStorage = openStorage(beforeCodeAbsolute.toString());
@@ -188,7 +187,6 @@ public final class IncrementalManager {
try { try {
final String afterCodePathName = afterCodeFile.getName(); final String afterCodePathName = afterCodeFile.getName();
linkFiles(apkStorage, beforeCodeAbsolute, "", linkedApkStorage, afterCodePathName); linkFiles(apkStorage, beforeCodeAbsolute, "", linkedApkStorage, afterCodePathName);
apkStorage.unBind(beforeCodeAbsolute.toString());
} catch (Exception e) { } catch (Exception e) {
linkedApkStorage.unBind(targetStorageDir); linkedApkStorage.unBind(targetStorageDir);
throw e; throw e;

View File

@@ -17993,7 +17993,9 @@ public class PackageManagerService extends IPackageManager.Stub
try { try {
makeDirRecursive(afterCodeFile.getParentFile(), 0775); makeDirRecursive(afterCodeFile.getParentFile(), 0775);
if (onIncremental) { 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 { } else {
Os.rename(beforeCodeFile.getAbsolutePath(), afterCodeFile.getAbsolutePath()); Os.rename(beforeCodeFile.getAbsolutePath(), afterCodeFile.getAbsolutePath());
} }
@@ -18002,7 +18004,6 @@ public class PackageManagerService extends IPackageManager.Stub
return false; return false;
} }
//TODO(b/136132412): enable selinux restorecon for incremental directories
if (!onIncremental && !SELinux.restoreconRecursive(afterCodeFile)) { if (!onIncremental && !SELinux.restoreconRecursive(afterCodeFile)) {
Slog.w(TAG, "Failed to restorecon"); Slog.w(TAG, "Failed to restorecon");
return false; return false;