summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Songchun Fan <schfan@google.com> 2020-02-13 09:38:58 -0800
committer Songchun Fan <schfan@google.com> 2020-02-19 01:46:27 +0000
commit7c0f3292cfa11ec42fde245f1bb140d92f79671f (patch)
tree4b2caf02f1866560f136d205740cfcea4c386cf7
parent75088d14f428f7ae8fc3bb0a44265be4309cde12 (diff)
copy first level apk dir on movePackage
The goal is to make sure the code path still has two levels after the move, on the target storage. Test: manual as follows: $ adb install ~/Downloads/yelp.apk $ adb shell walleye:/ # su walleye:/ # sm set-virtual-disk true walleye:/ # sm list-disks disk:7,224 walleye:/ # sm partition disk:7,224 private walleye:/ # sm list-volumes private mounted null private:7,226 mounted ea386596-0d69-4cd7-87f8-2d77ced59f0c emulated;0 mounted null emulated:7,226;0 unmounted null walleye:/ # pm move-package com.yelp.android ea386596-0d69-4cd7-87f8-2d77ced59f0c Success Example log: PackageManager: Update package com.yelp.android code path from /data/app/~~LKNWa_moIm9tFw5KY5E7ZA==/com.yelp.android-VgweFDciQH9cPQLnkooiMA== to /mnt/expand/ea386596-0d69-4cd7-87f8-2d77ced59f0c/app/~~LKNWa_moIm9tFw5KY5E7ZA==/com.yelp.android-VgweFDciQH9cPQLnkooiMA== BUG: b/148844589 b/148237378 Change-Id: I46109a7befa8971a05049b4f495ca0d73e244a0b
-rw-r--r--services/core/java/com/android/server/pm/Installer.java4
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java21
2 files changed, 14 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java
index 8ad3e9df8bdf..f37af3aef657 100644
--- a/services/core/java/com/android/server/pm/Installer.java
+++ b/services/core/java/com/android/server/pm/Installer.java
@@ -234,11 +234,11 @@ public class Installer extends SystemService {
}
public void moveCompleteApp(String fromUuid, String toUuid, String packageName,
- String dataAppName, int appId, String seInfo, int targetSdkVersion,
+ int appId, String seInfo, int targetSdkVersion,
String fromCodePath) throws InstallerException {
if (!checkBeforeRemote()) return;
try {
- mInstalld.moveCompleteApp(fromUuid, toUuid, packageName, dataAppName, appId, seInfo,
+ mInstalld.moveCompleteApp(fromUuid, toUuid, packageName, appId, seInfo,
targetSdkVersion, fromCodePath);
} catch (Exception e) {
throw InstallerException.from(e);
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index ad70345dfc48..4cbbaf33db77 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -14000,20 +14000,18 @@ public class PackageManagerService extends IPackageManager.Stub
final String fromUuid;
final String toUuid;
final String packageName;
- final String dataAppName;
final int appId;
final String seinfo;
final int targetSdkVersion;
final String fromCodePath;
public MoveInfo(int moveId, String fromUuid, String toUuid, String packageName,
- String dataAppName, int appId, String seinfo, int targetSdkVersion,
+ int appId, String seinfo, int targetSdkVersion,
String fromCodePath) {
this.moveId = moveId;
this.fromUuid = fromUuid;
this.toUuid = toUuid;
this.packageName = packageName;
- this.dataAppName = dataAppName;
this.appId = appId;
this.seinfo = seinfo;
this.targetSdkVersion = targetSdkVersion;
@@ -15137,7 +15135,7 @@ public class PackageManagerService extends IPackageManager.Stub
synchronized (mInstaller) {
try {
mInstaller.moveCompleteApp(move.fromUuid, move.toUuid, move.packageName,
- move.dataAppName, move.appId, move.seinfo, move.targetSdkVersion,
+ move.appId, move.seinfo, move.targetSdkVersion,
move.fromCodePath);
} catch (InstallerException e) {
Slog.w(TAG, "Failed to move app", e);
@@ -15145,7 +15143,8 @@ public class PackageManagerService extends IPackageManager.Stub
}
}
- codeFile = new File(Environment.getDataAppDirectory(move.toUuid), move.dataAppName);
+ final String toPathName = new File(move.fromCodePath).getName();
+ codeFile = new File(Environment.getDataAppDirectory(move.toUuid), toPathName);
resourceFile = codeFile;
if (DEBUG_INSTALL) Slog.d(TAG, "codeFile after move is " + codeFile);
@@ -15197,8 +15196,9 @@ public class PackageManagerService extends IPackageManager.Stub
}
private boolean cleanUp(String volumeUuid) {
+ final String toPathName = new File(move.fromCodePath).getName();
final File codeFile = new File(Environment.getDataAppDirectory(volumeUuid),
- move.dataAppName);
+ toPathName);
Slog.d(TAG, "Cleaning up " + move.packageName + " on " + volumeUuid);
final int[] userIds = mUserManager.getUserIds();
synchronized (mInstallLock) {
@@ -22152,7 +22152,11 @@ public class PackageManagerService extends IPackageManager.Stub
targetSdkVersion = pkg.getTargetSdkVersion();
freezer = freezePackage(packageName, "movePackageInternal");
installedUserIds = ps.queryInstalledUsers(mUserManager.getUserIds(), true);
- fromCodePath = pkg.getCodePath();
+ if (codeFile.getParentFile().getName().startsWith(RANDOM_DIR_PREFIX)) {
+ fromCodePath = codeFile.getParentFile().getAbsolutePath();
+ } else {
+ fromCodePath = codeFile.getAbsolutePath();
+ }
}
final Bundle extras = new Bundle();
@@ -22279,9 +22283,8 @@ public class PackageManagerService extends IPackageManager.Stub
}
}).start();
- final String dataAppName = codeFile.getName();
move = new MoveInfo(moveId, currentVolumeUuid, volumeUuid, packageName,
- dataAppName, appId, seinfo, targetSdkVersion, fromCodePath);
+ appId, seinfo, targetSdkVersion, fromCodePath);
} else {
move = null;
}