Merge "Log slider events from DPC." into tm-qpr-dev am: 78e321e038

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19559990

Change-Id: I69c9411fcfe64d5bbf5dad997527f0f8c5d6095d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Silvia Vinyes
2022-08-24 13:00:19 +00:00
committed by Automerger Merge Worker
3 changed files with 133 additions and 15 deletions

View File

@@ -148,6 +148,12 @@ class AutomaticBrightnessController {
// The currently accepted nominal ambient light level. // The currently accepted nominal ambient light level.
private float mAmbientLux; private float mAmbientLux;
// The last calculated ambient light level (long time window).
private float mSlowAmbientLux;
// The last calculated ambient light level (short time window).
private float mFastAmbientLux;
// The last ambient lux value prior to passing the darkening or brightening threshold. // The last ambient lux value prior to passing the darkening or brightening threshold.
private float mPreThresholdLux; private float mPreThresholdLux;
@@ -439,6 +445,14 @@ class AutomaticBrightnessController {
return mAmbientLux; return mAmbientLux;
} }
float getSlowAmbientLux() {
return mSlowAmbientLux;
}
float getFastAmbientLux() {
return mFastAmbientLux;
}
private boolean setDisplayPolicy(int policy) { private boolean setDisplayPolicy(int policy) {
if (mDisplayPolicy == policy) { if (mDisplayPolicy == policy) {
return false; return false;
@@ -811,20 +825,20 @@ class AutomaticBrightnessController {
// proposed ambient light value since the slow value might be sufficiently far enough away // proposed ambient light value since the slow value might be sufficiently far enough away
// from the fast value to cause a recalculation while its actually just converging on // from the fast value to cause a recalculation while its actually just converging on
// the fast value still. // the fast value still.
float slowAmbientLux = calculateAmbientLux(time, mAmbientLightHorizonLong); mSlowAmbientLux = calculateAmbientLux(time, mAmbientLightHorizonLong);
float fastAmbientLux = calculateAmbientLux(time, mAmbientLightHorizonShort); mFastAmbientLux = calculateAmbientLux(time, mAmbientLightHorizonShort);
if ((slowAmbientLux >= mAmbientBrighteningThreshold if ((mSlowAmbientLux >= mAmbientBrighteningThreshold
&& fastAmbientLux >= mAmbientBrighteningThreshold && mFastAmbientLux >= mAmbientBrighteningThreshold
&& nextBrightenTransition <= time) && nextBrightenTransition <= time)
|| (slowAmbientLux <= mAmbientDarkeningThreshold || (mSlowAmbientLux <= mAmbientDarkeningThreshold
&& fastAmbientLux <= mAmbientDarkeningThreshold && mFastAmbientLux <= mAmbientDarkeningThreshold
&& nextDarkenTransition <= time)) { && nextDarkenTransition <= time)) {
mPreThresholdLux = mAmbientLux; mPreThresholdLux = mAmbientLux;
setAmbientLux(fastAmbientLux); setAmbientLux(mFastAmbientLux);
if (mLoggingEnabled) { if (mLoggingEnabled) {
Slog.d(TAG, "updateAmbientLux: " Slog.d(TAG, "updateAmbientLux: "
+ ((fastAmbientLux > mAmbientLux) ? "Brightened" : "Darkened") + ": " + ((mFastAmbientLux > mAmbientLux) ? "Brightened" : "Darkened") + ": "
+ "mBrighteningLuxThreshold=" + mAmbientBrighteningThreshold + ", " + "mBrighteningLuxThreshold=" + mAmbientBrighteningThreshold + ", "
+ "mAmbientLightRingBuffer=" + mAmbientLightRingBuffer + ", " + "mAmbientLightRingBuffer=" + mAmbientLightRingBuffer + ", "
+ "mAmbientLux=" + mAmbientLux); + "mAmbientLux=" + mAmbientLux);

View File

@@ -1629,7 +1629,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
mTempBrightnessEvent.reason.set(mBrightnessReason); mTempBrightnessEvent.reason.set(mBrightnessReason);
mTempBrightnessEvent.hbmMax = mHbmController.getCurrentBrightnessMax(); mTempBrightnessEvent.hbmMax = mHbmController.getCurrentBrightnessMax();
mTempBrightnessEvent.hbmMode = mHbmController.getHighBrightnessMode(); mTempBrightnessEvent.hbmMode = mHbmController.getHighBrightnessMode();
mTempBrightnessEvent.flags |= (mIsRbcActive ? BrightnessEvent.FLAG_RBC : 0); mTempBrightnessEvent.flags = (mTempBrightnessEvent.flags
| (mIsRbcActive ? BrightnessEvent.FLAG_RBC : 0)
| (mPowerRequest.lowPowerMode ? BrightnessEvent.FLAG_LOW_POWER_MODE : 0));
mTempBrightnessEvent.physicalDisplayId = mUniqueDisplayId;
mTempBrightnessEvent.rbcStrength = mCdsi != null
? mCdsi.getReduceBrightColorsStrength() : -1;
mTempBrightnessEvent.powerFactor = mPowerRequest.screenLowPowerBrightnessFactor;
// Temporary is what we use during slider interactions. We avoid logging those so that // Temporary is what we use during slider interactions. We avoid logging those so that
// we don't spam logcat when the slider is being used. // we don't spam logcat when the slider is being used.
boolean tempToTempTransition = boolean tempToTempTransition =
@@ -1637,6 +1644,15 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
&& mLastBrightnessEvent.reason.reason == BrightnessReason.REASON_TEMPORARY; && mLastBrightnessEvent.reason.reason == BrightnessReason.REASON_TEMPORARY;
if ((!mTempBrightnessEvent.equalsMainData(mLastBrightnessEvent) && !tempToTempTransition) if ((!mTempBrightnessEvent.equalsMainData(mLastBrightnessEvent) && !tempToTempTransition)
|| brightnessAdjustmentFlags != 0) { || brightnessAdjustmentFlags != 0) {
float lastBrightness = mLastBrightnessEvent.brightness;
mTempBrightnessEvent.initialBrightness = lastBrightness;
mTempBrightnessEvent.fastAmbientLux =
mAutomaticBrightnessController == null
? -1f : mAutomaticBrightnessController.getFastAmbientLux();
mTempBrightnessEvent.slowAmbientLux =
mAutomaticBrightnessController == null
? -1f : mAutomaticBrightnessController.getSlowAmbientLux();
mTempBrightnessEvent.automaticBrightnessEnabled = mPowerRequest.useAutoBrightness;
mLastBrightnessEvent.copyFrom(mTempBrightnessEvent); mLastBrightnessEvent.copyFrom(mTempBrightnessEvent);
BrightnessEvent newEvent = new BrightnessEvent(mTempBrightnessEvent); BrightnessEvent newEvent = new BrightnessEvent(mTempBrightnessEvent);
@@ -1646,6 +1662,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
newEvent.flags |= (userSetBrightnessChanged ? BrightnessEvent.FLAG_USER_SET : 0); newEvent.flags |= (userSetBrightnessChanged ? BrightnessEvent.FLAG_USER_SET : 0);
Slog.i(TAG, newEvent.toString(/* includeTime= */ false)); Slog.i(TAG, newEvent.toString(/* includeTime= */ false));
if (userSetBrightnessChanged) {
logManualBrightnessEvent(newEvent);
}
if (mBrightnessEventRingBuffer != null) { if (mBrightnessEventRingBuffer != null) {
mBrightnessEventRingBuffer.append(newEvent); mBrightnessEventRingBuffer.append(newEvent);
} }
@@ -2736,27 +2755,63 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
} }
} }
private void logManualBrightnessEvent(BrightnessEvent event) {
float appliedHbmMaxNits =
event.hbmMode == BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF
? -1f : convertToNits(event.hbmMax);
// thermalCapNits set to -1 if not currently capping max brightness
float appliedThermalCapNits =
event.thermalMax == PowerManager.BRIGHTNESS_MAX
? -1f : convertToNits(event.thermalMax);
int appliedRbcStrength = event.isRbcEnabled() ? event.rbcStrength : -1;
float appliedPowerFactor = event.isLowPowerModeSet() ? event.powerFactor : -1f;
FrameworkStatsLog.write(FrameworkStatsLog.DISPLAY_BRIGHTNESS_CHANGED,
convertToNits(event.initialBrightness),
convertToNits(event.brightness),
event.slowAmbientLux,
event.physicalDisplayId,
event.isShortTermModelActive(),
appliedPowerFactor,
appliedRbcStrength,
appliedHbmMaxNits,
appliedThermalCapNits,
event.automaticBrightnessEnabled,
FrameworkStatsLog.DISPLAY_BRIGHTNESS_CHANGED__REASON__REASON_MANUAL);
}
class BrightnessEvent { class BrightnessEvent {
static final int FLAG_RBC = 0x1; static final int FLAG_RBC = 0x1;
static final int FLAG_INVALID_LUX = 0x2; static final int FLAG_INVALID_LUX = 0x2;
static final int FLAG_DOZE_SCALE = 0x4; static final int FLAG_DOZE_SCALE = 0x4;
static final int FLAG_USER_SET = 0x8; static final int FLAG_USER_SET = 0x8;
static final int FLAG_IDLE_CURVE = 0x16; static final int FLAG_IDLE_CURVE = 0x10;
static final int FLAG_LOW_POWER_MODE = 0x20;
public final BrightnessReason reason = new BrightnessReason(); public final BrightnessReason reason = new BrightnessReason();
public int displayId; public int displayId;
public String physicalDisplayId;
public float lux; public float lux;
public float fastAmbientLux;
public float slowAmbientLux;
public float preThresholdLux; public float preThresholdLux;
public long time; public long time;
public float brightness; public float brightness;
public float initialBrightness;
public float recommendedBrightness; public float recommendedBrightness;
public float preThresholdBrightness; public float preThresholdBrightness;
public float hbmMax; public float hbmMax;
public int rbcStrength;
public float thermalMax; public float thermalMax;
public float powerFactor;
public int hbmMode; public int hbmMode;
public int flags; public int flags;
public int adjustmentFlags; public int adjustmentFlags;
public boolean automaticBrightnessEnabled;
BrightnessEvent(BrightnessEvent that) { BrightnessEvent(BrightnessEvent that) {
copyFrom(that); copyFrom(that);
@@ -2769,71 +2824,115 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
void copyFrom(BrightnessEvent that) { void copyFrom(BrightnessEvent that) {
displayId = that.displayId; displayId = that.displayId;
physicalDisplayId = that.physicalDisplayId;
time = that.time; time = that.time;
lux = that.lux; lux = that.lux;
fastAmbientLux = that.fastAmbientLux;
slowAmbientLux = that.slowAmbientLux;
preThresholdLux = that.preThresholdLux; preThresholdLux = that.preThresholdLux;
brightness = that.brightness; brightness = that.brightness;
initialBrightness = that.initialBrightness;
recommendedBrightness = that.recommendedBrightness; recommendedBrightness = that.recommendedBrightness;
preThresholdBrightness = that.preThresholdBrightness; preThresholdBrightness = that.preThresholdBrightness;
hbmMax = that.hbmMax; hbmMax = that.hbmMax;
rbcStrength = that.rbcStrength;
thermalMax = that.thermalMax; thermalMax = that.thermalMax;
powerFactor = that.powerFactor;
flags = that.flags; flags = that.flags;
hbmMode = that.hbmMode; hbmMode = that.hbmMode;
reason.set(that.reason); reason.set(that.reason);
adjustmentFlags = that.adjustmentFlags; adjustmentFlags = that.adjustmentFlags;
automaticBrightnessEnabled = that.automaticBrightnessEnabled;
} }
void reset() { void reset() {
time = SystemClock.uptimeMillis(); time = SystemClock.uptimeMillis();
physicalDisplayId = "";
brightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; brightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
initialBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
recommendedBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; recommendedBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
lux = 0; lux = 0f;
preThresholdLux = 0; fastAmbientLux = 0f;
slowAmbientLux = 0f;
preThresholdLux = 0f;
preThresholdBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT; preThresholdBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
hbmMax = PowerManager.BRIGHTNESS_MAX; hbmMax = PowerManager.BRIGHTNESS_MAX;
rbcStrength = 0;
powerFactor = 1f;
thermalMax = PowerManager.BRIGHTNESS_MAX; thermalMax = PowerManager.BRIGHTNESS_MAX;
flags = 0; flags = 0;
hbmMode = BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF; hbmMode = BrightnessInfo.HIGH_BRIGHTNESS_MODE_OFF;
reason.set(null); reason.set(null);
adjustmentFlags = 0; adjustmentFlags = 0;
automaticBrightnessEnabled = true;
}
boolean isRbcEnabled() {
return (flags & FLAG_RBC) != 0;
}
public boolean isShortTermModelActive() {
return (flags & FLAG_USER_SET) != 0;
}
public boolean isLowPowerModeSet() {
return (flags & FLAG_LOW_POWER_MODE) != 0;
} }
boolean equalsMainData(BrightnessEvent that) { boolean equalsMainData(BrightnessEvent that) {
// This equals comparison purposefully ignores time since it is regularly changing and // This equals comparison purposefully ignores time since it is regularly changing and
// we don't want to log a brightness event just because the time changed. // we don't want to log a brightness event just because the time changed.
return displayId == that.displayId return displayId == that.displayId
&& physicalDisplayId.equals(that.physicalDisplayId)
&& Float.floatToRawIntBits(brightness) && Float.floatToRawIntBits(brightness)
== Float.floatToRawIntBits(that.brightness) == Float.floatToRawIntBits(that.brightness)
&& Float.floatToRawIntBits(initialBrightness)
== Float.floatToRawIntBits(that.initialBrightness)
&& Float.floatToRawIntBits(recommendedBrightness) && Float.floatToRawIntBits(recommendedBrightness)
== Float.floatToRawIntBits(that.recommendedBrightness) == Float.floatToRawIntBits(that.recommendedBrightness)
&& Float.floatToRawIntBits(preThresholdBrightness) && Float.floatToRawIntBits(preThresholdBrightness)
== Float.floatToRawIntBits(that.preThresholdBrightness) == Float.floatToRawIntBits(that.preThresholdBrightness)
&& Float.floatToRawIntBits(lux) == Float.floatToRawIntBits(that.lux) && Float.floatToRawIntBits(lux) == Float.floatToRawIntBits(that.lux)
&& Float.floatToRawIntBits(fastAmbientLux)
== Float.floatToRawIntBits(that.fastAmbientLux)
&& Float.floatToRawIntBits(slowAmbientLux)
== Float.floatToRawIntBits(that.slowAmbientLux)
&& Float.floatToRawIntBits(preThresholdLux) && Float.floatToRawIntBits(preThresholdLux)
== Float.floatToRawIntBits(that.preThresholdLux) == Float.floatToRawIntBits(that.preThresholdLux)
&& rbcStrength == that.rbcStrength
&& Float.floatToRawIntBits(hbmMax) == Float.floatToRawIntBits(that.hbmMax) && Float.floatToRawIntBits(hbmMax) == Float.floatToRawIntBits(that.hbmMax)
&& hbmMode == that.hbmMode && hbmMode == that.hbmMode
&& Float.floatToRawIntBits(thermalMax) && Float.floatToRawIntBits(thermalMax)
== Float.floatToRawIntBits(that.thermalMax) == Float.floatToRawIntBits(that.thermalMax)
&& Float.floatToRawIntBits(powerFactor)
== Float.floatToRawIntBits(that.powerFactor)
&& flags == that.flags && flags == that.flags
&& adjustmentFlags == that.adjustmentFlags && adjustmentFlags == that.adjustmentFlags
&& reason.equals(that.reason); && reason.equals(that.reason)
&& automaticBrightnessEnabled == that.automaticBrightnessEnabled;
} }
public String toString(boolean includeTime) { public String toString(boolean includeTime) {
return (includeTime ? TimeUtils.formatForLogging(time) + " - " : "") return (includeTime ? TimeUtils.formatForLogging(time) + " - " : "")
+ "BrightnessEvent: " + "BrightnessEvent: "
+ "disp=" + displayId + "disp=" + displayId
+ ", physDisp=" + physicalDisplayId
+ ", brt=" + brightness + ((flags & FLAG_USER_SET) != 0 ? "(user_set)" : "") + ", brt=" + brightness + ((flags & FLAG_USER_SET) != 0 ? "(user_set)" : "")
+ ", initBrt=" + initialBrightness
+ ", rcmdBrt=" + recommendedBrightness + ", rcmdBrt=" + recommendedBrightness
+ ", preBrt=" + preThresholdBrightness + ", preBrt=" + preThresholdBrightness
+ ", lux=" + lux + ", lux=" + lux
+ ", fastAmbientLux=" + fastAmbientLux
+ ", slowAmbientLux=" + slowAmbientLux
+ ", preLux=" + preThresholdLux + ", preLux=" + preThresholdLux
+ ", hbmMax=" + hbmMax + ", hbmMax=" + hbmMax
+ ", hbmMode=" + BrightnessInfo.hbmToString(hbmMode) + ", hbmMode=" + BrightnessInfo.hbmToString(hbmMode)
+ ", rbcStrength=" + rbcStrength
+ ", powerFactor=" + powerFactor
+ ", thrmMax=" + thermalMax + ", thrmMax=" + thermalMax
+ ", flags=" + flagsToString() + ", flags=" + flagsToString()
+ ", reason=" + reason.toString(adjustmentFlags); + ", reason=" + reason.toString(adjustmentFlags)
+ ", autoBrightness=" + automaticBrightnessEnabled;
} }
@Override @Override
@@ -2846,7 +2945,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
+ ((flags & FLAG_RBC) != 0 ? "rbc " : "") + ((flags & FLAG_RBC) != 0 ? "rbc " : "")
+ ((flags & FLAG_INVALID_LUX) != 0 ? "invalid_lux " : "") + ((flags & FLAG_INVALID_LUX) != 0 ? "invalid_lux " : "")
+ ((flags & FLAG_DOZE_SCALE) != 0 ? "doze_scale " : "") + ((flags & FLAG_DOZE_SCALE) != 0 ? "doze_scale " : "")
+ ((flags & FLAG_DOZE_SCALE) != 0 ? "idle_curve " : ""); + ((flags & FLAG_IDLE_CURVE) != 0 ? "idle_curve " : "")
+ ((flags & FLAG_LOW_POWER_MODE) != 0 ? "low_power_mode " : "");
} }
} }

View File

@@ -1515,6 +1515,10 @@ public final class ColorDisplayService extends SystemService {
return mReduceBrightColorsTintController.isActivated(); return mReduceBrightColorsTintController.isActivated();
} }
public int getReduceBrightColorsStrength() {
return mReduceBrightColorsTintController.getStrength();
}
/** /**
* Gets the computed brightness, in nits, when the reduce bright colors feature is applied * Gets the computed brightness, in nits, when the reduce bright colors feature is applied
* at the current strength. * at the current strength.