diff options
Diffstat (limited to 'core/java/android/app')
-rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 6 | ||||
-rw-r--r-- | core/java/android/app/ContextImpl.java | 14 | ||||
-rw-r--r-- | core/java/android/app/IActivityManager.java | 2 | ||||
-rw-r--r-- | core/java/android/app/Instrumentation.java | 18 | ||||
-rw-r--r-- | core/java/android/app/TaskStackBuilder.java | 21 |
5 files changed, 51 insertions, 10 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())); } /** |