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

Commit 2a9745e5 authored by Jieru Shi's avatar Jieru Shi
Browse files

Add click logging for media player seekbar interaction.

Bug: 181364757
Test: will append statsd_drive logs
Change-Id: I8d299ef3c06bfb541bf048a0f1c86f7cfb2f0ce1
parent 328d2d56
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;

import dagger.Lazy;
import kotlin.Unit;

/**
 * A view controller used for Media Playback.
@@ -133,6 +134,13 @@ public class MediaControlPanel {
        mMediaOutputDialogFactory = mediaOutputDialogFactory;
        mMediaCarouselController = mediaCarouselController;
        loadDimens();

        mSeekBarViewModel.setLogSmartspaceClick(() -> {
            logSmartspaceCardReported(
                    760, // SMARTSPACE_CARD_CLICK
                    /* isRecommendationCard */ false);
            return Unit.INSTANCE;
        });
    }

    public void onDestroy() {
+7 −2
Original line number Diff line number Diff line
@@ -28,8 +28,8 @@ import android.widget.SeekBar
import androidx.annotation.AnyThread
import androidx.annotation.WorkerThread
import androidx.core.view.GestureDetectorCompat
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.util.concurrency.RepeatableExecutor
import javax.inject.Inject
@@ -70,7 +70,9 @@ private fun PlaybackState.computePosition(duration: Long): Long {
}

/** ViewModel for seek bar in QS media player. */
class SeekBarViewModel @Inject constructor(@Background private val bgExecutor: RepeatableExecutor) {
class SeekBarViewModel @Inject constructor(
    @Background private val bgExecutor: RepeatableExecutor
) {
    private var _data = Progress(false, false, null, 0)
        set(value) {
            field = value
@@ -127,6 +129,8 @@ class SeekBarViewModel @Inject constructor(@Background private val bgExecutor: R
            }
        }

    lateinit var logSmartspaceClick: () -> Unit

    /**
     * Event indicating that the user has started interacting with the seek bar.
     */
@@ -167,6 +171,7 @@ class SeekBarViewModel @Inject constructor(@Background private val bgExecutor: R
            scrubbing = false
            checkPlaybackPosition()
        } else {
            logSmartspaceClick()
            controller?.transportControls?.seekTo(position)
            // Invalidate the cached playbackState to avoid the thumb jumping back to the previous
            // position.
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class SeekBarViewModelTest : SysuiTestCase() {
    fun setUp() {
        fakeExecutor = FakeExecutor(FakeSystemClock())
        viewModel = SeekBarViewModel(FakeRepeatableExecutor(fakeExecutor))
        viewModel.logSmartspaceClick = { }
        mockController = mock(MediaController::class.java)
        whenever(mockController.sessionToken).thenReturn(token1)
        mockTransport = mock(MediaController.TransportControls::class.java)