summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2012-09-24 16:11:18 -0700
committerAmith Yamasani <yamasani@google.com>2012-09-24 17:19:03 -0700
commitea7e91514ee1968d15713e82a5cca745e2c46a05 (patch)
treecea4f88f0db9fa4132f93745ee4605a59a129e80
parentbc391d58c8d09bd58b57dda20dd9d2281d90db32 (diff)
downloadframeworks_base-ea7e91514ee1968d15713e82a5cca745e2c46a05.zip
frameworks_base-ea7e91514ee1968d15713e82a5cca745e2c46a05.tar.gz
frameworks_base-ea7e91514ee1968d15713e82a5cca745e2c46a05.tar.bz2
AppInfo from Notifications for secondary users
Required wiring up startActivitiesAsUser() Bug: 7224950 Also fix a bug in navigateUp in secondary user Change-Id: I114ae2de0457362d62e899fdb94b12239a3eb778
-rw-r--r--core/java/android/app/ActivityManagerNative.java6
-rw-r--r--core/java/android/app/ContextImpl.java14
-rw-r--r--core/java/android/app/IActivityManager.java2
-rw-r--r--core/java/android/app/Instrumentation.java18
-rw-r--r--core/java/android/app/TaskStackBuilder.java21
-rw-r--r--core/java/android/content/Context.java30
-rw-r--r--core/java/android/content/ContextWrapper.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java3
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java9
9 files changed, 95 insertions, 14 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index c3f57e8..9b08493 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -1530,8 +1530,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IBinder resultTo = data.readStrongBinder();
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
+ int userId = data.readInt();
int result = startActivities(app, intents, resolvedTypes, resultTo,
- options);
+ options, userId);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -3708,7 +3709,7 @@ class ActivityManagerProxy implements IActivityManager
public int startActivities(IApplicationThread caller,
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
- Bundle options) throws RemoteException {
+ Bundle options, int userId) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -3722,6 +3723,7 @@ class ActivityManagerProxy implements IActivityManager
} else {
data.writeInt(0);
}
+ data.writeInt(userId);
mRemote.transact(START_ACTIVITIES_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index a6ec9b6..6df0c37 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -965,6 +965,20 @@ class ContextImpl extends Context {
startActivities(intents, null);
}
+ /** @hide */
+ @Override
+ public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
+ if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
+ throw new AndroidRuntimeException(
+ "Calling startActivities() from outside of an Activity "
+ + " context requires the FLAG_ACTIVITY_NEW_TASK flag on first Intent."
+ + " Is this really what you want?");
+ }
+ mMainThread.getInstrumentation().execStartActivitiesAsUser(
+ getOuterContext(), mMainThread.getApplicationThread(), null,
+ (Activity)null, intents, options, userHandle.getIdentifier());
+ }
+
@Override
public void startActivities(Intent[] intents, Bundle options) {
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 2b2679e..9454636 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -311,7 +311,7 @@ public interface IActivityManager extends IInterface {
public int startActivities(IApplicationThread caller,
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
- Bundle options) throws RemoteException;
+ Bundle options, int userId) throws RemoteException;
public int getFrontActivityScreenCompatMode() throws RemoteException;
public void setFrontActivityScreenCompatMode(int mode) throws RemoteException;
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index ee4e964..e0856ae 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1430,6 +1430,21 @@ public class Instrumentation {
*/
public void execStartActivities(Context who, IBinder contextThread,
IBinder token, Activity target, Intent[] intents, Bundle options) {
+ execStartActivitiesAsUser(who, contextThread, token, target, intents, options,
+ UserHandle.myUserId());
+ }
+
+ /**
+ * Like {@link #execStartActivity(Context, IBinder, IBinder, Activity, Intent, int)},
+ * but accepts an array of activities to be started. Note that active
+ * {@link ActivityMonitor} objects only match against the first activity in
+ * the array.
+ *
+ * {@hide}
+ */
+ public void execStartActivitiesAsUser(Context who, IBinder contextThread,
+ IBinder token, Activity target, Intent[] intents, Bundle options,
+ int userId) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1453,7 +1468,8 @@ public class Instrumentation {
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
}
int result = ActivityManagerNative.getDefault()
- .startActivities(whoThread, intents, resolvedTypes, token, options);
+ .startActivities(whoThread, intents, resolvedTypes, token, options,
+ userId);
checkStartActivityResult(result, intents[0]);
} catch (RemoteException e) {
}
diff --git a/core/java/android/app/TaskStackBuilder.java b/core/java/android/app/TaskStackBuilder.java
index cadf5e4..1eee5fd 100644
--- a/core/java/android/app/TaskStackBuilder.java
+++ b/core/java/android/app/TaskStackBuilder.java
@@ -23,6 +23,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
+import android.os.UserHandle;
import android.util.Log;
import java.util.ArrayList;
@@ -205,18 +206,26 @@ public class TaskStackBuilder {
/**
* Start the task stack constructed by this builder.
- *
- * @param options Additional options for how the Activity should be started.
- * See {@link android.content.Context#startActivity(Intent, Bundle)
- * Context.startActivity(Intent, Bundle)} for more details.
+ * @hide
*/
- public void startActivities(Bundle options) {
+ public void startActivities(Bundle options, UserHandle userHandle) {
if (mIntents.isEmpty()) {
throw new IllegalStateException(
"No intents added to TaskStackBuilder; cannot startActivities");
}
- mSourceContext.startActivities(getIntents(), options);
+ mSourceContext.startActivitiesAsUser(getIntents(), options, userHandle);
+ }
+
+ /**
+ * Start the task stack constructed by this builder.
+ *
+ * @param options Additional options for how the Activity should be started.
+ * See {@link android.content.Context#startActivity(Intent, Bundle)
+ * Context.startActivity(Intent, Bundle)} for more details.
+ */
+ public void startActivities(Bundle options) {
+ startActivities(options, new UserHandle(UserHandle.myUserId()));
}
/**
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 9162d29..ac36cf7 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -974,6 +974,36 @@ public abstract class Context {
public abstract void startActivities(Intent[] intents, Bundle options);
/**
+ * @hide
+ * Launch multiple new activities. This is generally the same as calling
+ * {@link #startActivity(Intent)} for the first Intent in the array,
+ * that activity during its creation calling {@link #startActivity(Intent)}
+ * for the second entry, etc. Note that unlike that approach, generally
+ * none of the activities except the last in the array will be created
+ * at this point, but rather will be created when the user first visits
+ * them (due to pressing back from the activity on top).
+ *
+ * <p>This method throws {@link ActivityNotFoundException}
+ * if there was no Activity found for <em>any</em> given Intent. In this
+ * case the state of the activity stack is undefined (some Intents in the
+ * list may be on it, some not), so you probably want to avoid such situations.
+ *
+ * @param intents An array of Intents to be started.
+ * @param options Additional options for how the Activity should be started.
+ * @param userHandle The user for whom to launch the activities
+ * See {@link android.content.Context#startActivity(Intent, Bundle)
+ * Context.startActivity(Intent, Bundle)} for more details.
+ *
+ * @throws ActivityNotFoundException
+ *
+ * @see {@link #startActivities(Intent[])}
+ * @see PackageManager#resolveActivity
+ */
+ public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
+ throw new RuntimeException("Not implemented. Must override in a subclass.");
+ }
+
+ /**
* Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
* with no options specified.
*
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index d824f1e..84ad667 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -311,6 +311,12 @@ public class ContextWrapper extends Context {
mBase.startActivities(intents, options);
}
+ /** @hide */
+ @Override
+ public void startActivitiesAsUser(Intent[] intents, Bundle options, UserHandle userHandle) {
+ mBase.startActivitiesAsUser(intents, options, userHandle);
+ }
+
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index dab6306..8c7c39a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -342,7 +342,8 @@ public abstract class BaseStatusBar extends SystemUI implements
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", packageName, null));
intent.setComponent(intent.resolveActivity(mContext.getPackageManager()));
- TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities();
+ TaskStackBuilder.create(mContext).addNextIntentWithParentStack(intent).startActivities(
+ null, UserHandle.CURRENT);
}
protected View.OnLongClickListener getNotificationLongClicker() {
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index a21f6d5..c49959d 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -2623,10 +2623,13 @@ public final class ActivityManagerService extends ActivityManagerNative
}
public final int startActivities(IApplicationThread caller,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options) {
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options,
+ int userId) {
enforceNotIsolatedCaller("startActivities");
+ userId = handleIncomingUserLocked(Binder.getCallingPid(), Binder.getCallingUid(), userId,
+ false, true, "startActivity", null);
int ret = mMainStack.startActivities(caller, -1, intents, resolvedTypes, resultTo,
- options, UserHandle.getCallingUserId());
+ options, userId);
return ret;
}
@@ -12434,7 +12437,7 @@ public final class ActivityManagerService extends ActivityManagerNative
} else {
try {
ActivityInfo aInfo = AppGlobals.getPackageManager().getActivityInfo(
- destIntent.getComponent(), 0, UserHandle.getCallingUserId());
+ destIntent.getComponent(), 0, srec.userId);
int res = mMainStack.startActivityLocked(srec.app.thread, destIntent,
null, aInfo, parent.appToken, null,
0, -1, parent.launchedFromUid, 0, null, true, null);