diff options
| author | 2019-05-07 21:20:05 +0000 | |
|---|---|---|
| committer | 2019-05-07 21:20:05 +0000 | |
| commit | 9d89fd9fb26d0fe395ee6aa7d9b9cdf11a9d1ec9 (patch) | |
| tree | f0598253e11919cc2f0a684f0236e1ea029e7a7e | |
| parent | 31b02a613f0b7ce2e44a2956e04c9e741584a892 (diff) | |
| parent | ff24ba9eff7703f841e11b2a065a9ed424db9c9d (diff) | |
Merge "Disable display white balance when accessibility features are enabled" into qt-dev
| -rw-r--r-- | services/core/java/com/android/server/display/color/ColorDisplayService.java | 33 | ||||
| -rw-r--r-- | services/tests/servicestests/src/com/android/server/display/color/ColorDisplayServiceTest.java | 28 |
2 files changed, 49 insertions, 12 deletions
diff --git a/services/core/java/com/android/server/display/color/ColorDisplayService.java b/services/core/java/com/android/server/display/color/ColorDisplayService.java index f599adb5118a..85fb1e0f4bdf 100644 --- a/services/core/java/com/android/server/display/color/ColorDisplayService.java +++ b/services/core/java/com/android/server/display/color/ColorDisplayService.java @@ -473,6 +473,20 @@ public final class ColorDisplayService extends SystemService { onDisplayColorModeChanged(getColorModeInternal()); } + private boolean isAccessiblityDaltonizerEnabled() { + return Secure.getIntForUser(getContext().getContentResolver(), + Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0, mCurrentUser) != 0; + } + + private boolean isAccessiblityInversionEnabled() { + return Secure.getIntForUser(getContext().getContentResolver(), + Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0, mCurrentUser) != 0; + } + + private boolean isAccessibilityEnabled() { + return isAccessiblityDaltonizerEnabled() || isAccessiblityInversionEnabled(); + } + /** * Apply the accessibility daltonizer transform based on the settings value. */ @@ -480,11 +494,10 @@ public final class ColorDisplayService extends SystemService { if (mCurrentUser == UserHandle.USER_NULL) { return; } - final boolean enabled = Secure.getIntForUser(getContext().getContentResolver(), - Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0, mCurrentUser) != 0; - final int daltonizerMode = enabled ? Secure.getIntForUser(getContext().getContentResolver(), - Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, - AccessibilityManager.DALTONIZER_CORRECT_DEUTERANOMALY, mCurrentUser) + final int daltonizerMode = isAccessiblityDaltonizerEnabled() + ? Secure.getIntForUser(getContext().getContentResolver(), + Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, + AccessibilityManager.DALTONIZER_CORRECT_DEUTERANOMALY, mCurrentUser) : AccessibilityManager.DALTONIZER_DISABLED; final DisplayTransformManager dtm = getLocalService(DisplayTransformManager.class); @@ -506,11 +519,9 @@ public final class ColorDisplayService extends SystemService { if (mCurrentUser == UserHandle.USER_NULL) { return; } - final boolean enabled = Secure.getIntForUser(getContext().getContentResolver(), - Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, 0, mCurrentUser) != 0; final DisplayTransformManager dtm = getLocalService(DisplayTransformManager.class); dtm.setColorMatrix(DisplayTransformManager.LEVEL_COLOR_MATRIX_INVERT_COLOR, - enabled ? MATRIX_INVERT_COLOR : null); + isAccessiblityInversionEnabled() ? MATRIX_INVERT_COLOR : null); } /** @@ -598,6 +609,7 @@ public final class ColorDisplayService extends SystemService { boolean oldActivated = mDisplayWhiteBalanceTintController.isActivated(); mDisplayWhiteBalanceTintController.setActivated(isDisplayWhiteBalanceSettingEnabled() && !mNightDisplayTintController.isActivated() + && !isAccessibilityEnabled() && DisplayTransformManager.needsLinearColorMatrix()); boolean activated = mDisplayWhiteBalanceTintController.isActivated(); @@ -761,10 +773,7 @@ public final class ColorDisplayService extends SystemService { private @ColorMode int getColorModeInternal() { final ContentResolver cr = getContext().getContentResolver(); - if (Secure.getIntForUser(cr, Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED, - 0, mCurrentUser) == 1 - || Secure.getIntForUser(cr, Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, - 0, mCurrentUser) == 1) { + if (isAccessibilityEnabled()) { // There are restrictions on the available color modes combined with a11y transforms. if (isColorModeAvailable(COLOR_MODE_SATURATED)) { return COLOR_MODE_SATURATED; diff --git a/services/tests/servicestests/src/com/android/server/display/color/ColorDisplayServiceTest.java b/services/tests/servicestests/src/com/android/server/display/color/ColorDisplayServiceTest.java index de841a0ac4ec..8bb8aae76849 100644 --- a/services/tests/servicestests/src/com/android/server/display/color/ColorDisplayServiceTest.java +++ b/services/tests/servicestests/src/com/android/server/display/color/ColorDisplayServiceTest.java @@ -1029,6 +1029,34 @@ public class ColorDisplayServiceTest { assertDwbActive(true); } + @Test + public void displayWhiteBalance_disabledWhileAccessibilityColorCorrectionEnabled() { + setDisplayWhiteBalanceEnabled(true); + startService(); + setAccessibilityColorCorrection(true); + + mCds.updateDisplayWhiteBalanceStatus(); + assertDwbActive(false); + + setAccessibilityColorCorrection(false); + mCds.updateDisplayWhiteBalanceStatus(); + assertDwbActive(true); + } + + @Test + public void displayWhiteBalance_disabledWhileAccessibilityColorInversionEnabled() { + setDisplayWhiteBalanceEnabled(true); + startService(); + setAccessibilityColorInversion(true); + + mCds.updateDisplayWhiteBalanceStatus(); + assertDwbActive(false); + + setAccessibilityColorInversion(false); + mCds.updateDisplayWhiteBalanceStatus(); + assertDwbActive(true); + } + /** * Configures Night display to use a custom schedule. * |