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

Commit 70f92c49 authored by Jean Chen's avatar Jean Chen Committed by Android (Google) Code Review
Browse files

Merge "feat(magnify_ime): Add magnify ime and magnify typing changed logs" into main

parents 22463fde 8a06a985
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -44,7 +44,8 @@ constructor(private val uiEventLogger: UiEventLogger, private val clock: SystemC
     * one is forgotten. e.g. if you send two types of events interlaced all within the delay
     * window, e.g. A->B->A within 1000ms, all three will be logged.
     */
    @JvmOverloads fun logThrottled(event: UiEventEnum, delayBeforeLoggingMs: Int = 2000) {
    @JvmOverloads
    fun logThrottled(event: UiEventEnum, delayBeforeLoggingMs: Int = 2000) {
        synchronized(clock) {
            val currentTimeMs = clock.elapsedRealtime()
            val shouldThrottle =
@@ -75,33 +76,35 @@ constructor(private val uiEventLogger: UiEventLogger, private val clock: SystemC
    }

    /** Events regarding interaction with the magnifier settings panel */
    enum class MagnificationSettingsEvent constructor(private val id: Int) :
        UiEventEnum {
    enum class MagnificationSettingsEvent constructor(private val id: Int) : UiEventEnum {
        @UiEvent(
            doc =
                "Magnification settings panel opened. The selection rank is from which " +
                    "magnifier mode it was opened (fullscreen or window)"
        )
        MAGNIFICATION_SETTINGS_PANEL_OPENED(1381),

        @UiEvent(doc = "Magnification settings panel closed")
        MAGNIFICATION_SETTINGS_PANEL_CLOSED(1382),

        @UiEvent(doc = "Magnification settings panel edit size button clicked")
        MAGNIFICATION_SETTINGS_SIZE_EDITING_ACTIVATED(1383),

        @UiEvent(doc = "Magnification settings panel edit size save button clicked")
        MAGNIFICATION_SETTINGS_SIZE_EDITING_DEACTIVATED(1384),

        @UiEvent(doc = "Magnification settings panel zoom slider changed")
        MAGNIFICATION_SETTINGS_ZOOM_SLIDER_CHANGED(1385),

        @UiEvent(
            doc =
                "Magnification settings panel window size selected. The selection rank is " +
                    "which size was selected."
        )
        MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED(1386);
        MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED(1386),
        @UiEvent(doc = "Magnification settings panel magnify ime preference enabled")
        MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_ENABLED(2321),
        @UiEvent(doc = "Magnification settings panel magnify ime preference disabled")
        MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_DISABLED(2322),
        @UiEvent(doc = "Magnification settings panel magnify typing preference enabled")
        MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_ENABLED(2323),
        @UiEvent(doc = "Magnification settings panel magnify typing preference disabled")
        MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_DISABLED(2324);

        override fun getId(): Int = this.id
    }
+10 −0
Original line number Diff line number Diff line
@@ -534,11 +534,21 @@ public class MagnificationImpl implements Magnification, CommandQueue.Callbacks
                @Override
                public void onSetMagnifyTyping(int displayId, boolean enable) {
                    mHandler.post(() -> onSetMagnifyTypingInternal(displayId, enable));
                    mA11yLogger.log(enable
                            ? MagnificationSettingsEvent
                                    .MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_ENABLED
                            : MagnificationSettingsEvent
                                    .MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_DISABLED);
                }

                @Override
                public void onSetMagnifyKeyboard(int displayId, boolean enable) {
                    mHandler.post(() -> onSetMagnifyKeyboardInternal(displayId, enable));
                    mA11yLogger.log(enable
                            ? MagnificationSettingsEvent
                                    .MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_ENABLED
                            : MagnificationSettingsEvent
                                    .MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_DISABLED);
                }

                @Override
+38 −0
Original line number Diff line number Diff line
@@ -251,6 +251,44 @@ public class MagnificationTest extends SysuiTestCase {
        verify(mWindowMagnificationController).setDiagonalScrolling(eq(true));
    }

    @Test
    public void onSetMagnifyKeyboard_delegateToMagnifier() {
        mMagnification.mMagnificationSettingsControllerCallback.onSetMagnifyKeyboard(
                TEST_DISPLAY, /* enable= */ true);
        waitForIdleSync();

        verify(mWindowMagnificationController).setMagnifyKeyboard(eq(true));
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_ENABLED));

        mMagnification.mMagnificationSettingsControllerCallback.onSetMagnifyKeyboard(
                TEST_DISPLAY, /* enable= */ false);
        waitForIdleSync();
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_ENABLED));
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_MAGNIFY_IME_DISABLED));
    }

    @Test
    public void onSetMagnifyTyping_delegateToMagnifier() {
        mMagnification.mMagnificationSettingsControllerCallback.onSetMagnifyTyping(
                TEST_DISPLAY, /* enable= */ true);
        waitForIdleSync();

        verify(mWindowMagnificationController).setMagnifyTyping(eq(true));
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_ENABLED));

        mMagnification.mMagnificationSettingsControllerCallback.onSetMagnifyTyping(
                TEST_DISPLAY, /* enable= */ false);
        waitForIdleSync();
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_ENABLED));
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_FOLLOW_TYPING_DISABLED));
    }

    @Test
    public void onEditMagnifierSizeMode_windowActivated_delegateToMagnifier() {
        when(mWindowMagnificationController.isActivated()).thenReturn(true);