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
diff --git a/services/java/com/android/server/UiModeManagerService.java b/services/java/com/android/server/UiModeManagerService.java
index c5c2901..84daead 100644
--- a/services/java/com/android/server/UiModeManagerService.java
+++ b/services/java/com/android/server/UiModeManagerService.java
@@ -189,8 +189,8 @@
                     }
                     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());
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 94b9e91..6f89f6e 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -286,9 +286,7 @@
     static class PendingActivityLaunch {
         ActivityRecord r;
         ActivityRecord sourceRecord;
-        Uri[] grantedUriPermissions;
-        int grantedMode;
-        boolean onlyIfNeeded;
+        int startFlags;
     }
     
     final ArrayList<PendingActivityLaunch> mPendingActivityLaunches
@@ -2095,8 +2093,8 @@
                     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 @@
                     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 @@
         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 @@
             }
         }
         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 @@
                 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 @@
             // 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 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 @@
         }
 
         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 @@
                     "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 @@
                     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 @@
         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 @@
         }
         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 @@
                 }
             } catch (RemoteException e) {
                 Slog.w(TAG, "Remote exception", e);
-                return BROADCAST_SUCCESS;
+                return ActivityManager.BROADCAST_SUCCESS;
             }
         }
         
@@ -12472,7 +12463,7 @@
             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 @@
             }
         }
 
-        return BROADCAST_SUCCESS;
+        return ActivityManager.BROADCAST_SUCCESS;
     }
 
     final Intent verifyBroadcastLocked(Intent intent) {
diff --git a/services/java/com/android/server/am/ActivityStack.java b/services/java/com/android/server/am/ActivityStack.java
index 64d52ed..edebbac 100644
--- a/services/java/com/android/server/am/ActivityStack.java
+++ b/services/java/com/android/server/am/ActivityStack.java
@@ -25,15 +25,6 @@
 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 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 @@
                 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 @@
             // 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 @@
             }
         }
 
-        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 @@
                     // 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 @@
                     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 @@
         }
         
         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 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 @@
         // 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 @@
                     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 @@
                         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 @@
                         if (doResume) {
                             resumeTopActivityLocked(null);
                         }
-                        return START_TASK_TO_FRONT;
+                        return ActivityManager.START_TASK_TO_FRONT;
                     }
                 }
             }
@@ -2710,14 +2696,14 @@
                             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 @@
                         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 @@
                     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 @@
                     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 @@
                     + " 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 @@
         }
         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 @@
                     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 @@
             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 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 @@
         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 @@
                                 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 @@
             }
             
             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 @@
             
             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 @@
                         } 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 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 @@
                     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 @@
                     }
 
                     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 @@
             Binder.restoreCallingIdentity(origId);
         }
 
-        return IActivityManager.START_SUCCESS;
+        return ActivityManager.START_SUCCESS;
     }
 
     void reportActivityLaunchedLocked(boolean timeout, ActivityRecord r,
diff --git a/services/java/com/android/server/am/PendingIntentRecord.java b/services/java/com/android/server/am/PendingIntentRecord.java
index 0043874..9676084 100644
--- a/services/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/java/com/android/server/am/PendingIntentRecord.java
@@ -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 @@
         
         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 @@
     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 @@
                 
                 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 @@
                                 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 @@
                                     "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 @@
                 return 0;
             }
         }
-        return IActivityManager.START_CANCELED;
+        return ActivityManager.START_CANCELED;
     }
     
     protected void finalize() throws Throwable {