diff options
author | Jeff Sharkey <jsharkey@android.com> | 2015-04-05 21:10:42 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2015-04-06 21:17:58 -0700 |
commit | b2b9ab8354da1485178cd8d8e9d89ac915b3f269 (patch) | |
tree | 3d58a32b4ef47c632e5aebebee34e143d1d8cc5a /cmds/pm/src | |
parent | b9223015261afdec7e8686b732b298b809bf87dc (diff) | |
download | frameworks_base-b2b9ab8354da1485178cd8d8e9d89ac915b3f269.zip frameworks_base-b2b9ab8354da1485178cd8d8e9d89ac915b3f269.tar.gz frameworks_base-b2b9ab8354da1485178cd8d8e9d89ac915b3f269.tar.bz2 |
Installing packages to expanded storage.
PackageManager now offers to load/unload packages when expanded
volumes are mounted/unmounted. Expanded storage volumes are still
treated as FLAG_EXTERNAL_STORAGE from a public API point-of-view,
but this change starts treating the INSTALL_EXTERNAL flag as
exclusively meaning ASEC containers.
Start tracking the UUID of the volume where a package is installed,
giving us a quick way to find relevant packages. When resolving an
install location, look across all expanded volumes and pick the one
with the largest free space. When upgrading an existing package,
continue preferring the existing volume. PackageInstaller now knows
how to stage on these volumes.
Add new movePackage() variant that accepts a target volume UUID
as destination, it will eventually move data too. Expose this
move command through "pm" command for testing.
Automount expanded volumes when they appear.
Bug: 19993667
Change-Id: I9ca2aa328b9977d34e8b3e153db4bea8b8d6f8e3
Diffstat (limited to 'cmds/pm/src')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 51152af..23a8629 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -30,6 +30,7 @@ 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; @@ -55,12 +56,12 @@ import android.os.UserManager; import android.text.TextUtils; import android.util.Log; +import libcore.io.IoUtils; + import com.android.internal.content.PackageHelper; import com.android.internal.util.ArrayUtils; import com.android.internal.util.SizedInputStream; -import libcore.io.IoUtils; - import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; @@ -234,6 +235,10 @@ public final class Pm { return runForceDexOpt(); } + if ("move".equals(op)) { + return runMove(); + } + try { if (args.length == 1) { if (args[0].equalsIgnoreCase("-l")) { @@ -1278,6 +1283,51 @@ 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(); + if ("internal".equals(volumeUuid)) { + volumeUuid = null; + } + + final LocalPackageMoveObserver obs = new LocalPackageMoveObserver(); + try { + mPm.movePackageAndData(packageName, volumeUuid, obs); + + 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; + } + } + } catch (RemoteException e) { + throw e.rethrowAsRuntimeException(); + } + } + private int runUninstall() throws RemoteException { int flags = 0; int userId = UserHandle.USER_ALL; @@ -1820,6 +1870,7 @@ 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 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"); |