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

Commit d60f6cfa authored by Omar Elmekkawy's avatar Omar Elmekkawy Committed by Android (Google) Code Review
Browse files

Merge changes from topic "tiling_p1_crashes" into main

* changes:
  Fix a crash where tiling animations are not canceled on resetting.
  Fix a crash where tiling is destroyed after a desk is removed from repo.
parents 076286e0 63d235c0
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -335,7 +335,6 @@ class DesktopTasksController(
                        RecentsTransitionStateListener.stateToString(state),
                    )
                    recentsTransitionState = state
                    snapEventHandler.onOverviewAnimationStateChange(state)
                }
            }
        )
@@ -498,8 +497,11 @@ class DesktopTasksController(
            returnToApp,
            activeDeskIdOnRecentsStart,
        )

        if (returnToApp) {
            // Returning to the same desk, nothing to do.
            // Returning to the same desk, notify the snap event handler of recents animation
            // ending to the same desk.
            snapEventHandler.onRecentsAnimationEndedToSameDesk()
            return
        }
        if (
@@ -692,6 +694,7 @@ class DesktopTasksController(
                                deskId = deskId,
                                tasks = emptySet(),
                                onDeskRemovedListener = onDeskRemovedListener,
                                runOnTransitEnd = { snapEventHandler.onDeskRemoved(deskId) },
                            )
                        )
                    } else {
@@ -739,6 +742,7 @@ class DesktopTasksController(
                            deskId = deskId,
                            tasks = emptySet(),
                            onDeskRemovedListener = onDeskRemovedListener,
                            runOnTransitEnd = { snapEventHandler.onDeskRemoved(deskId) },
                        )
                    )
                    desksTransitionObserver.addPendingTransition(
@@ -3956,6 +3960,7 @@ class DesktopTasksController(
                    deskId = deskId,
                    tasks = tasksToRemove,
                    onDeskRemovedListener = onDeskRemovedListener,
                    runOnTransitEnd = { snapEventHandler.onDeskRemoved(deskId) },
                )
            )
        }
+16 −0
Original line number Diff line number Diff line
@@ -33,6 +33,22 @@ sealed interface DeskTransition {
        val tasks: Set<Int>,
        val onDeskRemovedListener: OnDeskRemovedListener?,
    ) : DeskTransition {
        constructor(
            token: IBinder,
            displayId: Int,
            deskId: Int,
            tasks: Set<Int>,
            onDeskRemovedListener: OnDeskRemovedListener?,
            // TODO(b/415259520): Consolidate desk removed listeners and callback lambdas
            // after verifying that the call order before and after repository does not matter
            // for [DesktopDisplayEventHandler].
            runOnTransitEnd: (() -> Unit)?,
        ) : this(token, displayId, deskId, tasks, onDeskRemovedListener) {
            this.runOnTransitEnd = runOnTransitEnd
        }

        var runOnTransitEnd: (() -> Unit)? = null

        override fun copyWithToken(token: IBinder): DeskTransition = copy(token)
    }

+1 −0
Original line number Diff line number Diff line
@@ -101,6 +101,7 @@ class DesksTransitionObserver(
                //  visible, such as when dismissing from Overview.
                val deskId = deskTransition.deskId
                val displayId = deskTransition.displayId
                deskTransition.runOnTransitEnd?.invoke()
                desktopRepository.removeDesk(deskTransition.deskId)
                deskTransition.onDeskRemovedListener?.onDeskRemoved(displayId, deskId)
            }
+7 −3
Original line number Diff line number Diff line
@@ -1005,9 +1005,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
    }

    @Override
    public void onOverviewAnimationStateChange(
            @RecentsTransitionStateListener.RecentsTransitionState int state) {
        mDesktopTilingDecorViewModel.onOverviewAnimationStateChange(state);
    public void onRecentsAnimationEndedToSameDesk() {
        mDesktopTilingDecorViewModel.onOverviewAnimationEndedToSameDesk();
    }

    @Override
@@ -1039,6 +1038,11 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel,
                desktopModeSupportedOnNewDisplay);
    }

    @Override
    public void onDeskRemoved(int deskId) {
        mDesktopTilingDecorViewModel.onDeskRemoved(deskId);
    }

    private class DesktopModeTouchEventListener extends GestureDetector.SimpleOnGestureListener
            implements View.OnClickListener, View.OnTouchListener, View.OnLongClickListener,
            View.OnGenericMotionListener, DragDetector.MotionEventHandler {
+8 −5
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.wm.shell.desktopmode.DesktopUserRepositories
import com.android.wm.shell.desktopmode.ReturnToDragStartAnimator
import com.android.wm.shell.desktopmode.ToggleResizeDesktopTaskTransitionHandler
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.recents.RecentsTransitionStateListener
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
import com.android.wm.shell.shared.annotations.ShellMainThread
import com.android.wm.shell.shared.desktopmode.DesktopState
@@ -147,12 +146,10 @@ class DesktopTilingDecorViewModel(
            ?.moveTiledPairToFront(taskInfo.taskId, isFocusedOnDisplay = true) ?: false
    }

    fun onOverviewAnimationStateChange(
        @RecentsTransitionStateListener.RecentsTransitionState state: Int
    ) {
    fun onOverviewAnimationEndedToSameDesk() {
        val activeUserHandlers = tilingHandlerByUserAndDeskId[currentUserId] ?: return
        for (tilingHandler in activeUserHandlers.valueIterator()) {
            tilingHandler.onOverviewAnimationStateChange(state)
            tilingHandler.onRecentsAnimationEndedToSameDesk()
        }
    }

@@ -287,6 +284,12 @@ class DesktopTilingDecorViewModel(
    /** Removes [deskId] from the previously deactivated desks to mark it's activation. */
    fun onDeskActivated(deskId: Int): Boolean = disconnectedDisplayDesks.remove(deskId)

    /** Destroys a tiling session for a removed desk. */
    fun onDeskRemoved(deskId: Int) {
        tilingHandlerByUserAndDeskId[currentUserId]?.get(deskId)?.resetTilingSession()
        tilingHandlerByUserAndDeskId[currentUserId]?.remove(deskId)
    }

    fun getCurrentActiveDeskForDisplay(displayId: Int): Int? =
        desktopUserRepositories.current.getActiveDeskId(displayId)

Loading