summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-04-24 16:10:32 -0700
committerJeff Sharkey <jsharkey@android.com>2015-04-24 18:01:45 -0700
commit275e3e43f2fba72fa99001cafa2a70e5478fc545 (patch)
treebe196ff698ba222c410d0666d430fa0ec5aa5ae4 /cmds/pm
parentb423e300f77de90aea34321ef7f67882d4e526ed (diff)
downloadframeworks_base-275e3e43f2fba72fa99001cafa2a70e5478fc545.zip
frameworks_base-275e3e43f2fba72fa99001cafa2a70e5478fc545.tar.gz
frameworks_base-275e3e43f2fba72fa99001cafa2a70e5478fc545.tar.bz2
Migrate primary external storage.
Wire up through MountService to call down into vold. Watch for unsolicited events that report progress, including special value "82" that signals that copy has finished. We use this value to persist the volumeUuid in case of unexpected reboot, since it indicates the new volume is ready. Wire progress updates through existing callback pipeline. Update the volume mounting code to match against the persisted UUID when selecting the primary external storage. Bug: 19993667 Change-Id: Id46957610fb43517bbfbc368f29b7d430664590d
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index b84b1e2..39de1dc7 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -30,7 +30,6 @@ import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDataObserver;
import android.content.pm.IPackageInstaller;
import android.content.pm.IPackageManager;
-import android.content.pm.IPackageMoveObserver;
import android.content.pm.InstrumentationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInstaller;
@@ -237,8 +236,12 @@ public final class Pm {
return runForceDexOpt();
}
- if ("move".equals(op)) {
- return runMove();
+ if ("move-package".equals(op)) {
+ return runMovePackage();
+ }
+
+ if ("move-primary-storage".equals(op)) {
+ return runMovePrimaryStorage();
}
try {
@@ -1285,7 +1288,7 @@ public final class Pm {
}
}
- public int runMove() {
+ public int runMovePackage() {
final String packageName = nextArg();
String volumeUuid = nextArg();
if ("internal".equals(volumeUuid)) {
@@ -1313,6 +1316,33 @@ public final class Pm {
}
}
+ public int runMovePrimaryStorage() {
+ String volumeUuid = nextArg();
+ if ("internal".equals(volumeUuid)) {
+ volumeUuid = null;
+ }
+
+ try {
+ final int moveId = mPm.movePrimaryStorage(volumeUuid);
+
+ int status = mPm.getMoveStatus(moveId);
+ while (!PackageManager.isMoveStatusFinished(status)) {
+ SystemClock.sleep(DateUtils.SECOND_IN_MILLIS);
+ status = mPm.getMoveStatus(moveId);
+ }
+
+ if (status == PackageManager.MOVE_SUCCEEDED) {
+ System.out.println("Success");
+ return 0;
+ } else {
+ System.err.println("Failure [" + status + "]");
+ return 1;
+ }
+ } catch (RemoteException e) {
+ throw e.rethrowAsRuntimeException();
+ }
+ }
+
private int runUninstall() throws RemoteException {
int flags = 0;
int userId = UserHandle.USER_ALL;
@@ -1860,7 +1890,8 @@ public final class Pm {
System.err.println(" pm install-abandon SESSION_ID");
System.err.println(" pm uninstall [-k] [--user USER_ID] PACKAGE");
System.err.println(" pm set-installer PACKAGE INSTALLER");
- System.err.println(" pm move PACKAGE [internal|UUID]");
+ System.err.println(" pm move-package PACKAGE [internal|UUID]");
+ System.err.println(" pm move-primary-storage [internal|UUID]");
System.err.println(" pm clear [--user USER_ID] PACKAGE");
System.err.println(" pm enable [--user USER_ID] PACKAGE_OR_COMPONENT");
System.err.println(" pm disable [--user USER_ID] PACKAGE_OR_COMPONENT");