Loading services/core/java/com/android/server/display/color/ColorDisplayService.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -609,6 +609,9 @@ public final class ColorDisplayService extends SystemService { @Override @Override public void onAnimationEnd(Animator animator) { public void onAnimationEnd(Animator animator) { Slog.d(TAG, tintController.getClass().getSimpleName() + " Animation cancelled: " + mIsCancelled + " to matrix: " + TintController.matrixToString(to, 16)); if (!mIsCancelled) { if (!mIsCancelled) { // Ensure final color matrix is set at the end of the animation. If the // Ensure final color matrix is set at the end of the animation. If the // animation is cancelled then don't set the final color matrix so the new // animation is cancelled then don't set the final color matrix so the new Loading Loading @@ -1314,8 +1317,10 @@ public final class ColorDisplayService extends SystemService { * Reset the CCT value for the display white balance transform to its default value. * Reset the CCT value for the display white balance transform to its default value. */ */ public boolean resetDisplayWhiteBalanceColorTemperature() { public boolean resetDisplayWhiteBalanceColorTemperature() { return setDisplayWhiteBalanceColorTemperature(getContext().getResources() int temperatureDefault = getContext().getResources() .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault)); .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault); Slog.d(TAG, "resetDisplayWhiteBalanceColorTemperature: " + temperatureDefault); return setDisplayWhiteBalanceColorTemperature(temperatureDefault); } } /** /** Loading services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java +3 −24 Original line number Original line Diff line number Diff line Loading @@ -149,8 +149,6 @@ final class DisplayWhiteBalanceTintController extends TintController { cct = mTemperatureMax; cct = mTemperatureMax; } } Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct); synchronized (mLock) { synchronized (mLock) { mCurrentColorTemperature = cct; mCurrentColorTemperature = cct; Loading Loading @@ -185,6 +183,9 @@ final class DisplayWhiteBalanceTintController extends TintController { java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3); java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3); java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3); java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3); } } Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct + " matrix = " + matrixToString(mMatrixDisplayWhiteBalance, 16)); } } @Override @Override Loading Loading @@ -225,28 +226,6 @@ final class DisplayWhiteBalanceTintController extends TintController { } } } } /** * Format a given matrix into a string. * * @param matrix the matrix to format * @param columns number of columns in the matrix */ private String matrixToString(float[] matrix, int columns) { if (matrix == null || columns <= 0) { Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string"); return ""; } final StringBuilder sb = new StringBuilder(""); for (int i = 0; i < matrix.length; i++) { if (i % columns == 0) { sb.append("\n "); } sb.append(String.format("%9.6f", matrix[i])); } return sb.toString(); } private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { return new ColorSpace.Rgb( return new ColorSpace.Rgb( "Display Color Space", "Display Color Space", Loading services/core/java/com/android/server/display/color/TintController.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.display.color; import android.animation.ValueAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.content.Context; import android.util.Slog; import java.io.PrintWriter; import java.io.PrintWriter; Loading Loading @@ -95,4 +96,29 @@ abstract class TintController { * Returns whether or not this transform type is available on this device. * Returns whether or not this transform type is available on this device. */ */ public abstract boolean isAvailable(Context context); public abstract boolean isAvailable(Context context); /** * Format a given matrix into a string. * * @param matrix the matrix to format * @param columns number of columns in the matrix */ static String matrixToString(float[] matrix, int columns) { if (matrix == null || columns <= 0) { Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string," + " matrix is null: " + (matrix == null) + " columns: " + columns); return ""; } final StringBuilder sb = new StringBuilder(""); for (int i = 0; i < matrix.length; i++) { if (i % columns == 0) { sb.append("\n "); } sb.append(String.format("%9.6f", matrix[i])); } return sb.toString(); } } } services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -95,6 +95,11 @@ public class DisplayWhiteBalanceController implements // A piecewise linear relationship between high light brightness and high light bias. // A piecewise linear relationship between high light brightness and high light bias. private Spline.LinearSpline mHighLightAmbientBrightnessToBiasSpline; private Spline.LinearSpline mHighLightAmbientBrightnessToBiasSpline; private float mLatestAmbientColorTemperature; private float mLatestAmbientBrightness; private float mLatestLowLightBias; private float mLatestHighLightBias; /** /** * @param brightnessSensor * @param brightnessSensor * The sensor used to detect changes in the ambient brightness. * The sensor used to detect changes in the ambient brightness. Loading Loading @@ -348,6 +353,7 @@ public class DisplayWhiteBalanceController implements public void updateAmbientColorTemperature() { public void updateAmbientColorTemperature() { final long time = System.currentTimeMillis(); final long time = System.currentTimeMillis(); float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time); float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time); mLatestAmbientColorTemperature = ambientColorTemperature; if (mAmbientToDisplayColorTemperatureSpline != null && ambientColorTemperature != -1.0f) { if (mAmbientToDisplayColorTemperatureSpline != null && ambientColorTemperature != -1.0f) { ambientColorTemperature = ambientColorTemperature = Loading @@ -355,6 +361,7 @@ public class DisplayWhiteBalanceController implements } } float ambientBrightness = mBrightnessFilter.getEstimate(time); float ambientBrightness = mBrightnessFilter.getEstimate(time); mLatestAmbientBrightness = ambientBrightness; if (ambientColorTemperature != -1.0f && if (ambientColorTemperature != -1.0f && mLowLightAmbientBrightnessToBiasSpline != null) { mLowLightAmbientBrightnessToBiasSpline != null) { Loading @@ -362,6 +369,7 @@ public class DisplayWhiteBalanceController implements ambientColorTemperature = ambientColorTemperature = bias * ambientColorTemperature + (1.0f - bias) bias * ambientColorTemperature + (1.0f - bias) * mLowLightAmbientColorTemperature; * mLowLightAmbientColorTemperature; mLatestLowLightBias = bias; } } if (ambientColorTemperature != -1.0f && if (ambientColorTemperature != -1.0f && mHighLightAmbientBrightnessToBiasSpline != null) { mHighLightAmbientBrightnessToBiasSpline != null) { Loading @@ -369,6 +377,7 @@ public class DisplayWhiteBalanceController implements ambientColorTemperature = ambientColorTemperature = (1.0f - bias) * ambientColorTemperature + bias (1.0f - bias) * ambientColorTemperature + bias * mHighLightAmbientColorTemperature; * mHighLightAmbientColorTemperature; mLatestHighLightBias = bias; } } if (mAmbientColorTemperatureOverride != -1.0f) { if (mAmbientColorTemperatureOverride != -1.0f) { Loading Loading @@ -426,6 +435,11 @@ public class DisplayWhiteBalanceController implements } } mPendingAmbientColorTemperature = -1.0f; mPendingAmbientColorTemperature = -1.0f; mAmbientColorTemperatureHistory.add(mAmbientColorTemperature); mAmbientColorTemperatureHistory.add(mAmbientColorTemperature); Slog.d(TAG, "Display cct: " + mAmbientColorTemperature + " Latest ambient cct: " + mLatestAmbientColorTemperature + " Latest ambient lux: " + mLatestAmbientBrightness + " Latest low light bias: " + mLatestLowLightBias + " Latest high light bias: " + mLatestHighLightBias); mColorDisplayServiceInternal.setDisplayWhiteBalanceColorTemperature( mColorDisplayServiceInternal.setDisplayWhiteBalanceColorTemperature( (int) mAmbientColorTemperature); (int) mAmbientColorTemperature); mLastAmbientColorTemperature = mAmbientColorTemperature; mLastAmbientColorTemperature = mAmbientColorTemperature; Loading Loading
services/core/java/com/android/server/display/color/ColorDisplayService.java +7 −2 Original line number Original line Diff line number Diff line Loading @@ -609,6 +609,9 @@ public final class ColorDisplayService extends SystemService { @Override @Override public void onAnimationEnd(Animator animator) { public void onAnimationEnd(Animator animator) { Slog.d(TAG, tintController.getClass().getSimpleName() + " Animation cancelled: " + mIsCancelled + " to matrix: " + TintController.matrixToString(to, 16)); if (!mIsCancelled) { if (!mIsCancelled) { // Ensure final color matrix is set at the end of the animation. If the // Ensure final color matrix is set at the end of the animation. If the // animation is cancelled then don't set the final color matrix so the new // animation is cancelled then don't set the final color matrix so the new Loading Loading @@ -1314,8 +1317,10 @@ public final class ColorDisplayService extends SystemService { * Reset the CCT value for the display white balance transform to its default value. * Reset the CCT value for the display white balance transform to its default value. */ */ public boolean resetDisplayWhiteBalanceColorTemperature() { public boolean resetDisplayWhiteBalanceColorTemperature() { return setDisplayWhiteBalanceColorTemperature(getContext().getResources() int temperatureDefault = getContext().getResources() .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault)); .getInteger(R.integer.config_displayWhiteBalanceColorTemperatureDefault); Slog.d(TAG, "resetDisplayWhiteBalanceColorTemperature: " + temperatureDefault); return setDisplayWhiteBalanceColorTemperature(temperatureDefault); } } /** /** Loading
services/core/java/com/android/server/display/color/DisplayWhiteBalanceTintController.java +3 −24 Original line number Original line Diff line number Diff line Loading @@ -149,8 +149,6 @@ final class DisplayWhiteBalanceTintController extends TintController { cct = mTemperatureMax; cct = mTemperatureMax; } } Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct); synchronized (mLock) { synchronized (mLock) { mCurrentColorTemperature = cct; mCurrentColorTemperature = cct; Loading Loading @@ -185,6 +183,9 @@ final class DisplayWhiteBalanceTintController extends TintController { java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3); java.lang.System.arraycopy(result, 3, mMatrixDisplayWhiteBalance, 4, 3); java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3); java.lang.System.arraycopy(result, 6, mMatrixDisplayWhiteBalance, 8, 3); } } Slog.d(ColorDisplayService.TAG, "setDisplayWhiteBalanceTemperatureMatrix: cct = " + cct + " matrix = " + matrixToString(mMatrixDisplayWhiteBalance, 16)); } } @Override @Override Loading Loading @@ -225,28 +226,6 @@ final class DisplayWhiteBalanceTintController extends TintController { } } } } /** * Format a given matrix into a string. * * @param matrix the matrix to format * @param columns number of columns in the matrix */ private String matrixToString(float[] matrix, int columns) { if (matrix == null || columns <= 0) { Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string"); return ""; } final StringBuilder sb = new StringBuilder(""); for (int i = 0; i < matrix.length; i++) { if (i % columns == 0) { sb.append("\n "); } sb.append(String.format("%9.6f", matrix[i])); } return sb.toString(); } private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { private ColorSpace.Rgb makeRgbColorSpaceFromXYZ(float[] redGreenBlueXYZ, float[] whiteXYZ) { return new ColorSpace.Rgb( return new ColorSpace.Rgb( "Display Color Space", "Display Color Space", Loading
services/core/java/com/android/server/display/color/TintController.java +26 −0 Original line number Original line Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.display.color; import android.animation.ValueAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.content.Context; import android.util.Slog; import java.io.PrintWriter; import java.io.PrintWriter; Loading Loading @@ -95,4 +96,29 @@ abstract class TintController { * Returns whether or not this transform type is available on this device. * Returns whether or not this transform type is available on this device. */ */ public abstract boolean isAvailable(Context context); public abstract boolean isAvailable(Context context); /** * Format a given matrix into a string. * * @param matrix the matrix to format * @param columns number of columns in the matrix */ static String matrixToString(float[] matrix, int columns) { if (matrix == null || columns <= 0) { Slog.e(ColorDisplayService.TAG, "Invalid arguments when formatting matrix to string," + " matrix is null: " + (matrix == null) + " columns: " + columns); return ""; } final StringBuilder sb = new StringBuilder(""); for (int i = 0; i < matrix.length; i++) { if (i % columns == 0) { sb.append("\n "); } sb.append(String.format("%9.6f", matrix[i])); } return sb.toString(); } } }
services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -95,6 +95,11 @@ public class DisplayWhiteBalanceController implements // A piecewise linear relationship between high light brightness and high light bias. // A piecewise linear relationship between high light brightness and high light bias. private Spline.LinearSpline mHighLightAmbientBrightnessToBiasSpline; private Spline.LinearSpline mHighLightAmbientBrightnessToBiasSpline; private float mLatestAmbientColorTemperature; private float mLatestAmbientBrightness; private float mLatestLowLightBias; private float mLatestHighLightBias; /** /** * @param brightnessSensor * @param brightnessSensor * The sensor used to detect changes in the ambient brightness. * The sensor used to detect changes in the ambient brightness. Loading Loading @@ -348,6 +353,7 @@ public class DisplayWhiteBalanceController implements public void updateAmbientColorTemperature() { public void updateAmbientColorTemperature() { final long time = System.currentTimeMillis(); final long time = System.currentTimeMillis(); float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time); float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time); mLatestAmbientColorTemperature = ambientColorTemperature; if (mAmbientToDisplayColorTemperatureSpline != null && ambientColorTemperature != -1.0f) { if (mAmbientToDisplayColorTemperatureSpline != null && ambientColorTemperature != -1.0f) { ambientColorTemperature = ambientColorTemperature = Loading @@ -355,6 +361,7 @@ public class DisplayWhiteBalanceController implements } } float ambientBrightness = mBrightnessFilter.getEstimate(time); float ambientBrightness = mBrightnessFilter.getEstimate(time); mLatestAmbientBrightness = ambientBrightness; if (ambientColorTemperature != -1.0f && if (ambientColorTemperature != -1.0f && mLowLightAmbientBrightnessToBiasSpline != null) { mLowLightAmbientBrightnessToBiasSpline != null) { Loading @@ -362,6 +369,7 @@ public class DisplayWhiteBalanceController implements ambientColorTemperature = ambientColorTemperature = bias * ambientColorTemperature + (1.0f - bias) bias * ambientColorTemperature + (1.0f - bias) * mLowLightAmbientColorTemperature; * mLowLightAmbientColorTemperature; mLatestLowLightBias = bias; } } if (ambientColorTemperature != -1.0f && if (ambientColorTemperature != -1.0f && mHighLightAmbientBrightnessToBiasSpline != null) { mHighLightAmbientBrightnessToBiasSpline != null) { Loading @@ -369,6 +377,7 @@ public class DisplayWhiteBalanceController implements ambientColorTemperature = ambientColorTemperature = (1.0f - bias) * ambientColorTemperature + bias (1.0f - bias) * ambientColorTemperature + bias * mHighLightAmbientColorTemperature; * mHighLightAmbientColorTemperature; mLatestHighLightBias = bias; } } if (mAmbientColorTemperatureOverride != -1.0f) { if (mAmbientColorTemperatureOverride != -1.0f) { Loading Loading @@ -426,6 +435,11 @@ public class DisplayWhiteBalanceController implements } } mPendingAmbientColorTemperature = -1.0f; mPendingAmbientColorTemperature = -1.0f; mAmbientColorTemperatureHistory.add(mAmbientColorTemperature); mAmbientColorTemperatureHistory.add(mAmbientColorTemperature); Slog.d(TAG, "Display cct: " + mAmbientColorTemperature + " Latest ambient cct: " + mLatestAmbientColorTemperature + " Latest ambient lux: " + mLatestAmbientBrightness + " Latest low light bias: " + mLatestLowLightBias + " Latest high light bias: " + mLatestHighLightBias); mColorDisplayServiceInternal.setDisplayWhiteBalanceColorTemperature( mColorDisplayServiceInternal.setDisplayWhiteBalanceColorTemperature( (int) mAmbientColorTemperature); (int) mAmbientColorTemperature); mLastAmbientColorTemperature = mAmbientColorTemperature; mLastAmbientColorTemperature = mAmbientColorTemperature; Loading