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

Commit 8e5d5009 authored by dakinola's avatar dakinola Committed by Daniel Akinola
Browse files

Fix Partial Screenshare always launching split root when launching task from recents

There is a long standing bug with Partial Screenshare where if the target app is part of a split pair and we attempt to launch it from recents, while it is in the background, it will always launch the split root (whichever app started the split) instead of the selected app.

This is due to ActivtiyTaskManager#startActivityFromRecents's logic for launching an activity, instead of launching the task fresh in fullscreen, it leads to StageCoordinator attempting to launch the app in split screen instead of fullscreen.

By leveraging existing logic in RootWindowContainer#getOrCreateRootTask which handles finding the root task to launch, we can instead change the conditional path taken when starting the task, so it will be launched in fullscreen, ensuring that the selected app will be shared instead of the split root.

Bug: 299597333
Fix: 299597333
Test: atest com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorControllerTest
Test: atest com.android.systemui.mediaprojection.appselector.data.ShellRecentTaskListProviderTest
Change-Id: I0338956041c750453b781d1e8f407e705f7f9a60
parent d3f3084d
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.ComponentName


data class RecentTask(
data class RecentTask(
    val taskId: Int,
    val taskId: Int,
    val displayId: Int,
    @UserIdInt val userId: Int,
    @UserIdInt val userId: Int,
    val topActivityComponent: ComponentName?,
    val topActivityComponent: ComponentName?,
    val baseIntentComponent: ComponentName?,
    val baseIntentComponent: ComponentName?,
+1 −0
Original line number Original line Diff line number Diff line
@@ -60,6 +60,7 @@ constructor(
                .map {
                .map {
                    RecentTask(
                    RecentTask(
                        it.taskId,
                        it.taskId,
                        it.displayId,
                        it.userId,
                        it.userId,
                        it.topActivity,
                        it.topActivity,
                        it.baseIntent?.component,
                        it.baseIntent?.component,
+2 −2
Original line number Original line Diff line number Diff line
@@ -130,10 +130,10 @@ constructor(
                view.width,
                view.width,
                view.height
                view.height
            )
            )
        activityOptions.setPendingIntentBackgroundActivityStartMode(
        activityOptions.pendingIntentBackgroundActivityStartMode =
            MODE_BACKGROUND_ACTIVITY_START_ALLOWED
            MODE_BACKGROUND_ACTIVITY_START_ALLOWED
        )
        activityOptions.launchCookie = launchCookie
        activityOptions.launchCookie = launchCookie
        activityOptions.launchDisplayId = task.displayId


        activityTaskManager.startActivityFromRecents(task.taskId, activityOptions.toBundle())
        activityTaskManager.startActivityFromRecents(task.taskId, activityOptions.toBundle())
        resultHandler.returnSelectedApp(launchCookie)
        resultHandler.returnSelectedApp(launchCookie)
+1 −0
Original line number Original line Diff line number Diff line
@@ -216,6 +216,7 @@ class MediaProjectionAppSelectorControllerTest : SysuiTestCase() {
    ): RecentTask {
    ): RecentTask {
        return RecentTask(
        return RecentTask(
            taskId = taskId,
            taskId = taskId,
            displayId = 0,
            topActivityComponent = topActivityComponent,
            topActivityComponent = topActivityComponent,
            baseIntentComponent = ComponentName("com", "Test"),
            baseIntentComponent = ComponentName("com", "Test"),
            userId = userId,
            userId = userId,
+1 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,7 @@ class ShellRecentTaskListProviderTest : SysuiTestCase() {
    private fun createRecentTask(taskId: Int): RecentTask =
    private fun createRecentTask(taskId: Int): RecentTask =
        RecentTask(
        RecentTask(
            taskId = taskId,
            taskId = taskId,
            displayId = 0,
            userId = 0,
            userId = 0,
            topActivityComponent = null,
            topActivityComponent = null,
            baseIntentComponent = null,
            baseIntentComponent = null,