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

Commit c2b75079 authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Instrumenting flinging all apps for jank" into sc-dev

parents 505b4b2d 34c02627
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import static com.android.systemui.shared.system.SysUiStatsLog.LAUNCHER_UICHANGE

import android.content.Context;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;
@@ -55,6 +56,7 @@ import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.LogConfig;
import com.android.systemui.shared.system.InteractionJankMonitorWrapper;
import com.android.systemui.shared.system.SysUiStatsLog;

import java.util.Optional;
@@ -94,7 +96,7 @@ public class StatsLogCompatManager extends StatsLogManager {

    @Override
    protected StatsLogger createLogger() {
        return new StatsCompatLogger();
        return new StatsCompatLogger(mContext);
    }

    /**
@@ -136,6 +138,7 @@ public class StatsLogCompatManager extends StatsLogManager {

        private static final ItemInfo DEFAULT_ITEM_INFO = new ItemInfo();

        private Context mContext;
        private ItemInfo mItemInfo = DEFAULT_ITEM_INFO;
        private InstanceId mInstanceId = DEFAULT_INSTANCE_ID;
        private OptionalInt mRank = OptionalInt.empty();
@@ -147,6 +150,10 @@ public class StatsLogCompatManager extends StatsLogManager {
        private Optional<String> mEditText = Optional.empty();
        private SliceItem mSliceItem;

        StatsCompatLogger(Context context) {
            mContext = context;
        }

        @Override
        public StatsLogger withItemInfo(ItemInfo itemInfo) {
            if (mContainerInfo.isPresent()) {
@@ -220,7 +227,6 @@ public class StatsLogCompatManager extends StatsLogManager {
            if (!Utilities.ATLEAST_R) {
                return;
            }

            LauncherAppState appState = LauncherAppState.getInstanceNoCreate();

            if (mSliceItem != null) {
@@ -256,6 +262,26 @@ public class StatsLogCompatManager extends StatsLogManager {
            }
        }

        @Override
        public void sendToInteractionJankMonitor(EventEnum event, View view) {
            if (!(event instanceof LauncherEvent)) {
                return;
            }
            switch ((LauncherEvent) event) {
                case LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN:
                    InteractionJankMonitorWrapper.begin(
                            view,
                            InteractionJankMonitorWrapper.CUJ_ALL_APPS_SCROLL);
                    break;
                case LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END:
                    InteractionJankMonitorWrapper.end(
                            InteractionJankMonitorWrapper.CUJ_ALL_APPS_SCROLL);
                    break;
                default:
                    break;
            }
        }

        private LauncherAtom.ItemInfo applyOverwrites(LauncherAtom.ItemInfo atomInfo) {
            LauncherAtom.ItemInfo.Builder itemInfoBuilder = atomInfo.toBuilder();

+21 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.UNSPECIFIED;
import static android.view.View.MeasureSpec.makeMeasureSpec;

import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
@@ -36,6 +39,7 @@ import com.android.launcher3.BaseRecyclerView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.views.RecyclerViewFastScroller;

import java.util.ArrayList;
@@ -175,6 +179,23 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
        }
    }

    @Override
    public void onScrollStateChanged(int state) {
        super.onScrollStateChanged(state);

        StatsLogManager mgr = BaseDraggingActivity.fromContext(getContext()).getStatsLogManager();
        switch (state) {
            case SCROLL_STATE_DRAGGING:
                mgr.logger().sendToInteractionJankMonitor(
                        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN, this);
                break;
            case SCROLL_STATE_IDLE:
                mgr.logger().sendToInteractionJankMonitor(
                        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END, this);
                break;
        }
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        boolean result = super.onInterceptTouchEvent(e);
+14 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_OVERVIEW_GESTURE;

import android.content.Context;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.slice.SliceItem;
@@ -407,6 +408,12 @@ public class StatsLogManager implements ResourceBasedOverride {

        @UiEvent(doc = "User switched to AllApps Work tab by tapping on it.")
        LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB(722),

        @UiEvent(doc = "All apps vertical fling started.")
        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_BEGIN(724),

        @UiEvent(doc = "All apps vertical fling ended.")
        LAUNCHER_ALLAPPS_VERTICAL_SWIPE_END(725)
        ;

        // ADD MORE
@@ -525,6 +532,13 @@ public class StatsLogManager implements ResourceBasedOverride {
         */
        default void log(EventEnum event) {
        }

        /**
         * Builds the final message and logs it to two different atoms, one for
         * event tracking and the other for jank tracking.
         */
        default void sendToInteractionJankMonitor(EventEnum event, View v) {
        }
    }

    /**