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

Commit 144aac9d authored by Michael Wright's avatar Michael Wright
Browse files

Track brightness changes in nits rather than backlight values.

For the moment, the only one that actually knows the true brightness
value is the DisplayPowerController, so have that tell the
BrightnessTracker directly when brightness changes.

Bug: 69405990
Test: atest com.android.server.display.BrightnessTrackerTest
      atest com.android.server.display.BrightnessMappingStrategyTest

Change-Id: Ibf4e501ce2f7b071360bfac501dbbafb3ba55fa5
parent 8134c904
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.os.Parcelable;
 */
public final class BrightnessChangeEvent implements Parcelable {
    /** Brightness in nits */
    public int brightness;
    public float brightness;

    /** Timestamp of the change {@see System.currentTimeMillis()} */
    public long timeStamp;
@@ -58,7 +58,7 @@ public final class BrightnessChangeEvent implements Parcelable {
    public int colorTemperature;

    /** Brightness level before slider adjustment */
    public int lastBrightness;
    public float lastBrightness;

    public BrightnessChangeEvent() {
    }
@@ -78,7 +78,7 @@ public final class BrightnessChangeEvent implements Parcelable {
    }

    private BrightnessChangeEvent(Parcel source) {
        brightness = source.readInt();
        brightness = source.readFloat();
        timeStamp = source.readLong();
        packageName = source.readString();
        userId = source.readInt();
@@ -87,7 +87,7 @@ public final class BrightnessChangeEvent implements Parcelable {
        batteryLevel = source.readFloat();
        nightMode = source.readBoolean();
        colorTemperature = source.readInt();
        lastBrightness = source.readInt();
        lastBrightness = source.readFloat();
    }

    public static final Creator<BrightnessChangeEvent> CREATOR =
@@ -107,7 +107,7 @@ public final class BrightnessChangeEvent implements Parcelable {

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(brightness);
        dest.writeFloat(brightness);
        dest.writeLong(timeStamp);
        dest.writeString(packageName);
        dest.writeInt(userId);
@@ -116,6 +116,6 @@ public final class BrightnessChangeEvent implements Parcelable {
        dest.writeFloat(batteryLevel);
        dest.writeBoolean(nightMode);
        dest.writeInt(colorTemperature);
        dest.writeInt(lastBrightness);
        dest.writeFloat(lastBrightness);
    }
}
+0 −7
Original line number Diff line number Diff line
@@ -627,13 +627,6 @@ public final class DisplayManager {
        return mGlobal.getBrightnessEvents(mContext.getOpPackageName());
    }

    /**
     * @hide STOPSHIP - remove when adaptive brightness accepts curves.
     */
    public void setBrightness(int brightness) {
        mGlobal.setBrightness(brightness);
    }

    /**
     * Sets the global display brightness configuration.
     *
+0 −12
Original line number Diff line number Diff line
@@ -475,18 +475,6 @@ public final class DisplayManagerGlobal {
        }
    }

    /**
     * Set brightness but don't add a BrightnessChangeEvent
     * STOPSHIP remove when adaptive brightness accepts curves.
     */
    public void setBrightness(int brightness) {
        try {
            mDm.setBrightness(brightness);
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Sets the global brightness configuration for a given user.
     *
+8 −0
Original line number Diff line number Diff line
@@ -222,6 +222,11 @@ public abstract class DisplayManagerInternal {
        // set by the user as opposed to being programmatically controlled by apps.
        public boolean brightnessSetByUser;

        // Set to true if screenBrightness or screenAutoBrightnessAdjustment are being set
        // temporarily. This is typically set while the user has their finger on the brightness
        // control, before they've selected the final brightness value.
        public boolean brightnessIsTemporary;

        // If true, enables automatic brightness control.
        public boolean useAutoBrightness;

@@ -280,6 +285,7 @@ public abstract class DisplayManagerInternal {
            screenAutoBrightnessAdjustment = other.screenAutoBrightnessAdjustment;
            screenLowPowerBrightnessFactor = other.screenLowPowerBrightnessFactor;
            brightnessSetByUser = other.brightnessSetByUser;
            brightnessIsTemporary = other.brightnessIsTemporary;
            useAutoBrightness = other.useAutoBrightness;
            blockScreenOn = other.blockScreenOn;
            lowPowerMode = other.lowPowerMode;
@@ -303,6 +309,7 @@ public abstract class DisplayManagerInternal {
                    && screenLowPowerBrightnessFactor
                    == other.screenLowPowerBrightnessFactor
                    && brightnessSetByUser == other.brightnessSetByUser
                    && brightnessIsTemporary == other.brightnessIsTemporary
                    && useAutoBrightness == other.useAutoBrightness
                    && blockScreenOn == other.blockScreenOn
                    && lowPowerMode == other.lowPowerMode
@@ -324,6 +331,7 @@ public abstract class DisplayManagerInternal {
                    + ", screenAutoBrightnessAdjustment=" + screenAutoBrightnessAdjustment
                    + ", screenLowPowerBrightnessFactor=" + screenLowPowerBrightnessFactor
                    + ", brightnessSetByUser=" + brightnessSetByUser
                    + ", brightnessIsTemporary=" + brightnessIsTemporary
                    + ", useAutoBrightness=" + useAutoBrightness
                    + ", blockScreenOn=" + blockScreenOn
                    + ", lowPowerMode=" + lowPowerMode
+0 −4
Original line number Diff line number Diff line
@@ -87,10 +87,6 @@ interface IDisplayManager {
    // Requires BRIGHTNESS_SLIDER_USAGE permission.
    ParceledListSlice getBrightnessEvents(String callingPackage);

    // STOPSHIP remove when adaptive brightness code is updated to accept curves.
    // Requires BRIGHTNESS_SLIDER_USAGE permission.
    void setBrightness(int brightness);

    // Sets the global brightness configuration for a given user. Requires
    // CONFIGURE_DISPLAY_BRIGHTNESS, and INTERACT_ACROSS_USER if the user being configured is not
    // the same as the calling user.
Loading