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

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

Merge "Revert^2 "Add tiling jank CUJ."" into main

parents 0a9e09a7 2e6fcd4c
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -435,8 +435,15 @@ public class Cuj {
     */
     */
    public static final int CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL = 139;
    public static final int CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL = 139;


    /**
     * Track when tile resizing divider is simultaneously resizing apps.
     *
     * <p> Tracking starts when the divider move handle is dragged and ends when the drag ends.
     */
    public static final int CUJ_DESKTOP_MODE_TILE_RESIZING = 140;

    // When adding a CUJ, update this and make sure to also update CUJ_TO_STATSD_INTERACTION_TYPE.
    // When adding a CUJ, update this and make sure to also update CUJ_TO_STATSD_INTERACTION_TYPE.
    @VisibleForTesting static final int LAST_CUJ = CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL;
    @VisibleForTesting static final int LAST_CUJ = CUJ_DESKTOP_MODE_TILE_RESIZING;


    /** @hide */
    /** @hide */
    @IntDef({
    @IntDef({
@@ -567,7 +574,8 @@ public class Cuj {
            CUJ_WEAR_QSS_TRAY_OPEN,
            CUJ_WEAR_QSS_TRAY_OPEN,
            CUJ_WEAR_NOTIFICATION_TRAY_OPEN,
            CUJ_WEAR_NOTIFICATION_TRAY_OPEN,
            CUJ_DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE,
            CUJ_DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE,
            CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL
            CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL,
            CUJ_DESKTOP_MODE_TILE_RESIZING,
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface CujType {}
    public @interface CujType {}
@@ -709,6 +717,7 @@ public class Cuj {
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_WEAR_NOTIFICATION_TRAY_OPEN] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WEAR_NOTIFICATION_TRAY_OPEN;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_WEAR_NOTIFICATION_TRAY_OPEN] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WEAR_NOTIFICATION_TRAY_OPEN;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_OVERVIEW_CLEAR_ALL;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_OVERVIEW_CLEAR_ALL;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_DESKTOP_MODE_TILE_RESIZING] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__DESKTOP_MODE_TILE_RESIZING;
    }
    }


    private Cuj() {
    private Cuj() {
@@ -983,6 +992,8 @@ public class Cuj {
                return "DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE";
                return "DESKTOP_MODE_SHADE_WINDOW_DISPLAY_CHANGE";
            case CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL:
            case CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL:
                return "LAUNCHER_OVERVIEW_CLEAR_ALL";
                return "LAUNCHER_OVERVIEW_CLEAR_ALL";
            case CUJ_DESKTOP_MODE_TILE_RESIZING:
                return "DESKTOP_MODE_TILE_RESIZING";
        }
        }
        return "UNKNOWN";
        return "UNKNOWN";
    }
    }
+5 −2
Original line number Original line Diff line number Diff line
@@ -995,7 +995,9 @@ public abstract class WMShellModule {
            @ShellMainThread ShellExecutor mainExecutor,
            @ShellMainThread ShellExecutor mainExecutor,
            DesktopState desktopState,
            DesktopState desktopState,
            ShellInit shellInit,
            ShellInit shellInit,
            ShellController shellController) {
            ShellController shellController,
            InteractionJankMonitor interactionJankMonitor
    ) {
        return new DesktopTilingDecorViewModel(
        return new DesktopTilingDecorViewModel(
                context,
                context,
                mainDispatcher,
                mainDispatcher,
@@ -1014,7 +1016,8 @@ public abstract class WMShellModule {
                mainExecutor,
                mainExecutor,
                desktopState,
                desktopState,
                shellInit,
                shellInit,
                shellController
                shellController,
                interactionJankMonitor
        );
        );
    }
    }


+3 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.core.util.getOrElse
import androidx.core.util.keyIterator
import androidx.core.util.keyIterator
import androidx.core.util.valueIterator
import androidx.core.util.valueIterator
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.protolog.ProtoLog
import com.android.internal.protolog.ProtoLog
import com.android.wm.shell.R
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -74,6 +75,7 @@ class DesktopTilingDecorViewModel(
    private val desktopState: DesktopState,
    private val desktopState: DesktopState,
    private val shellInit: ShellInit,
    private val shellInit: ShellInit,
    private val shellController: ShellController,
    private val shellController: ShellController,
    private val interactionJankMonitor: InteractionJankMonitor,
) : DisplayChangeController.OnDisplayChangingListener {
) : DisplayChangeController.OnDisplayChangingListener {
    @VisibleForTesting
    @VisibleForTesting
    var tilingHandlerByUserAndDeskId = SparseArray<SparseArray<DesktopTilingWindowDecoration>>()
    var tilingHandlerByUserAndDeskId = SparseArray<SparseArray<DesktopTilingWindowDecoration>>()
@@ -123,6 +125,7 @@ class DesktopTilingDecorViewModel(
                            mainExecutor,
                            mainExecutor,
                            desktopState,
                            desktopState,
                            shellController,
                            shellController,
                            interactionJankMonitor,
                        )
                        )
                        .also { userHandlerList[deskId] = it }
                        .also { userHandlerList[deskId] = it }
                }
                }
+21 −0
Original line number Original line Diff line number Diff line
@@ -41,7 +41,10 @@ import android.view.WindowManager.LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION
import android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY
import android.view.WindowManager.LayoutParams.PRIVATE_FLAG_TRUSTED_OVERLAY
import android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER
import android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER
import android.view.WindowlessWindowManager
import android.view.WindowlessWindowManager
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_TILE_RESIZING
import com.android.internal.jank.InteractionJankMonitor
import com.android.wm.shell.R
import com.android.wm.shell.R
import java.util.concurrent.TimeUnit
import java.util.function.Supplier
import java.util.function.Supplier


/**
/**
@@ -57,6 +60,7 @@ class DesktopTilingDividerWindowManager(
    private var dividerBounds: Rect,
    private var dividerBounds: Rect,
    private val displayContext: Context,
    private val displayContext: Context,
    private val isDarkMode: Boolean,
    private val isDarkMode: Boolean,
    private val interactionJankMonitor: InteractionJankMonitor,
) : WindowlessWindowManager(config, leash, null), DividerMoveCallback, View.OnLayoutChangeListener {
) : WindowlessWindowManager(config, leash, null), DividerMoveCallback, View.OnLayoutChangeListener {
    private lateinit var viewHost: SurfaceControlViewHost
    private lateinit var viewHost: SurfaceControlViewHost
    private var tilingDividerView: TilingDividerView? = null
    private var tilingDividerView: TilingDividerView? = null
@@ -259,9 +263,22 @@ class DesktopTilingDividerWindowManager(


    override fun onDividerMoveStart(pos: Int, motionEvent: MotionEvent) {
    override fun onDividerMoveStart(pos: Int, motionEvent: MotionEvent) {
        setSlippery(false)
        setSlippery(false)
        beginJankMonitoring()
        transitionHandler.onDividerHandleDragStart(motionEvent)
        transitionHandler.onDividerHandleDragStart(motionEvent)
    }
    }


    private fun beginJankMonitoring() {
        val dividerView = tilingDividerView ?: return
        interactionJankMonitor.begin(
            InteractionJankMonitor.Configuration.Builder.withView(CUJ_DESKTOP_MODE_TILE_RESIZING, dividerView)
                .setTimeout(LONG_CUJ_TIMEOUT_MS)
        )
    }

    private fun endJankMonitoring() {
        interactionJankMonitor.end(CUJ_DESKTOP_MODE_TILE_RESIZING)
    }

    /**
    /**
     * Moves the divider view to a new position after touch, gets called from the
     * Moves the divider view to a new position after touch, gets called from the
     * [TilingDividerView] onTouch function.
     * [TilingDividerView] onTouch function.
@@ -280,6 +297,7 @@ class DesktopTilingDividerWindowManager(
     */
     */
    override fun onDividerMovedEnd(pos: Int, motionEvent: MotionEvent) {
    override fun onDividerMovedEnd(pos: Int, motionEvent: MotionEvent) {
        setSlippery(true)
        setSlippery(true)
        endJankMonitoring()
        val t = transactionSupplier.get()
        val t = transactionSupplier.get()
        t.setPosition(leash, pos.toFloat() - maxRoundedCornerRadius, dividerBounds.top.toFloat())
        t.setPosition(leash, pos.toFloat() - maxRoundedCornerRadius, dividerBounds.top.toFloat())
        val dividerWidth = dividerBounds.width()
        val dividerWidth = dividerBounds.width()
@@ -362,5 +380,8 @@ class DesktopTilingDividerWindowManager(
    companion object {
    companion object {
        private const val DIVIDER_FADE_IN_ALPHA_DURATION = 300L
        private const val DIVIDER_FADE_IN_ALPHA_DURATION = 300L
        private const val DIVIDER_FADE_IN_ALPHA_SLOW_DURATION = 900L
        private const val DIVIDER_FADE_IN_ALPHA_SLOW_DURATION = 900L
        // Timeout used for resize and drag CUJs, this is longer than the default timeout to avoid
        // timing out in the middle of a resize or drag action.
        private val LONG_CUJ_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(10L)
    }
    }
}
}
+3 −0
Original line number Original line Diff line number Diff line
@@ -38,6 +38,7 @@ import android.window.TransitionInfo.Change
import android.window.TransitionRequestInfo
import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import android.window.WindowContainerTransaction
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.launcher3.icons.BaseIconFactory
import com.android.launcher3.icons.BaseIconFactory
import com.android.wm.shell.R
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -94,6 +95,7 @@ class DesktopTilingWindowDecoration(
    @ShellMainThread private val mainExecutor: ShellExecutor,
    @ShellMainThread private val mainExecutor: ShellExecutor,
    private val desktopState: DesktopState,
    private val desktopState: DesktopState,
    private val shellController: ShellController,
    private val shellController: ShellController,
    private val interactionJankMonitor: InteractionJankMonitor,
    private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() },
    private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() },
) :
) :
    Transitions.TransitionHandler,
    Transitions.TransitionHandler,
@@ -264,6 +266,7 @@ class DesktopTilingWindowDecoration(
                    dividerBounds,
                    dividerBounds,
                    displayContext,
                    displayContext,
                    isDarkMode,
                    isDarkMode,
                    interactionJankMonitor
                )
                )
            }
            }
        // a leash to present the divider on top of, without re-parenting.
        // a leash to present the divider on top of, without re-parenting.
Loading