[pm/incremental] minor fix for unbind timing
Do not unbind stage dir after rename. IncrementalFileStorages.cleanUp() will take care of that. Otherwise, we lose the chance to unregister the loading progress listener. BUG: 181610887 Test: manual Change-Id: I690609ffeac25b07fd8fe6fd4fdfe44148325523
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user