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

Commit 2a12547c authored by Christine Franks's avatar Christine Franks
Browse files

Update night display intensity coefficients

Bug: 63438695
Test: manual - adjust intensity slider
Change-Id: I38ec7385b36367e5c9f6c606e65a982efbd32a1b
parent 8a986629
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -893,6 +893,18 @@
    <!-- Maximum color temperature, in Kelvin, supported by Night display. -->
    <integer name="config_nightDisplayColorTemperatureMax">4082</integer>

    <string-array name="config_nightDisplayColorTemperatureCoefficients">
        <!-- R a-coefficient --> <item>0.0</item>
        <!-- R b-coefficient --> <item>0.0</item>
        <!-- R y-intercept --> <item>1.0</item>
        <!-- G a-coefficient --> <item>-0.00000000962353339</item>
        <!-- G b-coefficient --> <item>0.000153045476</item>
        <!-- G y-intercept --> <item>0.390782778</item>
        <!-- B a-coefficient --> <item>-0.0000000189359041</item>
        <!-- B b-coefficient --> <item>0.000302412211</item>
        <!-- B y-intercept --> <item>-0.198650895</item>
    </string-array>

    <!-- Indicate whether to allow the device to suspend when the screen is off
         due to the proximity sensor.  This resource should only be set to true
         if the sensor HAL correctly handles the proximity sensor as a wake-up source.
+1 −0
Original line number Diff line number Diff line
@@ -2820,6 +2820,7 @@
  <java-symbol type="integer" name="config_nightDisplayColorTemperatureDefault" />
  <java-symbol type="integer" name="config_nightDisplayColorTemperatureMin" />
  <java-symbol type="integer" name="config_nightDisplayColorTemperatureMax" />
  <java-symbol type="array" name="config_nightDisplayColorTemperatureCoefficients" />

  <!-- Default first user restrictions -->
  <java-symbol type="array" name="config_defaultFirstUserRestrictions" />
+12 −22
Original line number Diff line number Diff line
@@ -110,23 +110,7 @@ public final class NightDisplayService extends SystemService

    private float[] mMatrixNight = new float[16];

    /**
     *  These coefficients were generated by an LLS quadratic regression fitted to the
     *  overdetermined system based on experimental readings (and subsequent conversion from xy
     *  chromaticity coordinates to gamma-corrected RGB values): { (temperature, R, G, B) } ->
     *  { (7304, 1.0, 1.0, 1.0), (4082, 1.0, 0.857, 0.719), (2850, 1.0, .754, .516),
     *  (2596, 1.0, 0.722, 0.454) }. The 3x3 matrix is formatted like so:
     *  <table>
     *      <tr><td>R: a coefficient</td><td>G: a coefficient</td><td>B: a coefficient</td></tr>
     *      <tr><td>R: b coefficient</td><td>G: b coefficient</td><td>B: b coefficient</td></tr>
     *      <tr><td>R: y-intercept</td><td>G: y-intercept</td><td>B: y-intercept</td></tr>
     *  </table>
     */
    private static final float[] mColorTempCoefficients = new float[] {
            0.0f, -0.00000000962353339f, -0.0000000189359041f,
            0.0f, 0.000153045476f, 0.000302412211f,
            1.0f, 0.390782778f, -0.198650895f
    };
    private final float[] mColorTempCoefficients = new float[9];

    private int mCurrentUser = UserHandle.USER_NULL;
    private ContentObserver mUserSetupObserver;
@@ -140,6 +124,12 @@ public final class NightDisplayService extends SystemService
    public NightDisplayService(Context context) {
        super(context);
        mHandler = new Handler(Looper.getMainLooper());

        final String[] coefficients = context.getResources().getStringArray(
                com.android.internal.R.array.config_nightDisplayColorTemperatureCoefficients);
        for (int i = 0; i < 9 && i < coefficients.length; i++) {
            mColorTempCoefficients[i] = Float.parseFloat(coefficients[i]);
        }
    }

    @Override
@@ -414,11 +404,11 @@ public final class NightDisplayService extends SystemService

        final float squareTemperature = colorTemperature * colorTemperature;
        final float red = squareTemperature * mColorTempCoefficients[0]
                + colorTemperature * mColorTempCoefficients[3] + mColorTempCoefficients[6];
        final float green = squareTemperature * mColorTempCoefficients[1]
                + colorTemperature * mColorTempCoefficients[4] + mColorTempCoefficients[7];
        final float blue = squareTemperature * mColorTempCoefficients[2]
                + colorTemperature * mColorTempCoefficients[5] + mColorTempCoefficients[8];
                + colorTemperature * mColorTempCoefficients[1] + mColorTempCoefficients[2];
        final float green = squareTemperature * mColorTempCoefficients[3]
                + colorTemperature * mColorTempCoefficients[4] + mColorTempCoefficients[5];
        final float blue = squareTemperature * mColorTempCoefficients[6]
                + colorTemperature * mColorTempCoefficients[7] + mColorTempCoefficients[8];
        outTemp[0] = red;
        outTemp[5] = green;
        outTemp[10] = blue;