Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 854a76c8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactored display white balance names/docs."

parents 9164fbec 1151ac0f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -3911,19 +3911,19 @@

    <!-- See DisplayWhiteBalanceController.
         A float array containing a list of ambient color temperatures, in Kelvin. This array,
         together with config_displayWhiteBalanceDisplayTemperatureValues, is used to generate a
         together with config_displayWhiteBalanceDisplayColorTemperatures, is used to generate a
         lookup table used in DisplayWhiteBalanceController. This lookup table is used to map
         ambient color temperature readings to a target color temperature for the display.
         This table is optional. If used, this array must,
         1) Contain at least two entries
         2) Be the same length as config_displayWhiteBalanceDisplayTemperatureValues. -->
    <array name="config_displayWhiteBalanceAmbientTemperatureValues">
         2) Be the same length as config_displayWhiteBalanceDisplayColorTemperatures. -->
    <array name="config_displayWhiteBalanceAmbientColorTemperatures">
    </array>

    <!-- See DisplayWhiteBalanceController.
         An array containing a list of display color temperatures, in Kelvin. See
         config_displayWhiteBalanceAmbientTemperatureValues for additional details.
         config_displayWhiteBalanceAmbientColorTemperatures for additional details.
         The same restrictions apply to this array. -->
    <array name="config_displayWhiteBalanceDisplayTemperatureValues">
    <array name="config_displayWhiteBalanceDisplayColorTemperatures">
    </array>
</resources>
+2 −2
Original line number Diff line number Diff line
@@ -3653,7 +3653,7 @@
  <java-symbol type="array" name="config_displayWhiteBalanceDecreaseThresholds" />
  <java-symbol type="dimen" name="config_displayWhiteBalanceLowLightAmbientBrightnessThreshold" />
  <java-symbol type="dimen" name="config_displayWhiteBalanceLowLightAmbientColorTemperature" />
  <java-symbol type="array" name="config_displayWhiteBalanceAmbientTemperatureValues" />
  <java-symbol type="array" name="config_displayWhiteBalanceDisplayTemperatureValues" />
  <java-symbol type="array" name="config_displayWhiteBalanceAmbientColorTemperatures" />
  <java-symbol type="array" name="config_displayWhiteBalanceDisplayColorTemperatures" />
  <java-symbol type="drawable" name="ic_action_open" />
</resources>
+1 −1
Original line number Diff line number Diff line
@@ -1019,7 +1019,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        if (mDisplayWhiteBalanceController != null) {
            if (state == Display.STATE_ON && mDisplayWhiteBalanceSettings.isEnabled()) {
                mDisplayWhiteBalanceController.setEnabled(true);
                mDisplayWhiteBalanceController.updateScreenColorTemperature();
                mDisplayWhiteBalanceController.updateDisplayColorTemperature();
            } else {
                mDisplayWhiteBalanceController.setEnabled(false);
            }
+26 −21
Original line number Diff line number Diff line
@@ -29,14 +29,14 @@ import java.io.PrintWriter;

/**
 * The DisplayWhiteBalanceController drives display white-balance (automatically correcting the
 * screen color temperature depending on the ambient color temperature).
 * display color temperature depending on the ambient color temperature).
 *
 * The DisplayWhiteBalanceController:
 * - Uses the AmbientColorTemperatureSensor to detect changes in the ambient color temperature;
 * - Uses the AmbientColorTemperatureFilter to average these changes over time, filter out the
 *   noise, and arrive at an estimate of the actual ambient color temperature;
 * - Uses the DisplayWhiteBalanceThrottler to decide whether the screen color tempearture should be
 *   updated, suppressing changes that are too frequent or too minor.
 * - Uses the DisplayWhiteBalanceThrottler to decide whether the display color tempearture should
 *   be updated, suppressing changes that are too frequent or too minor.
 */
public class DisplayWhiteBalanceController implements
        AmbientSensor.AmbientBrightnessSensor.Callbacks,
@@ -76,8 +76,8 @@ public class DisplayWhiteBalanceController implements
    // Override the ambient color temperature for debugging purposes.
    private float mAmbientColorTemperatureOverride;

    // A piecewise linear relationship between ambient and display color temperatures
    private Spline.LinearSpline mAmbientToDisplayTemperatureSpline;
    // A piecewise linear relationship between ambient and display color temperatures.
    private Spline.LinearSpline mAmbientToDisplayColorTemperatureSpline;

    /**
     * @param brightnessSensor
@@ -91,7 +91,7 @@ public class DisplayWhiteBalanceController implements
     *      The filter used to average ambient color temperature changes over time, filter out the
     *      noise and arrive at an estimate of the actual ambient color temperature.
     * @param throttler
     *      The throttler used to determine whether the new screen color temperature should be
     *      The throttler used to determine whether the new display color temperature should be
     *      updated or not.
     * @param lowLightAmbientBrightnessThreshold
     *      The ambient brightness threshold beneath which we fall back to a fixed ambient color
@@ -99,6 +99,12 @@ public class DisplayWhiteBalanceController implements
     * @param lowLightAmbientColorTemperature
     *      The ambient color temperature to which we fall back when the ambient brightness drops
     *      beneath a certain threshold.
     * @param ambientColorTemperatures
     *      The ambient color tempeartures used to map the ambient color temperature to the display
     *      color temperature (or null if no mapping is necessary).
     * @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).
     *
     * @throws NullPointerException
     *      - brightnessSensor is null;
@@ -114,7 +120,7 @@ public class DisplayWhiteBalanceController implements
            @NonNull AmbientFilter colorTemperatureFilter,
            @NonNull DisplayWhiteBalanceThrottler throttler,
            float lowLightAmbientBrightnessThreshold, float lowLightAmbientColorTemperature,
            float[] ambientTemperatures, float[] displayTemperatures) {
            float[] ambientColorTemperatures, float[] displayColorTemperatures) {
        validateArguments(brightnessSensor, brightnessFilter, colorTemperatureSensor,
                colorTemperatureFilter, throttler);
        mLoggingEnabled = false;
@@ -134,10 +140,10 @@ public class DisplayWhiteBalanceController implements
        mAmbientColorTemperatureOverride = -1.0f;

        try {
            mAmbientToDisplayTemperatureSpline = new Spline.LinearSpline(ambientTemperatures,
                    displayTemperatures);
            mAmbientToDisplayColorTemperatureSpline = new Spline.LinearSpline(
                    ambientColorTemperatures, displayColorTemperatures);
        } catch (Exception e) {
            mAmbientToDisplayTemperatureSpline = null;
            mAmbientToDisplayColorTemperatureSpline = null;
        }

        mColorDisplayServiceInternal = LocalServices.getService(ColorDisplayServiceInternal.class);
@@ -160,7 +166,7 @@ public class DisplayWhiteBalanceController implements
    }

    /**
     * Set an object to call back to when the screen color temperature should be updated.
     * Set an object to call back to when the display color temperature should be updated.
     *
     * @param callbacks
     *      The object to call back to.
@@ -201,7 +207,7 @@ public class DisplayWhiteBalanceController implements
     *
     * This is only applied when the ambient color temperature changes or is updated (in which case
     * it overrides the ambient color temperature estimate); in other words, it doesn't necessarily
     * change the screen color temperature immediately.
     * change the display color temperature immediately.
     *
     * @param ambientColorTemperatureOverride
     *      The ambient color temperature override.
@@ -240,9 +246,8 @@ public class DisplayWhiteBalanceController implements
        writer.println("  mLastAmbientColorTemperature=" + mLastAmbientColorTemperature);
        writer.println("  mAmbientColorTemperatureHistory=" + mAmbientColorTemperatureHistory);
        writer.println("  mAmbientColorTemperatureOverride=" + mAmbientColorTemperatureOverride);
        writer.println("  mAmbientToDisplayTemperatureSpline="
                + (mAmbientToDisplayTemperatureSpline == null ? "unused" :
                    mAmbientToDisplayTemperatureSpline));
        writer.println("  mAmbientToDisplayColorTemperatureSpline="
                + mAmbientToDisplayColorTemperatureSpline);
    }

    @Override // AmbientSensor.AmbientBrightnessSensor.Callbacks
@@ -266,9 +271,9 @@ public class DisplayWhiteBalanceController implements
        final long time = System.currentTimeMillis();
        float ambientColorTemperature = mColorTemperatureFilter.getEstimate(time);

        if (mAmbientToDisplayTemperatureSpline != null) {
        if (mAmbientToDisplayColorTemperatureSpline != null) {
            ambientColorTemperature =
                mAmbientToDisplayTemperatureSpline.interpolate(ambientColorTemperature);
                mAmbientToDisplayColorTemperatureSpline.interpolate(ambientColorTemperature);
        }

        final float ambientBrightness = mBrightnessFilter.getEstimate(time);
@@ -290,7 +295,7 @@ public class DisplayWhiteBalanceController implements
            ambientColorTemperature = mAmbientColorTemperatureOverride;
        }

        // When the screen color temperature needs to be updated, we call DisplayPowerController to
        // When the display color temperature needs to be updated, we call DisplayPowerController to
        // call our updateColorTemperature. The reason we don't call it directly is that we want
        // all changes to the system to happen in a predictable order in DPC's main loop
        // (updatePowerState).
@@ -308,9 +313,9 @@ public class DisplayWhiteBalanceController implements
    }

    /**
     * Updates the screen color temperature.
     * Updates the display color temperature.
     */
    public void updateScreenColorTemperature() {
    public void updateDisplayColorTemperature() {
        float ambientColorTemperature = -1.0f;

        // If both the pending and the current ambient color temperatures are -1, it means the DWBC
@@ -353,7 +358,7 @@ public class DisplayWhiteBalanceController implements
         * Called whenever the display white-balance state has changed.
         *
         * Usually, this means the estimated ambient color temperature has changed enough, and the
         * screen color temperature should be updated; but it is also called by
         * display color temperature should be updated; but it is also called if settings change.
         */
        void updateWhiteBalance();
    }
+5 −5
Original line number Diff line number Diff line
@@ -67,14 +67,14 @@ public class DisplayWhiteBalanceFactory {
        final float lowLightAmbientColorTemperature = getFloat(resources,
                com.android.internal.R.dimen
                .config_displayWhiteBalanceLowLightAmbientColorTemperature);
        final float[] ambientTemperatures = getFloatArray(resources,
                com.android.internal.R.array.config_displayWhiteBalanceAmbientTemperatureValues);
        final float[] displayTemperatures = getFloatArray(resources,
                com.android.internal.R.array.config_displayWhiteBalanceDisplayTemperatureValues);
        final float[] ambientColorTemperatures = getFloatArray(resources,
                com.android.internal.R.array.config_displayWhiteBalanceAmbientColorTemperatures);
        final float[] displayColorTempeartures = getFloatArray(resources,
                com.android.internal.R.array.config_displayWhiteBalanceDisplayColorTemperatures);
        final DisplayWhiteBalanceController controller = new DisplayWhiteBalanceController(
                brightnessSensor, brightnessFilter, colorTemperatureSensor, colorTemperatureFilter,
                throttler, lowLightAmbientBrightnessThreshold, lowLightAmbientColorTemperature,
                ambientTemperatures, displayTemperatures);
                ambientColorTemperatures, displayColorTempeartures);
        brightnessSensor.setCallbacks(controller);
        colorTemperatureSensor.setCallbacks(controller);
        return controller;
Loading