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

Commit 224131da authored by Wu Ahan's avatar Wu Ahan Committed by Android (Google) Code Review
Browse files

Merge "Instrument jank between lockscreen and AoD" into sc-dev

parents 765f55d9 c7311639
Loading
Loading
Loading
Loading
+53 −0
Original line number Diff line number Diff line
@@ -16,16 +16,23 @@

package com.android.systemui.statusbar;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_TRANSITION_FROM_AOD;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_TRANSITION_TO_AOD;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.text.format.DateFormat;
import android.util.FloatProperty;
import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;

import androidx.annotation.NonNull;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.DejankUtils;
import com.android.systemui.Dumpable;
@@ -81,6 +88,8 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll
    // Record the HISTORY_SIZE most recent states
    private int mHistoryIndex = 0;
    private HistoricalState[] mHistoricalRecords = new HistoricalState[HISTORY_SIZE];
    // This is used by InteractionJankMonitor to get callback from HWUI.
    private View mView;

    /**
     * If any of the system bars is hidden.
@@ -236,6 +245,11 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll

    @Override
    public void setDozeAmount(float dozeAmount, boolean animated) {
        setAndInstrumentDozeAmount(null, dozeAmount, animated);
    }

    @Override
    public void setAndInstrumentDozeAmount(View view, float dozeAmount, boolean animated) {
        if (mDarkAnimator != null && mDarkAnimator.isRunning()) {
            if (animated && mDozeAmountTarget == dozeAmount) {
                return;
@@ -244,6 +258,11 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll
            }
        }

        // We don't need a new attached view if we already have one.
        if ((mView == null || !mView.isAttachedToWindow())
                && (view != null && view.isAttachedToWindow())) {
            mView = view;
        }
        mDozeAmountTarget = dozeAmount;
        if (animated) {
            startDozeAnimation();
@@ -261,6 +280,22 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll
        mDarkAnimator = ObjectAnimator.ofFloat(this, SET_DARK_AMOUNT_PROPERTY, mDozeAmountTarget);
        mDarkAnimator.setInterpolator(Interpolators.LINEAR);
        mDarkAnimator.setDuration(StackStateAnimator.ANIMATION_DURATION_WAKEUP);
        mDarkAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                cancelInteractionJankMonitor();
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                endInteractionJankMonitor();
            }

            @Override
            public void onAnimationStart(Animator animation) {
                beginInteractionJankMonitor();
            }
        });
        mDarkAnimator.start();
    }

@@ -277,6 +312,24 @@ public class StatusBarStateControllerImpl implements SysuiStatusBarStateControll
        }
    }

    private void beginInteractionJankMonitor() {
        if (mView != null && mView.isAttachedToWindow()) {
            InteractionJankMonitor.getInstance().begin(mView, getCujType());
        }
    }

    private void endInteractionJankMonitor() {
        InteractionJankMonitor.getInstance().end(getCujType());
    }

    private void cancelInteractionJankMonitor() {
        InteractionJankMonitor.getInstance().cancel(getCujType());
    }

    private int getCujType() {
        return mIsDozing ? CUJ_LOCKSCREEN_TRANSITION_TO_AOD : CUJ_LOCKSCREEN_TRANSITION_FROM_AOD;
    }

    @Override
    public boolean goingToFullShade() {
        return mState == StatusBarState.SHADE && mLeaveOpenOnKeyguardHide;
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar;
import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.IntDef;
import android.view.View;

import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -75,6 +76,15 @@ public interface SysuiStatusBarStateController extends StatusBarStateController
     */
    void setDozeAmount(float dozeAmount, boolean animated);

    /**
     * Changes the current doze amount, also starts the
     * {@link com.android.internal.jank.InteractionJankMonitor InteractionJankMonitor} as possible.
     *
     * @param view An attached view, which will be used by InteractionJankMonitor.
     * @param dozeAmount New doze/dark amount.
     * @param animated If change should be animated or not. This will cancel current animations.
     */
    void setAndInstrumentDozeAmount(View view, float dozeAmount, boolean animated);

    /**
     * Update the expanded state from {@link StatusBar}'s perspective
+1 −1
Original line number Diff line number Diff line
@@ -3127,7 +3127,7 @@ public class NotificationPanelViewController extends PanelViewController {
        }

        final float dozeAmount = dozing ? 1 : 0;
        mStatusBarStateController.setDozeAmount(dozeAmount, animate);
        mStatusBarStateController.setAndInstrumentDozeAmount(mView, dozeAmount, animate);
    }

    public void setPulsing(boolean pulsing) {