Get Extra Dim availability through ColorDisplayManager
Test: atest ReduceBrightColorsIntensityPreferenceControllerTest Bug: 170970675 Change-Id: Ibccca13d6491e8861263887e33021dd467fc227f
This commit is contained in:
@@ -18,7 +18,6 @@ package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
@@ -38,10 +37,10 @@ public class ReduceBrightColorsIntensityPreferenceController extends SliderPrefe
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (!ColorDisplayManager.isColorTransformAccelerated(mContext)) {
|
||||
if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
} else if (Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0) != 1) {
|
||||
}
|
||||
if (!mColorDisplayManager.isReduceBrightColorsActivated()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
return AVAILABLE;
|
||||
|
@@ -17,21 +17,29 @@
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
/** PreferenceController for persisting feature activation state after a restart. */
|
||||
public class ReduceBrightColorsPersistencePreferenceController extends TogglePreferenceController {
|
||||
private final ColorDisplayManager mColorDisplayManager;
|
||||
|
||||
public ReduceBrightColorsPersistencePreferenceController(
|
||||
Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mColorDisplayManager = context.getSystemService(ColorDisplayManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
// TODO(b/170970675): call into CDS to get availability/config status
|
||||
if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) {
|
||||
return UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
if (!mColorDisplayManager.isReduceBrightColorsActivated()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
}
|
||||
return AVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ public class ReduceBrightColorsPreferenceController extends TogglePreferenceCont
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return ColorDisplayManager.isColorTransformAccelerated(mContext) ? AVAILABLE
|
||||
return ColorDisplayManager.isReduceBrightColorsAvailable(mContext) ? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.ColorDisplayManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -175,8 +176,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
||||
new BaseSearchIndexProvider(R.xml.reduce_bright_colors_settings) {
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
// TODO(b/170970675): call into CDS to get availability/config status
|
||||
return true;
|
||||
return ColorDisplayManager.isReduceBrightColorsAvailable(context);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1);
|
||||
doReturn(true).when(mResources).getBoolean(
|
||||
com.android.internal.R.bool.config_setColorTransformAccelerated);
|
||||
R.bool.config_reduceBrightColorsAvailable);
|
||||
assertThat(mPreferenceController.isAvailable()).isTrue();
|
||||
}
|
||||
@Test
|
||||
@@ -64,7 +64,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0);
|
||||
doReturn(true).when(mResources).getBoolean(
|
||||
com.android.internal.R.bool.config_setColorTransformAccelerated);
|
||||
R.bool.config_reduceBrightColorsAvailable);
|
||||
assertThat(mPreferenceController.isAvailable()).isTrue();
|
||||
}
|
||||
@Test
|
||||
@@ -72,7 +72,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1);
|
||||
doReturn(false).when(mResources).getBoolean(
|
||||
com.android.internal.R.bool.config_setColorTransformAccelerated);
|
||||
R.bool.config_reduceBrightColorsAvailable);
|
||||
assertThat(mPreferenceController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user