diff options
| author | 2023-06-09 14:59:43 +0000 | |
|---|---|---|
| committer | 2023-07-24 06:59:08 +0000 | |
| commit | 84c898de460812dde80f1954e7ddff37c2b7a3ee (patch) | |
| tree | 85bdbe7d498b39fdd7afacec765811d87ef2250d | |
| parent | eb9df37e70c0fb4d1ffa7105baed3efb8ac11566 (diff) | |
fix(#WindowMagnification): adjust Settings getter def to true for key ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING
As b/279397954, the allow diagonal scrolling default should be true by default. Therefore, we adjust the Settings getter to return true if Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING value is UN_ASSIGNED.
Bug: 279397954
Test: manually
atest WindowMagnificationControllerTest
atest WindowMagnificationSettingsTest
Change-Id: I244903a3fbf11a73998f440941b82c57f8ac4ef3
4 files changed, 48 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java index 602f817f826b..6c8f8f39646e 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationController.java @@ -262,6 +262,9 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, mResources.getInteger(R.integer.magnification_default_scale), UserHandle.USER_CURRENT); + mAllowDiagonalScrolling = secureSettings.getIntForUser( + Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, 1, + UserHandle.USER_CURRENT) == 1; setupMagnificationSizeScaleOptions(); @@ -1225,6 +1228,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold return isActivated() ? mMagnificationFrame.exactCenterY() : Float.NaN; } + + @VisibleForTesting + boolean isDiagonalScrollingEnabled() { + return mAllowDiagonalScrolling; + } + private CharSequence formatStateDescription(float scale) { // Cache the locale-appropriate NumberFormat. Configuration locale is guaranteed // non-null, so the first time this is called we will always get the appropriate diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java index bb29d52cf160..7c11311373ab 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java @@ -101,7 +101,9 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private Button mEditButton; private ImageButton mFullScreenButton; private int mLastSelectedButtonIndex = MagnificationSize.NONE; + private boolean mAllowDiagonalScrolling = false; + /** * Amount by which magnification scale changes compared to seekbar in settings. * magnitude = 10 means, for every 1 scale increase, 10 progress increase in seekbar. @@ -141,7 +143,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest mSecureSettings = secureSettings; mAllowDiagonalScrolling = mSecureSettings.getIntForUser( - Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, 0, + Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, 1, UserHandle.USER_CURRENT) == 1; mParams = createLayoutParams(context); @@ -420,6 +422,11 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest UserHandle.USER_CURRENT); } + @VisibleForTesting + boolean isDiagonalScrollingEnabled() { + return mAllowDiagonalScrolling; + } + /** * Only called from outside to notify the controlling magnifier scale changed * @@ -632,7 +639,7 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest private void toggleDiagonalScrolling() { boolean enabled = mSecureSettings.getIntForUser( - Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, 0, + Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING, 1, UserHandle.USER_CURRENT) == 1; setDiagonalScrolling(!enabled); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java index 56f81606a282..36cdfe642874 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -66,6 +66,7 @@ import android.graphics.RegionIterator; import android.os.Handler; import android.os.RemoteException; import android.os.SystemClock; +import android.provider.Settings; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.testing.TestableResources; @@ -224,6 +225,14 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { } @Test + public void initWindowMagnificationController_checkAllowDiagonalScrollingWithSecureSettings() { + verify(mSecureSettings).getIntForUser( + eq(Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING), + /* def */ eq(1), /* userHandle= */ anyInt()); + assertTrue(mWindowMagnificationController.isDiagonalScrollingEnabled()); + } + + @Test public void enableWindowMagnification_showControlAndNotifyBoundsChanged() { mInstrumentation.runOnMainSync(() -> { mWindowMagnificationController.enableWindowMagnificationInternal(Float.NaN, Float.NaN, diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java index eddb8d186d73..91c47480ae45 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationSettingsTest.java @@ -26,10 +26,12 @@ import static com.google.common.truth.Truth.assertThat; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; +import static org.mockito.AdditionalAnswers.returnsSecondArg; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; @@ -109,6 +111,11 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { mContext.addMockSystemService(Context.WINDOW_SERVICE, mWindowManager); mContext.addMockSystemService(Context.ACCESSIBILITY_SERVICE, mAccessibilityManager); + when(mSecureSettings.getIntForUser(anyString(), anyInt(), anyInt())).then( + returnsSecondArg()); + when(mSecureSettings.getFloatForUser(anyString(), anyFloat(), anyInt())).then( + returnsSecondArg()); + mWindowMagnificationSettings = new WindowMagnificationSettings(mContext, mWindowMagnificationSettingsCallback, mSfVsyncFrameProvider, mSecureSettings); @@ -128,6 +135,14 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { } @Test + public void initSettingPanel_checkAllowDiagonalScrollingWithSecureSettings() { + verify(mSecureSettings).getIntForUser( + eq(Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING), + /* def */ eq(1), /* userHandle= */ anyInt()); + assertThat(mWindowMagnificationSettings.isDiagonalScrollingEnabled()).isTrue(); + } + + @Test public void showSettingPanel_hasAccessibilityWindowTitle() { setupMagnificationCapabilityAndMode( /* capability= */ ACCESSIBILITY_MAGNIFICATION_MODE_WINDOW, @@ -273,7 +288,12 @@ public class WindowMagnificationSettingsTest extends SysuiTestCase { // Perform click diagonalScrollingSwitch.performClick(); - verify(mWindowMagnificationSettingsCallback).onSetDiagonalScrolling(!currentCheckedState); + final boolean isAllowed = !currentCheckedState; + verify(mSecureSettings).putIntForUser( + eq(Settings.Secure.ACCESSIBILITY_ALLOW_DIAGONAL_SCROLLING), + /* value= */ eq(isAllowed ? 1 : 0), + /* userHandle= */ anyInt()); + verify(mWindowMagnificationSettingsCallback).onSetDiagonalScrolling(isAllowed); } @Test |