Merge "Send RESULT_CANCELED immediately if start-activity-for-result across TaskFragments" into tm-qpr-dev am: e2bf40bc0c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19035147

Change-Id: I096ea9f0aed0690a5a267de97a398e0be05f3dc8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Louis Chang
2022-06-28 01:57:16 +00:00
committed by Automerger Merge Worker

View File

@@ -2576,6 +2576,7 @@ class ActivityStarter {
mInTask = null;
}
mInTaskFragment = inTaskFragment;
sendNewTaskFragmentResultRequestIfNeeded();
mStartFlags = startFlags;
// If the onlyIfNeeded flag is set, then we can do this if the activity being launched
@@ -2618,6 +2619,18 @@ class ActivityStarter {
}
}
private void sendNewTaskFragmentResultRequestIfNeeded() {
if (mStartActivity.resultTo != null && mInTaskFragment != null
&& mInTaskFragment != mStartActivity.resultTo.getTaskFragment()) {
Slog.w(TAG,
"Activity is launching as a new TaskFragment, so cancelling activity result.");
mStartActivity.resultTo.sendResult(INVALID_UID, mStartActivity.resultWho,
mStartActivity.requestCode, RESULT_CANCELED,
null /* data */, null /* dataGrants */);
mStartActivity.resultTo = null;
}
}
private void computeLaunchingTaskFlags() {
// If the caller is not coming from another activity, but has given us an explicit task into
// which they would like us to launch the new activity, then let's see about doing that.