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

Commit 36060e84 authored by Behnam Heydarshahi's avatar Behnam Heydarshahi
Browse files

Upload live caption button click events

The enable/disable captions button and captions tooltip close button
are part of the volume dialog. We log the click event on those buttons.

Bug: b/297061446
Test: atest SystemUITests:EventsTest VolumeDialogImplTest
Change-Id: I07c7565aee2974773b5c85889b4f204dca31b105
parent 6e4e5fcb
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -234,6 +234,10 @@ public class Events {
        VOLUME_DIALOG_SLIDER(150),
        @UiEvent(doc = "The audio stream was set to silent via slider")
        VOLUME_DIALOG_SLIDER_TO_ZERO(151),
        @UiEvent(doc = "ODI captions was clicked")
        VOLUME_DIALOG_ODI_CAPTIONS_CLICKED(1503),
        @UiEvent(doc = "ODI captions tooltip dismiss was clicked")
        VOLUME_DIALOG_ODI_CAPTIONS_TOOLTIP_CLICKED(1504),
        @UiEvent(doc = "The audio volume was adjusted to silent via key")
        VOLUME_KEY_TO_ZERO(152),
        @UiEvent(doc = "The audio volume was adjusted to non-silent via key")
@@ -362,6 +366,10 @@ public class Events {
            if (tag == EVENT_SETTINGS_CLICK) {
                sLegacyLogger.action(MetricsEvent.ACTION_VOLUME_SETTINGS);
                sUiEventLogger.log(VolumeDialogEvent.VOLUME_DIALOG_SETTINGS_CLICK);
            } else if (tag == EVENT_ODI_CAPTIONS_CLICK) {
                sUiEventLogger.log(VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_CLICKED);
            } else if (tag == EVENT_ODI_CAPTIONS_TOOLTIP_CLICK) {
                sUiEventLogger.log(VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_TOOLTIP_CLICKED);
            }
            return sb.toString();
        }
+2 −2
Original line number Diff line number Diff line
@@ -120,7 +120,6 @@ import com.android.internal.view.RotationPolicy;
import com.android.settingslib.Utils;
import com.android.systemui.Dumpable;
import com.android.systemui.Prefs;
import com.android.systemui.res.R;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.media.dialog.MediaOutputDialogFactory;
@@ -129,6 +128,7 @@ import com.android.systemui.plugins.VolumeDialog;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.plugins.VolumeDialogController.State;
import com.android.systemui.plugins.VolumeDialogController.StreamState;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DevicePostureController;
@@ -287,7 +287,7 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    private boolean mIsAnimatingDismiss = false;
    private boolean mHasSeenODICaptionsTooltip;
    private ViewStub mODICaptionsTooltipViewStub;
    private View mODICaptionsTooltipView = null;
    @VisibleForTesting View mODICaptionsTooltipView = null;

    private final boolean mUseBackgroundBlur;
    private Consumer<Boolean> mCrossWindowBlurEnabledListener;
+5 −0
Original line number Diff line number Diff line
@@ -209,6 +209,11 @@ public class EventsTest extends SysuiTestCase {
                        new int[]{MetricsEvent.POWER_OVERHEAT_ALARM,
                                MetricsEvent.RESERVED_FOR_LOGBUILDER_HISTOGRAM},
                        Events.VolumeDialogEvent.USB_OVERHEAT_ALARM_DISMISSED},
                {Events.EVENT_ODI_CAPTIONS_CLICK, null, "writeEvent odi_captions_click", null,
                        Events.VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_CLICKED},
                {Events.EVENT_ODI_CAPTIONS_TOOLTIP_CLICK, null,
                        "writeEvent odi_captions_tooltip_click", null,
                        Events.VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_TOOLTIP_CLICKED}
        });
    }
}
+59 −1
Original line number Diff line number Diff line
@@ -53,11 +53,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;

import androidx.test.core.view.MotionEventBuilder;
import androidx.test.filters.SmallTest;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.testing.UiEventLoggerFake;
import com.android.systemui.Prefs;
import com.android.systemui.res.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.animation.AnimatorTestRule;
import com.android.systemui.dump.DumpManager;
@@ -66,6 +67,7 @@ import com.android.systemui.media.dialog.MediaOutputDialogFactory;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.plugins.VolumeDialogController.State;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DevicePostureController;
@@ -76,6 +78,8 @@ import com.android.systemui.util.settings.SecureSettings;

import dagger.Lazy;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -699,6 +703,60 @@ public class VolumeDialogImplTest extends SysuiTestCase {
        }
    }

    /**
     * The click should be a single tap, thus we inject a down and an up event.
     */
    @Test
    public void clickCaptionsButton_logsUiEvent() {
        UiEventLoggerFake logger = new UiEventLoggerFake();
        Events.sUiEventLogger = logger;
        MotionEvent down = MotionEventBuilder.newBuilder()
                .setAction(MotionEvent.ACTION_DOWN).build();
        MotionEvent up = MotionEventBuilder.newBuilder()
                .setAction(MotionEvent.ACTION_UP).build();

        mODICaptionsIcon.onTouchEvent(down);
        mODICaptionsIcon.onTouchEvent(up);
        mTestableLooper.moveTimeForward(300); // to confirm it was only a single tap
        mTestableLooper.processAllMessages();

        boolean foundCaptionLog = false;
        for (UiEventLoggerFake.FakeUiEvent event : logger.getLogs()) {
            if (event.eventId
                    == Events.VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_CLICKED.getId()) {
                foundCaptionLog = true;
                break;
            }
        }
        Assert.assertTrue("Did not log the captions button click.", foundCaptionLog);
    }

    /**
     * Pressing the small x button at top right dismisses the captions tooltip.
     */
    @Test
    public void dismissCaptionsTooltip_logsUiEvent() {
        UiEventLoggerFake logger = new UiEventLoggerFake();
        Events.sUiEventLogger = logger;
        mDialog.showCaptionsTooltip();
        assumeNotNull(mDialog.mODICaptionsTooltipView);
        View dismissButton = mDialog.mODICaptionsTooltipView.findViewById(R.id.dismiss);

        dismissButton.performClick();

        boolean foundCaptionLog = false;
        for (UiEventLoggerFake.FakeUiEvent event : logger.getLogs()) {
            if (event.eventId
                    == Events.VolumeDialogEvent.VOLUME_DIALOG_ODI_CAPTIONS_TOOLTIP_CLICKED.getId()
            ) {
                foundCaptionLog = true;
                break;
            }
        }
        Assert.assertTrue("Did not log the captions tooltip dismiss button click.",
                foundCaptionLog);
    }

    @After
    public void teardown() {
        // Detailed logs to track down timeout issues in b/299491332