Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.app.ActivityOptions import android.app.Notification import android.app.PendingIntent Loading Loading @@ -46,11 +47,11 @@ import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_ANYTHING import com.android.wm.shell.R import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.bubbles.Bubbles.BubbleMetadataFlagListener import com.android.wm.shell.bubbles.util.verifyEnterBubbleTransaction import com.android.wm.shell.common.TestShellExecutor import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewController import com.android.wm.shell.taskview.TaskViewTaskController import com.android.wm.shell.bubbles.util.verifyEnterBubbleTransaction import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule Loading Loading @@ -89,9 +90,11 @@ class BubbleTaskViewListenerTest { on { asBinder() } doReturn mock<IBinder>() }) private var taskViewController = mock<TaskViewController>() private val taskInfo = mock<ActivityManager.RunningTaskInfo>() private val taskViewTaskController = mock<TaskViewTaskController> { on { taskOrganizer } doReturn taskOrganizer on { taskToken } doReturn taskViewTaskToken on { taskInfo } doReturn taskInfo } private var listenerCallback = mock<BubbleTaskViewListener.Callback>() private var expandedViewManager = mock<BubbleExpandedViewManager>() Loading Loading @@ -490,7 +493,9 @@ class BubbleTaskViewListenerTest { @Test fun onTaskRemovalStarted() { val mockTaskView = mock<TaskView>() val mockTaskView = mock<TaskView>() { on { getController() } doReturn taskViewTaskController } bubbleTaskView = BubbleTaskView(mockTaskView, mainExecutor) bubbleTaskViewListener = Loading @@ -511,12 +516,16 @@ class BubbleTaskViewListenerTest { getInstrumentation().waitForIdleSync() verify(mockTaskView).startActivity(any(), anyOrNull(), any(), any()) taskInfo.isRunning = true taskInfo.token = taskViewTaskToken whenever(expandedViewManager.shouldBeAppBubble(eq(taskInfo))).doReturn(true) getInstrumentation().runOnMainSync { bubbleTaskViewListener.onTaskRemovalStarted(1) } verify(expandedViewManager).removeBubble(eq(b.key), eq(Bubbles.DISMISS_TASK_FINISHED)) verify(mockTaskView).release() verify(taskOrganizer).setInterceptBackPressedOnTaskRoot(eq(taskViewTaskToken), eq(false)) assertThat(parentView.lastRemovedView).isEqualTo(mockTaskView) assertThat(bubbleTaskViewListener.taskView).isNull() verify(listenerCallback).onTaskRemovalStarted() Loading libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.window.WindowContainerToken import com.android.wm.shell.shared.bubbles.BubbleBarLocation import java.util.Collections Loading Loading @@ -56,4 +57,8 @@ class FakeBubbleExpandedViewManager(var bubbleBar: Boolean = false, var expanded override fun getAppBubbleRootTaskToken(): WindowContainerToken? { return null } override fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean { return false } } libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.window.WindowContainerToken import com.android.wm.shell.shared.bubbles.BubbleBarLocation Loading @@ -38,6 +39,7 @@ interface BubbleExpandedViewManager { @BubbleBarLocation.UpdateSource source: Int, ) fun getAppBubbleRootTaskToken(): WindowContainerToken? fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean companion object { /** Loading Loading @@ -96,6 +98,9 @@ interface BubbleExpandedViewManager { override fun getAppBubbleRootTaskToken(): WindowContainerToken? = controller.appBubbleRootTaskInfo?.token override fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean = controller.shouldBeAppBubble(taskInfo) } } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewListener.java +12 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT; import static com.android.wm.shell.bubbles.util.BubbleUtilsKt.getEnterBubbleTransaction; import static com.android.wm.shell.bubbles.util.BubbleUtilsKt.getExitBubbleTransaction; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.PendingIntent; Loading Loading @@ -236,6 +238,16 @@ public class BubbleTaskViewListener implements TaskView.Listener { mExpandedViewManager.removeBubble(mBubble.getKey(), Bubbles.DISMISS_TASK_FINISHED); } if (mTaskView != null) { final TaskViewTaskController tvc = mTaskView.getController(); final ActivityManager.RunningTaskInfo taskInfo = tvc.getTaskInfo(); if (taskInfo != null && taskInfo.isRunning && mExpandedViewManager.shouldBeAppBubble(taskInfo)) { final WindowContainerTransaction wct = getExitBubbleTransaction(taskInfo.token, mTaskView.getCaptionInsetsOwner()); tvc.getTaskOrganizer().applyTransaction(wct); tvc.getTaskOrganizer().setInterceptBackPressedOnTaskRoot(taskInfo.token, false /* interceptBackPressed */); } mTaskView.release(); ((ViewGroup) mParentView).removeView(mTaskView); mTaskView = null; Loading Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.app.ActivityOptions import android.app.Notification import android.app.PendingIntent Loading Loading @@ -46,11 +47,11 @@ import com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_ANYTHING import com.android.wm.shell.R import com.android.wm.shell.ShellTaskOrganizer import com.android.wm.shell.bubbles.Bubbles.BubbleMetadataFlagListener import com.android.wm.shell.bubbles.util.verifyEnterBubbleTransaction import com.android.wm.shell.common.TestShellExecutor import com.android.wm.shell.taskview.TaskView import com.android.wm.shell.taskview.TaskViewController import com.android.wm.shell.taskview.TaskViewTaskController import com.android.wm.shell.bubbles.util.verifyEnterBubbleTransaction import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule Loading Loading @@ -89,9 +90,11 @@ class BubbleTaskViewListenerTest { on { asBinder() } doReturn mock<IBinder>() }) private var taskViewController = mock<TaskViewController>() private val taskInfo = mock<ActivityManager.RunningTaskInfo>() private val taskViewTaskController = mock<TaskViewTaskController> { on { taskOrganizer } doReturn taskOrganizer on { taskToken } doReturn taskViewTaskToken on { taskInfo } doReturn taskInfo } private var listenerCallback = mock<BubbleTaskViewListener.Callback>() private var expandedViewManager = mock<BubbleExpandedViewManager>() Loading Loading @@ -490,7 +493,9 @@ class BubbleTaskViewListenerTest { @Test fun onTaskRemovalStarted() { val mockTaskView = mock<TaskView>() val mockTaskView = mock<TaskView>() { on { getController() } doReturn taskViewTaskController } bubbleTaskView = BubbleTaskView(mockTaskView, mainExecutor) bubbleTaskViewListener = Loading @@ -511,12 +516,16 @@ class BubbleTaskViewListenerTest { getInstrumentation().waitForIdleSync() verify(mockTaskView).startActivity(any(), anyOrNull(), any(), any()) taskInfo.isRunning = true taskInfo.token = taskViewTaskToken whenever(expandedViewManager.shouldBeAppBubble(eq(taskInfo))).doReturn(true) getInstrumentation().runOnMainSync { bubbleTaskViewListener.onTaskRemovalStarted(1) } verify(expandedViewManager).removeBubble(eq(b.key), eq(Bubbles.DISMISS_TASK_FINISHED)) verify(mockTaskView).release() verify(taskOrganizer).setInterceptBackPressedOnTaskRoot(eq(taskViewTaskToken), eq(false)) assertThat(parentView.lastRemovedView).isEqualTo(mockTaskView) assertThat(bubbleTaskViewListener.taskView).isNull() verify(listenerCallback).onTaskRemovalStarted() Loading
libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.window.WindowContainerToken import com.android.wm.shell.shared.bubbles.BubbleBarLocation import java.util.Collections Loading Loading @@ -56,4 +57,8 @@ class FakeBubbleExpandedViewManager(var bubbleBar: Boolean = false, var expanded override fun getAppBubbleRootTaskToken(): WindowContainerToken? { return null } override fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean { return false } }
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt +5 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.wm.shell.bubbles import android.app.ActivityManager import android.window.WindowContainerToken import com.android.wm.shell.shared.bubbles.BubbleBarLocation Loading @@ -38,6 +39,7 @@ interface BubbleExpandedViewManager { @BubbleBarLocation.UpdateSource source: Int, ) fun getAppBubbleRootTaskToken(): WindowContainerToken? fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean companion object { /** Loading Loading @@ -96,6 +98,9 @@ interface BubbleExpandedViewManager { override fun getAppBubbleRootTaskToken(): WindowContainerToken? = controller.appBubbleRootTaskInfo?.token override fun shouldBeAppBubble(taskInfo: ActivityManager.RunningTaskInfo): Boolean = controller.shouldBeAppBubble(taskInfo) } } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewListener.java +12 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,10 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT; import static com.android.wm.shell.bubbles.util.BubbleUtilsKt.getEnterBubbleTransaction; import static com.android.wm.shell.bubbles.util.BubbleUtilsKt.getExitBubbleTransaction; import static com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_BUBBLES; import android.app.ActivityManager; import android.app.ActivityOptions; import android.app.ActivityTaskManager; import android.app.PendingIntent; Loading Loading @@ -236,6 +238,16 @@ public class BubbleTaskViewListener implements TaskView.Listener { mExpandedViewManager.removeBubble(mBubble.getKey(), Bubbles.DISMISS_TASK_FINISHED); } if (mTaskView != null) { final TaskViewTaskController tvc = mTaskView.getController(); final ActivityManager.RunningTaskInfo taskInfo = tvc.getTaskInfo(); if (taskInfo != null && taskInfo.isRunning && mExpandedViewManager.shouldBeAppBubble(taskInfo)) { final WindowContainerTransaction wct = getExitBubbleTransaction(taskInfo.token, mTaskView.getCaptionInsetsOwner()); tvc.getTaskOrganizer().applyTransaction(wct); tvc.getTaskOrganizer().setInterceptBackPressedOnTaskRoot(taskInfo.token, false /* interceptBackPressed */); } mTaskView.release(); ((ViewGroup) mParentView).removeView(mTaskView); mTaskView = null; Loading