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

Commit 4f7fc4bd authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Use Kosmos jank tracker in FakeDialogTransitionAnimator

Use Kosmos for getting InteractionJankMonitor in tests

Bug: 304583132
Bug: 304582856
Test: atest FakeDialogTransitionAnimator
Flag: ACONFIG com.android.systemui.edge_back_gesture_handler_thread DISABLED
Change-Id: I9810b06b92fffa062cc01607cffaa44f6a033348
parent d6c34259
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.deviceentry.domain.interactor

import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.SceneKey
@@ -71,6 +72,7 @@ import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableSceneContainer
@TestableLooper.RunWithLooper
class DeviceEntryInteractorTest : SysuiTestCase() {

    private val kosmos = testKosmos()
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class LiftToRunFaceAuthBinderTest : SysuiTestCase() {
    @Captor private lateinit var triggerEventListenerCaptor: ArgumentCaptor<TriggerEventListener>
    @Mock private lateinit var mockSensor: Sensor

    private val underTest = kosmos.liftToRunFaceAuthBinder
    private val underTest by lazy { kosmos.liftToRunFaceAuthBinder }

    @Before
    fun setup() {
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ class StatusBarStateControllerImplTest(flags: FlagsParameterization?) : SysuiTes
            object :
                StatusBarStateControllerImpl(
                    uiEventLogger,
                    kosmos.interactionJankMonitor,
                    { kosmos.interactionJankMonitor },
                    JavaAdapter(testScope.backgroundScope),
                    { kosmos.shadeInteractor },
                    { kosmos.deviceUnlockedInteractor },
+19 −17
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ package com.android.systemui.shade;

import static android.view.WindowInsets.Type.ime;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE;
import static com.android.systemui.Flags.centralizedStatusBarHeightFix;
import static com.android.systemui.classifier.Classifier.QS_COLLAPSE;
import static com.android.systemui.shade.NotificationPanelViewController.COUNTER_PANEL_OPEN_QS;
@@ -57,6 +56,7 @@ import androidx.annotation.NonNull;

import com.android.app.animation.Interpolators;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.Cuj;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
@@ -153,7 +153,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
    private final DeviceEntryFaceAuthInteractor mDeviceEntryFaceAuthInteractor;
    private final CastController mCastController;
    private final SplitShadeStateController mSplitShadeStateController;
    private final InteractionJankMonitor mInteractionJankMonitor;
    private final Lazy<InteractionJankMonitor> mInteractionJankMonitorLazy;
    private final ShadeRepository mShadeRepository;
    private final ShadeInteractor mShadeInteractor;
    private final ActiveNotificationsInteractor mActiveNotificationsInteractor;
@@ -324,7 +324,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
            AccessibilityManager accessibilityManager,
            LockscreenGestureLogger lockscreenGestureLogger,
            MetricsLogger metricsLogger,
            InteractionJankMonitor interactionJankMonitor,
            Lazy<InteractionJankMonitor> interactionJankMonitorLazy,
            ShadeLogger shadeLog,
            DumpManager dumpManager,
            DeviceEntryFaceAuthInteractor deviceEntryFaceAuthInteractor,
@@ -375,7 +375,7 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
        mShadeLog = shadeLog;
        mDeviceEntryFaceAuthInteractor = deviceEntryFaceAuthInteractor;
        mCastController = castController;
        mInteractionJankMonitor = interactionJankMonitor;
        mInteractionJankMonitorLazy = interactionJankMonitorLazy;
        mShadeRepository = shadeRepository;
        mShadeInteractor = shadeInteractor;
        mActiveNotificationsInteractor = activeNotificationsInteractor;
@@ -2312,44 +2312,46 @@ public class QuickSettingsControllerImpl implements QuickSettingsController, Dum
    }

    void beginJankMonitoring(boolean isFullyCollapsed) {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        // TODO (b/265193930): remove dependency on NPVC
        InteractionJankMonitor.Configuration.Builder builder =
                InteractionJankMonitor.Configuration.Builder.withView(
                        InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE,
                        Cuj.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE,
                        mPanelView).setTag(isFullyCollapsed ? "Expand" : "Collapse");
        mInteractionJankMonitor.begin(builder);
        monitor.begin(builder);
    }

    void endJankMonitoring() {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        InteractionJankMonitor.getInstance().end(
                InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
        monitor.end(Cuj.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
    }

    void cancelJankMonitoring() {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        InteractionJankMonitor.getInstance().cancel(
                InteractionJankMonitor.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
        monitor.cancel(Cuj.CUJ_NOTIFICATION_SHADE_EXPAND_COLLAPSE);
    }

    void traceQsJank(boolean startTracing, boolean wasCancelled) {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        if (startTracing) {
            mInteractionJankMonitor.begin(mPanelView, CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
            monitor.begin(mPanelView, Cuj.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
        } else {
            if (wasCancelled) {
                mInteractionJankMonitor.cancel(CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
                monitor.cancel(Cuj.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
            } else {
                mInteractionJankMonitor.end(CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
                monitor.end(Cuj.CUJ_NOTIFICATION_SHADE_QS_EXPAND_COLLAPSE);
            }
        }
    }
+12 −9
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ public class StatusBarStateControllerImpl implements

    private final ArrayList<RankedListener> mListeners = new ArrayList<>();
    private final UiEventLogger mUiEventLogger;
    private final InteractionJankMonitor mInteractionJankMonitor;
    private final Lazy<InteractionJankMonitor> mInteractionJankMonitorLazy;
    private final JavaAdapter mJavaAdapter;
    private final Lazy<ShadeInteractor> mShadeInteractorLazy;
    private final Lazy<DeviceUnlockedInteractor> mDeviceUnlockedInteractorLazy;
@@ -173,14 +173,14 @@ public class StatusBarStateControllerImpl implements
    @Inject
    public StatusBarStateControllerImpl(
            UiEventLogger uiEventLogger,
            InteractionJankMonitor interactionJankMonitor,
            Lazy<InteractionJankMonitor> interactionJankMonitorLazy,
            JavaAdapter javaAdapter,
            Lazy<ShadeInteractor> shadeInteractorLazy,
            Lazy<DeviceUnlockedInteractor> deviceUnlockedInteractorLazy,
            Lazy<SceneInteractor> sceneInteractorLazy,
            Lazy<KeyguardClockInteractor> keyguardClockInteractorLazy) {
        mUiEventLogger = uiEventLogger;
        mInteractionJankMonitor = interactionJankMonitor;
        mInteractionJankMonitorLazy = interactionJankMonitorLazy;
        mJavaAdapter = javaAdapter;
        mShadeInteractorLazy = shadeInteractorLazy;
        mDeviceUnlockedInteractorLazy = deviceUnlockedInteractorLazy;
@@ -482,7 +482,8 @@ public class StatusBarStateControllerImpl implements
    private void beginInteractionJankMonitor() {
        final boolean shouldPost =
                (mIsDozing && mDozeAmount == 0) || (!mIsDozing && mDozeAmount == 1);
        if (mInteractionJankMonitor != null && mView != null && mView.isAttachedToWindow()) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor != null && mView != null && mView.isAttachedToWindow()) {
            if (shouldPost) {
                Choreographer.getInstance().postCallback(
                        Choreographer.CALLBACK_ANIMATION, this::beginInteractionJankMonitor, null);
@@ -490,23 +491,25 @@ public class StatusBarStateControllerImpl implements
                Configuration.Builder builder = Configuration.Builder.withView(getCujType(), mView)
                        .setTag(getClockId())
                        .setDeferMonitorForAnimationStart(false);
                mInteractionJankMonitor.begin(builder);
                monitor.begin(builder);
            }
        }
    }

    private void endInteractionJankMonitor() {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        mInteractionJankMonitor.end(getCujType());
        monitor.end(getCujType());
    }

    private void cancelInteractionJankMonitor() {
        if (mInteractionJankMonitor == null) {
        InteractionJankMonitor monitor = mInteractionJankMonitorLazy.get();
        if (monitor == null) {
            return;
        }
        mInteractionJankMonitor.cancel(getCujType());
        monitor.cancel(getCujType());
    }

    private int getCujType() {
Loading