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

Commit 06c98fd6 authored by Anushree Ganjam's avatar Anushree Ganjam
Browse files

Add InteractionJankMonitor for backpress from allapps CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK.

Jank CUJ's cannot be added in LauncherState since it's aosp code.
Introduced `onBackPressComplete` method so the LauncherState subclasses can override this method to get back press complete call after back press animation is successful. Here we can add necessary jank CUJ's.

Perfetto trace : https://ui.perfetto.dev/#!/?s=3fc6eed848bdd692949ddb3afbdcdf04a7ef0d99cb9a83804ce9e1840492ed66

Test: Perfetto trace. https://screenshot.googleplex.com/5yviY5LxKusnKvF.png
Bug: 319132905
Flag: NA. Adding jank CUJ.

Change-Id: Ia418f06cb76fe4e14c2032c62c2250e9143442f2
parent 1979abe3
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAP

import android.content.Context;

import com.android.internal.jank.Cuj;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
@@ -27,6 +28,7 @@ import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;

/**
 * Definition for AllApps state
@@ -48,6 +50,24 @@ public class AllAppsState extends LauncherState {
                : context.getDeviceProfile().allAppsCloseDuration;
    }

    @Override
    public void onBackPressed(Launcher launcher) {
        InteractionJankMonitorWrapper.begin(launcher.getAppsView(),
                Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
        super.onBackPressed(launcher);
    }

    @Override
    protected void onBackPressCompleted(boolean success) {
        if (success) {
            // Animation was successful.
            InteractionJankMonitorWrapper.end(Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
        } else {
            // Animation was canceled.
            InteractionJankMonitorWrapper.cancel(Cuj.CUJ_LAUNCHER_CLOSE_ALL_APPS_BACK);
        }
    }

    @Override
    public String getDescription(Launcher launcher) {
        return launcher.getAppsView().getDescription();
+11 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package com.android.launcher3;

import static com.android.app.animation.Interpolators.ACCELERATE_2;
import static com.android.app.animation.Interpolators.DECELERATE_2;
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
import static com.android.launcher3.testing.shared.TestProtocol.ALL_APPS_STATE_ORDINAL;
@@ -427,10 +428,19 @@ public abstract class LauncherState implements BaseState<LauncherState> {
        if (this != NORMAL) {
            StateManager<LauncherState> lsm = launcher.getStateManager();
            LauncherState lastState = lsm.getLastState();
            lsm.goToState(lastState);
            lsm.goToState(lastState, forEndCallback(this::onBackPressCompleted));
        }
    }

    /**
     * To be called if back press is completed in a launcher state.
     *
     * @param success whether back press animation was successful or canceled.
     */
    protected void onBackPressCompleted(boolean success) {
        // Do nothing. To be overridden by child class.
    }

    /**
     * Find {@link StateManager} and target {@link LauncherState} to handle back progress in
     * predictive back gesture.
+8 −1
Original line number Diff line number Diff line
@@ -156,6 +156,13 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
        goToState(state, shouldAnimateStateChange());
    }

    /**
     * @see #goToState(STATE_TYPE, boolean, AnimatorListener)
     */
    public void goToState(STATE_TYPE state, AnimatorListener listener) {
        goToState(state, shouldAnimateStateChange(), listener);
    }

    /**
     * @see #goToState(STATE_TYPE, boolean, AnimatorListener)
     */
@@ -168,7 +175,7 @@ public class StateManager<STATE_TYPE extends BaseState<STATE_TYPE>> {
     *
     * @param animated false if the state should change immediately without any animation,
     *                true otherwise
     * @paras onCompleteRunnable any action to perform at the end of the transition, of null.
     * @param listener any action to perform at the end of the transition, or null.
     */
    public void goToState(STATE_TYPE state, boolean animated, AnimatorListener listener) {
        goToState(state, animated, 0, listener);