From 3ad58186022a8ed919c9c68a9b18bab3af7c3632 Mon Sep 17 00:00:00 2001 From: Piotr WilczyƄski Date: Fri, 24 Feb 2023 15:53:36 +0000 Subject: Don't overlog BrightnessEvents - values for mTempBrightnessEvent should be set before comparing it to the last event - don't compare initialBrightness - it's the last brightness so comparing it will mean that we log every brightness change twice Bug: 268532189 Test: adb logcat | grep -i "brightnessEvent" Change-Id: Ibc57fea4a6ae32e082b7d0873ad63aebc6f92ae2 --- .../core/java/com/android/server/display/DisplayPowerController.java | 5 ++--- .../java/com/android/server/display/DisplayPowerController2.java | 5 ++--- .../java/com/android/server/display/brightness/BrightnessEvent.java | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 84fe8f21b764..537caf87f777 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -1868,6 +1868,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call ? mCdsi.getReduceBrightColorsStrength() : -1); mTempBrightnessEvent.setPowerFactor(mPowerRequest.screenLowPowerBrightnessFactor); mTempBrightnessEvent.setWasShortTermModelActive(wasShortTermModelActive); + mTempBrightnessEvent.setAutomaticBrightnessEnabled(mUseAutoBrightness); // 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. boolean tempToTempTransition = @@ -1876,9 +1877,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call == BrightnessReason.REASON_TEMPORARY; if ((!mTempBrightnessEvent.equalsMainData(mLastBrightnessEvent) && !tempToTempTransition) || brightnessAdjustmentFlags != 0) { - float lastBrightness = mLastBrightnessEvent.getBrightness(); - mTempBrightnessEvent.setInitialBrightness(lastBrightness); - mTempBrightnessEvent.setAutomaticBrightnessEnabled(mUseAutoBrightness); + mTempBrightnessEvent.setInitialBrightness(mLastBrightnessEvent.getBrightness()); mLastBrightnessEvent.copyFrom(mTempBrightnessEvent); BrightnessEvent newEvent = new BrightnessEvent(mTempBrightnessEvent); // Adjustment flags (and user-set flag) only get added after the equality checks since diff --git a/services/core/java/com/android/server/display/DisplayPowerController2.java b/services/core/java/com/android/server/display/DisplayPowerController2.java index 297a6f8a52e5..9e03194fba63 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController2.java +++ b/services/core/java/com/android/server/display/DisplayPowerController2.java @@ -1591,6 +1591,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mTempBrightnessEvent.setWasShortTermModelActive(wasShortTermModelActive); mTempBrightnessEvent.setDisplayBrightnessStrategyName(displayBrightnessState .getDisplayBrightnessStrategyName()); + mTempBrightnessEvent.setAutomaticBrightnessEnabled(mUseAutoBrightness); // 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. boolean tempToTempTransition = @@ -1599,9 +1600,7 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal == BrightnessReason.REASON_TEMPORARY; if ((!mTempBrightnessEvent.equalsMainData(mLastBrightnessEvent) && !tempToTempTransition) || brightnessAdjustmentFlags != 0) { - float lastBrightness = mLastBrightnessEvent.getBrightness(); - mTempBrightnessEvent.setInitialBrightness(lastBrightness); - mTempBrightnessEvent.setAutomaticBrightnessEnabled(mUseAutoBrightness); + mTempBrightnessEvent.setInitialBrightness(mLastBrightnessEvent.getBrightness()); mLastBrightnessEvent.copyFrom(mTempBrightnessEvent); BrightnessEvent newEvent = new BrightnessEvent(mTempBrightnessEvent); // Adjustment flags (and user-set flag) only get added after the equality checks since diff --git a/services/core/java/com/android/server/display/brightness/BrightnessEvent.java b/services/core/java/com/android/server/display/brightness/BrightnessEvent.java index aff80de0011d..a3bca9accb81 100644 --- a/services/core/java/com/android/server/display/brightness/BrightnessEvent.java +++ b/services/core/java/com/android/server/display/brightness/BrightnessEvent.java @@ -142,8 +142,6 @@ public final class BrightnessEvent { && Float.floatToRawIntBits(mLux) == Float.floatToRawIntBits(that.mLux) && Float.floatToRawIntBits(mPreThresholdLux) == Float.floatToRawIntBits(that.mPreThresholdLux) - && Float.floatToRawIntBits(mInitialBrightness) - == Float.floatToRawIntBits(that.mInitialBrightness) && Float.floatToRawIntBits(mBrightness) == Float.floatToRawIntBits(that.mBrightness) && Float.floatToRawIntBits(mRecommendedBrightness) -- cgit v1.2.3-59-g8ed1b