Loading core/res/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -935,6 +935,8 @@ <!-- Nominal White Z --> <item>1.089058</item> </string-array> <!-- Boolean indicating whether light mode is allowed when DWB is turned on. --> <bool name="config_displayWhiteBalanceLightModeAllowed">true</bool> <!-- Indicate available ColorDisplayManager.COLOR_MODE_xxx. --> <integer-array name="config_availableColorModes"> Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3418,6 +3418,7 @@ <java-symbol type="integer" name="config_displayWhiteBalanceColorTemperatureDefault" /> <java-symbol type="array" name="config_displayWhiteBalanceDisplayPrimaries" /> <java-symbol type="array" name="config_displayWhiteBalanceDisplayNominalWhite" /> <java-symbol type="bool" name="config_displayWhiteBalanceLightModeAllowed" /> <!-- Default first user restrictions --> <java-symbol type="array" name="config_defaultFirstUserRestrictions" /> Loading services/core/java/com/android/server/display/color/ColorDisplayService.java +8 −1 Original line number Diff line number Diff line Loading @@ -740,7 +740,8 @@ public final class ColorDisplayService extends SystemService { mDisplayWhiteBalanceTintController.setActivated(isDisplayWhiteBalanceSettingEnabled() && !mNightDisplayTintController.isActivated() && !isAccessibilityEnabled() && dtm.needsLinearColorMatrix()); && dtm.needsLinearColorMatrix() && mDisplayWhiteBalanceTintController.isAllowed()); boolean activated = mDisplayWhiteBalanceTintController.isActivated(); if (mDisplayWhiteBalanceListener != null && oldActivated != activated) { Loading Loading @@ -1453,6 +1454,12 @@ public final class ColorDisplayService extends SystemService { */ public class ColorDisplayServiceInternal { /** Sets whether DWB should be allowed in the current state. */ public void setDisplayWhiteBalanceAllowed(boolean allowed) { mDisplayWhiteBalanceTintController.setAllowed(allowed); updateDisplayWhiteBalanceStatus(); } /** * Set the current CCT value for the display white balance transform, and if the transform * is enabled, apply it. Loading services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java +14 −0 Original line number Diff line number Diff line Loading @@ -61,12 +61,17 @@ final class DisplayWhiteBalanceTintController extends TintController { boolean mSetUp = false; private float[] mMatrixDisplayWhiteBalance = new float[16]; private Boolean mIsAvailable; // This feature becomes disallowed if the device is in an unsupported strong/light state. private boolean mIsAllowed = true; @Override public void setUp(Context context, boolean needsLinear) { mSetUp = false; final Resources res = context.getResources(); // Initialize with the config value for light mode, so it starts in the right state. setAllowed(res.getBoolean(R.bool.config_displayWhiteBalanceLightModeAllowed)); ColorSpace.Rgb displayColorSpaceRGB = getDisplayColorSpaceFromSurfaceControl(); if (displayColorSpaceRGB == null) { Slog.w(ColorDisplayService.TAG, Loading Loading @@ -248,6 +253,7 @@ final class DisplayWhiteBalanceTintController extends TintController { + matrixToString(mDisplayColorSpaceRGB.getInverseTransform(), 3)); pw.println(" mMatrixDisplayWhiteBalance = " + matrixToString(mMatrixDisplayWhiteBalance, 4)); pw.println(" mIsAllowed = " + mIsAllowed); } } Loading @@ -263,6 +269,14 @@ final class DisplayWhiteBalanceTintController extends TintController { } } public void setAllowed(boolean allowed) { mIsAllowed = allowed; } public boolean isAllowed() { return mIsAllowed; } private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { return new ColorSpace.Rgb( "Display Color Space", Loading services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +9 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ public class DisplayWhiteBalanceController implements // this effect. private final float mHighLightAmbientColorTemperature; private final boolean mLightModeAllowed; private float mAmbientColorTemperature; @VisibleForTesting float mPendingAmbientColorTemperature; Loading Loading @@ -148,6 +150,8 @@ public class DisplayWhiteBalanceController implements * @param displayColorTemperatures * The display color temperatures used to map the ambient color temperature to the display * color temperature (or null if no mapping is necessary). * @param lightModeAllowed * Whether a lighter version should be applied when Strong Mode is not enabled. * * @throws NullPointerException * - brightnessSensor is null; Loading @@ -171,7 +175,8 @@ public class DisplayWhiteBalanceController implements float[] ambientColorTemperatures, float[] displayColorTemperatures, float[] strongAmbientColorTemperatures, float[] strongDisplayColorTemperatures) { float[] strongDisplayColorTemperatures, boolean lightModeAllowed) { validateArguments(brightnessSensor, brightnessFilter, colorTemperatureSensor, colorTemperatureFilter, throttler); mBrightnessSensor = brightnessSensor; Loading @@ -186,6 +191,7 @@ public class DisplayWhiteBalanceController implements mLastAmbientColorTemperature = -1.0f; mAmbientColorTemperatureHistory = new History(/* size= */ 50); mAmbientColorTemperatureOverride = -1.0f; mLightModeAllowed = lightModeAllowed; try { mLowLightAmbientBrightnessToBiasSpline = new Spline.LinearSpline( Loading Loading @@ -273,6 +279,8 @@ public class DisplayWhiteBalanceController implements */ public void setStrongModeEnabled(boolean enabled) { mStrongModeEnabled = enabled; mColorDisplayServiceInternal.setDisplayWhiteBalanceAllowed(mLightModeAllowed || mStrongModeEnabled); if (mEnabled) { updateAmbientColorTemperature(); updateDisplayColorTemperature(); Loading Loading
core/res/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -935,6 +935,8 @@ <!-- Nominal White Z --> <item>1.089058</item> </string-array> <!-- Boolean indicating whether light mode is allowed when DWB is turned on. --> <bool name="config_displayWhiteBalanceLightModeAllowed">true</bool> <!-- Indicate available ColorDisplayManager.COLOR_MODE_xxx. --> <integer-array name="config_availableColorModes"> Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -3418,6 +3418,7 @@ <java-symbol type="integer" name="config_displayWhiteBalanceColorTemperatureDefault" /> <java-symbol type="array" name="config_displayWhiteBalanceDisplayPrimaries" /> <java-symbol type="array" name="config_displayWhiteBalanceDisplayNominalWhite" /> <java-symbol type="bool" name="config_displayWhiteBalanceLightModeAllowed" /> <!-- Default first user restrictions --> <java-symbol type="array" name="config_defaultFirstUserRestrictions" /> Loading
services/core/java/com/android/server/display/color/ColorDisplayService.java +8 −1 Original line number Diff line number Diff line Loading @@ -740,7 +740,8 @@ public final class ColorDisplayService extends SystemService { mDisplayWhiteBalanceTintController.setActivated(isDisplayWhiteBalanceSettingEnabled() && !mNightDisplayTintController.isActivated() && !isAccessibilityEnabled() && dtm.needsLinearColorMatrix()); && dtm.needsLinearColorMatrix() && mDisplayWhiteBalanceTintController.isAllowed()); boolean activated = mDisplayWhiteBalanceTintController.isActivated(); if (mDisplayWhiteBalanceListener != null && oldActivated != activated) { Loading Loading @@ -1453,6 +1454,12 @@ public final class ColorDisplayService extends SystemService { */ public class ColorDisplayServiceInternal { /** Sets whether DWB should be allowed in the current state. */ public void setDisplayWhiteBalanceAllowed(boolean allowed) { mDisplayWhiteBalanceTintController.setAllowed(allowed); updateDisplayWhiteBalanceStatus(); } /** * Set the current CCT value for the display white balance transform, and if the transform * is enabled, apply it. Loading
services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java +14 −0 Original line number Diff line number Diff line Loading @@ -61,12 +61,17 @@ final class DisplayWhiteBalanceTintController extends TintController { boolean mSetUp = false; private float[] mMatrixDisplayWhiteBalance = new float[16]; private Boolean mIsAvailable; // This feature becomes disallowed if the device is in an unsupported strong/light state. private boolean mIsAllowed = true; @Override public void setUp(Context context, boolean needsLinear) { mSetUp = false; final Resources res = context.getResources(); // Initialize with the config value for light mode, so it starts in the right state. setAllowed(res.getBoolean(R.bool.config_displayWhiteBalanceLightModeAllowed)); ColorSpace.Rgb displayColorSpaceRGB = getDisplayColorSpaceFromSurfaceControl(); if (displayColorSpaceRGB == null) { Slog.w(ColorDisplayService.TAG, Loading Loading @@ -248,6 +253,7 @@ final class DisplayWhiteBalanceTintController extends TintController { + matrixToString(mDisplayColorSpaceRGB.getInverseTransform(), 3)); pw.println(" mMatrixDisplayWhiteBalance = " + matrixToString(mMatrixDisplayWhiteBalance, 4)); pw.println(" mIsAllowed = " + mIsAllowed); } } Loading @@ -263,6 +269,14 @@ final class DisplayWhiteBalanceTintController extends TintController { } } public void setAllowed(boolean allowed) { mIsAllowed = allowed; } public boolean isAllowed() { return mIsAllowed; } private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { return new ColorSpace.Rgb( "Display Color Space", Loading
services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +9 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ public class DisplayWhiteBalanceController implements // this effect. private final float mHighLightAmbientColorTemperature; private final boolean mLightModeAllowed; private float mAmbientColorTemperature; @VisibleForTesting float mPendingAmbientColorTemperature; Loading Loading @@ -148,6 +150,8 @@ public class DisplayWhiteBalanceController implements * @param displayColorTemperatures * The display color temperatures used to map the ambient color temperature to the display * color temperature (or null if no mapping is necessary). * @param lightModeAllowed * Whether a lighter version should be applied when Strong Mode is not enabled. * * @throws NullPointerException * - brightnessSensor is null; Loading @@ -171,7 +175,8 @@ public class DisplayWhiteBalanceController implements float[] ambientColorTemperatures, float[] displayColorTemperatures, float[] strongAmbientColorTemperatures, float[] strongDisplayColorTemperatures) { float[] strongDisplayColorTemperatures, boolean lightModeAllowed) { validateArguments(brightnessSensor, brightnessFilter, colorTemperatureSensor, colorTemperatureFilter, throttler); mBrightnessSensor = brightnessSensor; Loading @@ -186,6 +191,7 @@ public class DisplayWhiteBalanceController implements mLastAmbientColorTemperature = -1.0f; mAmbientColorTemperatureHistory = new History(/* size= */ 50); mAmbientColorTemperatureOverride = -1.0f; mLightModeAllowed = lightModeAllowed; try { mLowLightAmbientBrightnessToBiasSpline = new Spline.LinearSpline( Loading Loading @@ -273,6 +279,8 @@ public class DisplayWhiteBalanceController implements */ public void setStrongModeEnabled(boolean enabled) { mStrongModeEnabled = enabled; mColorDisplayServiceInternal.setDisplayWhiteBalanceAllowed(mLightModeAllowed || mStrongModeEnabled); if (mEnabled) { updateAmbientColorTemperature(); updateDisplayColorTemperature(); Loading