summaryrefslogtreecommitdiffstats
path: root/cmds
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-09-07 14:11:56 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-07 14:11:56 -0700
commit649d0d71b245d88746b78399ffa1f75da7c80974 (patch)
tree2e09499bacc887453c6fbe0c2a2c737e3d0bb247 /cmds
parent55e6b77bda7da1684ca32493d9e03184bd441dab (diff)
parent5e03e2ca7d25b899b129baad2dd5eca6bf99d88a (diff)
downloadframeworks_base-649d0d71b245d88746b78399ffa1f75da7c80974.zip
frameworks_base-649d0d71b245d88746b78399ffa1f75da7c80974.tar.gz
frameworks_base-649d0d71b245d88746b78399ffa1f75da7c80974.tar.bz2
Merge "More multi-user stuff:" into jb-mr1-dev
Diffstat (limited to 'cmds')
-rw-r--r--cmds/am/src/com/android/commands/am/Am.java47
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java18
2 files changed, 49 insertions, 16 deletions
diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java
index c8f4452..bb108c8 100644
--- a/cmds/am/src/com/android/commands/am/Am.java
+++ b/cmds/am/src/com/android/commands/am/Am.java
@@ -36,6 +36,7 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.os.UserHandle;
import android.util.AndroidException;
import android.view.Display;
import android.view.IWindowManager;
@@ -147,6 +148,18 @@ public class Am {
}
}
+ int parseUserArg(String arg) {
+ int userId;
+ if ("all".equals(arg)) {
+ userId = UserHandle.USER_ALL;
+ } else if ("current".equals(arg) || "cur".equals(arg)) {
+ userId = UserHandle.USER_CURRENT;
+ } else {
+ userId = Integer.parseInt(arg);
+ }
+ return userId;
+ }
+
private Intent makeIntent() throws URISyntaxException {
Intent intent = new Intent();
Intent baseIntent = intent;
@@ -321,7 +334,7 @@ public class Am {
} else if (opt.equals("--opengl-trace")) {
mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES;
} else if (opt.equals("--user")) {
- mUserId = Integer.parseInt(nextArgRequired());
+ mUserId = parseUserArg(nextArgRequired());
} else {
System.err.println("Error: Unknown option: " + opt);
return null;
@@ -392,8 +405,12 @@ public class Am {
private void runStartService() throws Exception {
Intent intent = makeIntent();
+ if (mUserId == UserHandle.USER_ALL) {
+ System.err.println("Error: Can't start activity with user 'all'");
+ return;
+ }
System.out.println("Starting service: " + intent);
- ComponentName cn = mAm.startService(null, intent, intent.getType(), 0);
+ ComponentName cn = mAm.startService(null, intent, intent.getType(), mUserId);
if (cn == null) {
System.err.println("Error: Not found; no service started.");
}
@@ -402,10 +419,15 @@ public class Am {
private void runStart() throws Exception {
Intent intent = makeIntent();
+ if (mUserId == UserHandle.USER_ALL) {
+ System.err.println("Error: Can't start service with user 'all'");
+ return;
+ }
+
String mimeType = intent.getType();
if (mimeType == null && intent.getData() != null
&& "content".equals(intent.getData().getScheme())) {
- mimeType = mAm.getProviderMimeType(intent.getData());
+ mimeType = mAm.getProviderMimeType(intent.getData(), mUserId);
}
do {
@@ -460,11 +482,11 @@ public class Am {
int res;
if (mWaitOption) {
result = mAm.startActivityAndWait(null, intent, mimeType,
- null, null, 0, mStartFlags, mProfileFile, fd, null);
+ null, null, 0, mStartFlags, mProfileFile, fd, null, mUserId);
res = result.result;
} else {
- res = mAm.startActivity(null, intent, mimeType,
- null, null, 0, mStartFlags, mProfileFile, fd, null);
+ res = mAm.startActivityAsUser(null, intent, mimeType,
+ null, null, 0, mStartFlags, mProfileFile, fd, null, mUserId);
}
PrintStream out = mWaitOption ? System.out : System.err;
boolean launched = false;
@@ -573,6 +595,7 @@ public class Am {
boolean wait = false;
boolean rawMode = false;
boolean no_window_animation = false;
+ int userId = 0;
Bundle args = new Bundle();
String argKey = null, argValue = null;
IWindowManager wm = IWindowManager.Stub.asInterface(ServiceManager.getService("window"));
@@ -592,12 +615,19 @@ public class Am {
} else if (opt.equals("--no_window_animation")
|| opt.equals("--no-window-animation")) {
no_window_animation = true;
+ } else if (opt.equals("--user")) {
+ userId = parseUserArg(nextArgRequired());
} else {
System.err.println("Error: Unknown option: " + opt);
return;
}
}
+ if (userId == UserHandle.USER_ALL) {
+ System.err.println("Error: Can't start instrumentation with user 'all'");
+ return;
+ }
+
String cnArg = nextArgRequired();
ComponentName cn = ComponentName.unflattenFromString(cnArg);
if (cn == null) throw new IllegalArgumentException("Bad component name: " + cnArg);
@@ -614,7 +644,7 @@ public class Am {
wm.setAnimationScale(1, 0.0f);
}
- if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher)) {
+ if (!mAm.startInstrumentation(cn, profileFile, 0, args, watcher, userId)) {
throw new AndroidException("INSTRUMENTATION_FAILED: " + cn.flattenToString());
}
@@ -1340,6 +1370,7 @@ public class Am {
" am kill-all\n" +
" am broadcast <INTENT>\n" +
" am instrument [-r] [-e <NAME> <VALUE>] [-p <FILE>] [-w]\n" +
+ " [--user <USER_ID> | all | current]\n" +
" [--no-window-animation] <COMPONENT>\n" +
" am profile start <PROCESS> <FILE>\n" +
" am profile stop [<PROCESS>]\n" +
@@ -1386,6 +1417,7 @@ public class Am {
" -p <FILE>: write profiling data to <FILE>\n" +
" -w: wait for instrumentation to finish before returning. Required for\n" +
" test runners.\n" +
+ " --user [<USER_ID> | all | current]: Specify user instrumentation runs in.\n" +
" --no-window-animation: turn off window animations will running.\n" +
"\n" +
"am profile: start and stop profiler on a process.\n" +
@@ -1433,6 +1465,7 @@ public class Am {
" [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]\n" +
" [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]\n" +
" [-n <COMPONENT>] [-f <FLAGS>]\n" +
+ " [--user [<USER_ID> | all | current]\n" +
" [--grant-read-uri-permission] [--grant-write-uri-permission]\n" +
" [--debug-log-resolution] [--exclude-stopped-packages]\n" +
" [--include-stopped-packages]\n" +
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 36bf38a..8570f27 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -20,7 +20,6 @@ import com.android.internal.content.PackageHelper;
import android.app.ActivityManagerNative;
import android.content.ComponentName;
-import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ContainerEncryptionParams;
import android.content.pm.FeatureInfo;
@@ -40,12 +39,9 @@ import android.content.pm.VerificationParams;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
-import android.os.Binder;
import android.os.IUserManager;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.UserManager;
import java.io.File;
import java.lang.reflect.Field;
@@ -74,7 +70,6 @@ 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);
@@ -1054,11 +1049,16 @@ public final class Pm {
}
private void runUninstall() {
- int unInstallFlags = 0;
+ int unInstallFlags = PackageManager.DELETE_ALL_USERS;
- String opt = nextOption();
- if (opt != null && opt.equals("-k")) {
- unInstallFlags = PackageManager.DELETE_KEEP_DATA;
+ String opt;
+ while ((opt=nextOption()) != null) {
+ if (opt.equals("-k")) {
+ unInstallFlags |= PackageManager.DELETE_KEEP_DATA;
+ } else {
+ System.err.println("Error: Unknown option: " + opt);
+ return;
+ }
}
String pkg = nextArg();