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

Commit 6c5c933d authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add method to start transition on intent launch." into main

parents 7173aaec 515b0a1a
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.graphics.PointF
import android.graphics.Rect
import android.graphics.Region
import android.os.Binder
import android.os.Bundle
import android.os.Handler
import android.os.IBinder
import android.os.SystemProperties
@@ -883,6 +884,36 @@ class DesktopTasksController(
        moveToDisplay(task, newDisplayId)
    }

    /**
     * Start an intent through a launch transition for starting tasks whose transition does not get
     * handled by [handleRequest]
     */
    fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) {
        val wct = WindowContainerTransaction()
        val displayLayout = displayController.getDisplayLayout(displayId) ?: return
        val bounds = calculateDefaultDesktopTaskBounds(displayLayout)
        if (DesktopModeFlags.ENABLE_CASCADING_WINDOWS.isTrue) {
            cascadeWindow(bounds, displayLayout, displayId)
        }
        val pendingIntent =
            PendingIntent.getActivity(
                context,
                /* requestCode= */ 0,
                intent,
                PendingIntent.FLAG_IMMUTABLE,
            )
        val ops =
            ActivityOptions.fromBundle(options).apply {
                launchWindowingMode = WINDOWING_MODE_FREEFORM
                pendingIntentBackgroundActivityStartMode =
                    ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOW_ALWAYS
                launchBounds = bounds
            }

        wct.sendPendingIntent(pendingIntent, intent, ops.toBundle())
        startLaunchTransition(TRANSIT_OPEN, wct, launchingTaskId = null)
    }

    /**
     * Move [task] to display with [displayId].
     *
@@ -2904,6 +2935,12 @@ class DesktopTasksController(
                c.moveToNextDisplay(taskId)
            }
        }

        override fun startLaunchIntentTransition(intent: Intent, options: Bundle, displayId: Int) {
            executeRemoteCallWithTaskPermission(controller, "startLaunchIntentTransition") { c ->
                c.startLaunchIntentTransition(intent, options, displayId)
            }
        }
    }

    private fun logV(msg: String, vararg arguments: Any?) {
+5 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.wm.shell.desktopmode;

import android.app.ActivityManager.RunningTaskInfo;
import android.content.Intent;
import android.os.Bundle;
import android.window.RemoteTransition;
import com.android.wm.shell.desktopmode.IDesktopTaskListener;
import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource;
@@ -61,4 +63,7 @@ interface IDesktopMode {

    /** Move a task with given `taskId` to external display */
    void moveToExternalDisplay(int taskId);

    /** Start a transition when launching an intent in desktop mode */
    void startLaunchIntentTransition(in Intent intent, in Bundle options, in int displayId);
}
 No newline at end of file
+16 −1
Original line number Diff line number Diff line
@@ -1145,6 +1145,21 @@ class DesktopTasksControllerTest : ShellTestCase() {
            .isEqualTo(DesktopTaskPosition.Center)
    }

    @Test
    fun launchIntent_taskInDesktopMode_transitionStarted() {
        setUpLandscapeDisplay()
        val freeformTask = setUpFreeformTask()

        controller.startLaunchIntentTransition(
            freeformTask.baseIntent,
            Bundle.EMPTY,
            DEFAULT_DISPLAY,
        )

        val wct = getLatestDesktopMixedTaskWct(type = TRANSIT_OPEN)
        assertThat(wct.hierarchyOps).hasSize(1)
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS)
    fun addMoveToDesktopChanges_landscapeDevice_userFullscreenOverride_defaultPortraitBounds() {
@@ -5204,7 +5219,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
        val arg: ArgumentCaptor<WindowContainerTransaction> =
            ArgumentCaptor.forClass(WindowContainerTransaction::class.java)
        verify(desktopMixedTransitionHandler)
            .startLaunchTransition(eq(type), capture(arg), anyInt(), anyOrNull(), anyOrNull())
            .startLaunchTransition(eq(type), capture(arg), anyOrNull(), anyOrNull(), anyOrNull())
        return arg.value
    }