RESTRICT AUTOMERGE Allow an activity to start a new task via startNextMatchingActivity

A vulnerability bug fix (b/230492947) causes this no longer works.
We cannot simply fix the issue by trying to avoid move the task to
the front. The real reason is that startNextMatchingActivity uses
launchedFromUid (the app the lauches the orignal activity) to as
the callingUid and realCallingUid to launch the next matching
activity - though setting callingUid is largely irrelevant because
ActivityStarter sets it to caller app's uid if the caller is set;
In this case, the caller is set to the app that calls the method.
But for BAL purpose, this is not good because the launched
from app might have privileges, such as the Launcher app. Change the
realCallingUid to the activity that calls startNextMatchingActivity.

Bug: 337726734
Test: Manual test. BackgroundActivityLaunchTest#testBackgroundActivityBlockedInStartNextMatchingActivity
Flag: EXEMPT Bug Fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d34ae40f870d4362a069940a035a4d58a536a231)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:cd9e02bd1cec948fbda7ef22745d57df5e56dc2c)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:d55fc71f0bcda732e4adc9142c858eef30e22615
Merged-In: Ia8c6123e8e9325d17d2bfab9589b11eb087da97a
Change-Id: Ia8c6123e8e9325d17d2bfab9589b11eb087da97a
1 file changed