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

Commit 9f2dcd70 authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "[SysUI][Floaty] Add CUJ_LPP_ASSIST_INVOCATION_EFFECT" into main

parents d45c2287 daacf879
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -342,8 +342,14 @@ public class Cuj {
     */
    public static final int CUJ_NOTIFICATIONS_ANIMATED_ACTION = 131;

    /**
     * Track the animation of the assistant invocation by long pressing the power button.
     */
    public static final int CUJ_LPP_ASSIST_INVOCATION_EFFECT = 132;


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

    /** @hide */
    @IntDef({
@@ -466,7 +472,8 @@ public class Cuj {
            CUJ_DEFAULT_TASK_TO_TASK_ANIMATION,
            CUJ_DESKTOP_MODE_MOVE_WINDOW_TO_DISPLAY,
            CUJ_STATUS_BAR_APP_RETURN_TO_CALL_CHIP,
            CUJ_NOTIFICATIONS_ANIMATED_ACTION
            CUJ_NOTIFICATIONS_ANIMATED_ACTION,
            CUJ_LPP_ASSIST_INVOCATION_EFFECT
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface CujType {}
@@ -600,6 +607,7 @@ public class Cuj {
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_DESKTOP_MODE_MOVE_WINDOW_TO_DISPLAY] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__DESKTOP_MODE_MOVE_WINDOW_TO_DISPLAY;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_STATUS_BAR_APP_RETURN_TO_CALL_CHIP] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__STATUS_BAR_APP_RETURN_TO_CALL_CHIP;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_NOTIFICATIONS_ANIMATED_ACTION] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__NOTIFICATIONS_ANIMATED_ACTION;
        CUJ_TO_STATSD_INTERACTION_TYPE[CUJ_LPP_ASSIST_INVOCATION_EFFECT] = FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LPP_ASSIST_INVOCATION_EFFECT;
    }

    private Cuj() {
@@ -858,6 +866,8 @@ public class Cuj {
                return "STATUS_BAR_APP_RETURN_TO_CALL_CHIP";
            case CUJ_NOTIFICATIONS_ANIMATED_ACTION:
                return "NOTIFICATIONS_ANIMATED_ACTION";
            case CUJ_LPP_ASSIST_INVOCATION_EFFECT:
                return "CUJ_LPP_ASSIST_INVOCATION_EFFECT";
        }
        return "UNKNOWN";
    }
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.view.WindowManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.jank.interactionJankMonitor
import com.android.systemui.keyevent.data.repository.fakeKeyEventRepository
import com.android.systemui.keyevent.domain.interactor.keyEventInteractor
import com.android.systemui.kosmos.Kosmos
@@ -79,6 +80,7 @@ class TopLevelWindowEffectsTest : SysuiTestCase() {
                    SqueezeEffectInteractor(squeezeEffectRepository = fakeSqueezeEffectRepository),
                appZoomOutOptional = Optional.empty(),
                notificationShadeWindowController = notificationShadeWindowController,
                interactionJankMonitor = kosmos.interactionJankMonitor,
            )
        }

+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.WindowInsets
import android.view.WindowManager
import androidx.annotation.DrawableRes
import androidx.annotation.VisibleForTesting
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.CoreStartable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -57,6 +58,7 @@ constructor(
    // TODO(b/409930584): make AppZoomOut non-optional
    private val appZoomOutOptional: Optional<AppZoomOut>,
    private val notificationShadeWindowController: NotificationShadeWindowController,
    private val interactionJankMonitor: InteractionJankMonitor,
) : CoreStartable {

    private var root: EffectsWindowRoot? = null
@@ -105,6 +107,7 @@ constructor(
                        }
                    },
                    appZoomOutOptional = appZoomOutOptional,
                    interactionJankMonitor = interactionJankMonitor,
                )
            root?.let { rootView ->
                runOnMainThread { notificationShadeWindowController.setRequestTopUi(true, TAG) }
+3 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.AbstractComposeView
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.compose.ComposeInitializer
import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel
import com.android.wm.shell.appzoomout.AppZoomOut
@@ -35,6 +36,7 @@ class EffectsWindowRoot(
    @DrawableRes private val bottomRoundedCornerResourceId: Int,
    private val physicalPixelDisplaySizeRatio: Float,
    private val appZoomOutOptional: Optional<AppZoomOut>,
    private val interactionJankMonitor: InteractionJankMonitor,
) : AbstractComposeView(context) {

    override fun onAttachedToWindow() {
@@ -56,6 +58,7 @@ class EffectsWindowRoot(
            bottomRoundedCornerResourceId = bottomRoundedCornerResourceId,
            physicalPixelDisplaySizeRatio = physicalPixelDisplaySizeRatio,
            appZoomOutOptional = appZoomOutOptional,
            interactionJankMonitor = interactionJankMonitor,
        )
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -37,9 +37,12 @@ import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.VectorPainter
import androidx.compose.ui.graphics.vector.rememberVectorPainter
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.android.internal.jank.Cuj
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.lifecycle.rememberViewModel
import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel
import com.android.systemui.topwindoweffects.ui.viewmodel.SqueezeEffectViewModel.Companion.ZOOM_OUT_SCALE
@@ -60,8 +63,10 @@ fun SqueezeEffect(
    physicalPixelDisplaySizeRatio: Float,
    onEffectFinished: suspend () -> Unit,
    appZoomOutOptional: Optional<AppZoomOut>,
    interactionJankMonitor: InteractionJankMonitor,
) {
    val viewModel = rememberViewModel(traceName = "SqueezeEffect") { viewModelFactory.create() }
    val view = LocalView.current

    val down = viewModel.isPowerButtonPressed
    val longPressed = viewModel.isPowerButtonLongPressed
@@ -97,9 +102,11 @@ fun SqueezeEffect(

    LaunchedEffect(isMainAnimationRunning) {
        if (isMainAnimationRunning) {
            interactionJankMonitor.begin(view, Cuj.CUJ_LPP_ASSIST_INVOCATION_EFFECT)
            squeezeProgress.animateTo(1f, animationSpec = tween(durationMillis = 800))
            squeezeProgress.animateTo(0f, animationSpec = tween(durationMillis = 333))
            if (squeezeProgress.value == 0f) {
                interactionJankMonitor.end(Cuj.CUJ_LPP_ASSIST_INVOCATION_EFFECT)
                onEffectFinished()
            }
            isAnimationInterruptible = true
@@ -108,6 +115,7 @@ fun SqueezeEffect(
                squeezeProgress.animateTo(0f, animationSpec = tween(durationMillis = 333))
            }
            if (squeezeProgress.value == 0f) {
                interactionJankMonitor.cancel(Cuj.CUJ_LPP_ASSIST_INVOCATION_EFFECT)
                onEffectFinished()
            }
        }