feat(brightness suw): add brightness preferences in suw

Add brightness level and auto brightness preference in
accessibility_settings_for_setup_wizard.xml. Since the flagging has not
be supported yet for non-Manifest resources, for now we add the
preferences by default, and update the preferece availablity status in
each preference controllers based on the flag.

Bug: 311093618
Flag: ACONFIG com.android.settings.accessibility.add_brightness_settings_in_suw DEVELOPMENT
Test: manually
      atest AccessibilitySettingsForSetupWizardTest
      atest AutoBrightnessPreferenceFragmentForSetupWizardTest
      atest AutoBrightnessPreferenceControllerTest
      atest BrightnessLevelPreferenceControllerTest
Change-Id: I350d99138bdd14bf28828a39e42f707b5b1066c1
This commit is contained in:
Roy Chou
2024-04-18 16:34:26 +00:00
parent 23349d60c0
commit 042c8c7328
19 changed files with 490 additions and 24 deletions

View File

@@ -21,18 +21,24 @@ import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL;
import static com.android.settings.core.BasePreferenceController.AVAILABLE_UNSEARCHABLE;
import static com.android.settings.core.BasePreferenceController.CONDITIONALLY_UNAVAILABLE;
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
import static com.google.common.truth.Truth.assertThat;
import android.content.ContentResolver;
import android.content.Context;
import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.accessibility.Flags;
import com.android.settings.testutils.shadow.SettingsShadowResources;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
@@ -44,6 +50,9 @@ import org.robolectric.annotation.Config;
@Config(shadows = {SettingsShadowResources.class})
public class AutoBrightnessPreferenceControllerTest {
@Rule
public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
private static final String PREFERENCE_KEY = "auto_brightness";
private Context mContext;
@@ -121,13 +130,34 @@ public class AutoBrightnessPreferenceControllerTest {
}
@Test
public void getAvailabilityStatus_configTrueSet_shouldReturnAvailableUnsearchable() {
public void getAvailabilityStatusNotInSUW_configTrueSet_shouldReturnAvailableUnsearchable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
@EnableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
public void getAvailabilityStatusInSUW_configTrueAndFlagOn_shouldReturnAvailableUnsearchable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
mController.setInSetupWizard(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE_UNSEARCHABLE);
}
@Test
@DisableFlags(Flags.FLAG_ADD_BRIGHTNESS_SETTINGS_IN_SUW)
public void
getAvailabilityStatusInSUW_configTrueAndFlagOff_shouldReturnConditionallyUnavailable() {
SettingsShadowResources.overrideResource(
com.android.internal.R.bool.config_automatic_brightness_available, true);
mController.setInSetupWizard(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
}
@Test
public void getAvailabilityStatus_configFalseSet_shouldReturnUnsupportedOnDevice() {
SettingsShadowResources.overrideResource(