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

Commit 4dc4b842 authored by Tyler Freeman's avatar Tyler Freeman
Browse files

chore(magnification settings): add logWithPosition() to log things like which...

chore(magnification settings): add logWithPosition() to log things like which magnification size was tapped.

Also from which magnifier the log panel opens (fullscreen or window).

Bug: 281241589
Test: atest frameworks/base/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationTest.java
  && aster-previz

Change-Id: I3d55c2c10507c5d6996d5744dc4339fabc54e29c
parent 4feabf9c
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.accessibility

import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import com.android.internal.logging.UiEventLogger.UiEventEnum
import javax.inject.Inject

/**
@@ -27,14 +28,28 @@ import javax.inject.Inject
 */
class AccessibilityLogger @Inject constructor(private val uiEventLogger: UiEventLogger) {
    /** Logs the given event */
    fun log(event: UiEventLogger.UiEventEnum) {
    fun log(event: UiEventEnum) {
        uiEventLogger.log(event)
    }

    /**
     * Logs the given event with an integer rank/position value.
     *
     * @param event the event to log
     * @param position the rank or position value that the user interacted with in the UI
     */
    fun logWithPosition(event: UiEventEnum, position: Int) {
        uiEventLogger.logWithPosition(event, /* uid= */ 0, /* packageName= */ null, position)
    }

    /** Events regarding interaction with the magnifier settings panel */
    enum class MagnificationSettingsEvent constructor(private val id: Int) :
        UiEventLogger.UiEventEnum {
        @UiEvent(doc = "Magnification settings panel opened.")
        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")
@@ -46,7 +61,11 @@ class AccessibilityLogger @Inject constructor(private val uiEventLogger: UiEvent
        @UiEvent(doc = "Magnification settings panel edit size save button clicked")
        MAGNIFICATION_SETTINGS_SIZE_EDITING_DEACTIVATED(1384),

        @UiEvent(doc = "Magnification settings panel window size selected")
        @UiEvent(
            doc =
                "Magnification settings panel window size selected. The selection rank is " +
                    "which size was selected."
        )
        MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED(1386);

        override fun getId(): Int = this.id
+21 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.accessibility;

import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN;
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;

@@ -346,7 +347,10 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
        @Override
        public void onSetMagnifierSize(int displayId, int index) {
            mHandler.post(() -> onSetMagnifierSizeInternal(displayId, index));
            mA11yLogger.log(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED);
            mA11yLogger.logWithPosition(
                    MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED,
                    index
            );
        }

        @Override
@@ -377,9 +381,6 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
        @Override
        public void onSettingsPanelVisibilityChanged(int displayId, boolean shown) {
            mHandler.post(() -> onSettingsPanelVisibilityChangedInternal(displayId, shown));
            mA11yLogger.log(shown
                    ? MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_OPENED
                    : MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_CLOSED);
        }
    };

@@ -433,9 +434,23 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
    private void onSettingsPanelVisibilityChangedInternal(int displayId, boolean shown) {
        final WindowMagnificationController windowMagnificationController =
                mMagnificationControllerSupplier.get(displayId);
        if (windowMagnificationController != null && windowMagnificationController.isActivated()) {
        if (windowMagnificationController != null) {
            boolean isWindowMagnifierActivated = windowMagnificationController.isActivated();
            if (isWindowMagnifierActivated) {
                windowMagnificationController.updateDragHandleResourcesIfNeeded(shown);
            }

            if (shown) {
                mA11yLogger.logWithPosition(
                        MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_OPENED,
                        isWindowMagnifierActivated
                                ? ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW
                                : ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN
                );
            } else {
                mA11yLogger.log(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_CLOSED);
            }
        }
    }

    @Override
+10 −4
Original line number Diff line number Diff line
@@ -117,6 +117,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
            return null;
        }).when(mMagnificationSettingsController).closeMagnificationSettings();

        when(mWindowMagnificationController.isActivated()).thenReturn(true);

        mCommandQueue = new CommandQueue(getContext(), mDisplayTracker);
        mWindowMagnification = new WindowMagnification(getContext(),
                getContext().getMainThreadHandler(), mCommandQueue, mModeSwitchesController,
@@ -199,8 +201,10 @@ public class WindowMagnificationTest extends SysuiTestCase {
        waitForIdleSync();

        verify(mMagnificationSettingsController).toggleSettingsPanelVisibility();
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_OPENED));
        verify(mA11yLogger).logWithPosition(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_OPENED),
                eq(ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW)
        );
    }

    @Test
@@ -211,8 +215,10 @@ public class WindowMagnificationTest extends SysuiTestCase {
        waitForIdleSync();

        verify(mWindowMagnificationController).changeMagnificationSize(eq(index));
        verify(mA11yLogger).log(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED));
        verify(mA11yLogger).logWithPosition(
                eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED),
                eq(index)
        );
    }

    @Test