Merge "chore(magnification settings): add logging for settings panel ui interactions" into udc-dev

This commit is contained in:
Tyler Freeman
2023-05-13 18:03:50 +00:00
committed by Android (Google) Code Review
4 changed files with 101 additions and 3 deletions

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.accessibility
import com.android.internal.logging.UiEvent
import com.android.internal.logging.UiEventLogger
import javax.inject.Inject
/**
* Handles logging UiEvent stats for simple UI interactions.
*
* See go/uievent
*/
class AccessibilityLogger @Inject constructor(private val uiEventLogger: UiEventLogger) {
/** Logs the given event */
fun log(event: UiEventLogger.UiEventEnum) {
uiEventLogger.log(event)
}
/** Events regarding interaction with the magnifier settings panel */
enum class MagnificationSettingsEvent constructor(private val id: Int) :
UiEventLogger.UiEventEnum {
@UiEvent(doc = "Magnification settings panel opened.")
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 window size selected")
MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED(1386);
override fun getId(): Int = this.id
}
}

View File

@@ -19,6 +19,7 @@ package com.android.systemui.accessibility;
import static android.provider.Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW;
import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
import static com.android.systemui.accessibility.AccessibilityLogger.MagnificationSettingsEvent;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
import android.annotation.MainThread;
@@ -66,6 +67,7 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
private final CommandQueue mCommandQueue;
private final OverviewProxyService mOverviewProxyService;
private final DisplayTracker mDisplayTracker;
private final AccessibilityLogger mA11yLogger;
private WindowMagnificationConnectionImpl mWindowMagnificationConnectionImpl;
private SysUiState mSysUiState;
@@ -151,7 +153,7 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
CommandQueue commandQueue, ModeSwitchesController modeSwitchesController,
SysUiState sysUiState, OverviewProxyService overviewProxyService,
SecureSettings secureSettings, DisplayTracker displayTracker,
DisplayManager displayManager) {
DisplayManager displayManager, AccessibilityLogger a11yLogger) {
mContext = context;
mHandler = mainHandler;
mAccessibilityManager = mContext.getSystemService(AccessibilityManager.class);
@@ -160,6 +162,7 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
mSysUiState = sysUiState;
mOverviewProxyService = overviewProxyService;
mDisplayTracker = displayTracker;
mA11yLogger = a11yLogger;
mMagnificationControllerSupplier = new ControllerSupplier(context,
mHandler, mWindowMagnifierCallback,
displayManager, sysUiState, secureSettings);
@@ -343,6 +346,7 @@ 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);
}
@Override
@@ -353,6 +357,9 @@ public class WindowMagnification implements CoreStartable, CommandQueue.Callback
@Override
public void onEditMagnifierSizeMode(int displayId, boolean enable) {
mHandler.post(() -> onEditMagnifierSizeModeInternal(displayId, enable));
mA11yLogger.log(enable
? MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_SIZE_EDITING_ACTIVATED
: MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_SIZE_EDITING_DEACTIVATED);
}
@Override
@@ -370,6 +377,9 @@ 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);
}
};

View File

@@ -80,6 +80,8 @@ public class IWindowMagnificationConnectionTest extends SysuiTestCase {
private OverviewProxyService mOverviewProxyService;
@Mock
private SecureSettings mSecureSettings;
@Mock
private AccessibilityLogger mA11yLogger;
private IWindowMagnificationConnection mIWindowMagnificationConnection;
private WindowMagnification mWindowMagnification;
@@ -97,7 +99,7 @@ public class IWindowMagnificationConnectionTest extends SysuiTestCase {
mWindowMagnification = new WindowMagnification(getContext(),
getContext().getMainThreadHandler(), mCommandQueue,
mModeSwitchesController, mSysUiState, mOverviewProxyService, mSecureSettings,
mDisplayTracker, getContext().getSystemService(DisplayManager.class));
mDisplayTracker, getContext().getSystemService(DisplayManager.class), mA11yLogger);
mWindowMagnification.mMagnificationControllerSupplier = new FakeControllerSupplier(
mContext.getSystemService(DisplayManager.class));
mWindowMagnification.mMagnificationSettingsSupplier = new FakeSettingsSupplier(

View File

@@ -19,6 +19,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 com.android.systemui.accessibility.AccessibilityLogger.MagnificationSettingsEvent;
import static com.android.systemui.accessibility.WindowMagnificationSettings.MagnificationSize;
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_MAGNIFICATION_OVERLAP;
@@ -89,6 +90,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
private WindowMagnificationController mWindowMagnificationController;
@Mock
private MagnificationSettingsController mMagnificationSettingsController;
@Mock
private AccessibilityLogger mA11yLogger;
@Before
public void setUp() throws Exception {
@@ -103,11 +106,22 @@ public class WindowMagnificationTest extends SysuiTestCase {
when(mSysUiState.setFlag(anyInt(), anyBoolean())).thenReturn(mSysUiState);
doAnswer(invocation -> {
mWindowMagnification.mMagnificationSettingsControllerCallback
.onSettingsPanelVisibilityChanged(TEST_DISPLAY, /* shown= */ true);
return null;
}).when(mMagnificationSettingsController).showMagnificationSettings();
doAnswer(invocation -> {
mWindowMagnification.mMagnificationSettingsControllerCallback
.onSettingsPanelVisibilityChanged(TEST_DISPLAY, /* shown= */ false);
return null;
}).when(mMagnificationSettingsController).closeMagnificationSettings();
mCommandQueue = new CommandQueue(getContext(), mDisplayTracker);
mWindowMagnification = new WindowMagnification(getContext(),
getContext().getMainThreadHandler(), mCommandQueue, mModeSwitchesController,
mSysUiState, mOverviewProxyService, mSecureSettings, mDisplayTracker,
getContext().getSystemService(DisplayManager.class));
getContext().getSystemService(DisplayManager.class), mA11yLogger);
mWindowMagnification.mMagnificationControllerSupplier = new FakeControllerSupplier(
mContext.getSystemService(DisplayManager.class), mWindowMagnificationController);
mWindowMagnification.mMagnificationSettingsSupplier = new FakeSettingsSupplier(
@@ -185,6 +199,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
waitForIdleSync();
verify(mMagnificationSettingsController).showMagnificationSettings();
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_OPENED));
}
@Test
@@ -195,6 +211,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
waitForIdleSync();
verify(mWindowMagnificationController).changeMagnificationSize(eq(index));
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_WINDOW_SIZE_SELECTED));
}
@Test
@@ -214,6 +232,16 @@ public class WindowMagnificationTest extends SysuiTestCase {
waitForIdleSync();
verify(mWindowMagnificationController).setEditMagnifierSizeMode(eq(true));
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_SIZE_EDITING_ACTIVATED));
mWindowMagnification.mMagnificationSettingsControllerCallback.onEditMagnifierSizeMode(
TEST_DISPLAY, /* enable= */ false);
waitForIdleSync();
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_SIZE_EDITING_ACTIVATED));
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_SIZE_EDITING_DEACTIVATED));
}
@Test
@@ -239,6 +267,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
waitForIdleSync();
verify(mMagnificationSettingsController).closeMagnificationSettings();
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_CLOSED));
verify(mConnectionCallback).onChangeMagnificationMode(eq(TEST_DISPLAY),
eq(ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN));
}
@@ -268,6 +298,8 @@ public class WindowMagnificationTest extends SysuiTestCase {
waitForIdleSync();
verify(mWindowMagnificationController).updateDragHandleResourcesIfNeeded(eq(shown));
verify(mA11yLogger).log(
eq(MagnificationSettingsEvent.MAGNIFICATION_SETTINGS_PANEL_CLOSED));
}
@Test