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

Commit d95d799d authored by menghanli's avatar menghanli
Browse files

Fix extra dim turns on failed in setting search bar

Root cause: Don't call displayPreference before setChecked called.
Solution: Don't show quick settings tooltips if preference is not ready.

Bug: 237850687
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest
Change-Id: I52425190cce4ab3cf31be025a743bf8b212fa1f9
parent 9450735e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -102,6 +102,11 @@ public abstract class AccessibilityQuickSettingsPrimarySwitchPreferenceControlle
    }

    private void showQuickSettingsTooltipIfNeeded() {
        if (mPreference == null) {
            // Returns if no preference found by slice highlight menu.
            return;
        }

        final ComponentName tileComponentName = getTileComponentName();
        if (tileComponentName == null) {
            // Returns if no tile service assigned.
+13 −1
Original line number Diff line number Diff line
@@ -118,18 +118,29 @@ public class AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest {
        mController = new TestAccessibilityQuickSettingsPrimarySwitchPreferenceController(mContext,
                TEST_KEY);
        when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
        mController.displayPreference(mScreen);
    }

    @Test
    public void setChecked_showTooltipView() {
        mController.displayPreference(mScreen);

        mController.setChecked(true);

        assertThat(getLatestPopupWindow().isShowing()).isTrue();
    }

    @Test
    public void setChecked_notCallDisplayPreference_notShowTooltipView() {
        // Simulates the slice highlight menu that does not call {@link #displayPreference} before
        // {@link #setChecked} called.
        mController.setChecked(true);

        assertThat(getLatestPopupWindow()).isNull();
    }

    @Test
    public void setChecked_tooltipViewShown_notShowTooltipView() {
        mController.displayPreference(mScreen);
        mController.setChecked(true);
        getLatestPopupWindow().dismiss();
        mController.setChecked(false);
@@ -142,6 +153,7 @@ public class AccessibilityQuickSettingsPrimarySwitchPreferenceControllerTest {
    @Test
    @Config(shadows = ShadowFragment.class)
    public void restoreValueFromSavedInstanceState_showTooltipView() {
        mController.displayPreference(mScreen);
        mController.setChecked(true);
        final Bundle savedInstanceState = new Bundle();
        savedInstanceState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);