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

Commit 667cf72a authored by Piotr Wilczyński's avatar Piotr Wilczyński
Browse files

Log display policy in BrightnessEvent

Bug: 327372564
Test: atest BrightnessEventTest
Change-Id: Icb935c767adeb30db20012d0aac14cde53a1278a
parent 12e0eee1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1724,6 +1724,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        mTempBrightnessEvent.setBrightness(brightnessState);
        mTempBrightnessEvent.setPhysicalDisplayId(mUniqueDisplayId);
        mTempBrightnessEvent.setDisplayState(state);
        mTempBrightnessEvent.setDisplayPolicy(mPowerRequest.policy);
        mTempBrightnessEvent.setReason(mBrightnessReason);
        mTempBrightnessEvent.setHbmMax(mBrightnessRangeController.getCurrentBrightnessMax());
        mTempBrightnessEvent.setHbmMode(mBrightnessRangeController.getHighBrightnessMode());
+12 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.server.display.brightness;

import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_OFF;
import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.policyToString;

import static com.android.server.display.AutomaticBrightnessController.AUTO_BRIGHTNESS_MODE_DEFAULT;
import static com.android.server.display.config.DisplayBrightnessMappingConfig.autoBrightnessModeToString;

@@ -46,6 +49,7 @@ public final class BrightnessEvent {
    private int mDisplayId;
    private String mPhysicalDisplayId;
    private int mDisplayState;
    private int mDisplayPolicy;
    private long mTime;
    private float mLux;
    private float mPreThresholdLux;
@@ -85,6 +89,7 @@ public final class BrightnessEvent {
        mDisplayId = that.getDisplayId();
        mPhysicalDisplayId = that.getPhysicalDisplayId();
        mDisplayState = that.mDisplayState;
        mDisplayPolicy = that.mDisplayPolicy;
        mTime = that.getTime();
        // Lux values
        mLux = that.getLux();
@@ -117,6 +122,7 @@ public final class BrightnessEvent {
        mTime = SystemClock.uptimeMillis();
        mPhysicalDisplayId = "";
        mDisplayState = Display.STATE_UNKNOWN;
        mDisplayPolicy = POLICY_OFF;
        // Lux values
        mLux = 0;
        mPreThresholdLux = 0;
@@ -155,6 +161,7 @@ public final class BrightnessEvent {
                && mDisplayId == that.mDisplayId
                && mPhysicalDisplayId.equals(that.mPhysicalDisplayId)
                && mDisplayState == that.mDisplayState
                && mDisplayPolicy == that.mDisplayPolicy
                && Float.floatToRawIntBits(mLux) == Float.floatToRawIntBits(that.mLux)
                && Float.floatToRawIntBits(mPreThresholdLux)
                == Float.floatToRawIntBits(that.mPreThresholdLux)
@@ -191,6 +198,7 @@ public final class BrightnessEvent {
                + "disp=" + mDisplayId
                + ", physDisp=" + mPhysicalDisplayId
                + ", displayState=" + Display.stateToString(mDisplayState)
                + ", displayPolicy=" + policyToString(mDisplayPolicy)
                + ", brt=" + mBrightness + ((mFlags & FLAG_USER_SET) != 0 ? "(user_set)" : "")
                + ", initBrt=" + mInitialBrightness
                + ", rcmdBrt=" + mRecommendedBrightness
@@ -251,6 +259,10 @@ public final class BrightnessEvent {
        mDisplayState = state;
    }

    public void setDisplayPolicy(int policy) {
        mDisplayPolicy = policy;
    }

    public float getLux() {
        return mLux;
    }
+9 −5
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.display.brightness;

import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_BRIGHT;

import static com.android.server.display.AutomaticBrightnessController.AUTO_BRIGHTNESS_MODE_IDLE;

import static org.junit.Assert.assertEquals;
@@ -43,6 +45,7 @@ public final class BrightnessEventTest {
                getReason(BrightnessReason.REASON_DOZE, BrightnessReason.MODIFIER_LOW_POWER));
        mBrightnessEvent.setPhysicalDisplayId("test");
        mBrightnessEvent.setDisplayState(Display.STATE_ON);
        mBrightnessEvent.setDisplayPolicy(POLICY_BRIGHT);
        mBrightnessEvent.setLux(100.0f);
        mBrightnessEvent.setPreThresholdLux(150.0f);
        mBrightnessEvent.setTime(System.currentTimeMillis());
@@ -74,11 +77,12 @@ public final class BrightnessEventTest {
    public void testToStringWorksAsExpected() {
        String actualString = mBrightnessEvent.toString(false);
        String expectedString =
                "BrightnessEvent: disp=1, physDisp=test, displayState=ON, brt=0.6, initBrt=25.0,"
                + " rcmdBrt=0.6, preBrt=NaN, lux=100.0, preLux=150.0, hbmMax=0.62, hbmMode=off,"
                + " rbcStrength=-1, thrmMax=0.65, powerFactor=0.2, wasShortTermModelActive=true,"
                + " flags=, reason=doze [ low_pwr ], autoBrightness=true, strategy="
                        + DISPLAY_BRIGHTNESS_STRATEGY_NAME + ", autoBrightnessMode=idle";
                "BrightnessEvent: disp=1, physDisp=test, displayState=ON, displayPolicy=BRIGHT,"
                + " brt=0.6, initBrt=25.0, rcmdBrt=0.6, preBrt=NaN, lux=100.0, preLux=150.0,"
                + " hbmMax=0.62, hbmMode=off, rbcStrength=-1, thrmMax=0.65, powerFactor=0.2,"
                + " wasShortTermModelActive=true, flags=, reason=doze [ low_pwr ],"
                + " autoBrightness=true, strategy=" + DISPLAY_BRIGHTNESS_STRATEGY_NAME
                + ", autoBrightnessMode=idle";
        assertEquals(expectedString, actualString);
    }