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
This commit is contained in:
Roy Chou
2023-02-04 17:32:46 +00:00
parent 3ba579514a
commit 0c1c87797e

View File

@@ -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);