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

Commit 5a5f28de authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Persist the nit brightness for the default display" into tm-qpr-dev am: 049f8dc0

parents 87ec2fc5 049f8dc0
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -6064,4 +6064,8 @@

    <!-- Whether to show weather on the lock screen by default. -->
    <bool name="config_lockscreenWeatherEnabledByDefault">false</bool>

    <!-- Whether we should persist the brightness value in nits for the default display even if
         the underlying display device changes. -->
    <bool name="config_persistBrightnessNitsForDefaultDisplay">false</bool>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -2275,6 +2275,7 @@
  <java-symbol type="bool" name="config_preventImeStartupUnlessTextEditor" />
  <java-symbol type="array" name="config_nonPreemptibleInputMethods" />
  <java-symbol type="bool" name="config_enhancedConfirmationModeEnabled" />
  <java-symbol type="bool" name="config_persistBrightnessNitsForDefaultDisplay" />

  <java-symbol type="layout" name="resolver_list" />
  <java-symbol type="id" name="resolver_list" />
+8 −0
Original line number Diff line number Diff line
@@ -1127,6 +1127,14 @@ class AutomaticBrightnessController {
        }
    }

    public float convertToFloatScale(float nits) {
        if (mCurrentBrightnessMapper != null) {
            return mCurrentBrightnessMapper.convertToFloatScale(nits);
        } else {
            return PowerManager.BRIGHTNESS_INVALID_FLOAT;
        }
    }

    public void recalculateSplines(boolean applyAdjustment, float[] adjustment) {
        mCurrentBrightnessMapper.recalculateSplines(applyAdjustment, adjustment);

+18 −0
Original line number Diff line number Diff line
@@ -321,6 +321,14 @@ public abstract class BrightnessMappingStrategy {
     */
    public abstract float convertToNits(float brightness);

    /**
     * Converts the provided nit value to a float scale value if possible.
     *
     * Returns {@link PowerManager.BRIGHTNESS_INVALID_FLOAT} if there's no available mapping for
     * the nits to float scale.
     */
    public abstract float convertToFloatScale(float nits);

    /**
     * Adds a user interaction data point to the brightness mapping.
     *
@@ -670,6 +678,11 @@ public abstract class BrightnessMappingStrategy {
            return -1.0f;
        }

        @Override
        public float convertToFloatScale(float nits) {
            return PowerManager.BRIGHTNESS_INVALID_FLOAT;
        }

        @Override
        public void addUserDataPoint(float lux, float brightness) {
            float unadjustedBrightness = getUnadjustedBrightness(lux);
@@ -912,6 +925,11 @@ public abstract class BrightnessMappingStrategy {
            return mBrightnessToNitsSpline.interpolate(brightness);
        }

        @Override
        public float convertToFloatScale(float nits) {
            return mNitsToBrightnessSpline.interpolate(nits);
        }

        @Override
        public void addUserDataPoint(float lux, float brightness) {
            float unadjustedBrightness = getUnadjustedBrightness(lux);
+17 −0
Original line number Diff line number Diff line
@@ -117,6 +117,23 @@ public class BrightnessSetting {
        }
    }

    /**
     * @return The brightness for the default display in nits. Used when the underlying display
     * device has changed but we want to persist the nit value.
     */
    float getBrightnessNitsForDefaultDisplay() {
        return mPersistentDataStore.getBrightnessNitsForDefaultDisplay();
    }

    /**
     * Set brightness in nits for the default display. Used when we want to persist the nit value
     * even if the underlying display device changes.
     * @param nits The brightness value in nits
     */
    void setBrightnessNitsForDefaultDisplay(float nits) {
        mPersistentDataStore.setBrightnessNitsForDefaultDisplay(nits);
    }

    private void notifyListeners(float brightness) {
        for (BrightnessSettingListener l : mListeners) {
            l.onBrightnessChanged(brightness);
Loading