Merge "Updates magnification button when the magnification activation state is changed"

This commit is contained in:
Minche Li
2021-09-29 09:23:42 +00:00
committed by Android (Google) Code Review
10 changed files with 31 additions and 115 deletions

View File

@@ -353,7 +353,7 @@ public class FullScreenMagnificationController {
mMagnificationActivated = spec.scale > 1.0f;
if (mMagnificationActivated != lastMagnificationActivated) {
mMagnificationInfoChangedCallback.onFullScreenMagnificationActivationState(
mMagnificationActivated);
mDisplayId, mMagnificationActivated);
}
}
@@ -1614,9 +1614,10 @@ public class FullScreenMagnificationController {
* Called when the state of the magnification activation is changed.
* It is for the logging data of the magnification activation state.
*
* @param displayId The logical display id.
* @param activated {@code true} if the magnification is activated, otherwise {@code false}.
*/
void onFullScreenMagnificationActivationState(boolean activated);
void onFullScreenMagnificationActivationState(int displayId, boolean activated);
/**
* Called when the IME window visibility changed.

View File

@@ -869,8 +869,6 @@ public class FullScreenMagnificationGestureHandler extends MagnificationGestureH
mPromptController.showNotificationIfNeeded();
zoomOn(up.getX(), up.getY());
}
mCallback.onTripleTapped(mDisplayId, getMode());
}
private boolean isMagnifying() {

View File

@@ -48,11 +48,12 @@ import com.android.server.accessibility.AccessibilityManagerService;
* the user touch interaction starts if magnification capabilities is all. </li>
* <li> 2. {@link #onTouchInteractionEnd} shows magnification switch UI when
* the user touch interaction ends if magnification capabilities is all. </li>
* <li> 3. {@link #onShortcutTriggered} updates magnification switch UI depending on
* magnification capabilities and magnification active state when magnification shortcut
* is triggered.</li>
* <li> 4. {@link #onTripleTapped} updates magnification switch UI depending on magnification
* capabilities and magnification active state when triple-tap gesture is detected. </li>
* <li> 3. {@link #onWindowMagnificationActivationState} updates magnification switch UI
* depending on magnification capabilities and magnification active state when window
* magnification activation state change.</li>
* <li> 4. {@link #onFullScreenMagnificationActivationState} updates magnification switch UI
* depending on magnification capabilities and magnification active state when fullscreen
* magnification activation state change.</li>
* <li> 4. {@link #onRequestMagnificationSpec} updates magnification switch UI depending on
* magnification capabilities and magnification active state when new magnification spec is
* changed by external request from calling public APIs. </li>
@@ -142,16 +143,6 @@ public class MagnificationController implements WindowMagnificationManager.Callb
}
}
@Override
public void onShortcutTriggered(int displayId, int mode) {
updateMagnificationButton(displayId, mode);
}
@Override
public void onTripleTapped(int displayId, int mode) {
updateMagnificationButton(displayId, mode);
}
private void updateMagnificationButton(int displayId, int mode) {
final boolean isActivated = isActivated(displayId, mode);
final boolean showButton;
@@ -250,6 +241,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
mActivatedMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE;
}
}
updateMagnificationButton(displayId, ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW);
}
private void disableFullScreenMagnificationIfNeeded(int displayId) {
@@ -264,7 +256,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
}
@Override
public void onFullScreenMagnificationActivationState(boolean activated) {
public void onFullScreenMagnificationActivationState(int displayId, boolean activated) {
if (activated) {
mFullScreenModeEnabledTime = SystemClock.uptimeMillis();
@@ -280,6 +272,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
mActivatedMode = ACCESSIBILITY_MAGNIFICATION_MODE_NONE;
}
}
updateMagnificationButton(displayId, ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
}
@Override

View File

@@ -80,25 +80,6 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
* @param mode The magnification mode
*/
void onTouchInteractionEnd(int displayId, int mode);
/**
* Called when the magnification shortcut is triggered by a user. The magnification
* shortcut can be accessibility button or volume shortcut.
*
* @param displayId The logical display id
* @param mode The magnification mode
*/
void onShortcutTriggered(int displayId, int mode);
/**
* Called when the triple-tap gesture is handled. The magnification
* shortcut can be a triple-tap gesture or accessibility button.
* Called when the triple-tap gesture is handled
*
* @param displayId The logical display id
* @param mode The magnification mode
*/
void onTripleTapped(int displayId, int mode);
}
private final AccessibilityTraceManager mTrace;
@@ -192,7 +173,6 @@ public abstract class MagnificationGestureHandler extends BaseEventStreamTransfo
}
if (mDetectShortcutTrigger) {
handleShortcutTriggered();
mCallback.onShortcutTriggered(mDisplayId, getMode());
}
}

View File

@@ -202,7 +202,6 @@ public class WindowMagnificationGestureHandler extends MagnificationGestureHandl
Slog.i(mLogTag, "onTripleTap()");
}
toggleMagnification(up.getX(), up.getY());
mCallback.onTripleTapped(mDisplayId, getMode());
}
void resetToDetectState() {

View File

@@ -1138,7 +1138,7 @@ public class FullScreenMagnificationControllerTest {
public void testSetScale_toMagnifying_shouldNotifyActivatedState() {
setScaleToMagnifying();
verify(mRequestObserver).onFullScreenMagnificationActivationState(eq(true));
verify(mRequestObserver).onFullScreenMagnificationActivationState(eq(DISPLAY_0), eq(true));
}
@Test
@@ -1146,7 +1146,7 @@ public class FullScreenMagnificationControllerTest {
setScaleToMagnifying();
mFullScreenMagnificationController.reset(DISPLAY_0, mAnimationCallback);
verify(mRequestObserver).onFullScreenMagnificationActivationState(eq(false));
verify(mRequestObserver).onFullScreenMagnificationActivationState(eq(DISPLAY_0), eq(false));
}
@Test

View File

@@ -42,7 +42,6 @@ import android.content.Context;
import android.graphics.PointF;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.util.DebugUtils;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -458,14 +457,6 @@ public class FullScreenMagnificationGestureHandlerTest {
verify(mWindowMagnificationPromptController).showNotificationIfNeeded();
}
@Test
public void testZoomedWithTripleTap_callsOnTripleTapped() {
goFromStateIdleTo(STATE_ZOOMED_2TAPS);
verify(mMockCallback).onTripleTapped(DISPLAY_0,
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN);
}
private void assertActionsInOrder(List<MotionEvent> actualEvents,
List<Integer> expectedActions) {
assertTrue(actualEvents.size() == expectedActions.size());

View File

@@ -380,9 +380,9 @@ public class MagnificationControllerTest {
@Test
public void
onFullScreenMagnificationActivationState_fullScreenActivated_logFullScreenDuration() {
mMagnificationController.onFullScreenMagnificationActivationState(true);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, true);
mMagnificationController.onFullScreenMagnificationActivationState(false);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, false);
verify(mMagnificationController).logMagnificationUsageState(
eq(ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN), anyLong());
@@ -460,75 +460,47 @@ public class MagnificationControllerTest {
}
@Test
public void onShortcutTriggered_windowModeEnabledAndCapabilitiesAll_showMagnificationButton()
public void onWindowActivated_windowModeEnabledAndCapabilitiesAll_showMagnificationButton()
throws RemoteException {
setMagnificationEnabled(MODE_WINDOW);
mMagnificationController.onShortcutTriggered(TEST_DISPLAY, MODE_WINDOW);
mMagnificationController.onWindowMagnificationActivationState(TEST_DISPLAY, true);
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
eq(MODE_WINDOW));
}
@Test
public void onShortcutTriggered_fullscreenEnabledAndCapabilitiesAll_showMagnificationButton()
public void onFullScreenActivated_fullscreenEnabledAndCapabilitiesAll_showMagnificationButton()
throws RemoteException {
setMagnificationEnabled(MODE_FULLSCREEN);
mMagnificationController.onShortcutTriggered(TEST_DISPLAY, MODE_FULLSCREEN);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, true);
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
eq(MODE_FULLSCREEN));
}
@Test
public void triggerShortcutToShowMagnificationBound_fullscreenMode_showMagnificationButton() {
setMagnificationModeSettings(MODE_FULLSCREEN);
when(mScreenMagnificationController.isForceShowMagnifiableBounds(TEST_DISPLAY)).thenReturn(
true);
mMagnificationController.onShortcutTriggered(TEST_DISPLAY, MODE_FULLSCREEN);
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
eq(MODE_FULLSCREEN));
}
@Test
public void onShortcutTriggered_windowModeDisabled_removeMagnificationButton()
public void onWindowDeactivated_windowModeInactive_removeMagnificationButton()
throws RemoteException {
setMagnificationEnabled(MODE_WINDOW);
mWindowMagnificationManager.disableWindowMagnification(TEST_DISPLAY, false);
mMagnificationController.onShortcutTriggered(TEST_DISPLAY, MODE_WINDOW);
mMagnificationController.onWindowMagnificationActivationState(TEST_DISPLAY, false);
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
}
@Test
public void onTripleTap_windowModeEnabledAndCapabilitiesAll_showMagnificationButton()
throws RemoteException {
setMagnificationEnabled(MODE_WINDOW);
mMagnificationController.onTripleTapped(TEST_DISPLAY, MODE_WINDOW);
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
eq(MODE_WINDOW));
}
@Test
public void onTripleTap_fullscreenEnabledAndCapabilitiesAll_showMagnificationButton()
public void onFullScreenDeactivated_fullscreenModeInactive_removeMagnificationButton()
throws RemoteException {
setMagnificationEnabled(MODE_FULLSCREEN);
mScreenMagnificationController.setScaleAndCenter(TEST_DISPLAY,
/* scale= */1, MAGNIFIED_CENTER_X, MAGNIFIED_CENTER_Y,
true, TEST_SERVICE_ID);
mMagnificationController.onTripleTapped(TEST_DISPLAY, MODE_FULLSCREEN);
verify(mWindowMagnificationManager).showMagnificationButton(eq(TEST_DISPLAY),
eq(MODE_FULLSCREEN));
}
@Test
public void onTripleTap_windowModeDisabled_removeMagnificationButton()
throws RemoteException {
mMagnificationController.onTripleTapped(TEST_DISPLAY, MODE_WINDOW);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, false);
verify(mWindowMagnificationManager).removeMagnificationButton(eq(TEST_DISPLAY));
}
@@ -574,7 +546,7 @@ public class MagnificationControllerTest {
@Test
public void imeWindowStateShown_fullScreenMagnifying_logFullScreenMode() {
mMagnificationController.onFullScreenMagnificationActivationState(true);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, true);
mMagnificationController.onImeWindowVisibilityChanged(true);
@@ -591,7 +563,7 @@ public class MagnificationControllerTest {
@Test
public void imeWindowStateHidden_windowMagnifying_noLogAnyMode() {
mMagnificationController.onFullScreenMagnificationActivationState(true);
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, true);
verify(mMagnificationController, never()).logMagnificationModeWithIme(anyInt());
}

View File

@@ -121,14 +121,6 @@ public class MagnificationGestureHandlerTest {
}
}
@Test
public void notifyShortcutTriggered_callsOnShortcutTriggered() {
mMgh.notifyShortcutTriggered();
verify(mCallback).onShortcutTriggered(eq(DISPLAY_0), eq(mMgh.getMode()));
}
private static class TestMagnificationGestureHandler extends MagnificationGestureHandler {
boolean mIsInternalMethodCalled = false;

View File

@@ -19,9 +19,7 @@ package com.android.server.accessibility.magnification;
import static com.android.server.testutils.TestUtils.strictMock;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import android.content.Context;
import android.graphics.PointF;
@@ -150,14 +148,6 @@ public class WindowMagnificationGestureHandlerTest {
});
}
@Test
public void onTripleTap_callsOnTripleTapped() {
goFromStateIdleTo(STATE_SHOW_MAGNIFIER_TRIPLE_TAP);
verify(mMockCallback).onTripleTapped(eq(DISPLAY_0),
eq(mWindowMagnificationGestureHandler.getMode()));
}
private void forEachState(IntConsumer action) {
for (int state = FIRST_STATE; state <= LAST_STATE; state++) {
action.accept(state);