Ensuring that we update the calling uid/package when updating a task's original intent. (Bug 16676636)

Change-Id: I5d75a912e86e83f05717cb19e9b6edb02eb053e6
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index d0ec106..ccca657 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -220,7 +220,15 @@
         return System.currentTimeMillis() - lastActiveTime;
     }
 
-    void setIntent(Intent _intent, ActivityInfo info) {
+    /** Sets the original intent, and the calling uid and package. */
+    void setIntent(ActivityRecord r) {
+        setIntent(r.intent, r.info);
+        mCallingUid = r.launchedFromUid;
+        mCallingPackage = r.launchedFromPackage;
+    }
+
+    /** Sets the original intent, _without_ updating the calling uid or package. */
+    private void setIntent(Intent _intent, ActivityInfo info) {
         if (intent == null) {
             mNeverRelinquishIdentity =
                     (info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0;
@@ -723,7 +731,7 @@
     void updateEffectiveIntent() {
         final int effectiveRootIndex = findEffectiveRootIndex();
         final ActivityRecord r = mActivities.get(effectiveRootIndex);
-        setIntent(r.intent, r.info);
+        setIntent(r);
     }
 
     void saveTaskDescription(ActivityManager.TaskDescription taskDescription,