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

Commit f6365408 authored by Alina Zaidi's avatar Alina Zaidi Committed by Android (Google) Code Review
Browse files

Merge "Create and attach additional Transition types to enter/exit transitions" into main

parents 667df8bb fe70f5fe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ filegroup {
        "src/com/android/wm/shell/common/split/SplitScreenConstants.java",
        "src/com/android/wm/shell/common/TransactionPool.java",
        "src/com/android/wm/shell/common/TriangleShape.java",
        "src/com/android/wm/shell/common/desktopmode/*.kt",
        "src/com/android/wm/shell/draganddrop/DragAndDropConstants.java",
        "src/com/android/wm/shell/pip/PipContentOverlay.java",
        "src/com/android/wm/shell/startingsurface/SplashScreenExitAnimationUtils.java",
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.common.desktopmode;

parcelable DesktopModeTransitionSource;
 No newline at end of file
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.wm.shell.common.desktopmode

import android.os.Parcel
import android.os.Parcelable

/** Transition source types for Desktop Mode. */
enum class DesktopModeTransitionSource : Parcelable {
    /** Transitions that originated as a consequence of task dragging. */
    TASK_DRAG,
    /** Transitions that originated from an app from Overview. */
    APP_FROM_OVERVIEW,
    /** Transitions that originated from app handle menu button */
    APP_HANDLE_MENU_BUTTON,
    /** Transitions that originated as a result of keyboard shortcuts. */
    KEYBOARD_SHORTCUT,
    /** Transitions with source unknown. */
    UNKNOWN;

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(name)
    }

    companion object {
        @JvmField
        val CREATOR =
            object : Parcelable.Creator<DesktopModeTransitionSource> {
                override fun createFromParcel(parcel: Parcel): DesktopModeTransitionSource {
                    return parcel.readString()?.let { valueOf(it) } ?: UNKNOWN
                }

                override fun newArray(size: Int) = arrayOfNulls<DesktopModeTransitionSource>(size)
            }
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.desktopmode;

import android.graphics.Region;

import com.android.wm.shell.common.desktopmode.DesktopModeTransitionSource;
import com.android.wm.shell.shared.annotations.ExternalThread;

import java.util.concurrent.Executor;
@@ -49,10 +50,10 @@ public interface DesktopMode {


    /** Called when requested to go to desktop mode from the current focused app. */
    void moveFocusedTaskToDesktop(int displayId);
    void moveFocusedTaskToDesktop(int displayId, DesktopModeTransitionSource transitionSource);

    /** Called when requested to go to fullscreen from the current focused desktop app. */
    void moveFocusedTaskToFullscreen(int displayId);
    void moveFocusedTaskToFullscreen(int displayId, DesktopModeTransitionSource transitionSource);

    /** Called when requested to go to split screen from the current focused desktop app. */
    void moveFocusedTaskToStageSplit(int displayId, boolean leftOrTop);
+15 −4
Original line number Diff line number Diff line
@@ -38,6 +38,12 @@ import com.android.internal.logging.InstanceIdSequence
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.EnterReason
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.ExitReason
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.TaskUpdate
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_EXIT_DESKTOP_MODE_HANDLE_MENU_BUTTON
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_EXIT_DESKTOP_MODE_KEYBOARD_SHORTCUT
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_EXIT_DESKTOP_MODE_TASK_DRAG
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_ENTER_DESKTOP_FROM_APP_FROM_OVERVIEW
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_ENTER_DESKTOP_FROM_APP_HANDLE_MENU_BUTTON
import com.android.wm.shell.desktopmode.DesktopModeTransitionTypes.TRANSIT_ENTER_DESKTOP_FROM_KEYBOARD_SHORTCUT
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.shared.DesktopModeStatus
import com.android.wm.shell.shared.TransitionUtil
@@ -304,11 +310,13 @@ class DesktopModeLoggerTransitionObserver(

    /** Get [EnterReason] for this session enter */
    private fun getEnterReason(transitionInfo: TransitionInfo): EnterReason {
        // TODO(b/326231756) - Add support for missing enter reasons
        return when (transitionInfo.type) {
            WindowManager.TRANSIT_WAKE -> EnterReason.SCREEN_ON
            Transitions.TRANSIT_DESKTOP_MODE_END_DRAG_TO_DESKTOP -> EnterReason.APP_HANDLE_DRAG
            Transitions.TRANSIT_MOVE_TO_DESKTOP -> EnterReason.APP_HANDLE_MENU_BUTTON
            TRANSIT_ENTER_DESKTOP_FROM_APP_HANDLE_MENU_BUTTON -> EnterReason.APP_HANDLE_MENU_BUTTON
            // TODO(b/344822506): Create and update EnterReason to APP_FROM_OVERVIEW
            TRANSIT_ENTER_DESKTOP_FROM_APP_FROM_OVERVIEW -> EnterReason.UNKNOWN_ENTER
            TRANSIT_ENTER_DESKTOP_FROM_KEYBOARD_SHORTCUT -> EnterReason.KEYBOARD_SHORTCUT_ENTER
            WindowManager.TRANSIT_OPEN -> EnterReason.APP_FREEFORM_INTENT
            else -> EnterReason.UNKNOWN_ENTER
        }
@@ -316,11 +324,14 @@ class DesktopModeLoggerTransitionObserver(

    /** Get [ExitReason] for this session exit */
    private fun getExitReason(transitionInfo: TransitionInfo): ExitReason {
        // TODO(b/326231756) - Add support for missing exit reasons
        return when {
            transitionInfo.type == WindowManager.TRANSIT_SLEEP -> ExitReason.SCREEN_OFF
            transitionInfo.type == WindowManager.TRANSIT_CLOSE -> ExitReason.TASK_FINISHED
            transitionInfo.type == Transitions.TRANSIT_EXIT_DESKTOP_MODE -> ExitReason.DRAG_TO_EXIT
            transitionInfo.type == TRANSIT_EXIT_DESKTOP_MODE_TASK_DRAG -> ExitReason.DRAG_TO_EXIT
            transitionInfo.type == TRANSIT_EXIT_DESKTOP_MODE_HANDLE_MENU_BUTTON ->
                ExitReason.APP_HANDLE_MENU_BUTTON_EXIT
            transitionInfo.type == TRANSIT_EXIT_DESKTOP_MODE_KEYBOARD_SHORTCUT ->
                ExitReason.KEYBOARD_SHORTCUT_EXIT
            transitionInfo.isRecentsTransition() -> ExitReason.RETURN_HOME_OR_OVERVIEW
            else -> ExitReason.UNKNOWN_EXIT
        }
Loading