By default if a RestrictedPreference is restricted then the preference becomes disabled but still visible. But for brightness preferences in A11y SUW we'd like to hide them if they're restricted and disabled, since it's meaningless to show disabled items in SUW. To achieve this, in PreferenceController#displayPreference we check the whether the preference is RestrictedPreference and restricted, so we can decide whether to hide it. Besides, if the preference is restricted and we hide it, in PreferenceController#getAvailableStatis we also return CONDITIONALLY_UNAVAILABLE to make consistency. Bug: 384620216 Flag: com.android.settings.accessibility.add_brightness_settings_in_suw Test: manually atest AutoBrightnessPreferenceControllerForSetupWizardTest atest BrightnessLevelPreferenceControllerForSetupWizardTest Change-Id: Ifb68b4d64fc111d91a23457882a006002173d232
Running Settings Robolectric tests
The full suite
$ croot
$ atest SettingsRoboTests
Running a single test class
With a filter
$ croot
$ atest SettingsRoboTests:com.android.settings.display.AdaptiveSleepPreferenceControllerTest
You can also run any single test class with atest (it will try to find the correct path)
$ atest AdaptiveSleepPreferenceControllerTest