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

Commit b00225be authored by Steven Wu's avatar Steven Wu
Browse files

Add additional UI logging for bubble click events.

Bug: 123543171
Test: manual
Change-Id: I32a5c359d277c2a895a806c126c56be65afaf74f
parent ec820ed3
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@ import android.graphics.drawable.ShapeDrawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.Log;
import android.util.StatsLog;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -234,6 +236,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            mStackView.collapseStack(() -> {
                try {
                    n.contentIntent.send();
                    logBubbleClickEvent(mEntry.notification,
                            StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_APP);
                } catch (PendingIntent.CanceledException e) {
                    Log.w(TAG, "Failed to send intent for bubble with key: "
                            + (mEntry != null ? mEntry.key : " null entry"));
@@ -242,7 +246,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        } else if (id == R.id.settings_button) {
            Intent intent = getSettingsIntent(mEntry.notification.getPackageName(),
                    mEntry.notification.getUid());
            mStackView.collapseStack(() -> mContext.startActivity(intent));
            mStackView.collapseStack(() -> {
                mContext.startActivity(intent);
                logBubbleClickEvent(mEntry.notification,
                        StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
            });
        } else if (id == R.id.no_bubbles_button) {
            setBubblesAllowed(false);
        } else if (id == R.id.yes_bubbles_button) {
@@ -262,6 +270,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            } else if (mOnBubbleBlockedListener != null) {
                mOnBubbleBlockedListener.onBubbleBlocked(mEntry);
            }
            logBubbleClickEvent(mEntry.notification,
                    allowed ? StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_IN :
                            StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_OUT);
        } catch (RemoteException e) {
            Log.w(TAG, e);
        }
@@ -318,4 +329,22 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
         */
        void onBubbleBlocked(NotificationEntry entry);
    }

    /**
     * Logs bubble UI click event.
     *
     * @param notification the bubble notification that user is interacting with.
     * @param action the user interaction enum.
     */
    private void logBubbleClickEvent(StatusBarNotification notification, int action) {
        StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
                notification.getPackageName(),
                notification.getNotification().getChannelId(),
                notification.getId(),
                mStackView.getBubbleIndex(mStackView.getExpandedBubble()),
                mStackView.getBubbleCount(),
                action,
                mStackView.getNormalizedXPosition(),
                mStackView.getNormalizedYPosition());
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -766,7 +766,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
    /**
     * @return the number of bubbles in the stack view.
     */
    private int getBubbleCount() {
    public int getBubbleCount() {
        return mBubbleContainer.getChildCount();
    }

@@ -777,14 +777,14 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
     * @return the index of the bubble view within the bubble stack. The range of the position
     * is between 0 and the bubble count minus 1.
     */
    private int getBubbleIndex(BubbleView bubbleView) {
    public int getBubbleIndex(BubbleView bubbleView) {
        return mBubbleContainer.indexOfChild(bubbleView);
    }

    /**
     * @return the normalized x-axis position of the bubble stack rounded to 4 decimal places.
     */
    private float getNormalizedXPosition() {
    public float getNormalizedXPosition() {
        return new BigDecimal(getPosition().x / mDisplaySize.x)
                .setScale(4, RoundingMode.CEILING.HALF_UP)
                .floatValue();
@@ -793,7 +793,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
    /**
     * @return the normalized y-axis position of the bubble stack rounded to 4 decimal places.
     */
    private float getNormalizedYPosition() {
    public float getNormalizedYPosition() {
        return new BigDecimal(getPosition().y / mDisplaySize.y)
                .setScale(4, RoundingMode.CEILING.HALF_UP)
                .floatValue();