From 0c1c87797e039df1972e3b63e68f50b72d9b416a Mon Sep 17 00:00:00 2001 From: Roy Chou Date: Sat, 4 Feb 2023 17:32:46 +0000 Subject: [PATCH] fix(#AlwaysOnMagnifier): Fix testSetConfigWithActivatedFalse_expectedConfig fails If setMagnificationConfig is called when WindowMagnificationSettings instance does not exist, the settings instance will be created. The WindowMagnificationSettings constructor would set up the scale seek bar progress with user persisted scale, and thus the seek bar would trigger the progress updated callback. When callback is triggered, the window magnifier scale would be set to seek bar scale, which may not be the same as the config target scale. Therefore, the result might not be correct. Therefore, in WindowMagnificationSettings, we modify the setup order to make the seek bar progress setup before the seek bar callback setup. It prevents the progress setup from triggering callback and thus changing the window magnifier scale. Bug: 267691832 Test: atest WindowMagnificationSettingsTest atest AccessibilityMagnificationTest treehugger presubmit Change-Id: I519d2b7be6691715a49ec6d368f9f103f8681359 --- .../systemui/accessibility/WindowMagnificationSettings.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java index b342a29640aa9..15264e64a241f 100644 --- a/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java +++ b/packages/SystemUI/src/com/android/systemui/accessibility/WindowMagnificationSettings.java @@ -398,13 +398,12 @@ class WindowMagnificationSettings implements MagnificationGestureDetector.OnGest mChangeModeButton = mSettingView.findViewById(R.id.magnifier_full_button); mZoomSeekbar = mSettingView.findViewById(R.id.magnifier_zoom_slider); - - mZoomSeekbar.setOnSeekBarChangeListener(new ZoomSeekbarChangeListener()); - float scale = mSecureSettings.getFloatForUser( Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_SCALE, 0, UserHandle.USER_CURRENT); setSeekbarProgress(scale); + mZoomSeekbar.setOnSeekBarChangeListener(new ZoomSeekbarChangeListener()); + mAllowDiagonalScrollingSwitch = (Switch) mSettingView.findViewById(R.id.magnifier_horizontal_lock_switch); mAllowDiagonalScrollingSwitch.setChecked(mAllowDiagonalScrolling);