Handle tranlucent strategy on back
The first opaque activity beneath a transparent one must not be
a finishing activity.
This prevents a wrong behaviour in case of permission requests
launched from activities after the user presses back.
Bug: 261721427
Test: Test on apps that automatically display permission dialog
when returning from a full screen (e.g. App Info screen)
Run `atest SizeCompatTests`
Change-Id: I04fb0f30087fad137ee6733889bcb32498b2e898
This commit is contained in:
@@ -3906,6 +3906,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFinishing() {
|
||||
return finishing;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is to only be called from the client via binder when the activity is destroyed
|
||||
* AND finished.
|
||||
|
||||
@@ -105,6 +105,7 @@ import com.android.server.wm.LetterboxConfiguration.LetterboxBackgroundType;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/** Controls behaviour of the letterbox UI for {@link mActivityRecord}. */
|
||||
// TODO(b/185262487): Improve test coverage of this class. Parts of it are tested in
|
||||
@@ -114,6 +115,9 @@ import java.util.function.BooleanSupplier;
|
||||
// TODO(b/263021211): Consider renaming to more generic CompatUIController.
|
||||
final class LetterboxUiController {
|
||||
|
||||
private static final Predicate<ActivityRecord> FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE =
|
||||
activityRecord -> activityRecord.fillsParent() && !activityRecord.isFinishing();
|
||||
|
||||
private static final String TAG = TAG_WITH_CLASS_NAME ? "LetterboxUiController" : TAG_ATM;
|
||||
|
||||
private static final float UNDEFINED_ASPECT_RATIO = 0f;
|
||||
@@ -1390,7 +1394,8 @@ final class LetterboxUiController {
|
||||
return;
|
||||
}
|
||||
final ActivityRecord firstOpaqueActivityBeneath = mActivityRecord.getTask().getActivity(
|
||||
ActivityRecord::fillsParent, mActivityRecord, false /* includeBoundary */,
|
||||
FIRST_OPAQUE_NOT_FINISHING_ACTIVITY_PREDICATE /* callback */,
|
||||
mActivityRecord /* boundary */, false /* includeBoundary */,
|
||||
true /* traverseTopToBottom */);
|
||||
if (firstOpaqueActivityBeneath == null) {
|
||||
// We skip letterboxing if the translucent activity doesn't have any opaque
|
||||
|
||||
@@ -254,6 +254,22 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
assertFalse(translucentActivity.inSizeCompatMode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckOpaqueIsLetterboxedWhenStrategyIsApplied() {
|
||||
mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
|
||||
setUpDisplaySizeWithApp(2000, 1000);
|
||||
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
|
||||
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
// Translucent Activity
|
||||
final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
|
||||
.setLaunchedFromUid(mActivity.getUid())
|
||||
.build();
|
||||
doReturn(false).when(translucentActivity).fillsParent();
|
||||
spyOn(mActivity);
|
||||
mTask.addChild(translucentActivity);
|
||||
verify(mActivity).isFinishing();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestartProcessIfVisible() {
|
||||
setUpDisplaySizeWithApp(1000, 2500);
|
||||
|
||||
Reference in New Issue
Block a user