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

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

Merge "Add tiling jank CUJ." into main

parents 5e4edde8 19b6a258
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -435,8 +435,15 @@ public class Cuj {
     */
    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.
    @VisibleForTesting static final int LAST_CUJ = CUJ_LAUNCHER_OVERVIEW_CLEAR_ALL;
    @VisibleForTesting static final int LAST_CUJ = CUJ_DESKTOP_MODE_TILE_RESIZING;

    /** @hide */
    @IntDef({
@@ -567,7 +574,8 @@ public class Cuj {
            CUJ_WEAR_QSS_TRAY_OPEN,
            CUJ_WEAR_NOTIFICATION_TRAY_OPEN,
            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)
    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_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_DESKTOP_MODE_TILE_RESIZING] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__DESKTOP_MODE_TILE_RESIZING;
    }

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

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

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

    override fun onDividerMoveStart(pos: Int, motionEvent: MotionEvent) {
        setSlippery(false)
        beginJankMonitoring()
        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
     * [TilingDividerView] onTouch function.
@@ -280,6 +297,7 @@ class DesktopTilingDividerWindowManager(
     */
    override fun onDividerMovedEnd(pos: Int, motionEvent: MotionEvent) {
        setSlippery(true)
        endJankMonitoring()
        val t = transactionSupplier.get()
        t.setPosition(leash, pos.toFloat() - maxRoundedCornerRadius, dividerBounds.top.toFloat())
        val dividerWidth = dividerBounds.width()
@@ -362,5 +380,8 @@ class DesktopTilingDividerWindowManager(
    companion object {
        private const val DIVIDER_FADE_IN_ALPHA_DURATION = 300L
        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 Diff line number Diff line
@@ -38,6 +38,7 @@ import android.window.TransitionInfo.Change
import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
import com.android.internal.annotations.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.launcher3.icons.BaseIconFactory
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
@@ -94,6 +95,7 @@ class DesktopTilingWindowDecoration(
    @ShellMainThread private val mainExecutor: ShellExecutor,
    private val desktopState: DesktopState,
    private val shellController: ShellController,
    private val interactionJankMonitor: InteractionJankMonitor,
    private val transactionSupplier: Supplier<Transaction> = Supplier { Transaction() },
) :
    Transitions.TransitionHandler,
@@ -264,6 +266,7 @@ class DesktopTilingWindowDecoration(
                    dividerBounds,
                    displayContext,
                    isDarkMode,
                    interactionJankMonitor
                )
            }
        // a leash to present the divider on top of, without re-parenting.
Loading