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

Commit 6e64829c authored by Annie Lin's avatar Annie Lin
Browse files

Remove caption insets source in exit bubble transaction behind flags.

Fix: 416159801
Test: atest WMShellUnitTests:BubbleUtilsTest
Flag: com.android.wm.shell.enable_create_any_bubble
Flag: com.android.wm.shell.enable_bubble_app_compat_fixes
Change-Id: If67a3ac02e5af09a2b8b7fc417e52560f1f0a627
parent 91380375
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.bubbles

import android.app.ActivityManager
import android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN
import android.os.Binder
import android.os.IBinder
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
@@ -30,11 +31,12 @@ import com.android.internal.protolog.ProtoLog
import com.android.window.flags.Flags.FLAG_DISALLOW_BUBBLE_TO_ENTER_PIP
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_APP_COMPAT_FIXES
import com.android.wm.shell.Flags.FLAG_ENABLE_CREATE_ANY_BUBBLE
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.bubbles.util.verifyExitBubbleTransaction
import com.android.wm.shell.taskview.TaskView
import com.android.wm.shell.taskview.TaskViewTaskController
import com.android.wm.shell.bubbles.util.verifyExitBubbleTransaction
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -44,6 +46,7 @@ import org.mockito.kotlin.doReturn
import org.mockito.kotlin.mock
import org.mockito.kotlin.stub
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever

/**
 * Unit tests for [BubbleTaskStackListener].
@@ -111,8 +114,11 @@ class BubbleTaskStackListenerTest {
        FLAG_ENABLE_BUBBLE_ANYTHING,
        FLAG_EXCLUDE_TASK_FROM_RECENTS,
        FLAG_DISALLOW_BUBBLE_TO_ENTER_PIP,
        FLAG_ENABLE_BUBBLE_APP_COMPAT_FIXES,
    )
    fun onActivityRestartAttempt_inStackAppBubbleToFullscreen_notifiesTaskRemoval() {
        val captionInsetsOwner = Binder()
        whenever(bubble.taskView.captionInsetsOwner).thenReturn(captionInsetsOwner)
        task.configuration.windowConfiguration.windowingMode = WINDOWING_MODE_FULLSCREEN
        bubbleData.stub {
            on { getBubbleInStackWithTaskId(bubbleTaskId) } doReturn bubble
@@ -131,7 +137,7 @@ class BubbleTaskStackListenerTest {
            verify(taskOrganizer).applyTransaction(wctCaptor.capture())
            wctCaptor.lastValue
        }
        verifyExitBubbleTransaction(wct, bubbleTaskToken.asBinder())
        verifyExitBubbleTransaction(wct, bubbleTaskToken.asBinder(), captionInsetsOwner)
        verify(taskOrganizer).setInterceptBackPressedOnTaskRoot(task.token, false /* intercept */)
        verify(taskViewTaskController).notifyTaskRemovalStarted(task)
    }
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ class BubbleTaskStackListener(
        val taskViewTaskController: TaskViewTaskController = bubble.taskView.controller
        val taskOrganizer: ShellTaskOrganizer = taskViewTaskController.taskOrganizer

        val wct = getExitBubbleTransaction(task.token)
        val wct = getExitBubbleTransaction(task.token, bubble.taskView.captionInsetsOwner)
        taskOrganizer.applyTransaction(wct)

        taskOrganizer.setInterceptBackPressedOnTaskRoot(task.token, false /* intercept */)
+6 −2
Original line number Diff line number Diff line
@@ -1320,7 +1320,9 @@ public class BubbleTransitions {

            mBubble.setPreparingTransition(this);
            final WindowContainerToken token = mTaskInfo.getToken();
            final WindowContainerTransaction wct = getExitBubbleTransaction(token);
            final Binder captionInsetsOwner = mBubble.getTaskView().getCaptionInsetsOwner();
            final WindowContainerTransaction wct =
                    getExitBubbleTransaction(token, captionInsetsOwner);
            mTaskOrganizer.setInterceptBackPressedOnTaskRoot(token, false /* intercept */);
            mTaskViewTransitions.enqueueExternal(
                    mBubble.getTaskView().getController(),
@@ -1479,7 +1481,9 @@ public class BubbleTransitions {
            mTransactionProvider = transactionProvider;
            bubble.setPreparingTransition(this);
            final WindowContainerToken token = bubble.getTaskView().getTaskInfo().getToken();
            final WindowContainerTransaction wct = getExitBubbleTransaction(token);
            final Binder captionInsetsOwner = bubble.getTaskView().getCaptionInsetsOwner();
            final WindowContainerTransaction wct =
                    getExitBubbleTransaction(token, captionInsetsOwner);
            wct.reorder(token, /* onTop= */ true);
            if (!BubbleAnythingFlagHelper.enableCreateAnyBubbleWithForceExcludedFromRecents()) {
                wct.setHidden(token, false);
+13 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.wm.shell.bubbles.util

import android.app.WindowConfiguration
import android.os.Binder
import android.view.WindowInsets
import android.window.WindowContainerToken
import android.window.WindowContainerTransaction
import com.android.window.flags.Flags
@@ -31,6 +33,7 @@ private fun getBubbleTransaction(
    toBubble: Boolean,
    isAppBubble: Boolean,
    reparentToTda: Boolean,
    captionInsetsOwner: Binder?,
): WindowContainerTransaction {
    val wct = WindowContainerTransaction()
    if (reparentToTda) {
@@ -63,6 +66,13 @@ private fun getBubbleTransaction(
    if (BubbleAnythingFlagHelper.enableCreateAnyBubble()) {
        wct.setDisableLaunchAdjacent(token, toBubble /* disableLaunchAdjacent */)
    }
    if (BubbleAnythingFlagHelper.enableCreateAnyBubbleWithAppCompatFixes()) {
        if (!toBubble && captionInsetsOwner != null) {
            wct.removeInsetsSource(
                token, captionInsetsOwner, 0 /* index */, WindowInsets.Type.captionBar()
            )
        }
    }
    return wct
}

@@ -84,6 +94,7 @@ fun getEnterBubbleTransaction(
        toBubble = true,
        isAppBubble,
        reparentToTda,
        captionInsetsOwner = null,
    )
}

@@ -92,6 +103,7 @@ fun getEnterBubbleTransaction(
 */
fun getExitBubbleTransaction(
    token: WindowContainerToken,
    captionInsetsOwner: Binder?,
): WindowContainerTransaction {
    return getBubbleTransaction(
        token,
@@ -99,6 +111,7 @@ fun getExitBubbleTransaction(
        // Everything will be reset, so doesn't matter for exit.
        isAppBubble = true,
        reparentToTda = false,
        captionInsetsOwner,
    )
}
+8 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.pm.ShortcutInfo;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Binder;
import android.os.Handler;
import android.view.SurfaceControl;
import android.view.SurfaceHolder;
@@ -245,6 +246,13 @@ public class TaskView extends SurfaceView implements SurfaceHolder.Callback,
        }
    }

    /**
     * Call to get the owner of the caption insets source.
     */
    @Nullable public Binder getCaptionInsetsOwner() {
        return mTaskViewTaskController.getCaptionInsetsOwner();
    }

    /**
     * Call when view position or size has changed. Do not call when animating.
     */
Loading