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

Commit d15fe538 authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "4/ Provide InteractionJankMonitor through Dagger"

parents 8975ee31 46f11afd
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ import kotlin.math.max
class NotificationLaunchAnimatorControllerProvider(
    private val notificationShadeWindowViewController: NotificationShadeWindowViewController,
    private val notificationListContainer: NotificationListContainer,
    private val headsUpManager: HeadsUpManagerPhone
    private val headsUpManager: HeadsUpManagerPhone,
    private val jankMonitor: InteractionJankMonitor
) {
    fun getAnimatorController(
        notification: ExpandableNotificationRow
@@ -25,7 +26,8 @@ class NotificationLaunchAnimatorControllerProvider(
            notificationShadeWindowViewController,
            notificationListContainer,
            headsUpManager,
            notification
            notification,
            jankMonitor
        )
    }
}
@@ -39,7 +41,8 @@ class NotificationLaunchAnimatorController(
    private val notificationShadeWindowViewController: NotificationShadeWindowViewController,
    private val notificationListContainer: NotificationListContainer,
    private val headsUpManager: HeadsUpManagerPhone,
    private val notification: ExpandableNotificationRow
    private val notification: ExpandableNotificationRow,
    private val jankMonitor: InteractionJankMonitor
) : ActivityLaunchAnimator.Controller {

    companion object {
@@ -137,12 +140,12 @@ class NotificationLaunchAnimatorController(
        notification.isExpandAnimationRunning = true
        notificationListContainer.setExpandingNotification(notification)

        InteractionJankMonitor.getInstance().begin(notification,
        jankMonitor.begin(notification,
            InteractionJankMonitor.CUJ_NOTIFICATION_APP_START)
    }

    override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) {
        InteractionJankMonitor.getInstance().end(InteractionJankMonitor.CUJ_NOTIFICATION_APP_START)
        jankMonitor.end(InteractionJankMonitor.CUJ_NOTIFICATION_APP_START)

        notification.isExpandAnimationRunning = false
        notificationShadeWindowViewController.setExpandAnimationRunning(false)
+14 −10
Original line number Diff line number Diff line
@@ -183,6 +183,7 @@ public class NotificationStackScrollLayoutController {
    private final NotificationGroupManagerLegacy mLegacyGroupManager;
    private final SectionHeaderController mSilentHeaderController;
    private final LockscreenShadeTransitionController mLockscreenShadeTransitionController;
    private final InteractionJankMonitor mJankMonitor;

    private NotificationStackScrollLayout mView;
    private boolean mFadeNotificationsOnDismiss;
@@ -661,7 +662,8 @@ public class NotificationStackScrollLayoutController {
            LayoutInflater layoutInflater,
            NotificationRemoteInputManager remoteInputManager,
            VisualStabilityManager visualStabilityManager,
            ShadeController shadeController) {
            ShadeController shadeController,
            InteractionJankMonitor jankMonitor) {
        mAllowLongPress = allowLongPress;
        mNotificationGutsManager = notificationGutsManager;
        mVisibilityProvider = visibilityProvider;
@@ -684,6 +686,7 @@ public class NotificationStackScrollLayoutController {
        mNotificationSwipeHelperBuilder = notificationSwipeHelperBuilder;
        mStatusBar = statusBar;
        mScrimController = scrimController;
        mJankMonitor = jankMonitor;
        groupManager.registerGroupExpansionChangeListener(
                (changedRow, expanded) -> mView.onGroupExpandChanged(changedRow, expanded));
        legacyGroupManager.registerGroupChangeListener(new OnGroupChangeListener() {
@@ -1784,9 +1787,9 @@ public class NotificationStackScrollLayoutController {
            // We log any touches other than down, which will be captured by onTouchEvent.
            // In the intercept we only start tracing when it's not a down (otherwise that down
            // would be duplicated when intercepted).
            if (scrollWantsIt && ev.getActionMasked() != MotionEvent.ACTION_DOWN) {
                InteractionJankMonitor.getInstance().begin(mView,
                        CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
            if (mJankMonitor != null && scrollWantsIt
                    && ev.getActionMasked() != MotionEvent.ACTION_DOWN) {
                mJankMonitor.begin(mView, CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
            }
            return swipeWantsIt || scrollWantsIt || expandWantsIt || longPressWantsIt;
        }
@@ -1854,24 +1857,25 @@ public class NotificationStackScrollLayoutController {
        }

        private void traceJankOnTouchEvent(int action, boolean scrollerWantsIt) {
            if (mJankMonitor == null) {
                Log.w(TAG, "traceJankOnTouchEvent, mJankMonitor is null");
                return;
            }
            // Handle interaction jank monitor cases.
            switch (action) {
                case MotionEvent.ACTION_DOWN:
                    if (scrollerWantsIt) {
                        InteractionJankMonitor.getInstance()
                                .begin(mView, CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                        mJankMonitor.begin(mView, CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (scrollerWantsIt && !mView.isFlingAfterUpEvent()) {
                        InteractionJankMonitor.getInstance()
                                .end(CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                        mJankMonitor.end(CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                    }
                    break;
                case MotionEvent.ACTION_CANCEL:
                    if (scrollerWantsIt) {
                        InteractionJankMonitor.getInstance()
                                .cancel(CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                        mJankMonitor.cancel(CUJ_NOTIFICATION_SHADE_SCROLL_FLING);
                    }
                    break;
            }
+8 −2
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ import androidx.lifecycle.LifecycleRegistry;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
@@ -677,6 +678,8 @@ public class StatusBar extends CoreStartable implements
    private final ColorExtractor.OnColorsChangedListener mOnColorsChangedListener =
            (extractor, which) -> updateTheme();

    private final InteractionJankMonitor mJankMonitor;


    /**
     * Public constructor for StatusBar.
@@ -779,7 +782,8 @@ public class StatusBar extends CoreStartable implements
            WallpaperManager wallpaperManager,
            Optional<StartingSurface> startingSurfaceOptional,
            ActivityLaunchAnimator activityLaunchAnimator,
            NotifPipelineFlags notifPipelineFlags) {
            NotifPipelineFlags notifPipelineFlags,
            InteractionJankMonitor jankMonitor) {
        super(context);
        mNotificationsController = notificationsController;
        mFragmentService = fragmentService;
@@ -867,6 +871,7 @@ public class StatusBar extends CoreStartable implements
        mMainExecutor = delayableExecutor;
        mMessageRouter = messageRouter;
        mWallpaperManager = wallpaperManager;
        mJankMonitor = jankMonitor;

        mLockscreenShadeTransitionController = lockscreenShadeTransitionController;
        mStartingSurfaceOptional = startingSurfaceOptional;
@@ -1387,7 +1392,8 @@ public class StatusBar extends CoreStartable implements
        mNotificationAnimationProvider = new NotificationLaunchAnimatorControllerProvider(
                mNotificationShadeWindowViewController,
                mStackScrollerController.getNotificationListContainer(),
                mHeadsUpManager
                mHeadsUpManager,
                mJankMonitor
        );

        // TODO: inject this.
+5 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.PowerManager;
import android.util.DisplayMetrics;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.MetricsLogger;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
@@ -227,7 +228,8 @@ public interface StatusBarPhoneModule {
            WallpaperManager wallpaperManager,
            Optional<StartingSurface> startingSurfaceOptional,
            ActivityLaunchAnimator activityLaunchAnimator,
            NotifPipelineFlags notifPipelineFlags) {
            NotifPipelineFlags notifPipelineFlags,
            InteractionJankMonitor jankMonitor) {
        return new StatusBar(
                context,
                notificationsController,
@@ -321,7 +323,8 @@ public interface StatusBarPhoneModule {
                wallpaperManager,
                startingSurfaceOptional,
                activityLaunchAnimator,
                notifPipelineFlags
                notifPipelineFlags,
                jankMonitor
        );
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.testing.AndroidTestingRunner
import android.testing.TestableLooper
import android.testing.TestableLooper.RunWithLooper
import androidx.test.filters.SmallTest
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.SysuiTestCase
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.NotificationTestHelper
@@ -29,6 +30,7 @@ class NotificationLaunchAnimatorControllerTest : SysuiTestCase() {
    @Mock lateinit var notificationShadeWindowViewController: NotificationShadeWindowViewController
    @Mock lateinit var notificationListContainer: NotificationListContainer
    @Mock lateinit var headsUpManager: HeadsUpManagerPhone
    @Mock lateinit var jankMonitor: InteractionJankMonitor

    private lateinit var notificationTestHelper: NotificationTestHelper
    private lateinit var notification: ExpandableNotificationRow
@@ -49,7 +51,8 @@ class NotificationLaunchAnimatorControllerTest : SysuiTestCase() {
                notificationShadeWindowViewController,
                notificationListContainer,
                headsUpManager,
                notification
                notification,
                jankMonitor
        )
    }

Loading