fix(Color correction): Display default value in slider to match the radio button

The default value for display in the radio buttons were hard-coded and was not
being reflected to the slider correctly.

Bug: 359379399
Test: locally tested + unit tests added
Flag: com.android.server.accessibility.enable_color_correction_saturation

Change-Id: I95bd0ae1d32561dbbf6b4e87efe70595c9566de8
This commit is contained in:
Isaac Chai
2024-08-15 19:36:54 +00:00
parent 1dfc18740e
commit 23258c2b10
5 changed files with 110 additions and 48 deletions

View File

@@ -15,6 +15,9 @@
*/
package com.android.settings.accessibility;
import static com.android.settings.accessibility.DaltonizerPreferenceUtil.isSecureAccessibilityDaltonizerEnabled;
import static com.android.settings.accessibility.DaltonizerPreferenceUtil.getSecureAccessibilityDaltonizerValue;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
@@ -158,14 +161,11 @@ public class DaltonizerSaturationSeekbarPreferenceController
}
private boolean shouldSeekBarEnabled() {
int enabled = Settings.Secure.getInt(
mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
int mode = Settings.Secure.getInt(
mContentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, -1);
boolean enabled = isSecureAccessibilityDaltonizerEnabled(mContentResolver);
int mode = getSecureAccessibilityDaltonizerValue(mContentResolver);
// enabled == 0 is disabled and also default.
// mode == 0 is gray scale where saturation level isn't applicable.
// mode == -1 is disabled and also default.
return enabled != 0 && mode != -1 && mode != 0;
return enabled && mode != -1 && mode != 0;
}
}