diff options
author | Dianne Hackborn <hackbod@google.com> | 2012-08-23 18:25:40 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-08-24 13:53:13 -0700 |
commit | 7767eac3232ba2fb9828766813cdb481d6a97584 (patch) | |
tree | 41cc717fb9f11190e9da3dc12d61faf23a22861d /cmds | |
parent | 1552586283f329253edc4786a6cf40c5bb69ea36 (diff) | |
download | frameworks_base-7767eac3232ba2fb9828766813cdb481d6a97584.zip frameworks_base-7767eac3232ba2fb9828766813cdb481d6a97584.tar.gz frameworks_base-7767eac3232ba2fb9828766813cdb481d6a97584.tar.bz2 |
Keep track of whether an app is installed for each user.
This add a new per-user state for an app, indicating whether
it is installed for that user.
All system apps are always installed for all users (we still
use disable to "uninstall" them).
Now when you call into the package manager to install an app,
it will only install the app for that user unless you supply
a flag saying to install for all users. Only being installed
for the user is just the normal install state, but all other
users have marked in their state for that app that it is not
installed.
When you call the package manager APIs for information about
apps, uninstalled apps are treated as really being not visible
(somewhat more-so than disabled apps), unless you use the
GET_UNINSTALLED_PACKAGES flag.
If another user calls to install an app that is already installed,
just not for them, then the normal install process takes place
but in addition that user's installed state is toggled on.
The package manager will not send PACKAGE_ADDED, PACKAGE_REMOVED,
PACKAGE_REPLACED etc broadcasts to users who don't have a package
installed or not being involved in a change in the install state.
There are a few things that are not quite right with this -- for
example if you go through a full install (with a new apk) of an
app for one user who doesn't have it already installed, you will
still get the PACKAGED_REPLACED messages even though this is
technically the first install for your user. I'm not sure how
much of an issue this is.
When you call the existing API to uninstall an app, this toggles
the installed state of the app for that user to be off. Only if
that is the last user user that has the app uinstalled will it
actually be removed from the device. Again there is a new flag
you can pass in to force the app to be uninstalled for all users.
Also fixed issues with cleaning external storage of apps, which
was not dealing with multiple users. We now keep track of cleaning
each user for each package.
Change-Id: I00e66452b149defc08c5e0183fa673f532465ed5
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/am/src/com/android/commands/am/Am.java | 2 | ||||
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index a79eb14..22fc1ad 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -393,7 +393,7 @@ public class Am { private void runStartService() throws Exception { Intent intent = makeIntent(); System.out.println("Starting service: " + intent); - ComponentName cn = mAm.startService(null, intent, intent.getType()); + ComponentName cn = mAm.startService(null, intent, intent.getType(), 0); if (cn == null) { System.err.println("Error: Not found; no service started."); } diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index b34fd05..32865a4 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -776,7 +776,7 @@ public final class Pm { } private void runInstall() { - int installFlags = 0; + int installFlags = PackageManager.INSTALL_ALL_USERS; String installerPackageName = null; String opt; @@ -811,6 +811,8 @@ public final class Pm { } else if (opt.equals("-f")) { // Override if -s option is specified. installFlags |= PackageManager.INSTALL_INTERNAL; + } else if (opt.equals("-d")) { + installFlags |= PackageManager.INSTALL_ALLOW_DOWNGRADE; } else if (opt.equals("--algo")) { algo = nextOptionData(); if (algo == null) { @@ -1105,7 +1107,7 @@ public final class Pm { String opt = nextOption(); if (opt != null && opt.equals("-k")) { - unInstallFlags = PackageManager.DONT_DELETE_DATA; + unInstallFlags = PackageManager.DELETE_KEEP_DATA; } String pkg = nextArg(); @@ -1525,6 +1527,7 @@ public final class Pm { System.err.println(" -i: specify the installer package name."); System.err.println(" -s: install package on sdcard."); System.err.println(" -f: install package on internal flash."); + System.err.println(" -d: allow version code downgrade."); System.err.println(""); System.err.println("pm uninstall: removes a package from the system. Options:"); System.err.println(" -k: keep the data and cache directories around after package removal."); |