Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93e246e7 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Handle activity as incompatible if whole stack is transparent

Currently we only handle single top transparent activities as
incompatible for desktop windowing. The idea behind this was that if a
transparent activity is on top of another activity, it can be contained
within the window of the activity below. However, if the below activity
is also transparent, when the top activity is contained within it there
will be no background producing a weird floating window.

Instead we should treat an activity as incompatible and force it to
fullscreen if all the activities in the task's stack are transparent.

Flag: com.android.window.flags.enable_desktop_windowing_modals_policy
Test: atest WMShellUnitTests:AppCompatUtilsTest
Test: atest WMShellUnitTests:DesktopTasksControllerTest
Test: atest WMShellUnitTests:DesktopModeWindowDecorViewModelTests
Test: atest WMShellUnitTests:SystemModalsTransitionHandlerTest
Fixes: 379735058
Fixes: 369796795
Change-Id: Ie97286a7553a7318d36e250c82a78ae02b7b78b6
parent b6c4db10
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -308,11 +308,17 @@ public class TaskInfo {
    public boolean isSleeping;

    /**
     * Whether the top activity fillsParent() is false
     * Whether the top activity fillsParent() is false.
     * @hide
     */
    public boolean isTopActivityTransparent;

    /**
     * Whether fillsParent() is false for every activity in the tasks stack.
     * @hide
     */
    public boolean isActivityStackTransparent;

    /**
     * The last non-fullscreen bounds the task was launched in or resized to.
     * @hide
@@ -489,6 +495,7 @@ public class TaskInfo {
                && parentTaskId == that.parentTaskId
                && Objects.equals(topActivity, that.topActivity)
                && isTopActivityTransparent == that.isTopActivityTransparent
                && isActivityStackTransparent == that.isActivityStackTransparent
                && Objects.equals(lastNonFullscreenBounds, that.lastNonFullscreenBounds)
                && Objects.equals(capturedLink, that.capturedLink)
                && capturedLinkTimestamp == that.capturedLinkTimestamp
@@ -567,6 +574,7 @@ public class TaskInfo {
        mTopActivityLocusId = source.readTypedObject(LocusId.CREATOR);
        displayAreaFeatureId = source.readInt();
        isTopActivityTransparent = source.readBoolean();
        isActivityStackTransparent = source.readBoolean();
        lastNonFullscreenBounds = source.readTypedObject(Rect.CREATOR);
        capturedLink = source.readTypedObject(Uri.CREATOR);
        capturedLinkTimestamp = source.readLong();
@@ -623,6 +631,7 @@ public class TaskInfo {
        dest.writeTypedObject(mTopActivityLocusId, flags);
        dest.writeInt(displayAreaFeatureId);
        dest.writeBoolean(isTopActivityTransparent);
        dest.writeBoolean(isActivityStackTransparent);
        dest.writeTypedObject(lastNonFullscreenBounds, flags);
        dest.writeTypedObject(capturedLink, flags);
        dest.writeLong(capturedLinkTimestamp);
@@ -668,6 +677,7 @@ public class TaskInfo {
                + " locusId=" + mTopActivityLocusId
                + " displayAreaFeatureId=" + displayAreaFeatureId
                + " isTopActivityTransparent=" + isTopActivityTransparent
                + " isActivityStackTransparent=" + isActivityStackTransparent
                + " lastNonFullscreenBounds=" + lastNonFullscreenBounds
                + " capturedLink=" + capturedLink
                + " capturedLinkTimestamp=" + capturedLinkTimestamp
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import com.android.internal.R
 * desktop windowing environment.
 */
fun isTopActivityExemptFromDesktopWindowing(context: Context, task: TaskInfo) =
    (isSystemUiTask(context, task) || (task.isTopActivityTransparent && task.numActivities == 1))
    (isSystemUiTask(context, task) || (task.numActivities > 0 && task.isActivityStackTransparent))
            && !task.isTopActivityNoDisplay

private fun isSystemUiTask(context: Context, task: TaskInfo): Boolean {
+8 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public final class TestRunningTaskInfoBuilder {
    private final Point mPositionInParent = new Point();
    private boolean mIsVisible = false;
    private boolean mIsTopActivityTransparent = false;
    private boolean mIsActivityStackTransparent = false;
    private int mNumActivities = 1;
    private long mLastActiveTime;

@@ -158,6 +159,12 @@ public final class TestRunningTaskInfoBuilder {
        return this;
    }

    public TestRunningTaskInfoBuilder setActivityStackTransparent(
            boolean isActivityStackTransparent) {
        mIsActivityStackTransparent = isActivityStackTransparent;
        return this;
    }

    public TestRunningTaskInfoBuilder setNumActivities(int numActivities) {
        mNumActivities = numActivities;
        return this;
@@ -187,6 +194,7 @@ public final class TestRunningTaskInfoBuilder {
        info.positionInParent = mPositionInParent;
        info.isVisible = mIsVisible;
        info.isTopActivityTransparent = mIsTopActivityTransparent;
        info.isActivityStackTransparent = mIsActivityStackTransparent;
        info.numActivities = mNumActivities;
        info.lastActiveTime = mLastActiveTime;
        info.userId = mUserId;
+19 −8
Original line number Diff line number Diff line
@@ -37,35 +37,46 @@ import org.junit.runner.RunWith
@SmallTest
class AppCompatUtilsTest : ShellTestCase() {
    @Test
    fun testIsTopActivityExemptFromDesktopWindowing_topActivityTransparent() {
    fun testIsTopActivityExemptFromDesktopWindowing_onlyTransparentActivitiesInStack() {
        assertTrue(isTopActivityExemptFromDesktopWindowing(mContext,
            createFreeformTask(/* displayId */ 0)
                    .apply {
                        isTopActivityTransparent = true
                        numActivities = 1
                        isActivityStackTransparent = true
                        isTopActivityNoDisplay = false
                        numActivities = 1
                    }))
    }

    @Test
    fun testIsTopActivityExemptFromDesktopWindowing_topActivityTransparent_multipleActivities() {
    fun testIsTopActivityExemptFromDesktopWindowing_noActivitiesInStack() {
        assertFalse(isTopActivityExemptFromDesktopWindowing(mContext,
            createFreeformTask(/* displayId */ 0)
                .apply {
                    isTopActivityTransparent = true
                    numActivities = 2
                    isActivityStackTransparent = true
                    isTopActivityNoDisplay = false
                    numActivities = 0
                }))
    }

    @Test
    fun testIsTopActivityExemptFromDesktopWindowing_topActivityTransparent_notDisplayed() {
    fun testIsTopActivityExemptFromDesktopWindowing_nonTransparentActivitiesInStack() {
        assertFalse(isTopActivityExemptFromDesktopWindowing(mContext,
            createFreeformTask(/* displayId */ 0)
                .apply {
                    isTopActivityTransparent = true
                    isActivityStackTransparent = false
                    isTopActivityNoDisplay = false
                    numActivities = 1
                }))
    }

    @Test
    fun testIsTopActivityExemptFromDesktopWindowing_transparentActivityStack_notDisplayed() {
        assertFalse(isTopActivityExemptFromDesktopWindowing(mContext,
            createFreeformTask(/* displayId */ 0)
                .apply {
                    isActivityStackTransparent = true
                    isTopActivityNoDisplay = true
                    numActivities = 1
                }))
    }

+4 −4
Original line number Diff line number Diff line
@@ -1151,7 +1151,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
  fun moveRunningTaskToDesktop_topActivityTranslucentWithoutDisplay_taskIsMovedToDesktop() {
    val task =
      setUpFullscreenTask().apply {
        isTopActivityTransparent = true
        isActivityStackTransparent = true
        isTopActivityNoDisplay = true
        numActivities = 1
      }
@@ -1167,7 +1167,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
  fun moveRunningTaskToDesktop_topActivityTranslucentWithDisplay_doesNothing() {
    val task =
      setUpFullscreenTask().apply {
        isTopActivityTransparent = true
        isActivityStackTransparent = true
        isTopActivityNoDisplay = false
        numActivities = 1
      }
@@ -2260,7 +2260,7 @@ class DesktopTasksControllerTest : ShellTestCase() {

    val task =
      setUpFullscreenTask().apply {
        isTopActivityTransparent = true
        isActivityStackTransparent = true
        isTopActivityNoDisplay = true
        numActivities = 1
      }
@@ -2278,7 +2278,7 @@ class DesktopTasksControllerTest : ShellTestCase() {

    val task =
      setUpFreeformTask().apply {
        isTopActivityTransparent = true
        isActivityStackTransparent = true
        isTopActivityNoDisplay = false
        numActivities = 1
      }
Loading