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

Commit 7e72a16e authored by Jieru Shi's avatar Jieru Shi
Browse files

Add click logging for Smartspace media recommendation card

Test: statsd_testdrive output https://paste.googleplex.com/5438521440468992
Bug: 181364757

Change-Id: I2fdb8f60144a823a720e3bc3803eb350f6b36e7b
parent a5850308
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.systemui.animation.GhostedViewLaunchAnimatorController;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.media.dialog.MediaOutputDialogFactory;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.phone.KeyguardDismissUtil;
import com.android.systemui.util.animation.TransitionLayout;

@@ -519,7 +520,8 @@ public class MediaControlPanel {
            mediaCoverImageView.setImageIcon(recommendation.getIcon());

            // Set up the click listener if applicable.
            setSmartspaceOnClickListener(mediaCoverImageView, recommendation, callback);
            setSmartspaceOnClickListener(mediaCoverImageView, recommendation,
                    target.getSmartspaceTargetId(), callback);

            setVisibleAndAlpha(expandedSet, mediaCoverItemsResIds.get(i), true);
            setVisibleAndAlpha(expandedSet, mediaLogoItemsResIds.get(i), true);
@@ -614,6 +616,7 @@ public class MediaControlPanel {
    private void setSmartspaceOnClickListener(
            @NonNull View view,
            @NonNull SmartspaceAction action,
            @NonNull String targetId,
            @Nullable View.OnClickListener callback) {
        if (view == null || action == null || action.getIntent() == null) {
            Log.e(TAG, "No tap action can be set up");
@@ -621,6 +624,16 @@ public class MediaControlPanel {
        }

        view.setOnClickListener(v -> {
            // When media recommendation card is shown, there could be only one card.
            SysUiStatsLog.write(SysUiStatsLog.SMARTSPACE_CARD_REPORTED,
                    760, // SMARTSPACE_CARD_CLICK
                    targetId.hashCode(),
                    SysUiStatsLog
                            .SMART_SPACE_CARD_REPORTED__CARD_TYPE__HEADPHONE_MEDIA_RECOMMENDATIONS,
                    getSurfaceForSmartspaceLogging(mMediaViewController.getCurrentEndLocation()),
                    /* rank */ 1,
                    /* cardinality */ 1);

            mActivityStarter.postStartActivityDismissingKeyguard(
                    action.getIntent(),
                    0 /* delay */,
@@ -630,4 +643,14 @@ public class MediaControlPanel {
            }
        });
    }

    private int getSurfaceForSmartspaceLogging(int currentEndLocation) {
        if (currentEndLocation == MediaHierarchyManager.LOCATION_QQS
                || currentEndLocation == MediaHierarchyManager.LOCATION_QS) {
            return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__SHADE;
        } else if (currentEndLocation == MediaHierarchyManager.LOCATION_LOCKSCREEN) {
            return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__LOCKSCREEN;
        }
        return SysUiStatsLog.SMART_SPACE_CARD_REPORTED__DISPLAY_SURFACE__DEFAULT_SURFACE;
    }
}
+2 −3
Original line number Diff line number Diff line
@@ -70,11 +70,10 @@ class MediaViewController @Inject constructor(
     * finished
     */
    @MediaLocation
    private var currentEndLocation: Int = -1
    var currentEndLocation: Int = -1

    /**
     * The ending location of the view where it ends when all animations and transitions have
     * finished
     * The starting location of the view where it starts for all animations and transitions
     */
    @MediaLocation
    private var currentStartLocation: Int = -1