Add new "options" argument to all startActivity APIs.

This will be used to allow new features to be requested...  such as,
say, a special kind of animation.  Right now there are no options
defined.

Change-Id: I4eb6f27275cdd4bf186f6da316ab93a2372ad4b7
This commit is contained in:
Dianne Hackborn
2012-03-14 10:38:05 -07:00
parent 89ea4ca9c2
commit a4972e951b
20 changed files with 871 additions and 374 deletions

View File

@@ -2688,13 +2688,20 @@ package android.app {
method public final deprecated boolean showDialog(int, android.os.Bundle);
method public android.view.ActionMode startActionMode(android.view.ActionMode.Callback);
method public void startActivityForResult(android.content.Intent, int);
method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
method public void startActivityFromChild(android.app.Activity, android.content.Intent, int);
method public void startActivityFromChild(android.app.Activity, android.content.Intent, int, android.os.Bundle);
method public void startActivityFromFragment(android.app.Fragment, android.content.Intent, int);
method public void startActivityFromFragment(android.app.Fragment, android.content.Intent, int, android.os.Bundle);
method public boolean startActivityIfNeeded(android.content.Intent, int);
method public boolean startActivityIfNeeded(android.content.Intent, int, android.os.Bundle);
method public void startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public void startIntentSenderFromChild(android.app.Activity, android.content.IntentSender, int, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSenderFromChild(android.app.Activity, android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public deprecated void startManagingCursor(android.database.Cursor);
method public boolean startNextMatchingActivity(android.content.Intent);
method public boolean startNextMatchingActivity(android.content.Intent, android.os.Bundle);
method public void startSearch(java.lang.String, boolean, android.os.Bundle, boolean);
method public deprecated void stopManagingCursor(android.database.Cursor);
method public void takeKeyEvents(boolean);
@@ -3320,7 +3327,9 @@ package android.app {
method public void setTargetFragment(android.app.Fragment, int);
method public void setUserVisibleHint(boolean);
method public void startActivity(android.content.Intent);
method public void startActivity(android.content.Intent, android.os.Bundle);
method public void startActivityForResult(android.content.Intent, int);
method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
method public void unregisterForContextMenu(android.view.View);
}
@@ -5149,9 +5158,12 @@ package android.content {
method public abstract deprecated void setWallpaper(android.graphics.Bitmap) throws java.io.IOException;
method public abstract deprecated void setWallpaper(java.io.InputStream) throws java.io.IOException;
method public abstract void startActivities(android.content.Intent[]);
method public abstract void startActivities(android.content.Intent[], android.os.Bundle);
method public abstract void startActivity(android.content.Intent);
method public abstract void startActivity(android.content.Intent, android.os.Bundle);
method public abstract boolean startInstrumentation(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public abstract void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public abstract void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public abstract android.content.ComponentName startService(android.content.Intent);
method public abstract boolean stopService(android.content.Intent);
method public abstract void unbindService(android.content.ServiceConnection);
@@ -5274,9 +5286,12 @@ package android.content {
method public void setWallpaper(android.graphics.Bitmap) throws java.io.IOException;
method public void setWallpaper(java.io.InputStream) throws java.io.IOException;
method public void startActivities(android.content.Intent[]);
method public void startActivities(android.content.Intent[], android.os.Bundle);
method public void startActivity(android.content.Intent);
method public void startActivity(android.content.Intent, android.os.Bundle);
method public boolean startInstrumentation(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public android.content.ComponentName startService(android.content.Intent);
method public boolean stopService(android.content.Intent);
method public void unbindService(android.content.ServiceConnection);
@@ -19926,9 +19941,12 @@ package android.test.mock {
method public void setWallpaper(android.graphics.Bitmap) throws java.io.IOException;
method public void setWallpaper(java.io.InputStream) throws java.io.IOException;
method public void startActivities(android.content.Intent[]);
method public void startActivities(android.content.Intent[], android.os.Bundle);
method public void startActivity(android.content.Intent);
method public void startActivity(android.content.Intent, android.os.Bundle);
method public boolean startInstrumentation(android.content.ComponentName, java.lang.String, android.os.Bundle);
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public android.content.ComponentName startService(android.content.Intent);
method public boolean stopService(android.content.Intent);
method public void unbindService(android.content.ServiceConnection);

View File

@@ -57,16 +57,13 @@ public class Am {
private int mNextArg;
private String mCurArgData;
private boolean mDebugOption = false;
private int mStartFlags = 0;
private boolean mWaitOption = false;
private boolean mStopOption = false;
private boolean mOpenglTraceOption = false;
private int mRepeat = 0;
private String mProfileFile;
private boolean mProfileAutoStop;
// These are magic strings understood by the Eclipse plugin.
private static final String FATAL_ERROR_CODE = "Error type 1";
@@ -150,10 +147,9 @@ public class Am {
Intent baseIntent = intent;
boolean hasIntentInfo = false;
mDebugOption = false;
mStartFlags = 0;
mWaitOption = false;
mStopOption = false;
mOpenglTraceOption = false;
mRepeat = 0;
mProfileFile = null;
Uri data = null;
@@ -297,21 +293,21 @@ public class Am {
intent.setDataAndType(data, type);
intent = new Intent();
} else if (opt.equals("-D")) {
mDebugOption = true;
mStartFlags |= ActivityManager.START_FLAG_DEBUG;
} else if (opt.equals("-W")) {
mWaitOption = true;
} else if (opt.equals("-P")) {
mProfileFile = nextArgRequired();
mProfileAutoStop = true;
mStartFlags |= ActivityManager.START_FLAG_AUTO_STOP_PROFILER;
} else if (opt.equals("--start-profiler")) {
mProfileFile = nextArgRequired();
mProfileAutoStop = false;
mStartFlags &= ~ActivityManager.START_FLAG_AUTO_STOP_PROFILER;
} else if (opt.equals("-R")) {
mRepeat = Integer.parseInt(nextArgRequired());
} else if (opt.equals("-S")) {
mStopOption = true;
} else if (opt.equals("--opengl-trace")) {
mOpenglTraceOption = true;
mStartFlags |= ActivityManager.START_FLAG_OPENGL_TRACES;
} else {
System.err.println("Error: Unknown option: " + opt);
showUsage();
@@ -450,64 +446,60 @@ public class Am {
int res;
if (mWaitOption) {
result = mAm.startActivityAndWait(null, intent, mimeType,
null, 0, null, null, 0, false,
mDebugOption, mOpenglTraceOption,
mProfileFile, fd, mProfileAutoStop);
null, null, 0, mStartFlags, mProfileFile, fd, null);
res = result.result;
} else {
res = mAm.startActivity(null, intent, mimeType,
null, 0, null, null, 0, false,
mDebugOption, mOpenglTraceOption,
mProfileFile, fd, mProfileAutoStop);
null, null, 0, mStartFlags, mProfileFile, fd, null);
}
PrintStream out = mWaitOption ? System.out : System.err;
boolean launched = false;
switch (res) {
case IActivityManager.START_SUCCESS:
case ActivityManager.START_SUCCESS:
launched = true;
break;
case IActivityManager.START_SWITCHES_CANCELED:
case ActivityManager.START_SWITCHES_CANCELED:
launched = true;
out.println(
"Warning: Activity not started because the "
+ " current activity is being kept for the user.");
break;
case IActivityManager.START_DELIVERED_TO_TOP:
case ActivityManager.START_DELIVERED_TO_TOP:
launched = true;
out.println(
"Warning: Activity not started, intent has "
+ "been delivered to currently running "
+ "top-most instance.");
break;
case IActivityManager.START_RETURN_INTENT_TO_CALLER:
case ActivityManager.START_RETURN_INTENT_TO_CALLER:
launched = true;
out.println(
"Warning: Activity not started because intent "
+ "should be handled by the caller");
break;
case IActivityManager.START_TASK_TO_FRONT:
case ActivityManager.START_TASK_TO_FRONT:
launched = true;
out.println(
"Warning: Activity not started, its current "
+ "task has been brought to the front");
break;
case IActivityManager.START_INTENT_NOT_RESOLVED:
case ActivityManager.START_INTENT_NOT_RESOLVED:
out.println(
"Error: Activity not started, unable to "
+ "resolve " + intent.toString());
break;
case IActivityManager.START_CLASS_NOT_FOUND:
case ActivityManager.START_CLASS_NOT_FOUND:
out.println(NO_CLASS_ERROR_CODE);
out.println("Error: Activity class " +
intent.getComponent().toShortString()
+ " does not exist.");
break;
case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
case ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
out.println(
"Error: Activity not started, you requested to "
+ "both forward and receive its result");
break;
case IActivityManager.START_PERMISSION_DENIED:
case ActivityManager.START_PERMISSION_DENIED:
out.println(
"Error: Activity not started, you do not "
+ "have permission to access it.");

View File

@@ -3165,43 +3165,61 @@ public class Activity extends ContextThemeWrapper
}
}
/**
* Same as calling {@link #startActivityForResult(Intent, int, Bundle)}
* with no options.
*
* @param intent The intent to start.
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*
* @throws android.content.ActivityNotFoundException
*
* @see #startActivity
*/
public void startActivityForResult(Intent intent, int requestCode) {
startActivityForResult(intent, requestCode, null);
}
/**
* Launch an activity for which you would like a result when it finished.
* When this activity exits, your
* onActivityResult() method will be called with the given requestCode.
* Using a negative requestCode is the same as calling
* {@link #startActivity} (the activity is not launched as a sub-activity).
*
*
* <p>Note that this method should only be used with Intent protocols
* that are defined to return a result. In other protocols (such as
* {@link Intent#ACTION_MAIN} or {@link Intent#ACTION_VIEW}), you may
* not get the result when you expect. For example, if the activity you
* are launching uses the singleTask launch mode, it will not run in your
* task and thus you will immediately receive a cancel result.
*
*
* <p>As a special case, if you call startActivityForResult() with a requestCode
* >= 0 during the initial onCreate(Bundle savedInstanceState)/onResume() of your
* activity, then your window will not be displayed until a result is
* returned back from the started activity. This is to avoid visible
* flickering when redirecting to another activity.
*
*
* <p>This method throws {@link android.content.ActivityNotFoundException}
* if there was no Activity found to run the given Intent.
*
*
* @param intent The intent to start.
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
*
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
*
* @see #startActivity
*/
public void startActivityForResult(Intent intent, int requestCode) {
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (mParent == null) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, this,
intent, requestCode);
intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, mEmbeddedID, requestCode, ar.getResultCode(),
@@ -3218,10 +3236,38 @@ public class Activity extends ContextThemeWrapper
mStartedActivity = true;
}
} else {
mParent.startActivityFromChild(this, intent, requestCode);
if (options != null) {
mParent.startActivityFromChild(this, intent, requestCode, options);
} else {
// Note we want to go through this method for compatibility with
// existing applications that may have overridden it.
mParent.startActivityFromChild(this, intent, requestCode);
}
}
}
/**
* Same as calling {@link #startIntentSenderForResult(IntentSender, int,
* Intent, int, int, int, Bundle)} with no options.
*
* @param intent The IntentSender to launch.
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits.
* @param fillInIntent If non-null, this will be provided as the
* intent parameter to {@link IntentSender#sendIntent}.
* @param flagsMask Intent flags in the original IntentSender that you
* would like to change.
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
*/
public void startIntentSenderForResult(IntentSender intent, int requestCode,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
startIntentSenderForResult(intent, requestCode, fillInIntent, flagsMask,
flagsValues, extraFlags, null);
}
/**
* Like {@link #startActivityForResult(Intent, int)}, but allowing you
* to use a IntentSender to describe the activity to be started. If
@@ -3241,21 +3287,29 @@ public class Activity extends ContextThemeWrapper
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*/
public void startIntentSenderForResult(IntentSender intent, int requestCode,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
if (mParent == null) {
startIntentSenderForResultInner(intent, requestCode, fillInIntent,
flagsMask, flagsValues, this);
flagsMask, flagsValues, this, options);
} else if (options != null) {
mParent.startIntentSenderFromChild(this, intent, requestCode,
fillInIntent, flagsMask, flagsValues, extraFlags, options);
} else {
// Note we want to go through this call for compatibility with
// existing applications that may have overridden the method.
mParent.startIntentSenderFromChild(this, intent, requestCode,
fillInIntent, flagsMask, flagsValues, extraFlags);
}
}
private void startIntentSenderForResultInner(IntentSender intent, int requestCode,
Intent fillInIntent, int flagsMask, int flagsValues, Activity activity)
Intent fillInIntent, int flagsMask, int flagsValues, Activity activity,
Bundle options)
throws IntentSender.SendIntentException {
try {
String resolvedType = null;
@@ -3266,8 +3320,8 @@ public class Activity extends ContextThemeWrapper
int result = ActivityManagerNative.getDefault()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent,
fillInIntent, resolvedType, mToken, activity.mEmbeddedID,
requestCode, flagsMask, flagsValues);
if (result == IActivityManager.START_CANCELED) {
requestCode, flagsMask, flagsValues, options);
if (result == ActivityManager.START_CANCELED) {
throw new IntentSender.SendIntentException();
}
Instrumentation.checkStartActivityResult(result, null);
@@ -3285,6 +3339,22 @@ public class Activity extends ContextThemeWrapper
}
}
/**
* Same as {@link #startActivity(Intent, Bundle)} with no options
* specified.
*
* @param intent The intent to start.
*
* @throws android.content.ActivityNotFoundException
*
* @see {@link #startActivity(Intent, Bundle)}
* @see #startActivityForResult
*/
@Override
public void startActivity(Intent intent) {
startActivity(intent, null);
}
/**
* Launch a new activity. You will not receive any information about when
* the activity exits. This implementation overrides the base version,
@@ -3298,14 +3368,39 @@ public class Activity extends ContextThemeWrapper
* if there was no Activity found to run the given Intent.
*
* @param intent The intent to start.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
*
* @see {@link #startActivity(Intent)}
* @see #startActivityForResult
*/
@Override
public void startActivity(Intent intent) {
startActivityForResult(intent, -1);
public void startActivity(Intent intent, Bundle options) {
if (options != null) {
startActivityForResult(intent, -1, options);
} else {
// Note we want to go through this call for compatibility with
// applications that may have overridden the method.
startActivityForResult(intent, -1);
}
}
/**
* Same as {@link #startActivities(Intent[], Bundle)} with no options
* specified.
*
* @param intents The intents to start.
*
* @throws android.content.ActivityNotFoundException
*
* @see {@link #startActivities(Intent[], Bundle)}
* @see #startActivityForResult
*/
@Override
public void startActivities(Intent[] intents) {
startActivities(intents, null);
}
/**
@@ -3321,22 +3416,23 @@ public class Activity extends ContextThemeWrapper
* if there was no Activity found to run the given Intent.
*
* @param intents The intents to start.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
* @see {@link #startActivities(Intent[])}
* @see #startActivityForResult
*/
@Override
public void startActivities(Intent[] intents) {
public void startActivities(Intent[] intents, Bundle options) {
mInstrumentation.execStartActivities(this, mMainThread.getApplicationThread(),
mToken, this, intents);
mToken, this, intents, options);
}
/**
* Like {@link #startActivity(Intent)}, but taking a IntentSender
* to start; see
* {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int)}
* for more information.
* Same as calling {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
* with no options.
*
* @param intent The IntentSender to launch.
* @param fillInIntent If non-null, this will be provided as the
@@ -3350,8 +3446,58 @@ public class Activity extends ContextThemeWrapper
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
flagsValues, extraFlags);
startIntentSender(intent, fillInIntent, flagsMask, flagsValues,
extraFlags, null);
}
/**
* Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
* to start; see
* {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int, Bundle)}
* for more information.
*
* @param intent The IntentSender to launch.
* @param fillInIntent If non-null, this will be provided as the
* intent parameter to {@link IntentSender#sendIntent}.
* @param flagsMask Intent flags in the original IntentSender that you
* would like to change.
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*/
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
if (options != null) {
startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
flagsValues, extraFlags, options);
} else {
// Note we want to go through this call for compatibility with
// applications that may have overridden the method.
startIntentSenderForResult(intent, -1, fillInIntent, flagsMask,
flagsValues, extraFlags);
}
}
/**
* Same as calling {@link #startActivityIfNeeded(Intent, int, Bundle)}
* with no options.
*
* @param intent The intent to start.
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits, as described in
* {@link #startActivityForResult}.
*
* @return If a new activity was launched then true is returned; otherwise
* false is returned and you must handle the Intent yourself.
*
* @see #startActivity
* @see #startActivityForResult
*/
public boolean startActivityIfNeeded(Intent intent, int requestCode) {
return startActivityIfNeeded(intent, requestCode, null);
}
/**
@@ -3374,6 +3520,8 @@ public class Activity extends ContextThemeWrapper
* @param requestCode If >= 0, this code will be returned in
* onActivityResult() when the activity exits, as described in
* {@link #startActivityForResult}.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @return If a new activity was launched then true is returned; otherwise
* false is returned and you must handle the Intent yourself.
@@ -3381,17 +3529,17 @@ public class Activity extends ContextThemeWrapper
* @see #startActivity
* @see #startActivityForResult
*/
public boolean startActivityIfNeeded(Intent intent, int requestCode) {
public boolean startActivityIfNeeded(Intent intent, int requestCode, Bundle options) {
if (mParent == null) {
int result = IActivityManager.START_RETURN_INTENT_TO_CALLER;
int result = ActivityManager.START_RETURN_INTENT_TO_CALLER;
try {
intent.setAllowFds(false);
result = ActivityManagerNative.getDefault()
.startActivity(mMainThread.getApplicationThread(),
intent, intent.resolveTypeIfNeeded(getContentResolver()),
null, 0,
mToken, mEmbeddedID, requestCode, true /* onlyIfNeeded */,
false, false, null, null, false);
mToken, mEmbeddedID, requestCode,
ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null,
options);
} catch (RemoteException e) {
// Empty
}
@@ -3408,13 +3556,31 @@ public class Activity extends ContextThemeWrapper
// activity is finished, no matter what happens to it.
mStartedActivity = true;
}
return result != IActivityManager.START_RETURN_INTENT_TO_CALLER;
return result != ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
throw new UnsupportedOperationException(
"startActivityIfNeeded can only be called from a top-level activity");
}
/**
* Same as calling {@link #startNextMatchingActivity(Intent, Bundle)} with
* no options.
*
* @param intent The intent to dispatch to the next activity. For
* correct behavior, this must be the same as the Intent that started
* your own activity; the only changes you can make are to the extras
* inside of it.
*
* @return Returns a boolean indicating whether there was another Activity
* to start: true if there was a next activity to start, false if there
* wasn't. In general, if true is returned you will then want to call
* finish() on yourself.
*/
public boolean startNextMatchingActivity(Intent intent) {
return startNextMatchingActivity(intent, null);
}
/**
* Special version of starting an activity, for use when you are replacing
* other activity components. You can use this to hand the Intent off
@@ -3425,18 +3591,20 @@ public class Activity extends ContextThemeWrapper
* correct behavior, this must be the same as the Intent that started
* your own activity; the only changes you can make are to the extras
* inside of it.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @return Returns a boolean indicating whether there was another Activity
* to start: true if there was a next activity to start, false if there
* wasn't. In general, if true is returned you will then want to call
* finish() on yourself.
*/
public boolean startNextMatchingActivity(Intent intent) {
public boolean startNextMatchingActivity(Intent intent, Bundle options) {
if (mParent == null) {
try {
intent.setAllowFds(false);
return ActivityManagerNative.getDefault()
.startNextMatchingActivity(mToken, intent);
.startNextMatchingActivity(mToken, intent, options);
} catch (RemoteException e) {
// Empty
}
@@ -3446,7 +3614,25 @@ public class Activity extends ContextThemeWrapper
throw new UnsupportedOperationException(
"startNextMatchingActivity can only be called from a top-level activity");
}
/**
* Same as calling {@link #startActivityFromChild(Activity, Intent, int, Bundle)}
* with no options.
*
* @param child The activity making the call.
* @param intent The intent to start.
* @param requestCode Reply request code. < 0 if reply is not requested.
*
* @throws android.content.ActivityNotFoundException
*
* @see #startActivity
* @see #startActivityForResult
*/
public void startActivityFromChild(Activity child, Intent intent,
int requestCode) {
startActivityFromChild(child, intent, requestCode);
}
/**
* This is called when a child activity of this one calls its
* {@link #startActivity} or {@link #startActivityForResult} method.
@@ -3456,7 +3642,9 @@ public class Activity extends ContextThemeWrapper
*
* @param child The activity making the call.
* @param intent The intent to start.
* @param requestCode Reply request code. < 0 if reply is not requested.
* @param requestCode Reply request code. < 0 if reply is not requested.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
@@ -3464,11 +3652,11 @@ public class Activity extends ContextThemeWrapper
* @see #startActivityForResult
*/
public void startActivityFromChild(Activity child, Intent intent,
int requestCode) {
int requestCode, Bundle options) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, child,
intent, requestCode);
intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, child.mEmbeddedID, requestCode,
@@ -3476,6 +3664,24 @@ public class Activity extends ContextThemeWrapper
}
}
/**
* Same as calling {@link #startActivityFromFragment(Fragment, Intent, int, Bundle)}
* with no options.
*
* @param fragment The fragment making the call.
* @param intent The intent to start.
* @param requestCode Reply request code. < 0 if reply is not requested.
*
* @throws android.content.ActivityNotFoundException
*
* @see Fragment#startActivity
* @see Fragment#startActivityForResult
*/
public void startActivityFromFragment(Fragment fragment, Intent intent,
int requestCode) {
startActivityFromFragment(fragment, intent, requestCode, null);
}
/**
* This is called when a Fragment in this activity calls its
* {@link Fragment#startActivity} or {@link Fragment#startActivityForResult}
@@ -3487,6 +3693,8 @@ public class Activity extends ContextThemeWrapper
* @param fragment The fragment making the call.
* @param intent The intent to start.
* @param requestCode Reply request code. < 0 if reply is not requested.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws android.content.ActivityNotFoundException
*
@@ -3494,11 +3702,11 @@ public class Activity extends ContextThemeWrapper
* @see Fragment#startActivityForResult
*/
public void startActivityFromFragment(Fragment fragment, Intent intent,
int requestCode) {
int requestCode, Bundle options) {
Instrumentation.ActivityResult ar =
mInstrumentation.execStartActivity(
this, mMainThread.getApplicationThread(), mToken, fragment,
intent, requestCode);
intent, requestCode, options);
if (ar != null) {
mMainThread.sendActivityResult(
mToken, fragment.mWho, requestCode,
@@ -3506,6 +3714,18 @@ public class Activity extends ContextThemeWrapper
}
}
/**
* Same as calling {@link #startIntentSenderFromChild(Activity, IntentSender,
* int, Intent, int, int, int, Bundle)} with no options.
*/
public void startIntentSenderFromChild(Activity child, IntentSender intent,
int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
int extraFlags)
throws IntentSender.SendIntentException {
startIntentSenderFromChild(child, intent, requestCode, fillInIntent,
flagsMask, flagsValues, extraFlags, null);
}
/**
* Like {@link #startActivityFromChild(Activity, Intent, int)}, but
* taking a IntentSender; see
@@ -3514,10 +3734,10 @@ public class Activity extends ContextThemeWrapper
*/
public void startIntentSenderFromChild(Activity child, IntentSender intent,
int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
int extraFlags)
int extraFlags, Bundle options)
throws IntentSender.SendIntentException {
startIntentSenderForResultInner(intent, requestCode, fillInIntent,
flagsMask, flagsValues, child);
flagsMask, flagsValues, child, options);
}
/**
@@ -3843,7 +4063,7 @@ public class Activity extends ContextThemeWrapper
data.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
ActivityManager.INTENT_SENDER_ACTIVITY_RESULT, packageName,
mParent == null ? mToken : mParent.mToken,
mEmbeddedID, requestCode, new Intent[] { data }, null, flags);
return target != null ? new PendingIntent(target) : null;

View File

@@ -59,6 +59,154 @@ public class ActivityManager {
private final Context mContext;
private final Handler mHandler;
/**
* Result for IActivityManager.startActivity: an error where the
* start had to be canceled.
* @hide
*/
public static final int START_CANCELED = -6;
/**
* Result for IActivityManager.startActivity: an error where the
* thing being started is not an activity.
* @hide
*/
public static final int START_NOT_ACTIVITY = -5;
/**
* Result for IActivityManager.startActivity: an error where the
* caller does not have permission to start the activity.
* @hide
*/
public static final int START_PERMISSION_DENIED = -4;
/**
* Result for IActivityManager.startActivity: an error where the
* caller has requested both to forward a result and to receive
* a result.
* @hide
*/
public static final int START_FORWARD_AND_REQUEST_CONFLICT = -3;
/**
* Result for IActivityManager.startActivity: an error where the
* requested class is not found.
* @hide
*/
public static final int START_CLASS_NOT_FOUND = -2;
/**
* Result for IActivityManager.startActivity: an error where the
* given Intent could not be resolved to an activity.
* @hide
*/
public static final int START_INTENT_NOT_RESOLVED = -1;
/**
* Result for IActivityManaqer.startActivity: the activity was started
* successfully as normal.
* @hide
*/
public static final int START_SUCCESS = 0;
/**
* Result for IActivityManaqer.startActivity: the caller asked that the Intent not
* be executed if it is the recipient, and that is indeed the case.
* @hide
*/
public static final int START_RETURN_INTENT_TO_CALLER = 1;
/**
* Result for IActivityManaqer.startActivity: activity wasn't really started, but
* a task was simply brought to the foreground.
* @hide
*/
public static final int START_TASK_TO_FRONT = 2;
/**
* Result for IActivityManaqer.startActivity: activity wasn't really started, but
* the given Intent was given to the existing top activity.
* @hide
*/
public static final int START_DELIVERED_TO_TOP = 3;
/**
* Result for IActivityManaqer.startActivity: request was canceled because
* app switches are temporarily canceled to ensure the user's last request
* (such as pressing home) is performed.
* @hide
*/
public static final int START_SWITCHES_CANCELED = 4;
/**
* Flag for IActivityManaqer.startActivity: do special start mode where
* a new activity is launched only if it is needed.
* @hide
*/
public static final int START_FLAG_ONLY_IF_NEEDED = 1<<0;
/**
* Flag for IActivityManaqer.startActivity: launch the app for
* debugging.
* @hide
*/
public static final int START_FLAG_DEBUG = 1<<1;
/**
* Flag for IActivityManaqer.startActivity: launch the app for
* OpenGL tracing.
* @hide
*/
public static final int START_FLAG_OPENGL_TRACES = 1<<2;
/**
* Flag for IActivityManaqer.startActivity: if the app is being
* launched for profiling, automatically stop the profiler once done.
* @hide
*/
public static final int START_FLAG_AUTO_STOP_PROFILER = 1<<3;
/**
* Result for IActivityManaqer.broadcastIntent: success!
* @hide
*/
public static final int BROADCAST_SUCCESS = 0;
/**
* Result for IActivityManaqer.broadcastIntent: attempt to broadcast
* a sticky intent without appropriate permission.
* @hide
*/
public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;
/**
* Type for IActivityManaqer.getIntentSender: this PendingIntent is
* for a sendBroadcast operation.
* @hide
*/
public static final int INTENT_SENDER_BROADCAST = 1;
/**
* Type for IActivityManaqer.getIntentSender: this PendingIntent is
* for a startActivity operation.
* @hide
*/
public static final int INTENT_SENDER_ACTIVITY = 2;
/**
* Type for IActivityManaqer.getIntentSender: this PendingIntent is
* for an activity result operation.
* @hide
*/
public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
/**
* Type for IActivityManaqer.getIntentSender: this PendingIntent is
* for a startService operation.
* @hide
*/
public static final int INTENT_SENDER_SERVICE = 4;
/*package*/ ActivityManager(Context context, Handler handler) {
mContext = context;
mHandler = handler;

View File

@@ -117,22 +117,18 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
boolean onlyIfNeeded = data.readInt() != 0;
boolean debug = data.readInt() != 0;
boolean openglTrace = data.readInt() != 0;
int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
? data.readFileDescriptor() : null;
boolean autoStopProfiler = data.readInt() != 0;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivity(app, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho,
requestCode, onlyIfNeeded, debug, openglTrace,
profileFile, profileFd, autoStopProfiler);
resultTo, resultWho, requestCode, startFlags,
profileFile, profileFd, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -145,22 +141,18 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
boolean onlyIfNeeded = data.readInt() != 0;
boolean debug = data.readInt() != 0;
boolean openglTrace = data.readInt() != 0;
int startFlags = data.readInt();
String profileFile = data.readString();
ParcelFileDescriptor profileFd = data.readInt() != 0
? data.readFileDescriptor() : null;
boolean autoStopProfiler = data.readInt() != 0;
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
WaitResult result = startActivityAndWait(app, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho,
requestCode, onlyIfNeeded, debug, openglTrace,
profileFile, profileFd, autoStopProfiler);
resultTo, resultWho, requestCode, startFlags,
profileFile, profileFd, options);
reply.writeNoException();
result.writeToParcel(reply, 0);
return true;
@@ -173,17 +165,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IApplicationThread app = ApplicationThreadNative.asInterface(b);
Intent intent = Intent.CREATOR.createFromParcel(data);
String resolvedType = data.readString();
Uri[] grantedUriPermissions = data.createTypedArray(Uri.CREATOR);
int grantedMode = data.readInt();
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
boolean onlyIfNeeded = data.readInt() != 0;
boolean debug = data.readInt() != 0;
int startFlags = data.readInt();
Configuration config = Configuration.CREATOR.createFromParcel(data);
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityWithConfig(app, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho,
requestCode, onlyIfNeeded, debug, config);
resultTo, resultWho, requestCode, startFlags, config, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -205,9 +195,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
int requestCode = data.readInt();
int flagsMask = data.readInt();
int flagsValues = data.readInt();
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityIntentSender(app, intent,
fillInIntent, resolvedType, resultTo, resultWho,
requestCode, flagsMask, flagsValues);
requestCode, flagsMask, flagsValues, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -218,7 +210,9 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
data.enforceInterface(IActivityManager.descriptor);
IBinder callingActivity = data.readStrongBinder();
Intent intent = Intent.CREATOR.createFromParcel(data);
boolean result = startNextMatchingActivity(callingActivity, intent);
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
boolean result = startNextMatchingActivity(callingActivity, intent, options);
reply.writeNoException();
reply.writeInt(result ? 1 : 0);
return true;
@@ -1231,9 +1225,11 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
IBinder resultTo = data.readStrongBinder();
String resultWho = data.readString();
int requestCode = data.readInt();
boolean onlyIfNeeded = data.readInt() != 0;
int startFlags = data.readInt();
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivityInPackage(uid, intent, resolvedType,
resultTo, resultWho, requestCode, onlyIfNeeded);
resultTo, resultWho, requestCode, startFlags, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1412,7 +1408,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
Intent[] intents = data.createTypedArray(Intent.CREATOR);
String[] resolvedTypes = data.createStringArray();
IBinder resultTo = data.readStrongBinder();
int result = startActivitiesInPackage(uid, intents, resolvedTypes, resultTo);
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivitiesInPackage(uid, intents, resolvedTypes,
resultTo, options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1426,7 +1425,10 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
Intent[] intents = data.createTypedArray(Intent.CREATOR);
String[] resolvedTypes = data.createStringArray();
IBinder resultTo = data.readStrongBinder();
int result = startActivities(app, intents, resolvedTypes, resultTo);
Bundle options = data.readInt() != 0
? Bundle.CREATOR.createFromParcel(data) : null;
int result = startActivities(app, intents, resolvedTypes, resultTo,
options);
reply.writeNoException();
reply.writeInt(result);
return true;
@@ -1618,25 +1620,19 @@ class ActivityManagerProxy implements IActivityManager
}
public int startActivity(IApplicationThread caller, Intent intent,
String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
IBinder resultTo, String resultWho,
int requestCode, boolean onlyIfNeeded,
boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) throws RemoteException {
String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
data.writeTypedArray(grantedUriPermissions, 0);
data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(onlyIfNeeded ? 1 : 0);
data.writeInt(debug ? 1 : 0);
data.writeInt(openglTrace ? 1 : 0);
data.writeInt(startFlags);
data.writeString(profileFile);
if (profileFd != null) {
data.writeInt(1);
@@ -1644,7 +1640,12 @@ class ActivityManagerProxy implements IActivityManager
} else {
data.writeInt(0);
}
data.writeInt(autoStopProfiler ? 1 : 0);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1653,25 +1654,19 @@ class ActivityManagerProxy implements IActivityManager
return result;
}
public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent,
String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
IBinder resultTo, String resultWho,
int requestCode, boolean onlyIfNeeded,
boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) throws RemoteException {
String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
data.writeTypedArray(grantedUriPermissions, 0);
data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(onlyIfNeeded ? 1 : 0);
data.writeInt(debug ? 1 : 0);
data.writeInt(openglTrace ? 1 : 0);
data.writeInt(startFlags);
data.writeString(profileFile);
if (profileFd != null) {
data.writeInt(1);
@@ -1679,7 +1674,12 @@ class ActivityManagerProxy implements IActivityManager
} else {
data.writeInt(0);
}
data.writeInt(autoStopProfiler ? 1 : 0);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITY_AND_WAIT_TRANSACTION, data, reply, 0);
reply.readException();
WaitResult result = WaitResult.CREATOR.createFromParcel(reply);
@@ -1688,24 +1688,26 @@ class ActivityManagerProxy implements IActivityManager
return result;
}
public int startActivityWithConfig(IApplicationThread caller, Intent intent,
String resolvedType, Uri[] grantedUriPermissions, int grantedMode,
IBinder resultTo, String resultWho,
int requestCode, boolean onlyIfNeeded,
boolean debug, Configuration config) throws RemoteException {
String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int startFlags, Configuration config,
Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(caller != null ? caller.asBinder() : null);
intent.writeToParcel(data, 0);
data.writeString(resolvedType);
data.writeTypedArray(grantedUriPermissions, 0);
data.writeInt(grantedMode);
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(onlyIfNeeded ? 1 : 0);
data.writeInt(debug ? 1 : 0);
data.writeInt(startFlags);
config.writeToParcel(data, 0);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1716,7 +1718,7 @@ class ActivityManagerProxy implements IActivityManager
public int startActivityIntentSender(IApplicationThread caller,
IntentSender intent, Intent fillInIntent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode,
int flagsMask, int flagsValues) throws RemoteException {
int flagsMask, int flagsValues, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -1734,6 +1736,12 @@ class ActivityManagerProxy implements IActivityManager
data.writeInt(requestCode);
data.writeInt(flagsMask);
data.writeInt(flagsValues);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITY_INTENT_SENDER_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -1742,12 +1750,18 @@ class ActivityManagerProxy implements IActivityManager
return result;
}
public boolean startNextMatchingActivity(IBinder callingActivity,
Intent intent) throws RemoteException {
Intent intent, Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeStrongBinder(callingActivity);
intent.writeToParcel(data, 0);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_NEXT_MATCHING_ACTIVITY_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3075,7 +3089,7 @@ class ActivityManagerProxy implements IActivityManager
public int startActivityInPackage(int uid,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded)
String resultWho, int requestCode, int startFlags, Bundle options)
throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
@@ -3086,7 +3100,13 @@ class ActivityManagerProxy implements IActivityManager
data.writeStrongBinder(resultTo);
data.writeString(resultWho);
data.writeInt(requestCode);
data.writeInt(onlyIfNeeded ? 1 : 0);
data.writeInt(startFlags);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITY_IN_PACKAGE_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3339,7 +3359,8 @@ class ActivityManagerProxy implements IActivityManager
}
public int startActivities(IApplicationThread caller,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -3347,6 +3368,12 @@ class ActivityManagerProxy implements IActivityManager
data.writeTypedArray(intents, 0);
data.writeStringArray(resolvedTypes);
data.writeStrongBinder(resultTo);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITIES_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();
@@ -3356,7 +3383,8 @@ class ActivityManagerProxy implements IActivityManager
}
public int startActivitiesInPackage(int uid,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException {
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options) throws RemoteException {
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
@@ -3364,6 +3392,12 @@ class ActivityManagerProxy implements IActivityManager
data.writeTypedArray(intents, 0);
data.writeStringArray(resolvedTypes);
data.writeStrongBinder(resultTo);
if (options != null) {
data.writeInt(1);
options.writeToParcel(data, 0);
} else {
data.writeInt(0);
}
mRemote.transact(START_ACTIVITIES_IN_PACKAGE_TRANSACTION, data, reply, 0);
reply.readException();
int result = reply.readInt();

View File

@@ -1802,7 +1802,7 @@ public final class ActivityThread {
if (aInfo == null) {
// Throw an exception.
Instrumentation.checkStartActivityResult(
IActivityManager.START_CLASS_NOT_FOUND, intent);
ActivityManager.START_CLASS_NOT_FOUND, intent);
}
return aInfo;
}

View File

@@ -852,6 +852,11 @@ class ContextImpl extends Context {
@Override
public void startActivity(Intent intent) {
startActivity(intent, null);
}
@Override
public void startActivity(Intent intent, Bundle options) {
if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivity() from outside of an Activity "
@@ -860,11 +865,16 @@ class ContextImpl extends Context {
}
mMainThread.getInstrumentation().execStartActivity(
getOuterContext(), mMainThread.getApplicationThread(), null,
(Activity)null, intent, -1);
(Activity)null, intent, -1, options);
}
@Override
public void startActivities(Intent[] intents) {
startActivities(intents, null);
}
@Override
public void startActivities(Intent[] intents, Bundle options) {
if ((intents[0].getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) == 0) {
throw new AndroidRuntimeException(
"Calling startActivities() from outside of an Activity "
@@ -873,13 +883,20 @@ class ContextImpl extends Context {
}
mMainThread.getInstrumentation().execStartActivities(
getOuterContext(), mMainThread.getApplicationThread(), null,
(Activity)null, intents);
(Activity)null, intents, options);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, null);
}
@Override
public void startIntentSender(IntentSender intent, Intent fillInIntent,
int flagsMask, int flagsValues, int extraFlags, Bundle options)
throws IntentSender.SendIntentException {
try {
String resolvedType = null;
if (fillInIntent != null) {
@@ -889,8 +906,8 @@ class ContextImpl extends Context {
int result = ActivityManagerNative.getDefault()
.startActivityIntentSender(mMainThread.getApplicationThread(), intent,
fillInIntent, resolvedType, null, null,
0, flagsMask, flagsValues);
if (result == IActivityManager.START_CANCELED) {
0, flagsMask, flagsValues, options);
if (result == ActivityManager.START_CANCELED) {
throw new IntentSender.SendIntentException();
}
Instrumentation.checkStartActivityResult(result, null);

View File

@@ -961,27 +961,55 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mLoaderManager = mActivity.getLoaderManager(mIndex, mLoadersStarted, true);
return mLoaderManager;
}
/**
* Call {@link Activity#startActivity(Intent)} on the fragment's
* containing Activity.
*/
public void startActivity(Intent intent) {
startActivity(intent, null);
}
/**
* Call {@link Activity#startActivity(Intent, Bundle)} on the fragment's
* containing Activity.
*/
public void startActivity(Intent intent, Bundle options) {
if (mActivity == null) {
throw new IllegalStateException("Fragment " + this + " not attached to Activity");
}
mActivity.startActivityFromFragment(this, intent, -1);
if (options != null) {
mActivity.startActivityFromFragment(this, intent, -1, options);
} else {
// Note we want to go through this call for compatibility with
// applications that may have overridden the method.
mActivity.startActivityFromFragment(this, intent, -1);
}
}
/**
* Call {@link Activity#startActivityForResult(Intent, int)} on the fragment's
* containing Activity.
*/
public void startActivityForResult(Intent intent, int requestCode) {
startActivityForResult(intent, requestCode, null);
}
/**
* Call {@link Activity#startActivityForResult(Intent, int, Bundle)} on the fragment's
* containing Activity.
*/
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (mActivity == null) {
throw new IllegalStateException("Fragment " + this + " not attached to Activity");
}
mActivity.startActivityFromFragment(this, intent, requestCode);
if (options != null) {
mActivity.startActivityFromFragment(this, intent, requestCode, options);
} else {
// Note we want to go through this call for compatibility with
// applications that may have overridden the method.
mActivity.startActivityFromFragment(this, intent, requestCode, options);
}
}
/**

View File

@@ -50,57 +50,24 @@ import java.util.List;
* {@hide}
*/
public interface IActivityManager extends IInterface {
/**
* Returned by startActivity() if the start request was canceled because
* app switches are temporarily canceled to ensure the user's last request
* (such as pressing home) is performed.
*/
public static final int START_SWITCHES_CANCELED = 4;
/**
* Returned by startActivity() if an activity wasn't really started, but
* the given Intent was given to the existing top activity.
*/
public static final int START_DELIVERED_TO_TOP = 3;
/**
* Returned by startActivity() if an activity wasn't really started, but
* a task was simply brought to the foreground.
*/
public static final int START_TASK_TO_FRONT = 2;
/**
* Returned by startActivity() if the caller asked that the Intent not
* be executed if it is the recipient, and that is indeed the case.
*/
public static final int START_RETURN_INTENT_TO_CALLER = 1;
/**
* Activity was started successfully as normal.
*/
public static final int START_SUCCESS = 0;
public static final int START_INTENT_NOT_RESOLVED = -1;
public static final int START_CLASS_NOT_FOUND = -2;
public static final int START_FORWARD_AND_REQUEST_CONFLICT = -3;
public static final int START_PERMISSION_DENIED = -4;
public static final int START_NOT_ACTIVITY = -5;
public static final int START_CANCELED = -6;
public int startActivity(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo, String resultWho, int requestCode,
boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int flags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
public WaitResult startActivityAndWait(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo, String resultWho, int requestCode,
boolean onlyIfNeeded, boolean debug, boolean openglTrace, String profileFile,
ParcelFileDescriptor profileFd, boolean autoStopProfiler) throws RemoteException;
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int flags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) throws RemoteException;
public int startActivityWithConfig(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo, String resultWho, int requestCode,
boolean onlyIfNeeded, boolean debug, Configuration newConfig) throws RemoteException;
Intent intent, String resolvedType, IBinder resultTo, String resultWho,
int requestCode, int startFlags, Configuration newConfig,
Bundle options) throws RemoteException;
public int startActivityIntentSender(IApplicationThread caller,
IntentSender intent, Intent fillInIntent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode,
int flagsMask, int flagsValues) throws RemoteException;
int flagsMask, int flagsValues, Bundle options) throws RemoteException;
public boolean startNextMatchingActivity(IBinder callingActivity,
Intent intent) throws RemoteException;
Intent intent, Bundle options) throws RemoteException;
public boolean finishActivity(IBinder token, int code, Intent data)
throws RemoteException;
public void finishSubActivity(IBinder token, String resultWho, int requestCode) throws RemoteException;
@@ -109,8 +76,6 @@ public interface IActivityManager extends IInterface {
IIntentReceiver receiver, IntentFilter filter,
String requiredPermission) throws RemoteException;
public void unregisterReceiver(IIntentReceiver receiver) throws RemoteException;
public static final int BROADCAST_SUCCESS = 0;
public static final int BROADCAST_STICKY_CANT_HAVE_PERMISSION = -1;
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String requiredPermission,
@@ -201,10 +166,6 @@ public interface IActivityManager extends IInterface {
public ComponentName getActivityClassForToken(IBinder token) throws RemoteException;
public String getPackageForToken(IBinder token) throws RemoteException;
public static final int INTENT_SENDER_BROADCAST = 1;
public static final int INTENT_SENDER_ACTIVITY = 2;
public static final int INTENT_SENDER_ACTIVITY_RESULT = 3;
public static final int INTENT_SENDER_SERVICE = 4;
public IIntentSender getIntentSender(int type,
String packageName, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes,
@@ -302,7 +263,7 @@ public interface IActivityManager extends IInterface {
public int startActivityInPackage(int uid,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded)
String resultWho, int requestCode, int startFlags, Bundle options)
throws RemoteException;
public void killApplicationWithUid(String pkg, int uid) throws RemoteException;
@@ -342,9 +303,11 @@ public interface IActivityManager extends IInterface {
ParcelFileDescriptor fd) throws RemoteException;
public int startActivities(IApplicationThread caller,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException;
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options) throws RemoteException;
public int startActivitiesInPackage(int uid,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) throws RemoteException;
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options) throws RemoteException;
public int getFrontActivityScreenCompatMode() throws RemoteException;
public void setFrontActivityScreenCompatMode(int mode) throws RemoteException;

View File

@@ -1346,6 +1346,7 @@ public class Instrumentation {
* @param intent The actual Intent to start.
* @param requestCode Identifier for this request's result; less than zero
* if the caller is not expecting a result.
* @param options Addition options.
*
* @return To force the return of a particular result, return an
* ActivityResult object containing the desired data; otherwise
@@ -1361,7 +1362,7 @@ public class Instrumentation {
*/
public ActivityResult execStartActivity(
Context who, IBinder contextThread, IBinder token, Activity target,
Intent intent, int requestCode) {
Intent intent, int requestCode, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1383,8 +1384,8 @@ public class Instrumentation {
int result = ActivityManagerNative.getDefault()
.startActivity(whoThread, intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
null, 0, token, target != null ? target.mEmbeddedID : null,
requestCode, false, false, false, null, null, false);
token, target != null ? target.mEmbeddedID : null,
requestCode, 0, null, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1400,7 +1401,7 @@ public class Instrumentation {
* {@hide}
*/
public void execStartActivities(Context who, IBinder contextThread,
IBinder token, Activity target, Intent[] intents) {
IBinder token, Activity target, Intent[] intents, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1424,7 +1425,7 @@ public class Instrumentation {
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
}
int result = ActivityManagerNative.getDefault()
.startActivities(whoThread, intents, resolvedTypes, token);
.startActivities(whoThread, intents, resolvedTypes, token, options);
checkStartActivityResult(result, intents[0]);
} catch (RemoteException e) {
}
@@ -1459,7 +1460,7 @@ public class Instrumentation {
*/
public ActivityResult execStartActivity(
Context who, IBinder contextThread, IBinder token, Fragment target,
Intent intent, int requestCode) {
Intent intent, int requestCode, Bundle options) {
IApplicationThread whoThread = (IApplicationThread) contextThread;
if (mActivityMonitors != null) {
synchronized (mSync) {
@@ -1481,9 +1482,8 @@ public class Instrumentation {
int result = ActivityManagerNative.getDefault()
.startActivity(whoThread, intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
null, 0, token, target != null ? target.mWho : null,
requestCode, false, false /* debug */, false /* openglTrace */,
null, null, false);
token, target != null ? target.mWho : null,
requestCode, 0, null, null, options);
checkStartActivityResult(result, intent);
} catch (RemoteException e) {
}
@@ -1502,13 +1502,13 @@ public class Instrumentation {
}
/*package*/ static void checkStartActivityResult(int res, Object intent) {
if (res >= IActivityManager.START_SUCCESS) {
if (res >= ActivityManager.START_SUCCESS) {
return;
}
switch (res) {
case IActivityManager.START_INTENT_NOT_RESOLVED:
case IActivityManager.START_CLASS_NOT_FOUND:
case ActivityManager.START_INTENT_NOT_RESOLVED:
case ActivityManager.START_CLASS_NOT_FOUND:
if (intent instanceof Intent && ((Intent)intent).getComponent() != null)
throw new ActivityNotFoundException(
"Unable to find explicit activity class "
@@ -1516,13 +1516,13 @@ public class Instrumentation {
+ "; have you declared this activity in your AndroidManifest.xml?");
throw new ActivityNotFoundException(
"No Activity found to handle " + intent);
case IActivityManager.START_PERMISSION_DENIED:
case ActivityManager.START_PERMISSION_DENIED:
throw new SecurityException("Not allowed to start activity "
+ intent);
case IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
case ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT:
throw new AndroidRuntimeException(
"FORWARD_RESULT_FLAG used while also requesting a result");
case IActivityManager.START_NOT_ACTIVITY:
case ActivityManager.START_NOT_ACTIVITY:
throw new IllegalArgumentException(
"PendingIntent is not an activity");
default:

View File

@@ -195,7 +195,7 @@ public final class PendingIntent implements Parcelable {
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
@@ -256,7 +256,7 @@ public final class PendingIntent implements Parcelable {
try {
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
ActivityManager.INTENT_SENDER_ACTIVITY, packageName,
null, null, requestCode, intents, resolvedTypes, flags);
return target != null ? new PendingIntent(target) : null;
} catch (RemoteException e) {
@@ -292,7 +292,7 @@ public final class PendingIntent implements Parcelable {
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_BROADCAST, packageName,
ActivityManager.INTENT_SENDER_BROADCAST, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;
@@ -330,7 +330,7 @@ public final class PendingIntent implements Parcelable {
intent.setAllowFds(false);
IIntentSender target =
ActivityManagerNative.getDefault().getIntentSender(
IActivityManager.INTENT_SENDER_SERVICE, packageName,
ActivityManager.INTENT_SENDER_SERVICE, packageName,
null, null, requestCode, new Intent[] { intent },
resolvedType != null ? new String[] { resolvedType } : null, flags);
return target != null ? new PendingIntent(target) : null;

View File

@@ -817,6 +817,19 @@ public abstract class Context {
@Deprecated
public abstract void clearWallpaper() throws IOException;
/**
* Same as {@link #startActivity(Intent, Bundle)} with no options
* specified.
*
* @param intent The description of the activity to start.
*
* @throws ActivityNotFoundException
*
* @see {@link #startActivity(Intent, Bundle)}
* @see PackageManager#resolveActivity
*/
public abstract void startActivity(Intent intent);
/**
* Launch a new activity. You will not receive any information about when
* the activity exits.
@@ -832,12 +845,28 @@ public abstract class Context {
* if there was no Activity found to run the given Intent.
*
* @param intent The description of the activity to start.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @throws ActivityNotFoundException
*
* @see {@link #startActivity(Intent)}
* @see PackageManager#resolveActivity
*/
public abstract void startActivity(Intent intent);
public abstract void startActivity(Intent intent, Bundle options);
/**
* Same as {@link #startActivities(Intent[], Bundle)} with no options
* specified.
*
* @param intents An array of Intents to be started.
*
* @throws ActivityNotFoundException
*
* @see {@link #startActivities(Intent[], Bundle)}
* @see PackageManager#resolveActivity
*/
public abstract void startActivities(Intent[] intents);
/**
* Launch multiple new activities. This is generally the same as calling
@@ -854,15 +883,38 @@ public abstract class Context {
* 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.
* May be null if there are no options.
*
* @throws ActivityNotFoundException
*
* @see {@link #startActivities(Intent[])}
* @see PackageManager#resolveActivity
*/
public abstract void startActivities(Intent[] intents);
public abstract void startActivities(Intent[] intents, Bundle options);
/**
* Like {@link #startActivity(Intent)}, but taking a IntentSender
* Same as {@link #startIntentSender(IntentSender, Intent, int, int, int, Bundle)}
* with no options specified.
*
* @param intent The IntentSender to launch.
* @param fillInIntent If non-null, this will be provided as the
* intent parameter to {@link IntentSender#sendIntent}.
* @param flagsMask Intent flags in the original IntentSender that you
* would like to change.
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
*
* @see #startActivity(Intent)
* @see #startIntentSender(IntentSender, Intent, int, int, int, Bundle)
*/
public abstract void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException;
/**
* Like {@link #startActivity(Intent, Bundle)}, but taking a IntentSender
* to start. If the IntentSender is for an activity, that activity will be started
* as if you had called the regular {@link #startActivity(Intent)}
* here; otherwise, its associated action will be executed (such as
@@ -877,10 +929,15 @@ public abstract class Context {
* @param flagsValues Desired values for any bits set in
* <var>flagsMask</var>
* @param extraFlags Always set to 0.
* @param options Additional options for how the Activity should be started.
* May be null if there are no options.
*
* @see #startActivity(Intent, Bundle)
* @see #startIntentSender(IntentSender, Intent, int, int, int)
*/
public abstract void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException;
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException;
/**
* Broadcast the given intent to all interested BroadcastReceivers. This

View File

@@ -276,11 +276,21 @@ public class ContextWrapper extends Context {
mBase.startActivity(intent);
}
@Override
public void startActivity(Intent intent, Bundle options) {
mBase.startActivity(intent, options);
}
@Override
public void startActivities(Intent[] intents) {
mBase.startActivities(intents);
}
@Override
public void startActivities(Intent[] intents, Bundle options) {
mBase.startActivities(intents, options);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
@@ -288,6 +298,14 @@ public class ContextWrapper extends Context {
mBase.startIntentSender(intent, fillInIntent, flagsMask,
flagsValues, extraFlags);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
mBase.startIntentSender(intent, fillInIntent, flagsMask,
flagsValues, extraFlags, options);
}
@Override
public void sendBroadcast(Intent intent) {

View File

@@ -17,8 +17,8 @@
package com.android.internal.policy.impl;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
import android.app.IUiModeManager;
import android.app.ProgressDialog;
import android.app.UiModeManager;
@@ -3832,10 +3832,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int result = ActivityManagerNative.getDefault()
.startActivity(null, dock,
dock.resolveTypeIfNeeded(mContext.getContentResolver()),
null, 0, null, null, 0, true /* onlyIfNeeded*/,
false /* debug */, false /* openglTrace */,
null, null, false);
if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
null, null, 0,
ActivityManager.START_FLAG_ONLY_IF_NEEDED,
null, null, null);
if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) {
return false;
}
}
@@ -3843,10 +3843,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
int result = ActivityManagerNative.getDefault()
.startActivity(null, mHomeIntent,
mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, 0, null, null, 0, true /* onlyIfNeeded*/,
false /* debug */, false /* openglTrace */,
null, null, false);
if (result == IActivityManager.START_RETURN_INTENT_TO_CALLER) {
null, null, 0,
ActivityManager.START_FLAG_ONLY_IF_NEEDED,
null, null, null);
if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) {
return false;
}
} catch (RemoteException ex) {

View File

@@ -189,8 +189,8 @@ class UiModeManagerService extends IUiModeManager.Stub {
}
try {
ActivityManagerNative.getDefault().startActivityWithConfig(
null, homeIntent, null, null, 0, null, null, 0, false, false,
newConfig);
null, homeIntent, null, null, null, 0, 0,
newConfig, null);
mHoldingConfiguration = false;
} catch (RemoteException e) {
Slog.w(TAG, e.getCause());

View File

@@ -286,9 +286,7 @@ public final class ActivityManagerService extends ActivityManagerNative
static class PendingActivityLaunch {
ActivityRecord r;
ActivityRecord sourceRecord;
Uri[] grantedUriPermissions;
int grantedMode;
boolean onlyIfNeeded;
int startFlags;
}
final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
@@ -2095,8 +2093,8 @@ public final class ActivityManagerService extends ActivityManagerNative
aInfo.applicationInfo.uid);
if (app == null || app.instrumentationClass == null) {
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);
mMainStack.startActivityLocked(null, intent, null, null, 0, aInfo,
null, null, 0, 0, 0, false, false, null);
mMainStack.startActivityLocked(null, intent, null, aInfo,
null, null, 0, 0, 0, 0, null, false, null);
}
}
@@ -2150,8 +2148,8 @@ public final class ActivityManagerService extends ActivityManagerNative
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(new ComponentName(
ri.activityInfo.packageName, ri.activityInfo.name));
mMainStack.startActivityLocked(null, intent, null, null, 0, ri.activityInfo,
null, null, 0, 0, 0, false, false, null);
mMainStack.startActivityLocked(null, intent, null, ri.activityInfo,
null, null, 0, 0, 0, 0, null, false, null);
}
}
}
@@ -2257,18 +2255,15 @@ public final class ActivityManagerService extends ActivityManagerNative
for (int i=0; i<N; i++) {
PendingActivityLaunch pal = mPendingActivityLaunches.get(i);
mMainStack.startActivityUncheckedLocked(pal.r, pal.sourceRecord,
pal.grantedUriPermissions, pal.grantedMode, pal.onlyIfNeeded,
doResume && i == (N-1));
pal.startFlags, doResume && i == (N-1));
}
mPendingActivityLaunches.clear();
}
public final int startActivity(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded, boolean debug,
boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) {
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags,
String profileFile, ParcelFileDescriptor profileFd, Bundle options) {
enforceNotIsolatedCaller("startActivity");
int userId = 0;
if (intent.getCategories() != null && intent.getCategories().contains(Intent.CATEGORY_HOME)) {
@@ -2285,43 +2280,38 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
return mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho, requestCode, onlyIfNeeded,
debug, openglTrace, profileFile, profileFd, autoStopProfiler, null, null, userId);
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
null, null, options, userId);
}
public final WaitResult startActivityAndWait(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded, boolean debug,
boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) {
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) {
enforceNotIsolatedCaller("startActivityAndWait");
WaitResult res = new WaitResult();
int userId = Binder.getOrigCallingUser();
mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho,
requestCode, onlyIfNeeded, debug, openglTrace, profileFile, profileFd, autoStopProfiler,
res, null, userId);
resultTo, resultWho, requestCode, startFlags, profileFile, profileFd,
res, null, options, userId);
return res;
}
public final int startActivityWithConfig(IApplicationThread caller,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded,
boolean debug, Configuration config) {
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, Configuration config,
Bundle options) {
enforceNotIsolatedCaller("startActivityWithConfig");
int ret = mMainStack.startActivityMayWait(caller, -1, intent, resolvedType,
grantedUriPermissions, grantedMode, resultTo, resultWho,
requestCode, onlyIfNeeded,
debug, false, null, null, false, null, config, Binder.getOrigCallingUser());
resultTo, resultWho, requestCode, startFlags,
null, null, null, config, options, Binder.getOrigCallingUser());
return ret;
}
public int startActivityIntentSender(IApplicationThread caller,
IntentSender intent, Intent fillInIntent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode,
int flagsMask, int flagsValues) {
int flagsMask, int flagsValues, Bundle options) {
enforceNotIsolatedCaller("startActivityIntentSender");
// Refuse possible leaked file descriptors
if (fillInIntent != null && fillInIntent.hasFileDescriptors()) {
@@ -2344,13 +2334,13 @@ public final class ActivityManagerService extends ActivityManagerNative
mAppSwitchesAllowedTime = 0;
}
}
int ret = pir.sendInner(0, fillInIntent, resolvedType, null,
null, resultTo, resultWho, requestCode, flagsMask, flagsValues);
int ret = pir.sendInner(0, fillInIntent, resolvedType, null, null,
resultTo, resultWho, requestCode, flagsMask, flagsValues, options);
return ret;
}
public boolean startNextMatchingActivity(IBinder callingActivity,
Intent intent) {
Intent intent, Bundle options) {
// Refuse possible leaked file descriptors
if (intent != null && intent.hasFileDescriptors() == true) {
throw new IllegalArgumentException("File descriptors passed in Intent");
@@ -2430,13 +2420,13 @@ public final class ActivityManagerService extends ActivityManagerNative
// XXX we are not dealing with propagating grantedUriPermissions...
// those are not yet exposed to user code, so there is no need.
int res = mMainStack.startActivityLocked(r.app.thread, intent,
r.resolvedType, null, 0, aInfo,
resultTo != null ? resultTo.appToken : null, resultWho,
requestCode, -1, r.launchedFromUid, false, false, null);
r.resolvedType, aInfo, resultTo != null ? resultTo.appToken : null,
resultWho, requestCode, -1, r.launchedFromUid, 0,
options, false, null);
Binder.restoreCallingIdentity(origId);
r.finishing = wasFinishing;
if (res != START_SUCCESS) {
if (res != ActivityManager.START_SUCCESS) {
return false;
}
return true;
@@ -2445,7 +2435,7 @@ public final class ActivityManagerService extends ActivityManagerNative
public final int startActivityInPackage(int uid,
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded) {
String resultWho, int requestCode, int startFlags, Bundle options) {
// This is so super not safe, that only the system (or okay root)
// can do it.
@@ -2457,21 +2447,22 @@ public final class ActivityManagerService extends ActivityManagerNative
}
int ret = mMainStack.startActivityMayWait(null, uid, intent, resolvedType,
null, 0, resultTo, resultWho, requestCode, onlyIfNeeded, false, false,
null, null, false, null, null, userId);
resultTo, resultWho, requestCode, startFlags,
null, null, null, null, options, userId);
return ret;
}
public final int startActivities(IApplicationThread caller,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) {
Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options) {
enforceNotIsolatedCaller("startActivities");
int ret = mMainStack.startActivities(caller, -1, intents, resolvedTypes, resultTo,
Binder.getOrigCallingUser());
options, Binder.getOrigCallingUser());
return ret;
}
public final int startActivitiesInPackage(int uid,
Intent[] intents, String[] resolvedTypes, IBinder resultTo) {
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options) {
// This is so super not safe, that only the system (or okay root)
// can do it.
@@ -2481,7 +2472,7 @@ public final class ActivityManagerService extends ActivityManagerNative
"startActivityInPackage only available to the system");
}
int ret = mMainStack.startActivities(null, uid, intents, resolvedTypes, resultTo,
UserId.getUserId(uid));
options, UserId.getUserId(uid));
return ret;
}
@@ -4193,7 +4184,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (intent.hasFileDescriptors()) {
throw new IllegalArgumentException("File descriptors passed in Intent");
}
if (type == INTENT_SENDER_BROADCAST &&
if (type == ActivityManager.INTENT_SENDER_BROADCAST &&
(intent.getFlags()&Intent.FLAG_RECEIVER_BOOT_UPGRADE) != 0) {
throw new IllegalArgumentException(
"Can't use FLAG_RECEIVER_BOOT_UPGRADE here");
@@ -4242,7 +4233,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (DEBUG_MU)
Slog.v(TAG_MU, "getIntentSenderLocked(): uid=" + callingUid);
ActivityRecord activity = null;
if (type == INTENT_SENDER_ACTIVITY_RESULT) {
if (type == ActivityManager.INTENT_SENDER_ACTIVITY_RESULT) {
activity = mMainStack.isInStackLocked(token);
if (activity == null) {
return null;
@@ -4289,7 +4280,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
rec = new PendingIntentRecord(this, key, callingUid);
mIntentSenderRecords.put(key, rec.ref);
if (type == INTENT_SENDER_ACTIVITY_RESULT) {
if (type == ActivityManager.INTENT_SENDER_ACTIVITY_RESULT) {
if (activity.pendingResults == null) {
activity.pendingResults
= new HashSet<WeakReference<PendingIntentRecord>>();
@@ -12454,7 +12445,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
} catch (RemoteException e) {
Slog.w(TAG, "Remote exception", e);
return BROADCAST_SUCCESS;
return ActivityManager.BROADCAST_SUCCESS;
}
}
@@ -12472,7 +12463,7 @@ public final class ActivityManagerService extends ActivityManagerNative
if (requiredPermission != null) {
Slog.w(TAG, "Can't broadcast sticky intent " + intent
+ " and enforce permission " + requiredPermission);
return BROADCAST_STICKY_CANT_HAVE_PERMISSION;
return ActivityManager.BROADCAST_STICKY_CANT_HAVE_PERMISSION;
}
if (intent.getComponent() != null) {
throw new SecurityException(
@@ -12646,7 +12637,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
}
return BROADCAST_SUCCESS;
return ActivityManager.BROADCAST_SUCCESS;
}
final Intent verifyBroadcastLocked(Intent intent) {

View File

@@ -25,15 +25,6 @@ import android.app.ActivityManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.app.IThumbnailRetriever;
import static android.app.IActivityManager.START_CLASS_NOT_FOUND;
import static android.app.IActivityManager.START_DELIVERED_TO_TOP;
import static android.app.IActivityManager.START_FORWARD_AND_REQUEST_CONFLICT;
import static android.app.IActivityManager.START_INTENT_NOT_RESOLVED;
import static android.app.IActivityManager.START_PERMISSION_DENIED;
import static android.app.IActivityManager.START_RETURN_INTENT_TO_CALLER;
import static android.app.IActivityManager.START_SUCCESS;
import static android.app.IActivityManager.START_SWITCHES_CANCELED;
import static android.app.IActivityManager.START_TASK_TO_FRONT;
import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.app.ResultInfo;
@@ -2270,14 +2261,12 @@ final class ActivityStack {
}
final int startActivityLocked(IApplicationThread caller,
Intent intent, String resolvedType,
Uri[] grantedUriPermissions,
int grantedMode, ActivityInfo aInfo, IBinder resultTo,
Intent intent, String resolvedType, ActivityInfo aInfo, IBinder resultTo,
String resultWho, int requestCode,
int callingPid, int callingUid, boolean onlyIfNeeded,
int callingPid, int callingUid, int startFlags, Bundle options,
boolean componentSpecified, ActivityRecord[] outActivity) {
int err = START_SUCCESS;
int err = ActivityManager.START_SUCCESS;
ProcessRecord callerApp = null;
if (caller != null) {
@@ -2289,11 +2278,11 @@ final class ActivityStack {
Slog.w(TAG, "Unable to find app for caller " + caller
+ " (pid=" + callingPid + ") when starting: "
+ intent.toString());
err = START_PERMISSION_DENIED;
err = ActivityManager.START_PERMISSION_DENIED;
}
}
if (err == START_SUCCESS) {
if (err == ActivityManager.START_SUCCESS) {
Slog.i(TAG, "START {" + intent.toShortString(true, true, true, false)
+ "} from pid " + (callerApp != null ? callerApp.pid : callingPid));
}
@@ -2319,7 +2308,7 @@ final class ActivityStack {
// Transfer the result target from the source activity to the new
// one being started, including any failures.
if (requestCode >= 0) {
return START_FORWARD_AND_REQUEST_CONFLICT;
return ActivityManager.START_FORWARD_AND_REQUEST_CONFLICT;
}
resultRecord = sourceRecord.resultTo;
resultWho = sourceRecord.resultWho;
@@ -2331,19 +2320,19 @@ final class ActivityStack {
}
}
if (err == START_SUCCESS && intent.getComponent() == null) {
if (err == ActivityManager.START_SUCCESS && intent.getComponent() == null) {
// We couldn't find a class that can handle the given Intent.
// That's the end of that!
err = START_INTENT_NOT_RESOLVED;
err = ActivityManager.START_INTENT_NOT_RESOLVED;
}
if (err == START_SUCCESS && aInfo == null) {
if (err == ActivityManager.START_SUCCESS && aInfo == null) {
// We couldn't find the specific class specified in the Intent.
// Also the end of the line.
err = START_CLASS_NOT_FOUND;
err = ActivityManager.START_CLASS_NOT_FOUND;
}
if (err != START_SUCCESS) {
if (err != ActivityManager.START_SUCCESS) {
if (resultRecord != null) {
sendActivityResultLocked(-1,
resultRecord, resultWho, requestCode,
@@ -2400,7 +2389,7 @@ final class ActivityStack {
// We pretend to the caller that it was really started, but
// they will just get a cancel result.
mDismissKeyguardOnNextActivity = false;
return START_SUCCESS;
return ActivityManager.START_SUCCESS;
}
}
}
@@ -2419,12 +2408,10 @@ final class ActivityStack {
PendingActivityLaunch pal = new PendingActivityLaunch();
pal.r = r;
pal.sourceRecord = sourceRecord;
pal.grantedUriPermissions = grantedUriPermissions;
pal.grantedMode = grantedMode;
pal.onlyIfNeeded = onlyIfNeeded;
pal.startFlags = startFlags;
mService.mPendingActivityLaunches.add(pal);
mDismissKeyguardOnNextActivity = false;
return START_SWITCHES_CANCELED;
return ActivityManager.START_SWITCHES_CANCELED;
}
}
@@ -2443,7 +2430,7 @@ final class ActivityStack {
}
err = startActivityUncheckedLocked(r, sourceRecord,
grantedUriPermissions, grantedMode, onlyIfNeeded, true);
startFlags, true);
if (mDismissKeyguardOnNextActivity && mPausingActivity == null) {
// Someone asked to have the keyguard dismissed on the next
// activity start, but we are not actually doing an activity
@@ -2466,8 +2453,7 @@ final class ActivityStack {
}
final int startActivityUncheckedLocked(ActivityRecord r,
ActivityRecord sourceRecord, Uri[] grantedUriPermissions,
int grantedMode, boolean onlyIfNeeded, boolean doResume) {
ActivityRecord sourceRecord, int startFlags, boolean doResume) {
final Intent intent = r.intent;
final int callingUid = r.launchedFromUid;
final int userId = r.userId;
@@ -2494,14 +2480,14 @@ final class ActivityStack {
// being launched is the same as the one making the call... or, as
// a special case, if we do not know the caller then we count the
// current top activity as the caller.
if (onlyIfNeeded) {
if ((startFlags&ActivityManager.START_FLAG_ONLY_IF_NEEDED) != 0) {
ActivityRecord checkedCaller = sourceRecord;
if (checkedCaller == null) {
checkedCaller = topRunningNonDelayedActivityLocked(notTop);
}
if (!checkedCaller.realActivity.equals(r.realActivity)) {
// Caller is not the same as launcher, so always needed.
onlyIfNeeded = false;
startFlags &= ~ActivityManager.START_FLAG_ONLY_IF_NEEDED;
}
}
@@ -2586,7 +2572,7 @@ final class ActivityStack {
if ((launchFlags&Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0) {
taskTop = resetTaskIfNeededLocked(taskTop, r);
}
if (onlyIfNeeded) {
if ((startFlags&ActivityManager.START_FLAG_ONLY_IF_NEEDED) != 0) {
// We don't need to start a new activity, and
// the client said not to do anything if that
// is the case, so this is it! And for paranoia, make
@@ -2594,7 +2580,7 @@ final class ActivityStack {
if (doResume) {
resumeTopActivityLocked(null);
}
return START_RETURN_INTENT_TO_CALLER;
return ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
if ((launchFlags &
(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK))
@@ -2681,7 +2667,7 @@ final class ActivityStack {
if (doResume) {
resumeTopActivityLocked(null);
}
return START_TASK_TO_FRONT;
return ActivityManager.START_TASK_TO_FRONT;
}
}
}
@@ -2710,14 +2696,14 @@ final class ActivityStack {
if (doResume) {
resumeTopActivityLocked(null);
}
if (onlyIfNeeded) {
if ((startFlags&ActivityManager.START_FLAG_ONLY_IF_NEEDED) != 0) {
// We don't need to start a new activity, and
// the client said not to do anything if that
// is the case, so this is it!
return START_RETURN_INTENT_TO_CALLER;
return ActivityManager.START_RETURN_INTENT_TO_CALLER;
}
top.deliverNewIntentLocked(callingUid, r.intent);
return START_DELIVERED_TO_TOP;
return ActivityManager.START_DELIVERED_TO_TOP;
}
}
}
@@ -2729,7 +2715,7 @@ final class ActivityStack {
r.resultTo, r.resultWho, r.requestCode,
Activity.RESULT_CANCELED, null);
}
return START_CLASS_NOT_FOUND;
return ActivityManager.START_CLASS_NOT_FOUND;
}
boolean newTask = false;
@@ -2770,7 +2756,7 @@ final class ActivityStack {
if (doResume) {
resumeTopActivityLocked(null);
}
return START_DELIVERED_TO_TOP;
return ActivityManager.START_DELIVERED_TO_TOP;
}
} else if (!addingToTask &&
(launchFlags&Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) != 0) {
@@ -2785,7 +2771,7 @@ final class ActivityStack {
if (doResume) {
resumeTopActivityLocked(null);
}
return START_DELIVERED_TO_TOP;
return ActivityManager.START_DELIVERED_TO_TOP;
}
}
// An existing activity is starting this new activity, so we want
@@ -2809,13 +2795,6 @@ final class ActivityStack {
+ " in new guessed " + r.task);
}
if (grantedUriPermissions != null && callingUid > 0) {
for (int i=0; i<grantedUriPermissions.length; i++) {
mService.grantUriPermissionLocked(callingUid, r.packageName,
grantedUriPermissions[i], grantedMode, r.getUriPermissionsLocked());
}
}
mService.grantUriPermissionFromIntentLocked(callingUid, r.packageName,
intent, r.getUriPermissionsLocked());
@@ -2824,12 +2803,11 @@ final class ActivityStack {
}
logStartActivity(EventLogTags.AM_CREATE_ACTIVITY, r, r.task);
startActivityLocked(r, newTask, doResume, keepCurTransition);
return START_SUCCESS;
return ActivityManager.START_SUCCESS;
}
ActivityInfo resolveActivity(Intent intent, String resolvedType, boolean debug,
boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) {
ActivityInfo resolveActivity(Intent intent, String resolvedType, int startFlags,
String profileFile, ParcelFileDescriptor profileFd) {
// Collect information about the target of the Intent.
ActivityInfo aInfo;
try {
@@ -2852,13 +2830,13 @@ final class ActivityStack {
aInfo.applicationInfo.packageName, aInfo.name));
// Don't debug things in the system process
if (debug) {
if ((startFlags&ActivityManager.START_FLAG_DEBUG) != 0) {
if (!aInfo.processName.equals("system")) {
mService.setDebugApp(aInfo.processName, true, false);
}
}
if (openglTrace) {
if ((startFlags&ActivityManager.START_FLAG_OPENGL_TRACES) != 0) {
if (!aInfo.processName.equals("system")) {
mService.setOpenGlTraceApp(aInfo.applicationInfo, aInfo.processName);
}
@@ -2867,7 +2845,8 @@ final class ActivityStack {
if (profileFile != null) {
if (!aInfo.processName.equals("system")) {
mService.setProfileApp(aInfo.applicationInfo, aInfo.processName,
profileFile, profileFd, autoStopProfiler);
profileFile, profileFd,
(startFlags&ActivityManager.START_FLAG_AUTO_STOP_PROFILER) != 0);
}
}
}
@@ -2875,12 +2854,10 @@ final class ActivityStack {
}
final int startActivityMayWait(IApplicationThread caller, int callingUid,
Intent intent, String resolvedType, Uri[] grantedUriPermissions,
int grantedMode, IBinder resultTo,
String resultWho, int requestCode, boolean onlyIfNeeded,
boolean debug, boolean openglTrace, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler,
WaitResult outResult, Configuration config, int userId) {
Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int startFlags, String profileFile,
ParcelFileDescriptor profileFd, WaitResult outResult, Configuration config,
Bundle options, int userId) {
// Refuse possible leaked file descriptors
if (intent != null && intent.hasFileDescriptors()) {
throw new IllegalArgumentException("File descriptors passed in Intent");
@@ -2891,8 +2868,8 @@ final class ActivityStack {
intent = new Intent(intent);
// Collect information about the target of the Intent.
ActivityInfo aInfo = resolveActivity(intent, resolvedType, debug, openglTrace,
profileFile, profileFd, autoStopProfiler);
ActivityInfo aInfo = resolveActivity(intent, resolvedType, startFlags,
profileFile, profileFd);
aInfo = mService.getActivityInfoForUser(aInfo, userId);
synchronized (mService) {
@@ -2932,12 +2909,12 @@ final class ActivityStack {
Slog.w(TAG, "Unable to find app for caller " + caller
+ " (pid=" + realCallingPid + ") when starting: "
+ intent.toString());
return START_PERMISSION_DENIED;
return ActivityManager.START_PERMISSION_DENIED;
}
}
IIntentSender target = mService.getIntentSenderLocked(
IActivityManager.INTENT_SENDER_ACTIVITY, "android",
ActivityManager.INTENT_SENDER_ACTIVITY, "android",
realCallingUid, null, null, 0, new Intent[] { intent },
new String[] { resolvedType }, PendingIntent.FLAG_CANCEL_CURRENT
| PendingIntent.FLAG_ONE_SHOT);
@@ -2983,9 +2960,8 @@ final class ActivityStack {
}
int res = startActivityLocked(caller, intent, resolvedType,
grantedUriPermissions, grantedMode, aInfo,
resultTo, resultWho, requestCode, callingPid, callingUid,
onlyIfNeeded, componentSpecified, null);
aInfo, resultTo, resultWho, requestCode, callingPid, callingUid,
startFlags, options, componentSpecified, null);
if (mConfigWillChange && mMainStack) {
// If the caller also wants to switch to a new configuration,
@@ -3004,7 +2980,7 @@ final class ActivityStack {
if (outResult != null) {
outResult.result = res;
if (res == IActivityManager.START_SUCCESS) {
if (res == ActivityManager.START_SUCCESS) {
mWaitingActivityLaunched.add(outResult);
do {
try {
@@ -3012,7 +2988,7 @@ final class ActivityStack {
} catch (InterruptedException e) {
}
} while (!outResult.timeout && outResult.who == null);
} else if (res == IActivityManager.START_TASK_TO_FRONT) {
} else if (res == ActivityManager.START_TASK_TO_FRONT) {
ActivityRecord r = this.topRunningActivityLocked(null);
if (r.nowVisible) {
outResult.timeout = false;
@@ -3037,8 +3013,8 @@ final class ActivityStack {
}
final int startActivities(IApplicationThread caller, int callingUid,
Intent[] intents,
String[] resolvedTypes, IBinder resultTo, int userId) {
Intent[] intents, String[] resolvedTypes, IBinder resultTo,
Bundle options, int userId) {
if (intents == null) {
throw new NullPointerException("intents is null");
}
@@ -3081,8 +3057,8 @@ final class ActivityStack {
intent = new Intent(intent);
// Collect information about the target of the Intent.
ActivityInfo aInfo = resolveActivity(intent, resolvedTypes[i], false, false,
null, null, false);
ActivityInfo aInfo = resolveActivity(intent, resolvedTypes[i],
0, null, null);
// TODO: New, check if this is correct
aInfo = mService.getActivityInfoForUser(aInfo, userId);
@@ -3093,8 +3069,8 @@ final class ActivityStack {
}
int res = startActivityLocked(caller, intent, resolvedTypes[i],
null, 0, aInfo, resultTo, null, -1, callingPid, callingUid,
false, componentSpecified, outActivity);
aInfo, resultTo, null, -1, callingPid, callingUid,
0, options, componentSpecified, outActivity);
if (res < 0) {
return res;
}
@@ -3106,7 +3082,7 @@ final class ActivityStack {
Binder.restoreCallingIdentity(origId);
}
return IActivityManager.START_SUCCESS;
return ActivityManager.START_SUCCESS;
}
void reportActivityLaunchedLocked(boolean timeout, ActivityRecord r,

View File

@@ -16,12 +16,13 @@
package com.android.server.am;
import android.app.IActivityManager;
import android.app.ActivityManager;
import android.content.IIntentSender;
import android.content.IIntentReceiver;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserId;
@@ -158,13 +159,13 @@ class PendingIntentRecord extends IIntentSender.Stub {
String typeName() {
switch (type) {
case IActivityManager.INTENT_SENDER_ACTIVITY:
case ActivityManager.INTENT_SENDER_ACTIVITY:
return "startActivity";
case IActivityManager.INTENT_SENDER_BROADCAST:
case ActivityManager.INTENT_SENDER_BROADCAST:
return "broadcastIntent";
case IActivityManager.INTENT_SENDER_SERVICE:
case ActivityManager.INTENT_SENDER_SERVICE:
return "startService";
case IActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
case ActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
return "activityResult";
}
return Integer.toString(type);
@@ -181,13 +182,13 @@ class PendingIntentRecord extends IIntentSender.Stub {
public int send(int code, Intent intent, String resolvedType,
IIntentReceiver finishedReceiver, String requiredPermission) {
return sendInner(code, intent, resolvedType, finishedReceiver,
requiredPermission, null, null, 0, 0, 0);
requiredPermission, null, null, 0, 0, 0, null);
}
int sendInner(int code, Intent intent, String resolvedType,
IIntentReceiver finishedReceiver, String requiredPermission,
IBinder resultTo, String resultWho, int requestCode,
int flagsMask, int flagsValues) {
int flagsMask, int flagsValues, Bundle options) {
synchronized(owner) {
if (!canceled) {
sent = true;
@@ -213,7 +214,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
boolean sendFinish = finishedReceiver != null;
switch (key.type) {
case IActivityManager.INTENT_SENDER_ACTIVITY:
case ActivityManager.INTENT_SENDER_ACTIVITY:
try {
if (key.allIntents != null && key.allIntents.length > 1) {
Intent[] allIntents = new Intent[key.allIntents.length];
@@ -227,22 +228,22 @@ class PendingIntentRecord extends IIntentSender.Stub {
allIntents[allIntents.length-1] = finalIntent;
allResolvedTypes[allResolvedTypes.length-1] = resolvedType;
owner.startActivitiesInPackage(uid, allIntents,
allResolvedTypes, resultTo);
allResolvedTypes, resultTo, options);
} else {
owner.startActivityInPackage(uid,
finalIntent, resolvedType,
resultTo, resultWho, requestCode, false);
resultTo, resultWho, requestCode, 0, options);
}
} catch (RuntimeException e) {
Slog.w(ActivityManagerService.TAG,
"Unable to send startActivity intent", e);
}
break;
case IActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
case ActivityManager.INTENT_SENDER_ACTIVITY_RESULT:
key.activity.stack.sendActivityResultLocked(-1, key.activity,
key.who, key.requestCode, code, finalIntent);
break;
case IActivityManager.INTENT_SENDER_BROADCAST:
case ActivityManager.INTENT_SENDER_BROADCAST:
try {
// If a completion callback has been requested, require
// that the broadcast be delivered synchronously
@@ -257,7 +258,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
"Unable to send startActivity intent", e);
}
break;
case IActivityManager.INTENT_SENDER_SERVICE:
case ActivityManager.INTENT_SENDER_SERVICE:
try {
owner.startServiceInPackage(uid,
finalIntent, resolvedType);
@@ -281,7 +282,7 @@ class PendingIntentRecord extends IIntentSender.Stub {
return 0;
}
}
return IActivityManager.START_CANCELED;
return ActivityManager.START_CANCELED;
}
protected void finalize() throws Throwable {

View File

@@ -250,17 +250,34 @@ public class MockContext extends Context {
throw new UnsupportedOperationException();
}
@Override
public void startActivity(Intent intent, Bundle options) {
startActivity(intent);
}
@Override
public void startActivities(Intent[] intents) {
throw new UnsupportedOperationException();
}
@Override
public void startActivities(Intent[] intents, Bundle options) {
startActivities(intents);
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags)
throws IntentSender.SendIntentException {
throw new UnsupportedOperationException();
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags);
}
@Override
public void sendBroadcast(Intent intent) {

View File

@@ -1234,7 +1234,11 @@ public final class BridgeContext extends Context {
@Override
public void startActivity(Intent arg0) {
// TODO Auto-generated method stub
}
@Override
public void startActivity(Intent arg0, Bundle arg1) {
// TODO Auto-generated method stub
}
@Override
@@ -1244,6 +1248,13 @@ public final class BridgeContext extends Context {
// TODO Auto-generated method stub
}
@Override
public void startIntentSender(IntentSender intent,
Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
Bundle options) throws IntentSender.SendIntentException {
// TODO Auto-generated method stub
}
@Override
public boolean startInstrumentation(ComponentName arg0, String arg1,
Bundle arg2) {
@@ -1286,6 +1297,12 @@ public final class BridgeContext extends Context {
}
@Override
public void startActivities(Intent[] arg0, Bundle arg1) {
// TODO Auto-generated method stub
}
@Override
public boolean isRestricted() {
return false;