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

Commit 59638ad7 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Disable launch-adjacent for bubbled tasks" into main

parents cee2cada 763d5688
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.test.core.app.ApplicationProvider
import androidx.test.filters.SmallTest
import com.android.internal.protolog.ProtoLog
import com.android.window.flags.Flags.FLAG_EXCLUDE_TASK_FROM_RECENTS
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_ANYTHING
import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_TASK_VIEW_LISTENER
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.taskview.TaskView
@@ -36,6 +37,7 @@ import com.android.wm.shell.taskview.TaskViewController
import com.android.wm.shell.taskview.TaskViewTaskController
import com.google.common.truth.Truth.assertThat
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -107,10 +109,24 @@ class BubbleExpandedViewTest(flags: FlagsParameterization) {
        val wctCaptor = argumentCaptor<WindowContainerTransaction>()
        verify(taskOrganizer).applyTransaction(wctCaptor.capture())
        val wct = wctCaptor.lastValue
        assertThat(wct.changes).hasSize(1)
        val chg = wct.changes.get(taskViewTaskToken.asBinder())
        assertThat(chg).isNotNull()
        assertThat(chg!!.forceExcludedFromRecents).isTrue()
        val hasForceExcludedFromRecents = wct.changes.entries.stream()
            .filter { it.key.equals(taskViewTaskToken.asBinder()) }
            .anyMatch { it.value.forceExcludedFromRecents }
        assertTrue(hasForceExcludedFromRecents)
    }

    @Test
    @EnableFlags(FLAG_ENABLE_BUBBLE_ANYTHING)
    fun onTaskCreated_disallowFlagLaunchAdjacent() {
        bubbleTaskView.listener.onTaskCreated(123 /* taskId */, componentName)

        val wctCaptor = argumentCaptor<WindowContainerTransaction>()
        verify(taskOrganizer).applyTransaction(wctCaptor.capture())
        val wct = wctCaptor.lastValue
        val hasDisableLaunchAdjacent = wct.hierarchyOps.stream()
            .filter { it.container.equals(taskViewTaskToken.asBinder()) }
            .anyMatch { it.isLaunchAdjacentDisabled }
        assertTrue(hasDisableLaunchAdjacent)
    }

    companion object {
+29 −4
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.wm.shell.taskview.TaskView
import com.android.wm.shell.taskview.TaskViewController
import com.android.wm.shell.taskview.TaskViewTaskController
import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -432,10 +433,34 @@ class BubbleTaskViewListenerTest {
        val wctCaptor = argumentCaptor<WindowContainerTransaction>()
        verify(taskOrganizer).applyTransaction(wctCaptor.capture())
        val wct = wctCaptor.lastValue
        assertThat(wct.changes).hasSize(1)
        val chg = wct.changes.get(taskViewTaskToken.asBinder())
        assertThat(chg).isNotNull()
        assertThat(chg!!.forceExcludedFromRecents).isTrue()
        val hasForceExcludedFromRecents = wct.changes.entries.stream()
            .filter { it.key.equals(taskViewTaskToken.asBinder()) }
            .anyMatch { it.value.forceExcludedFromRecents }
        assertTrue(hasForceExcludedFromRecents)
    }

    @Test
    @EnableFlags(FLAG_ENABLE_BUBBLE_ANYTHING)
    fun onTaskCreated_disallowFlagLaunchAdjacent() {
        val b = createAppBubble()
        bubbleTaskViewListener.setBubble(b)
        getInstrumentation().runOnMainSync {
            bubbleTaskViewListener.onInitialized()
        }
        getInstrumentation().waitForIdleSync()

        getInstrumentation().runOnMainSync {
            bubbleTaskViewListener.onTaskCreated(123 /* taskId */, mock<ComponentName>())
        }
        getInstrumentation().waitForIdleSync()

        val wctCaptor = argumentCaptor<WindowContainerTransaction>()
        verify(taskOrganizer).applyTransaction(wctCaptor.capture())
        val wct = wctCaptor.lastValue
        val hasDisableLaunchAdjacent = wct.hierarchyOps.stream()
            .filter { it.container.equals(taskViewTaskToken.asBinder()) }
            .anyMatch { it.isLaunchAdjacentDisabled }
        assertTrue(hasDisableLaunchAdjacent)
    }

    @Test
+4 −1
Original line number Diff line number Diff line
@@ -311,7 +311,10 @@ public class BubbleExpandedView extends LinearLayout {
                wct.setTaskForceExcludedFromRecents(token, true /* forceExcluded */);
            }
            if (com.android.window.flags.Flags.disallowBubbleToEnterPip()) {
                wct.setDisablePip(tvc.getTaskToken(), true /* disablePip */);
                wct.setDisablePip(token, true /* disablePip */);
            }
            if (BubbleAnythingFlagHelper.enableBubbleAnything()) {
                wct.setDisableLaunchAdjacent(token, true);
            }
            tvc.getTaskOrganizer().applyTransaction(wct);

+3 −0
Original line number Diff line number Diff line
@@ -148,6 +148,9 @@ class BubbleTaskStackListener(
        val wct = WindowContainerTransaction()
        wct.setTaskForceExcludedFromRecents(task.token, false /* forceExcluded */)
            .setLaunchNextToBubble(task.token, false /* launchNextToBubble */)
        if (BubbleAnythingFlagHelper.enableBubbleAnything()) {
            wct.setDisableLaunchAdjacent(task.token, false)
        }
        if (com.android.window.flags.Flags.disallowBubbleToEnterPip()) {
            wct.setDisablePip(task.token, false /* disablePip */)
        }
+3 −0
Original line number Diff line number Diff line
@@ -209,6 +209,9 @@ public class BubbleTaskViewListener implements TaskView.Listener {
        if (com.android.window.flags.Flags.disallowBubbleToEnterPip()) {
            wct.setDisablePip(token, true /* disablePip */);
        }
        if (BubbleAnythingFlagHelper.enableBubbleAnything()) {
            wct.setDisableLaunchAdjacent(token, true);
        }
        tvc.getTaskOrganizer().applyTransaction(wct);

        // With the task org, the taskAppeared callback will only happen once the task has
Loading