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

Commit 0909b6b4 authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix an issue where the wrong position would be used for app bubbles

The location was incorrectly being set to 'default' in one path
for new bubble launches. This could result in mis-matching location
on screen for bubble bar & the expanded view.

The fix is to pass null, so that the location is not changed through
this flow.

Bug: 425675028
Flag: com.android.wm.shell.enable_create_any_bubble
Test: manual - bubble google TV (or something that trampolines)
             - move bubble bar to the left side
             - re-bubble google TV
             => observe that bubble bar/expanded view remain on left
Test: atest BubbleControllerTest
Change-Id: Id156b69f9381e241b9ccb791c67cebdf32de2ddf
parent 5a480c2d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -84,8 +84,6 @@ import com.android.wm.shell.transition.Transitions.TransitionHandler
import com.android.wm.shell.unfold.ShellUnfoldProgressProvider
import com.google.common.truth.Truth.assertThat
import com.google.common.util.concurrent.MoreExecutors.directExecutor
import java.util.Optional
import java.util.concurrent.Executor
import org.junit.After
import org.junit.Assume.assumeTrue
import org.junit.Before
@@ -103,6 +101,8 @@ import org.mockito.kotlin.never
import org.mockito.kotlin.verify
import platform.test.runner.parameterized.ParameterizedAndroidJunit4
import platform.test.runner.parameterized.Parameters
import java.util.Optional
import java.util.concurrent.Executor

/** Tests for [BubbleController].
 *
@@ -456,12 +456,14 @@ class BubbleControllerTest(flags: FlagsParameterization) {
    fun expandStackAndSelectBubbleForExistingTransition_reusesExistingBubble() {
        assumeTrue(BubbleAnythingFlagHelper.enableCreateAnyBubble())

        val bubbleStateListener = FakeBubblesStateListener()

        // switch to bubble bar mode because the transition currently requires bubble layer view
        bubblePositioner.update(deviceConfigUnfolded)
        bubblePositioner.isShowingInBubbleBar = true
        getInstrumentation().runOnMainSync {
            bubbleController.setLauncherHasBubbleBar(true)
            bubbleController.registerBubbleStateListener(FakeBubblesStateListener())
            bubbleController.registerBubbleStateListener(bubbleStateListener)
        }

        val taskInfo = ActivityManager.RunningTaskInfo().apply {
@@ -484,6 +486,7 @@ class BubbleControllerTest(flags: FlagsParameterization) {
            ) {}
        }

        assertThat(bubbleStateListener.lastUpdate!!.bubbleBarLocation).isNull()
        assertThat(bubbleData.selectedBubble).isEqualTo(bubble)
        assertThat(bubbleController.isStackExpanded).isTrue()
    }
+4 −1
Original line number Diff line number Diff line
@@ -21,8 +21,11 @@ import com.android.wm.shell.shared.bubbles.BubbleBarUpdate

/** A fake implementation of [Bubbles.BubbleStateListener] */
class FakeBubblesStateListener : Bubbles.BubbleStateListener {
    var lastUpdate: BubbleBarUpdate? = null

    override fun onBubbleStateChange(update: BubbleBarUpdate?) {}
    override fun onBubbleStateChange(update: BubbleBarUpdate?) {
        lastUpdate = update
    }

    override fun animateBubbleBarLocation(location: BubbleBarLocation?) {}

+2 −2
Original line number Diff line number Diff line
@@ -1751,8 +1751,8 @@ public class BubbleController implements ConfigurationChangeListener,

        Bubble b = mBubbleData.getBubbleInStackWithTaskId(taskInfo.taskId);
        if (b != null) {
            // Reuse the existing bubble
            mBubbleData.setSelectedBubbleAndExpandStack(b, BubbleBarLocation.DEFAULT);
            // Reuse the existing bubble; pass null for location to use existing location.
            mBubbleData.setSelectedBubbleAndExpandStack(b, null /* bubbleBarLocation */);
        } else {
            // Create a new bubble and show it, remove from overflow
            b = mBubbleData.getOrCreateBubble(taskInfo);