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

Commit c017e577 authored by Jorge Gil's avatar Jorge Gil
Browse files

[17/N] Desks: Adjust activity opacity calculation

Checks whether the container is an ActivityRecord and applies the
same opacity calculation it used prior to
I166fa4977d6c1e988275d58ea718ce1119ab9b66, otherwise activities will
always be considered transparent.

Flag: com.android.window.flags.enable_multiple_desktops_backend
Bug: 395755508
Test: manual - activities or tasks behind Home/Launcher are
invisible/paused
Test: atest ActivityTaskSuperVisorTests

Change-Id: I7bdf3839003af6bec1d586b17ed82c72dc9c0642
parent b3a7a167
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -2949,13 +2949,16 @@ public class ActivityTaskSupervisor implements RecentTasks.Callbacks {
        }

        private boolean isOpaqueInner(@NonNull WindowContainer<?> container) {
            // If it's a leaf task fragment, then opacity is calculated based on its activities.
            if (container.asTaskFragment() != null
                    && ((TaskFragment) container).isLeafTaskFragment()) {
            final boolean isActivity = container.asActivityRecord() != null;
            final boolean isLeafTaskFragment = container.asTaskFragment() != null
                    && ((TaskFragment) container).isLeafTaskFragment();
            if (isActivity || isLeafTaskFragment) {
                // When it is an activity or leaf task fragment, then opacity is calculated based
                // on itself or its activities.
                return container.getActivity(this,
                        true /* traverseTopToBottom */, null /* boundary */) != null;
            }
            // When not a leaf, it's considered opaque if any of its opaque children fill this
            // Otherwise, it's considered opaque if any of its opaque children fill this
            // container, unless the children are adjacent fragments, in which case as long as they
            // are all opaque then |container| is also considered opaque, even if the adjacent
            // task fragment aren't filling.
+26 −0
Original line number Diff line number Diff line
@@ -509,6 +509,32 @@ public class ActivityTaskSupervisorTests extends WindowTestsBase {
        assertThat(mSupervisor.mOpaqueContainerHelper.isOpaque(rootTask)).isTrue();
    }

    @Test
    public void testOpaque_nonLeafTaskFragmentWithDirectActivity_opaque() {
        final ActivityRecord directChildActivity = new ActivityBuilder(mAtm).setCreateTask(true)
                .build();
        directChildActivity.setOccludesParent(true);
        final Task nonLeafTask = directChildActivity.getTask();
        final TaskFragment directChildFragment = new TaskFragment(mAtm, new Binder(),
                true /* createdByOrganizer */, false /* isEmbedded */);
        nonLeafTask.addChild(directChildFragment, 0);

        assertThat(mSupervisor.mOpaqueContainerHelper.isOpaque(nonLeafTask)).isTrue();
    }

    @Test
    public void testOpaque_nonLeafTaskFragmentWithDirectActivity_transparent() {
        final ActivityRecord directChildActivity = new ActivityBuilder(mAtm).setCreateTask(true)
                .build();
        directChildActivity.setOccludesParent(false);
        final Task nonLeafTask = directChildActivity.getTask();
        final TaskFragment directChildFragment = new TaskFragment(mAtm, new Binder(),
                true /* createdByOrganizer */, false /* isEmbedded */);
        nonLeafTask.addChild(directChildFragment, 0);

        assertThat(mSupervisor.mOpaqueContainerHelper.isOpaque(nonLeafTask)).isFalse();
    }

    @NonNull
    private TaskFragment createChildTaskFragment(@NonNull Task parent,
            @WindowConfiguration.WindowingMode int windowingMode,