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:
@@ -25,6 +25,7 @@ import android.provider.Settings;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.accessibility.Flags;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.PrimarySwitchPreference;
|
||||
|
||||
@@ -33,10 +34,16 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
||||
private final String SYSTEM_KEY = SCREEN_BRIGHTNESS_MODE;
|
||||
private final int DEFAULT_VALUE = SCREEN_BRIGHTNESS_MODE_MANUAL;
|
||||
|
||||
private boolean mInSetupWizard;
|
||||
|
||||
public AutoBrightnessPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
public void setInSetupWizard(boolean inSetupWizard) {
|
||||
mInSetupWizard = inSetupWizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.System.getInt(mContext.getContentResolver(),
|
||||
@@ -53,10 +60,14 @@ public class AutoBrightnessPreferenceController extends TogglePreferenceControll
|
||||
@Override
|
||||
@AvailabilityStatus
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available)
|
||||
? AVAILABLE_UNSEARCHABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
if (!mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_automatic_brightness_available)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (mInSetupWizard && !Flags.addBrightnessSettingsInSuw()) {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
return AVAILABLE_UNSEARCHABLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user