diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2010-04-07 16:15:50 -0700 |
---|---|---|
committer | Suchi Amalapurapu <asuchitra@google.com> | 2010-04-07 20:43:54 -0700 |
commit | 40e472521a544f26cb6956995788f7c36fff1404 (patch) | |
tree | b579a480e80d8ac15128c31c142b22d0938a44f8 /cmds/pm | |
parent | 4b18ced6b5409bb9dd4013c06b9562b76a062939 (diff) | |
download | frameworks_base-40e472521a544f26cb6956995788f7c36fff1404.zip frameworks_base-40e472521a544f26cb6956995788f7c36fff1404.tar.gz frameworks_base-40e472521a544f26cb6956995788f7c36fff1404.tar.bz2 |
Fix 2579461
Move install location values to secure settings.
Diable attribute for UI. Set default value to auto.
Add command line interface to set install location via pm.
Change-Id: I80e97b3d24845adad7102f40dcbe238f00efa406
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 659d70f..9b8b0ac 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -16,6 +16,8 @@ package com.android.commands.pm; +import com.android.internal.content.PackageHelper; + import android.content.ComponentName; import android.content.pm.ApplicationInfo; import android.content.pm.FeatureInfo; @@ -33,6 +35,7 @@ import android.content.res.Resources; import android.net.Uri; import android.os.RemoteException; import android.os.ServiceManager; +import android.provider.Settings; import java.io.File; import java.lang.reflect.Field; @@ -107,6 +110,16 @@ public final class Pm { return; } + if ("setInstallLocation".equals(op)) { + runSetInstallLocation(); + return; + } + + if ("getInstallLocation".equals(op)) { + runGetInstallLocation(); + return; + } + try { if (args.length == 1) { if (args[0].equalsIgnoreCase("-l")) { @@ -575,6 +588,51 @@ public final class Pm { return Integer.toString(result); } + private void runSetInstallLocation() { + int loc; + + String arg = nextArg(); + if (arg == null) { + System.err.println("Error: no install location specified."); + showUsage(); + return; + } + try { + loc = Integer.parseInt(arg); + } catch (NumberFormatException e) { + System.err.println("Error: install location has to be a number."); + showUsage(); + return; + } + try { + if (!mPm.setInstallLocation(loc)) { + System.err.println("Error: install location has to be a number."); + showUsage(); + } + } catch (RemoteException e) { + System.err.println(e.toString()); + System.err.println(PM_NOT_RUNNING_ERR); + } + } + + private void runGetInstallLocation() { + try { + int loc = mPm.getInstallLocation(); + String locStr = "invalid"; + if (loc == PackageHelper.APP_INSTALL_AUTO) { + locStr = "auto"; + } else if (loc == PackageHelper.APP_INSTALL_INTERNAL) { + locStr = "internal"; + } else if (loc == PackageHelper.APP_INSTALL_EXTERNAL) { + locStr = "external"; + } + System.out.println(loc + "[" + locStr + "]"); + } catch (RemoteException e) { + System.err.println(e.toString()); + System.err.println(PM_NOT_RUNNING_ERR); + } + } + private void runInstall() { int installFlags = 0; String installerPackageName = null; @@ -832,6 +890,7 @@ public final class Pm { System.err.println(" pm uninstall [-k] PACKAGE"); System.err.println(" pm enable PACKAGE_OR_COMPONENT"); System.err.println(" pm disable PACKAGE_OR_COMPONENT"); + System.err.println(" pm setInstallLocation [0/auto] [1/internal] [2/external]"); System.err.println(""); System.err.println("The list packages command prints all packages. Options:"); System.err.println(" -f: see their associated file."); @@ -867,10 +926,17 @@ public final class Pm { System.err.println(" -k: keep the data and cache directories around."); System.err.println("after the package removal."); System.err.println(""); - System.err.println("The mountsd command simulates mounting/unmounting sdcard.Options:"); - System.err.println(" -m: true or false."); - System.err.println(""); System.err.println("The enable and disable commands change the enabled state of"); System.err.println("a given package or component (written as \"package/class\")."); + System.err.println(""); + System.err.println("The getInstallLocation command gets the current install location"); + System.err.println(" 0 [auto]: Let system decide the best location"); + System.err.println(" 1 [internal]: Install on internal device storage"); + System.err.println(" 2 [external]: Install on external media"); + System.err.println(""); + System.err.println("The setInstallLocation command changes the default install location"); + System.err.println(" 0 [auto]: Let system decide the best location"); + System.err.println(" 1 [internal]: Install on internal device storage"); + System.err.println(" 2 [external]: Install on external media"); } } |