summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2015-04-23 19:36:02 -0700
committerJeff Sharkey <jsharkey@android.com>2015-04-23 20:32:17 -0700
commit620b32b316fd4f1bab4eef55ec8802d14a55e7dd (patch)
treeafedbccf5c135e8d19ba52db199316ab0932a277 /cmds/pm
parent61044cfd9c7f02d3806338a6b8f137f50e1b1e0f (diff)
downloadframeworks_base-620b32b316fd4f1bab4eef55ec8802d14a55e7dd.zip
frameworks_base-620b32b316fd4f1bab4eef55ec8802d14a55e7dd.tar.gz
frameworks_base-620b32b316fd4f1bab4eef55ec8802d14a55e7dd.tar.bz2
Package and storage movement callbacks.
Since package and primary storage movement can take quite awhile, we want to have SystemUI surface progress and allow the Settings app to be torn down while the movement proceeds in the background. Movement requests now return a unique ID that identifies an ongoing operation, and interested parties can observe ongoing progress and final status. Internally, progress and status are overloaded so the values 0-100 are progress, and any values outside that range are terminal status. Add explicit constants for special-cased volume UUIDs, and change the APIs to accept VolumeInfo to reduce confusion. Internally the UUID value "null" means internal storage, and "primary_physical" means the current primary physical volume. These values are used for both package and primary storage movement destinations. Persist the current primary storage location in MountService metadata, since it can be moved over time. Surface disk scanned events with separate volume count so we can determine when it's partitioned successfully. Also send broadcast to support TvSettings launching into adoption flow. Bug: 19993667 Change-Id: Ic8a4034033c3cb3262023dba4a642efc6795af10
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java45
1 files changed, 15 insertions, 30 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index d5cc8cc..b84b1e2 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -51,9 +51,11 @@ import android.os.Bundle;
import android.os.IUserManager;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
+import android.text.format.DateUtils;
import android.util.Log;
import libcore.io.IoUtils;
@@ -1283,20 +1285,6 @@ public final class Pm {
}
}
- class LocalPackageMoveObserver extends IPackageMoveObserver.Stub {
- boolean finished;
- int returnCode;
-
- @Override
- public void packageMoved(String packageName, int returnCode) throws RemoteException {
- synchronized (this) {
- this.finished = true;
- this.returnCode = returnCode;
- notifyAll();
- }
- }
- }
-
public int runMove() {
final String packageName = nextArg();
String volumeUuid = nextArg();
@@ -1304,24 +1292,21 @@ public final class Pm {
volumeUuid = null;
}
- final LocalPackageMoveObserver obs = new LocalPackageMoveObserver();
try {
- mPm.movePackageAndData(packageName, volumeUuid, obs);
+ final int moveId = mPm.movePackage(packageName, volumeUuid);
- synchronized (obs) {
- while (!obs.finished) {
- try {
- obs.wait();
- } catch (InterruptedException e) {
- }
- }
- if (obs.returnCode == PackageManager.MOVE_SUCCEEDED) {
- System.out.println("Success");
- return 0;
- } else {
- System.err.println("Failure [" + obs.returnCode + "]");
- return 1;
- }
+ 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();