summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2011-04-14 17:35:23 -0700
committerAmith Yamasani <yamasani@google.com>2011-04-15 15:15:27 -0700
commit0b285499db739ba50f2f839d633e763c70e67f96 (patch)
tree77e6ecb6572cefdfae2095dcf64c4388adae15c2 /cmds/pm
parent4123211637dcc0155091016f0c0987b80e56ab7b (diff)
downloadframeworks_base-0b285499db739ba50f2f839d633e763c70e67f96.zip
frameworks_base-0b285499db739ba50f2f839d633e763c70e67f96.tar.gz
frameworks_base-0b285499db739ba50f2f839d633e763c70e67f96.tar.bz2
Plumbing in PackageManager and installd for multi-user support.
- Create /data/user directory and symlink /data/user/0 -> /data/data for backward compatibility - Create data directories for all packages for new user - Remove data directories when removing a user - Create data directories for all users when a package is created - Clear / Remove data for multiple users - Fixed a bug in verifying the location of a system app - pm commands for createUser and removeUser (will be disabled later) - symlink duplicate lib directories to the original lib directory Change-Id: Id9fdfcf0e62406a8896aa811314dfc08d5f6ed95
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java72
1 files changed, 71 insertions, 1 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index d058e38..78a450c 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -35,9 +35,9 @@ import android.content.pm.PermissionInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.provider.Settings;
import java.io.File;
import java.lang.reflect.Field;
@@ -60,6 +60,7 @@ public final class Pm {
private static final String PM_NOT_RUNNING_ERR =
"Error: Could not access the Package Manager. Is the system running?";
+ private static final int ROOT_UID = 0;
public static void main(String[] args) {
new Pm().run(args);
@@ -127,6 +128,16 @@ public final class Pm {
return;
}
+ if ("createUser".equals(op)) {
+ runCreateUser();
+ return;
+ }
+
+ if ("removeUser".equals(op)) {
+ runRemoveUser();
+ return;
+ }
+
try {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("-l")) {
@@ -763,6 +774,63 @@ public final class Pm {
}
}
+ public void runCreateUser() {
+ // Need to be run as root
+ if (Process.myUid() != ROOT_UID) {
+ System.err.println("Error: createUser must be run as root");
+ return;
+ }
+ String name;
+ String arg = nextArg();
+ if (arg == null) {
+ System.err.println("Error: no user name specified.");
+ showUsage();
+ return;
+ }
+ name = arg;
+ try {
+ if (mPm.createUser(name, 0) == null) {
+ System.err.println("Error: couldn't create user.");
+ showUsage();
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ }
+
+ }
+
+ public void runRemoveUser() {
+ // Need to be run as root
+ if (Process.myUid() != ROOT_UID) {
+ System.err.println("Error: removeUser must be run as root");
+ return;
+ }
+ int userId;
+ String arg = nextArg();
+ if (arg == null) {
+ System.err.println("Error: no user id specified.");
+ showUsage();
+ return;
+ }
+ try {
+ userId = Integer.parseInt(arg);
+ } catch (NumberFormatException e) {
+ System.err.println("Error: user id has to be a number.");
+ showUsage();
+ return;
+ }
+ try {
+ if (!mPm.removeUser(userId)) {
+ System.err.println("Error: couldn't remove user.");
+ showUsage();
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ }
+ }
+
class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
boolean finished;
boolean result;
@@ -1006,6 +1074,8 @@ public final class Pm {
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(" pm createUser USER_NAME");
+ System.err.println(" pm removeUser USER_ID");
System.err.println("");
System.err.println("The list packages command prints all packages, optionally only");
System.err.println("those whose package name contains the text in FILTER. Options:");