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

Commit ec13cf21 authored by Ats Jenk's avatar Ats Jenk Committed by Android (Google) Code Review
Browse files

Merge "Log bubble bar location update metrics" into main

parents 137d0215 81895d37
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -475,6 +475,6 @@ class BubbleStackViewTest {

        override fun hideCurrentInputMethod() {}

        override fun updateBubbleBarLocation(location: BubbleBarLocation) {}
        override fun updateBubbleBarLocation(location: BubbleBarLocation, source: Int) {}
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -375,7 +375,7 @@ class BubbleBarExpandedViewTest {
            override fun hideCurrentInputMethod() {
            }

            override fun updateBubbleBarLocation(location: BubbleBarLocation) {
            override fun updateBubbleBarLocation(location: BubbleBarLocation, source: Int) {
            }
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -351,7 +351,7 @@ class BubbleBarLayerViewTest {

            override fun hideCurrentInputMethod() {}

            override fun updateBubbleBarLocation(location: BubbleBarLocation) {}
            override fun updateBubbleBarLocation(location: BubbleBarLocation, source: Int) {}
        }
    }

+33 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.wm.shell.shared.bubbles

import android.annotation.IntDef
import android.os.Parcel
import android.os.Parcelable

@@ -60,4 +61,36 @@ enum class BubbleBarLocation : Parcelable {
            override fun newArray(size: Int) = arrayOfNulls<BubbleBarLocation>(size)
        }
    }

    /** Define set of constants that allow to determine why location changed. */
    @IntDef(
        UpdateSource.DRAG_BAR,
        UpdateSource.DRAG_BUBBLE,
        UpdateSource.DRAG_EXP_VIEW,
        UpdateSource.A11Y_ACTION_BAR,
        UpdateSource.A11Y_ACTION_BUBBLE,
        UpdateSource.A11Y_ACTION_EXP_VIEW,
    )
    @Retention(AnnotationRetention.SOURCE)
    annotation class UpdateSource {
        companion object {
            /** Location changed from dragging the bar */
            const val DRAG_BAR = 1

            /** Location changed from dragging the bubble */
            const val DRAG_BUBBLE = 2

            /** Location changed from dragging the expanded view */
            const val DRAG_EXP_VIEW = 3

            /** Location changed via a11y action on the bar */
            const val A11Y_ACTION_BAR = 4

            /** Location changed via a11y action on the bubble */
            const val A11Y_ACTION_BUBBLE = 5

            /** Location changed via a11y action on the expanded view */
            const val A11Y_ACTION_EXP_VIEW = 6
        }
    }
}
+41 −4
Original line number Diff line number Diff line
@@ -740,8 +740,10 @@ public class BubbleController implements ConfigurationChangeListener,
    /**
     * Update bubble bar location and trigger and update to listeners
     */
    public void setBubbleBarLocation(BubbleBarLocation bubbleBarLocation) {
    public void setBubbleBarLocation(BubbleBarLocation bubbleBarLocation,
            @BubbleBarLocation.UpdateSource int source) {
        if (canShowAsBubbleBar()) {
            BubbleBarLocation previousLocation = mBubblePositioner.getBubbleBarLocation();
            mBubblePositioner.setBubbleBarLocation(bubbleBarLocation);
            if (mLayerView != null && !mLayerView.isExpandedViewDragged()) {
                mLayerView.updateExpandedView();
@@ -749,13 +751,47 @@ public class BubbleController implements ConfigurationChangeListener,
            BubbleBarUpdate bubbleBarUpdate = new BubbleBarUpdate();
            bubbleBarUpdate.bubbleBarLocation = bubbleBarLocation;
            mBubbleStateListener.onBubbleStateChange(bubbleBarUpdate);

            logBubbleBarLocationIfChanged(bubbleBarLocation, previousLocation, source);
        }
    }

    private void logBubbleBarLocationIfChanged(BubbleBarLocation location,
            BubbleBarLocation previous,
            @BubbleBarLocation.UpdateSource int source) {
        if (mLayerView == null) {
            return;
        }
        boolean isRtl = mLayerView.isLayoutRtl();
        boolean wasLeft = previous.isOnLeft(isRtl);
        boolean onLeft = location.isOnLeft(isRtl);
        if (wasLeft == onLeft) {
            // No changes, skip logging
            return;
        }
        switch (source) {
            case BubbleBarLocation.UpdateSource.DRAG_BAR:
            case BubbleBarLocation.UpdateSource.A11Y_ACTION_BAR:
                mLogger.log(onLeft ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_BAR
                        : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_BAR);
                break;
            case BubbleBarLocation.UpdateSource.DRAG_BUBBLE:
            case BubbleBarLocation.UpdateSource.A11Y_ACTION_BUBBLE:
                mLogger.log(onLeft ? BubbleLogger.Event.BUBBLE_BAR_MOVED_LEFT_DRAG_BUBBLE
                        : BubbleLogger.Event.BUBBLE_BAR_MOVED_RIGHT_DRAG_BUBBLE);
                break;
            case BubbleBarLocation.UpdateSource.DRAG_EXP_VIEW:
            case BubbleBarLocation.UpdateSource.A11Y_ACTION_EXP_VIEW:
                // TODO(b/349845968): move logging from BubbleBarLayerView to here
                break;
        }
    }

    /**
     * Animate bubble bar to the given location. The location change is transient. It does not
     * update the state of the bubble bar.
     * To update bubble bar pinned location, use {@link #setBubbleBarLocation(BubbleBarLocation)}.
     * To update bubble bar pinned location, use
     * {@link #setBubbleBarLocation(BubbleBarLocation, int)}.
     */
    public void animateBubbleBarLocation(BubbleBarLocation bubbleBarLocation) {
        if (canShowAsBubbleBar()) {
@@ -2568,9 +2604,10 @@ public class BubbleController implements ConfigurationChangeListener,
        }

        @Override
        public void setBubbleBarLocation(BubbleBarLocation location) {
        public void setBubbleBarLocation(BubbleBarLocation location,
                @BubbleBarLocation.UpdateSource int source) {
            mMainExecutor.execute(() ->
                    mController.setBubbleBarLocation(location));
                    mController.setBubbleBarLocation(location, source));
        }

        @Override
Loading