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