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

Commit 4aa15eb2 authored by Roy Chou's avatar Roy Chou
Browse files

cleanup(magnification): remove...

cleanup(magnification): remove only_reset_magnification_if_needed_when_destroy_handler flag usage and definition

Bug: 437282459
Flag: EXEMPT flag cleanup
Test: build pass
      atest AccessibilityInputFilterTest
Change-Id: Ia6f00b91cce80405bf1bd3b2b1e7407ed798ef99
parent 57f25dbf
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -930,16 +930,11 @@ public class AccessibilityInputFilter extends InputFilter implements EventStream

        final MagnificationGestureHandler handler = mMagnificationGestureHandler.get(displayId);
        if (handler != null) {
            if (Flags.onlyResetMagnificationIfNeededWhenDestroyHandler()) {
            // With the given enabledFeatures parameter if the magnification feature is still
            // enabled, which means after the disabling there is a recreating coming, so the
            // magnification reset is not needed.
            handler.onDestroy(
                    /* resetMagnification= */ !isAnyMagnificationEnabled(featuresToBeEnabled));
            } else {
                // The old behavior is always resetting the magnification when destroying handler
                handler.onDestroy(/* resetMagnification= */ true);
            }
            mMagnificationGestureHandler.remove(displayId);
        }

+1 −24
Original line number Diff line number Diff line
@@ -27,14 +27,13 @@ import static com.android.server.accessibility.AccessibilityInputFilter.FLAG_FEA
import static com.android.server.accessibility.AccessibilityInputFilter.FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP;
import static com.android.server.accessibility.AccessibilityInputFilter.FLAG_FEATURE_TOUCH_EXPLORATION;
import static com.android.server.accessibility.AccessibilityInputFilter.FLAG_FEATURE_TRIGGERED_SCREEN_MAGNIFIER;
import static com.android.server.accessibility.Flags.FLAG_ONLY_RESET_MAGNIFICATION_IF_NEEDED_WHEN_DESTROY_HANDLER;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.ArgumentMatchers.notNull;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -51,7 +50,6 @@ import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Looper;
import android.os.SystemClock;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
@@ -410,26 +408,6 @@ public class AccessibilityInputFilterTest {
    }

    @Test
    @RequiresFlagsDisabled(FLAG_ONLY_RESET_MAGNIFICATION_IF_NEEDED_WHEN_DESTROY_HANDLER)
    public void testEnabledFeaturesChanged_magFeatureKeepsEnabled_flagOff_resetMagnification() {
        prepareLooper();
        doReturn(Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN)
                .when(mAms).getMagnificationMode(DEFAULT_DISPLAY);
        // Create FullScreenMagnificationGestureHandler
        mA11yInputFilter.setUserAndEnabledFeatures(0, mFeatures);

        MagnificationGestureHandler handler = mock(MagnificationGestureHandler.class);
        mMagnificationGestureHandler.put(DEFAULT_DISPLAY, handler);
        // Any feature changes causes the AccessibilityInputFilter to destroy the gesture handler
        // and recreate new one. The destroying of gesture handler causes the magnification reset
        mA11yInputFilter.setUserAndEnabledFeatures(0,
                mFeatures | FLAG_FEATURE_MAGNIFICATION_SINGLE_FINGER_TRIPLE_TAP);

        verify(handler).onDestroy(/* resetMagnification= */ eq(true));
    }

    @Test
    @RequiresFlagsEnabled(FLAG_ONLY_RESET_MAGNIFICATION_IF_NEEDED_WHEN_DESTROY_HANDLER)
    public void testEnabledFeaturesChanged_magFeatureKeepsEnabled_flagOn_doNotResetMagnification() {
        prepareLooper();
        doReturn(Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN)
@@ -449,7 +427,6 @@ public class AccessibilityInputFilterTest {
    }

    @Test
    @RequiresFlagsEnabled(FLAG_ONLY_RESET_MAGNIFICATION_IF_NEEDED_WHEN_DESTROY_HANDLER)
    public void testDisablingMagFeatures_magFeatureWasEnabled_flagOn_resetMagnification() {
        prepareLooper();
        doReturn(Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN)