From 483f3b06ea84440a082e21b68ec2c2e54046f5a6 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 13 Mar 2012 16:08:00 -0700 Subject: Package restrictions per user Packages can be enabled/disabled per user. This requires maintaining stopped/launched states and enabled / disabled components and packages per user. Refactored pm.Settings and PackageSettingsBase to keep track of states per user. Migrated the stopped-packages.xml to users//package-restrictions.xml Changed intent resolution to handle individual user restrictions. Bunch of IPackageManager calls now have a userId argument. Make AppWidgetService handle removals of packages. Added some tests for pm.Settings and PackageManager. Change-Id: Ia83b529e1df88dbcb3bd55ebfc952a6e9b20e861 --- cmds/am/src/com/android/commands/am/Am.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cmds/am/src') diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index c15c49f..53a0186 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -62,6 +62,7 @@ public class Am { private boolean mStopOption = false; private int mRepeat = 0; + private int mUserId = 0; private String mProfileFile; @@ -135,7 +136,7 @@ public class Am { runToUri(false); } else if (op.equals("to-intent-uri")) { runToUri(true); - } else if (op.equals("switch-profile")) { + } else if (op.equals("switch-user")) { runSwitchUser(); } else { throw new IllegalArgumentException("Unknown command: " + op); @@ -152,6 +153,7 @@ public class Am { mStopOption = false; mRepeat = 0; mProfileFile = null; + mUserId = 0; Uri data = null; String type = null; @@ -308,6 +310,8 @@ public class Am { mStopOption = true; } else if (opt.equals("--opengl-trace")) { mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES; + } else if (opt.equals("--user")) { + mUserId = Integer.parseInt(nextArgRequired()); } else { System.err.println("Error: Unknown option: " + opt); showUsage(); @@ -407,7 +411,8 @@ public class Am { System.err.println("Error: Package manager not running; aborting"); return; } - List activities = pm.queryIntentActivities(intent, mimeType, 0); + List activities = pm.queryIntentActivities(intent, mimeType, 0, + mUserId); if (activities == null || activities.size() <= 0) { System.err.println("Error: Intent does not match any activities: " + intent); @@ -550,7 +555,7 @@ public class Am { IntentReceiver receiver = new IntentReceiver(); System.out.println("Broadcasting: " + intent); mAm.broadcastIntent(null, intent, null, receiver, 0, null, null, null, true, false, - Binder.getOrigCallingUser()); + mUserId); receiver.waitForFinish(); } @@ -1294,6 +1299,7 @@ public class Am { " am display-size [reset|MxN]\n" + " am to-uri [INTENT]\n" + " am to-intent-uri [INTENT]\n" + + " am switch-user \n" + "\n" + "am start: start an Activity. Options are:\n" + " -D: enable debugging\n" + -- cgit v1.1