[RESTRICT AUTOMERGE] Do not resume activity if behind a translucent task

The top-focusable activity resides in the RESUMED state while the app
process is newly created and attached. The behavior may enable UI
hijacking attacks against apps implementing authentication.

This CL disallows the system to resume the activity for the case if it
is not visible or is occluded by other translucent tasks.

Bug: 211481342
Test: atest CtsWindowManagerDeviceTestCases:ActivityLifecycleTests
Change-Id: I7903494cf928b5b5613700262b7c5fff10f3c5a0
This commit is contained in:
Jeff Chang
2022-03-07 16:47:21 +08:00
parent 3837076d84
commit 8b7e0c52e8
3 changed files with 14 additions and 2 deletions

View File

@@ -93,7 +93,7 @@ class EnsureActivitiesVisibleHelper {
// activities are actually behind other fullscreen activities, but still required
// to be visible (such as performing Recents animation).
final boolean resumeTopActivity = mTop != null && !mTop.mLaunchTaskBehind
&& mContiner.isTopActivityFocusable()
&& mContiner.canBeResumed(starting)
&& (starting == null || !starting.isDescendantOf(mContiner));
final PooledConsumer f = PooledLambda.obtainConsumer(

View File

@@ -1971,7 +1971,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
try {
if (mStackSupervisor.realStartActivityLocked(r, app,
top == r && r.isFocusable() /*andResume*/, true /*checkConfig*/)) {
top == r && r.getTask().canBeResumed(r) /*andResume*/,
true /*checkConfig*/)) {
mTmpBoolean = true;
}
} catch (RemoteException e) {

View File

@@ -3660,6 +3660,17 @@ class Task extends WindowContainer<WindowContainer> {
return getVisibility(starting) != STACK_VISIBILITY_INVISIBLE;
}
/**
* Returns {@code true} is the activity in this Task can be resumed.
*
* @param starting The currently starting activity or {@code null} if there is none.
*/
boolean canBeResumed(@Nullable ActivityRecord starting) {
// No need to resume activity in Task that is not visible.
return isTopActivityFocusable()
&& getVisibility(starting) == STACK_VISIBILITY_VISIBLE;
}
/**
* Returns true if the task should be visible.
*