summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2011-05-04 14:49:28 -0700
committerAmith Yamasani <yamasani@google.com>2012-02-03 12:01:47 -0800
commit742a67127366c376fdf188ff99ba30b27d3bf90c (patch)
tree4a801b0b2e9ee10fb322e3b450e2af9eb6e3002f /cmds/pm
parent8ca8a69d5801ad4b809e7b9dbf53bd728820924b (diff)
downloadframeworks_base-742a67127366c376fdf188ff99ba30b27d3bf90c.zip
frameworks_base-742a67127366c376fdf188ff99ba30b27d3bf90c.tar.gz
frameworks_base-742a67127366c376fdf188ff99ba30b27d3bf90c.tar.bz2
Multi-user - 1st major checkin
Switching activity stacks Cache ContentProvider per user Long-press power to switch users (on phone) Added ServiceMap for separating services by user Launch PendingIntents on the correct user's uid Fix task switching from Recents list AppWidgetService is mostly working. Commands added to pm and am to allow creating and switching profiles. Change-Id: I15810e8cfbe50a04bd3323a7ef5a8ff4230870ed
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java60
1 files changed, 44 insertions, 16 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index c0ba543..f457842 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -16,8 +16,6 @@
package com.android.commands.pm;
-import com.android.internal.content.PackageHelper;
-
import android.app.ActivityManagerNative;
import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
@@ -33,14 +31,17 @@ import android.content.pm.PackageManager;
import android.content.pm.ParceledListSlice;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
+import android.content.pm.UserInfo;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
-import android.os.Parcel;
+import android.os.Binder;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
+import com.android.internal.content.PackageHelper;
+
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -135,13 +136,18 @@ public final class Pm {
return;
}
- if ("createUser".equals(op)) {
- runCreateUser();
+ if ("create-profile".equals(op)) {
+ runCreateProfile();
+ return;
+ }
+
+ if ("remove-profile".equals(op)) {
+ runRemoveProfile();
return;
}
- if ("removeUser".equals(op)) {
- runRemoveUser();
+ if ("list-profiles".equals(op)) {
+ runListProfiles();
return;
}
@@ -829,10 +835,10 @@ public final class Pm {
}
}
- public void runCreateUser() {
+ public void runCreateProfile() {
// Need to be run as root
if (Process.myUid() != ROOT_UID) {
- System.err.println("Error: createUser must be run as root");
+ System.err.println("Error: create-profile must be run as root");
return;
}
String name;
@@ -845,7 +851,7 @@ public final class Pm {
name = arg;
try {
if (mPm.createUser(name, 0) == null) {
- System.err.println("Error: couldn't create user.");
+ System.err.println("Error: couldn't create profile.");
showUsage();
}
} catch (RemoteException e) {
@@ -855,10 +861,10 @@ public final class Pm {
}
- public void runRemoveUser() {
+ public void runRemoveProfile() {
// Need to be run as root
if (Process.myUid() != ROOT_UID) {
- System.err.println("Error: removeUser must be run as root");
+ System.err.println("Error: remove-profile must be run as root");
return;
}
int userId;
@@ -877,7 +883,7 @@ public final class Pm {
}
try {
if (!mPm.removeUser(userId)) {
- System.err.println("Error: couldn't remove user.");
+ System.err.println("Error: couldn't remove profile.");
showUsage();
}
} catch (RemoteException e) {
@@ -886,6 +892,27 @@ public final class Pm {
}
}
+ public void runListProfiles() {
+ // Need to be run as root
+ if (Process.myUid() != ROOT_UID) {
+ System.err.println("Error: list-profiles must be run as root");
+ return;
+ }
+ try {
+ List<UserInfo> users = mPm.getUsers();
+ if (users == null) {
+ System.err.println("Error: couldn't get users");
+ } else {
+ System.out.println("Users:");
+ for (int i = 0; i < users.size(); i++) {
+ System.out.println("\t" + users.get(i).toString());
+ }
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ }
+ }
class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
boolean finished;
boolean result;
@@ -966,7 +993,8 @@ public final class Pm {
ClearDataObserver obs = new ClearDataObserver();
try {
- if (!ActivityManagerNative.getDefault().clearApplicationUserData(pkg, obs)) {
+ if (!ActivityManagerNative.getDefault().clearApplicationUserData(pkg, obs,
+ Binder.getOrigCallingUser())) {
System.err.println("Failed");
}
@@ -1132,8 +1160,8 @@ public final class Pm {
System.err.println(" pm disable-user PACKAGE_OR_COMPONENT");
System.err.println(" pm set-install-location [0/auto] [1/internal] [2/external]");
System.err.println(" pm get-install-location");
- System.err.println(" pm createUser USER_NAME");
- System.err.println(" pm removeUser USER_ID");
+ System.err.println(" pm create-profile USER_NAME");
+ System.err.println(" pm remove-profile USER_ID");
System.err.println("");
System.err.println("pm list packages: prints all packages, optionally only");
System.err.println(" those whose package name contains the text in FILTER. Options:");