Fix UiBlcoker regression

We determine if the visibility should be updated by mIsFirstLaunch, and
mIsFirstLaunch is set to false in onStop(). This breaks the updatability
if there's a change before onStop() gets called.

So we move the value assignment to the end of checkUiBlocker() because
at that time, all blocker work should be either finished or timeout.
Also remove mIsFirstLaunch since mUiBlockerFinished can cover the
determination with the new design.

Fixes: 229565193
Test: Toggle Use Location in the location page and see the Recent used
section react accordingly.

Change-Id: Id6005e5b8b29cb8a6309068d0a2177489a3fb2f4
This commit is contained in:
Yi-Ling Chuang
2022-04-18 15:35:52 +08:00
parent 4dc79d92f0
commit 61022c6419
2 changed files with 7 additions and 16 deletions

View File

@@ -132,17 +132,22 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
@VisibleForTesting
void checkUiBlocker(List<AbstractPreferenceController> controllers) {
final List<String> keys = new ArrayList<>();
final List<BasePreferenceController> baseControllers = new ArrayList<>();
controllers.forEach(controller -> {
if (controller instanceof BasePreferenceController.UiBlocker
&& controller.isAvailable()) {
((BasePreferenceController) controller).setUiBlockListener(this);
keys.add(controller.getPreferenceKey());
baseControllers.add((BasePreferenceController) controller);
}
});
if (!keys.isEmpty()) {
mBlockerController = new UiBlockerController(keys);
mBlockerController.start(() -> updatePreferenceVisibility(mPreferenceControllers));
mBlockerController.start(() -> {
updatePreferenceVisibility(mPreferenceControllers);
baseControllers.forEach(controller -> controller.setUiBlockerFinished(true));
});
}
}
@@ -250,11 +255,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
}
mListeningToCategoryChange = false;
}
mControllers.forEach(controller -> {
if (controller instanceof BasePreferenceController.UiBlocker) {
((BasePreferenceController) controller).revokeFirstLaunch();
}
});
}
@Override