Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5108b1b3 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Add new "options" argument to all startActivity APIs."

parents f98f68d5 a4972e95
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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);
+17 −25
Original line number Diff line number Diff line
@@ -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.");
+263 −43

File changed.

Preview size limit exceeded, changes collapsed.

+148 −0
Original line number Diff line number Diff line
@@ -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;
+100 −66

File changed.

Preview size limit exceeded, changes collapsed.

Loading