Skip to content

Commit 7a2b993

Browse files
Winson ChungAndroid (Google) Code Review
authored andcommitted
Merge "Ensuring that we update the calling uid/package when updating a task's original intent. (Bug 16676636)" into lmp-dev
2 parents 015cb5d + fee2677 commit 7a2b993

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

services/core/java/com/android/server/am/ActivityStackSupervisor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
17141714
// the activity based on affinity... now that we
17151715
// are actually launching it, we can assign the
17161716
// base intent.
1717-
intentActivity.task.setIntent(intent, r.info);
1717+
intentActivity.task.setIntent(r);
17181718
}
17191719
// If the target task is not in the front, then we need
17201720
// to bring it to the front... except... well, with
@@ -1771,7 +1771,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
17711771
// not be too hard...
17721772
reuseTask = intentActivity.task;
17731773
reuseTask.performClearTaskLocked();
1774-
reuseTask.setIntent(r.intent, r.info);
1774+
reuseTask.setIntent(r);
17751775
} else if ((launchFlags&Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0
17761776
|| launchSingleInstance || launchSingleTask) {
17771777
// In this situation we want to remove all activities
@@ -1786,7 +1786,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
17861786
// intents for the top activity, so make sure
17871787
// the task now has the identity of the new
17881788
// intent.
1789-
top.task.setIntent(r.intent, r.info);
1789+
top.task.setIntent(r);
17901790
}
17911791
ActivityStack.logStartActivity(EventLogTags.AM_NEW_INTENT,
17921792
r, top.task);
@@ -1815,7 +1815,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
18151815
ActivityStack.logStartActivity(EventLogTags.AM_NEW_INTENT, r,
18161816
intentActivity.task);
18171817
if (intentActivity.frontOfTask) {
1818-
intentActivity.task.setIntent(r.intent, r.info);
1818+
intentActivity.task.setIntent(r);
18191819
}
18201820
intentActivity.deliverNewIntentLocked(callingUid, r.intent);
18211821
} else if (!r.intent.filterEquals(intentActivity.task.intent)) {
@@ -1841,7 +1841,7 @@ final int startActivityUncheckedLocked(ActivityRecord r,
18411841
// at the bottom of its stack, but that's a little hard
18421842
// to do with the current organization of the code so
18431843
// for now we'll just drop it.
1844-
intentActivity.task.setIntent(r.intent, r.info);
1844+
intentActivity.task.setIntent(r);
18451845
}
18461846
if (!addingToTask && reuseTask == null) {
18471847
// We didn't do anything... but it was needed (a.k.a., client

services/core/java/com/android/server/am/TaskRecord.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,15 @@ long getInactiveDuration() {
220220
return System.currentTimeMillis() - lastActiveTime;
221221
}
222222

223-
void setIntent(Intent _intent, ActivityInfo info) {
223+
/** Sets the original intent, and the calling uid and package. */
224+
void setIntent(ActivityRecord r) {
225+
setIntent(r.intent, r.info);
226+
mCallingUid = r.launchedFromUid;
227+
mCallingPackage = r.launchedFromPackage;
228+
}
229+
230+
/** Sets the original intent, _without_ updating the calling uid or package. */
231+
private void setIntent(Intent _intent, ActivityInfo info) {
224232
if (intent == null) {
225233
mNeverRelinquishIdentity =
226234
(info.flags & ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY) == 0;
@@ -723,7 +731,7 @@ int findEffectiveRootIndex() {
723731
void updateEffectiveIntent() {
724732
final int effectiveRootIndex = findEffectiveRootIndex();
725733
final ActivityRecord r = mActivities.get(effectiveRootIndex);
726-
setIntent(r.intent, r.info);
734+
setIntent(r);
727735
}
728736

729737
void saveTaskDescription(ActivityManager.TaskDescription taskDescription,

0 commit comments

Comments
 (0)