Loading services/core/java/com/android/server/EventLogTags.logtags +1 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ option java_package com.android.server # DisplayManagerService.java # --------------------------- # Auto-brightness adjustments by the user. 35000 auto_brightness_adj (old_adj|5),(old_lux|5),(old_brightness|5),(old_gamma|5),(new_adj|5),(new_lux|5),(new_brightness|5),(new_gamma|5) 35000 auto_brightness_adj (old_lux|5),(old_brightness|5),(new_lux|5),(new_brightness|5) # --------------------------- # ConnectivityService.java Loading services/core/java/com/android/server/display/AutomaticBrightnessController.java +36 −88 Original line number Diff line number Diff line Loading @@ -169,16 +169,6 @@ class AutomaticBrightnessController { // Use -1 if there is no current auto-brightness value available. private int mScreenAutoBrightness = -1; // The screen auto-brightness adjustment factor in the range -1 (dimmer) to 1 (brighter) private float mScreenAutoBrightnessAdjustment = 0.0f; // The maximum range of gamma adjustment possible using the screen // auto-brightness adjustment setting. private float mScreenAutoBrightnessAdjustmentMaxGamma; // The last screen auto-brightness gamma. (For printing in dump() only.) private float mLastScreenAutoBrightnessGamma = 1.0f; // The current display policy. This is useful, for example, for knowing when we're dozing, // where the light sensor may not be available. private int mDisplayPolicy = DisplayPowerRequest.POLICY_OFF; Loading @@ -186,10 +176,8 @@ class AutomaticBrightnessController { // True if we are collecting a brightness adjustment sample, along with some data // for the initial state of the sample. private boolean mBrightnessAdjustmentSamplePending; private float mBrightnessAdjustmentSampleOldAdjustment; private float mBrightnessAdjustmentSampleOldLux; private int mBrightnessAdjustmentSampleOldBrightness; private float mBrightnessAdjustmentSampleOldGamma; // When the short term model is invalidated, we don't necessarily reset it (i.e. clear the // user's adjustment) immediately, but wait for a drastic enough change in the ambient light. Loading @@ -200,12 +188,11 @@ class AutomaticBrightnessController { private float SHORT_TERM_MODEL_THRESHOLD_RATIO = 0.6f; public AutomaticBrightnessController(Callbacks callbacks, Looper looper, SensorManager sensorManager, BrightnessMappingStrategy mapper, int lightSensorWarmUpTime, int brightnessMin, int brightnessMax, float dozeScaleFactor, SensorManager sensorManager, BrightnessMappingStrategy mapper, int lightSensorWarmUpTime, int brightnessMin, int brightnessMax, float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, int ambientLightHorizon, float autoBrightnessAdjustmentMaxGamma, HysteresisLevels dynamicHysteresis) { int ambientLightHorizon, HysteresisLevels dynamicHysteresis) { mCallbacks = callbacks; mSensorManager = sensorManager; mBrightnessMapper = mapper; Loading @@ -221,7 +208,6 @@ class AutomaticBrightnessController { mResetAmbientLuxAfterWarmUpConfig = resetAmbientLuxAfterWarmUpConfig; mAmbientLightHorizon = ambientLightHorizon; mWeightingIntercept = ambientLightHorizon; mScreenAutoBrightnessAdjustmentMaxGamma = autoBrightnessAdjustmentMaxGamma; mDynamicHysteresis = dynamicHysteresis; mShortTermModelValid = true; mShortTermModelAnchor = -1; Loading @@ -243,7 +229,7 @@ class AutomaticBrightnessController { } public float getAutomaticScreenBrightnessAdjustment() { return mScreenAutoBrightnessAdjustment; return mBrightnessMapper.getAutoBrightnessAdjustment(); } public void configure(boolean enable, @Nullable BrightnessConfiguration configuration, Loading @@ -257,7 +243,9 @@ class AutomaticBrightnessController { boolean dozing = (displayPolicy == DisplayPowerRequest.POLICY_DOZE); boolean changed = setBrightnessConfiguration(configuration); changed |= setDisplayPolicy(displayPolicy); changed |= setScreenAutoBrightnessAdjustment(adjustment); if (userChangedAutoBrightnessAdjustment) { changed |= setAutoBrightnessAdjustment(adjustment); } if (userChangedBrightness && enable) { // Update the brightness curve with the new user control point. It's critical this // happens after we update the autobrightness adjustment since it may reset it. Loading Loading @@ -322,9 +310,6 @@ class AutomaticBrightnessController { if (DEBUG) { Slog.d(TAG, "ShortTermModel: anchor=" + mShortTermModelAnchor); } // Reset the brightness adjustment so that the next time we're queried for brightness we // return the value the user set. mScreenAutoBrightnessAdjustment = 0.0f; return true; } Loading Loading @@ -369,10 +354,6 @@ class AutomaticBrightnessController { pw.println(" mRecentLightSamples=" + mRecentLightSamples); pw.println(" mAmbientLightRingBuffer=" + mAmbientLightRingBuffer); pw.println(" mScreenAutoBrightness=" + mScreenAutoBrightness); pw.println(" mScreenAutoBrightnessAdjustment=" + mScreenAutoBrightnessAdjustment); pw.println(" mScreenAutoBrightnessAdjustmentMaxGamma=" + mScreenAutoBrightnessAdjustmentMaxGamma); pw.println(" mLastScreenAutoBrightnessGamma=" + mLastScreenAutoBrightnessGamma); pw.println(" mDisplayPolicy=" + mDisplayPolicy); pw.println(" mShortTermModelAnchor=" + mShortTermModelAnchor); Loading Loading @@ -439,12 +420,8 @@ class AutomaticBrightnessController { } } private boolean setScreenAutoBrightnessAdjustment(float adjustment) { if (adjustment != mScreenAutoBrightnessAdjustment) { mScreenAutoBrightnessAdjustment = adjustment; return true; } return false; private boolean setAutoBrightnessAdjustment(float adjustment) { return mBrightnessMapper.setAutoBrightnessAdjustment(adjustment); } private void setAmbientLux(float lux) { Loading @@ -466,8 +443,10 @@ class AutomaticBrightnessController { final float maxAmbientLux = mShortTermModelAnchor + mShortTermModelAnchor * SHORT_TERM_MODEL_THRESHOLD_RATIO; if (minAmbientLux < mAmbientLux && mAmbientLux < maxAmbientLux) { if (DEBUG) { Slog.d(TAG, "ShortTermModel: re-validate user data, ambient lux is " + minAmbientLux + " < " + mAmbientLux + " < " + maxAmbientLux); } mShortTermModelValid = true; } else { Slog.d(TAG, "ShortTermModel: reset data, ambient lux is " + mAmbientLux + Loading Loading @@ -498,9 +477,9 @@ class AutomaticBrightnessController { } } if (DEBUG) { Slog.d(TAG, "calculateAmbientLux: selected endIndex=" + endIndex + ", point=(" + mAmbientLightRingBuffer.getTime(endIndex) + ", " + mAmbientLightRingBuffer.getLux(endIndex) + ")"); Slog.d(TAG, "calculateAmbientLux: selected endIndex=" + endIndex + ", point=(" + mAmbientLightRingBuffer.getTime(endIndex) + ", " + mAmbientLightRingBuffer.getLux(endIndex) + ")"); } float sum = 0; float totalWeight = 0; Loading Loading @@ -652,28 +631,6 @@ class AutomaticBrightnessController { } float value = mBrightnessMapper.getBrightness(mAmbientLux); float gamma = 1.0f; if (USE_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT && mScreenAutoBrightnessAdjustment != 0.0f) { final float adjGamma = MathUtils.pow(mScreenAutoBrightnessAdjustmentMaxGamma, Math.min(1.0f, Math.max(-1.0f, -mScreenAutoBrightnessAdjustment))); gamma *= adjGamma; if (DEBUG) { Slog.d(TAG, "updateAutoBrightness: adjGamma=" + adjGamma); } } if (gamma != 1.0f) { final float in = value; value = MathUtils.pow(value, gamma); if (DEBUG) { Slog.d(TAG, "updateAutoBrightness: " + "gamma=" + gamma + ", " + "in=" + in + ", " + "out=" + value); } } int newScreenAutoBrightness = clampScreenBrightness(Math.round(value * PowerManager.BRIGHTNESS_ON)); Loading @@ -685,7 +642,6 @@ class AutomaticBrightnessController { } mScreenAutoBrightness = newScreenAutoBrightness; mLastScreenAutoBrightnessGamma = gamma; if (sendUpdate) { mCallbacks.updateBrightness(); } Loading @@ -700,10 +656,8 @@ class AutomaticBrightnessController { private void prepareBrightnessAdjustmentSample() { if (!mBrightnessAdjustmentSamplePending) { mBrightnessAdjustmentSamplePending = true; mBrightnessAdjustmentSampleOldAdjustment = mScreenAutoBrightnessAdjustment; mBrightnessAdjustmentSampleOldLux = mAmbientLuxValid ? mAmbientLux : -1; mBrightnessAdjustmentSampleOldBrightness = mScreenAutoBrightness; mBrightnessAdjustmentSampleOldGamma = mLastScreenAutoBrightnessGamma; } else { mHandler.removeMessages(MSG_BRIGHTNESS_ADJUSTMENT_SAMPLE); } Loading @@ -725,22 +679,16 @@ class AutomaticBrightnessController { if (mAmbientLuxValid && mScreenAutoBrightness >= 0) { if (DEBUG) { Slog.d(TAG, "Auto-brightness adjustment changed by user: " + "adj=" + mScreenAutoBrightnessAdjustment + ", " + "lux=" + mAmbientLux + ", " + "brightness=" + mScreenAutoBrightness + ", " + "gamma=" + mLastScreenAutoBrightnessGamma + ", " + "ring=" + mAmbientLightRingBuffer); } EventLog.writeEvent(EventLogTags.AUTO_BRIGHTNESS_ADJ, mBrightnessAdjustmentSampleOldAdjustment, mBrightnessAdjustmentSampleOldLux, mBrightnessAdjustmentSampleOldBrightness, mBrightnessAdjustmentSampleOldGamma, mScreenAutoBrightnessAdjustment, mAmbientLux, mScreenAutoBrightness, mLastScreenAutoBrightnessGamma); mScreenAutoBrightness); } } } Loading services/core/java/com/android/server/display/BrightnessMappingStrategy.java +260 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/display/DisplayPowerController.java +1 −4 Original line number Diff line number Diff line Loading @@ -424,9 +424,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call com.android.internal.R.bool.config_autoBrightnessResetAmbientLuxAfterWarmUp); int ambientLightHorizon = resources.getInteger( com.android.internal.R.integer.config_autoBrightnessAmbientLightHorizon); float autoBrightnessAdjustmentMaxGamma = resources.getFraction( com.android.internal.R.fraction.config_autoBrightnessAdjustmentMaxGamma, 1, 1); int lightSensorWarmUpTimeConfig = resources.getInteger( com.android.internal.R.integer.config_lightSensorWarmupTime); Loading @@ -450,7 +447,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp, ambientLightHorizon, autoBrightnessAdjustmentMaxGamma, dynamicHysteresis); dynamicHysteresis); } else { mUseSoftwareAutoBrightnessConfig = false; } Loading services/core/java/com/android/server/display/utils/Plog.java 0 → 100644 +141 −0 Original line number Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.display.utils; import java.lang.StringBuilder; import java.lang.System; import android.util.Slog; /** * A utility to log multiple points and curves in a structured way so they can be easily consumed * by external tooling * * To start a plot, call {@link Plog.start} with the plot's title; to add a point to it, call * {@link Plog.logPoint} with the point name (that will appear in the legend) and coordinates; and * to log a curve, call {@link Plog.logCurve} with its name and points. */ public abstract class Plog { // A unique identifier used to group points and curves that belong on the same plot. private long mId; /** * Returns a Plog instance that emits messages to the system log. * * @param tag The tag of the emitted messages in the system log. * @return A plog instance that emits messages to the system log. */ public static Plog createSystemPlog(String tag) { return new SystemPlog(tag); } /** * Start a new plot. * * @param title The plot title. * @return The Plog instance (for chaining). */ public Plog start(String title) { mId = System.currentTimeMillis(); write(formatTitle(title)); return this; } /** * Adds a point to the current plot. * * @param name The point name (that will appear in the legend). * @param x The point x coordinate. * @param y The point y coordinate. * @return The Plog instance (for chaining). */ public Plog logPoint(String name, float x, float y) { write(formatPoint(name, x, y)); return this; } /** * Adds a curve to the current plot. * * @param name The curve name (that will appear in the legend). * @param xs The curve x coordinates. * @param ys The curve y coordinates. * @return The Plog instance (for chaining). */ public Plog logCurve(String name, float[] xs, float[] ys) { write(formatCurve(name, xs, ys)); return this; } private String formatTitle(String title) { return "title: " + title; } private String formatPoint(String name, float x, float y) { return "point: " + name + ": (" + x + "," + y + ")"; } private String formatCurve(String name, float[] xs, float[] ys) { StringBuilder sb = new StringBuilder(); sb.append("curve: " + name + ": ["); int n = xs.length <= ys.length ? xs.length : ys.length; for (int i = 0; i < n; i++) { sb.append("(" + xs[i] + "," + ys[i] + "),"); } sb.append("]"); return sb.toString(); } private void write(String message) { emit("[PLOG " + mId + "] " + message); } /** * Emits a message (depending on the concrete Plog implementation). * * @param message The message. */ protected abstract void emit(String message); /** * A Plog that emits messages to the system log. */ public static class SystemPlog extends Plog { // The tag of the emitted messages in the system log. private final String mTag; /** * Returns a Plog instance that emits messages to the system log. * * @param tag The tag of the emitted messages in the system log. * @return A Plog instance that emits messages to the system log. */ public SystemPlog(String tag) { mTag = tag; } /** * Emits a message to the system log. * * @param message The message. */ protected void emit(String message) { Slog.d(mTag, message); } } } Loading
services/core/java/com/android/server/EventLogTags.logtags +1 −1 Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ option java_package com.android.server # DisplayManagerService.java # --------------------------- # Auto-brightness adjustments by the user. 35000 auto_brightness_adj (old_adj|5),(old_lux|5),(old_brightness|5),(old_gamma|5),(new_adj|5),(new_lux|5),(new_brightness|5),(new_gamma|5) 35000 auto_brightness_adj (old_lux|5),(old_brightness|5),(new_lux|5),(new_brightness|5) # --------------------------- # ConnectivityService.java Loading
services/core/java/com/android/server/display/AutomaticBrightnessController.java +36 −88 Original line number Diff line number Diff line Loading @@ -169,16 +169,6 @@ class AutomaticBrightnessController { // Use -1 if there is no current auto-brightness value available. private int mScreenAutoBrightness = -1; // The screen auto-brightness adjustment factor in the range -1 (dimmer) to 1 (brighter) private float mScreenAutoBrightnessAdjustment = 0.0f; // The maximum range of gamma adjustment possible using the screen // auto-brightness adjustment setting. private float mScreenAutoBrightnessAdjustmentMaxGamma; // The last screen auto-brightness gamma. (For printing in dump() only.) private float mLastScreenAutoBrightnessGamma = 1.0f; // The current display policy. This is useful, for example, for knowing when we're dozing, // where the light sensor may not be available. private int mDisplayPolicy = DisplayPowerRequest.POLICY_OFF; Loading @@ -186,10 +176,8 @@ class AutomaticBrightnessController { // True if we are collecting a brightness adjustment sample, along with some data // for the initial state of the sample. private boolean mBrightnessAdjustmentSamplePending; private float mBrightnessAdjustmentSampleOldAdjustment; private float mBrightnessAdjustmentSampleOldLux; private int mBrightnessAdjustmentSampleOldBrightness; private float mBrightnessAdjustmentSampleOldGamma; // When the short term model is invalidated, we don't necessarily reset it (i.e. clear the // user's adjustment) immediately, but wait for a drastic enough change in the ambient light. Loading @@ -200,12 +188,11 @@ class AutomaticBrightnessController { private float SHORT_TERM_MODEL_THRESHOLD_RATIO = 0.6f; public AutomaticBrightnessController(Callbacks callbacks, Looper looper, SensorManager sensorManager, BrightnessMappingStrategy mapper, int lightSensorWarmUpTime, int brightnessMin, int brightnessMax, float dozeScaleFactor, SensorManager sensorManager, BrightnessMappingStrategy mapper, int lightSensorWarmUpTime, int brightnessMin, int brightnessMax, float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, int ambientLightHorizon, float autoBrightnessAdjustmentMaxGamma, HysteresisLevels dynamicHysteresis) { int ambientLightHorizon, HysteresisLevels dynamicHysteresis) { mCallbacks = callbacks; mSensorManager = sensorManager; mBrightnessMapper = mapper; Loading @@ -221,7 +208,6 @@ class AutomaticBrightnessController { mResetAmbientLuxAfterWarmUpConfig = resetAmbientLuxAfterWarmUpConfig; mAmbientLightHorizon = ambientLightHorizon; mWeightingIntercept = ambientLightHorizon; mScreenAutoBrightnessAdjustmentMaxGamma = autoBrightnessAdjustmentMaxGamma; mDynamicHysteresis = dynamicHysteresis; mShortTermModelValid = true; mShortTermModelAnchor = -1; Loading @@ -243,7 +229,7 @@ class AutomaticBrightnessController { } public float getAutomaticScreenBrightnessAdjustment() { return mScreenAutoBrightnessAdjustment; return mBrightnessMapper.getAutoBrightnessAdjustment(); } public void configure(boolean enable, @Nullable BrightnessConfiguration configuration, Loading @@ -257,7 +243,9 @@ class AutomaticBrightnessController { boolean dozing = (displayPolicy == DisplayPowerRequest.POLICY_DOZE); boolean changed = setBrightnessConfiguration(configuration); changed |= setDisplayPolicy(displayPolicy); changed |= setScreenAutoBrightnessAdjustment(adjustment); if (userChangedAutoBrightnessAdjustment) { changed |= setAutoBrightnessAdjustment(adjustment); } if (userChangedBrightness && enable) { // Update the brightness curve with the new user control point. It's critical this // happens after we update the autobrightness adjustment since it may reset it. Loading Loading @@ -322,9 +310,6 @@ class AutomaticBrightnessController { if (DEBUG) { Slog.d(TAG, "ShortTermModel: anchor=" + mShortTermModelAnchor); } // Reset the brightness adjustment so that the next time we're queried for brightness we // return the value the user set. mScreenAutoBrightnessAdjustment = 0.0f; return true; } Loading Loading @@ -369,10 +354,6 @@ class AutomaticBrightnessController { pw.println(" mRecentLightSamples=" + mRecentLightSamples); pw.println(" mAmbientLightRingBuffer=" + mAmbientLightRingBuffer); pw.println(" mScreenAutoBrightness=" + mScreenAutoBrightness); pw.println(" mScreenAutoBrightnessAdjustment=" + mScreenAutoBrightnessAdjustment); pw.println(" mScreenAutoBrightnessAdjustmentMaxGamma=" + mScreenAutoBrightnessAdjustmentMaxGamma); pw.println(" mLastScreenAutoBrightnessGamma=" + mLastScreenAutoBrightnessGamma); pw.println(" mDisplayPolicy=" + mDisplayPolicy); pw.println(" mShortTermModelAnchor=" + mShortTermModelAnchor); Loading Loading @@ -439,12 +420,8 @@ class AutomaticBrightnessController { } } private boolean setScreenAutoBrightnessAdjustment(float adjustment) { if (adjustment != mScreenAutoBrightnessAdjustment) { mScreenAutoBrightnessAdjustment = adjustment; return true; } return false; private boolean setAutoBrightnessAdjustment(float adjustment) { return mBrightnessMapper.setAutoBrightnessAdjustment(adjustment); } private void setAmbientLux(float lux) { Loading @@ -466,8 +443,10 @@ class AutomaticBrightnessController { final float maxAmbientLux = mShortTermModelAnchor + mShortTermModelAnchor * SHORT_TERM_MODEL_THRESHOLD_RATIO; if (minAmbientLux < mAmbientLux && mAmbientLux < maxAmbientLux) { if (DEBUG) { Slog.d(TAG, "ShortTermModel: re-validate user data, ambient lux is " + minAmbientLux + " < " + mAmbientLux + " < " + maxAmbientLux); } mShortTermModelValid = true; } else { Slog.d(TAG, "ShortTermModel: reset data, ambient lux is " + mAmbientLux + Loading Loading @@ -498,9 +477,9 @@ class AutomaticBrightnessController { } } if (DEBUG) { Slog.d(TAG, "calculateAmbientLux: selected endIndex=" + endIndex + ", point=(" + mAmbientLightRingBuffer.getTime(endIndex) + ", " + mAmbientLightRingBuffer.getLux(endIndex) + ")"); Slog.d(TAG, "calculateAmbientLux: selected endIndex=" + endIndex + ", point=(" + mAmbientLightRingBuffer.getTime(endIndex) + ", " + mAmbientLightRingBuffer.getLux(endIndex) + ")"); } float sum = 0; float totalWeight = 0; Loading Loading @@ -652,28 +631,6 @@ class AutomaticBrightnessController { } float value = mBrightnessMapper.getBrightness(mAmbientLux); float gamma = 1.0f; if (USE_SCREEN_AUTO_BRIGHTNESS_ADJUSTMENT && mScreenAutoBrightnessAdjustment != 0.0f) { final float adjGamma = MathUtils.pow(mScreenAutoBrightnessAdjustmentMaxGamma, Math.min(1.0f, Math.max(-1.0f, -mScreenAutoBrightnessAdjustment))); gamma *= adjGamma; if (DEBUG) { Slog.d(TAG, "updateAutoBrightness: adjGamma=" + adjGamma); } } if (gamma != 1.0f) { final float in = value; value = MathUtils.pow(value, gamma); if (DEBUG) { Slog.d(TAG, "updateAutoBrightness: " + "gamma=" + gamma + ", " + "in=" + in + ", " + "out=" + value); } } int newScreenAutoBrightness = clampScreenBrightness(Math.round(value * PowerManager.BRIGHTNESS_ON)); Loading @@ -685,7 +642,6 @@ class AutomaticBrightnessController { } mScreenAutoBrightness = newScreenAutoBrightness; mLastScreenAutoBrightnessGamma = gamma; if (sendUpdate) { mCallbacks.updateBrightness(); } Loading @@ -700,10 +656,8 @@ class AutomaticBrightnessController { private void prepareBrightnessAdjustmentSample() { if (!mBrightnessAdjustmentSamplePending) { mBrightnessAdjustmentSamplePending = true; mBrightnessAdjustmentSampleOldAdjustment = mScreenAutoBrightnessAdjustment; mBrightnessAdjustmentSampleOldLux = mAmbientLuxValid ? mAmbientLux : -1; mBrightnessAdjustmentSampleOldBrightness = mScreenAutoBrightness; mBrightnessAdjustmentSampleOldGamma = mLastScreenAutoBrightnessGamma; } else { mHandler.removeMessages(MSG_BRIGHTNESS_ADJUSTMENT_SAMPLE); } Loading @@ -725,22 +679,16 @@ class AutomaticBrightnessController { if (mAmbientLuxValid && mScreenAutoBrightness >= 0) { if (DEBUG) { Slog.d(TAG, "Auto-brightness adjustment changed by user: " + "adj=" + mScreenAutoBrightnessAdjustment + ", " + "lux=" + mAmbientLux + ", " + "brightness=" + mScreenAutoBrightness + ", " + "gamma=" + mLastScreenAutoBrightnessGamma + ", " + "ring=" + mAmbientLightRingBuffer); } EventLog.writeEvent(EventLogTags.AUTO_BRIGHTNESS_ADJ, mBrightnessAdjustmentSampleOldAdjustment, mBrightnessAdjustmentSampleOldLux, mBrightnessAdjustmentSampleOldBrightness, mBrightnessAdjustmentSampleOldGamma, mScreenAutoBrightnessAdjustment, mAmbientLux, mScreenAutoBrightness, mLastScreenAutoBrightnessGamma); mScreenAutoBrightness); } } } Loading
services/core/java/com/android/server/display/BrightnessMappingStrategy.java +260 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/display/DisplayPowerController.java +1 −4 Original line number Diff line number Diff line Loading @@ -424,9 +424,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call com.android.internal.R.bool.config_autoBrightnessResetAmbientLuxAfterWarmUp); int ambientLightHorizon = resources.getInteger( com.android.internal.R.integer.config_autoBrightnessAmbientLightHorizon); float autoBrightnessAdjustmentMaxGamma = resources.getFraction( com.android.internal.R.fraction.config_autoBrightnessAdjustmentMaxGamma, 1, 1); int lightSensorWarmUpTimeConfig = resources.getInteger( com.android.internal.R.integer.config_lightSensorWarmupTime); Loading @@ -450,7 +447,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp, ambientLightHorizon, autoBrightnessAdjustmentMaxGamma, dynamicHysteresis); dynamicHysteresis); } else { mUseSoftwareAutoBrightnessConfig = false; } Loading
services/core/java/com/android/server/display/utils/Plog.java 0 → 100644 +141 −0 Original line number Diff line number Diff line /* * Copyright 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.display.utils; import java.lang.StringBuilder; import java.lang.System; import android.util.Slog; /** * A utility to log multiple points and curves in a structured way so they can be easily consumed * by external tooling * * To start a plot, call {@link Plog.start} with the plot's title; to add a point to it, call * {@link Plog.logPoint} with the point name (that will appear in the legend) and coordinates; and * to log a curve, call {@link Plog.logCurve} with its name and points. */ public abstract class Plog { // A unique identifier used to group points and curves that belong on the same plot. private long mId; /** * Returns a Plog instance that emits messages to the system log. * * @param tag The tag of the emitted messages in the system log. * @return A plog instance that emits messages to the system log. */ public static Plog createSystemPlog(String tag) { return new SystemPlog(tag); } /** * Start a new plot. * * @param title The plot title. * @return The Plog instance (for chaining). */ public Plog start(String title) { mId = System.currentTimeMillis(); write(formatTitle(title)); return this; } /** * Adds a point to the current plot. * * @param name The point name (that will appear in the legend). * @param x The point x coordinate. * @param y The point y coordinate. * @return The Plog instance (for chaining). */ public Plog logPoint(String name, float x, float y) { write(formatPoint(name, x, y)); return this; } /** * Adds a curve to the current plot. * * @param name The curve name (that will appear in the legend). * @param xs The curve x coordinates. * @param ys The curve y coordinates. * @return The Plog instance (for chaining). */ public Plog logCurve(String name, float[] xs, float[] ys) { write(formatCurve(name, xs, ys)); return this; } private String formatTitle(String title) { return "title: " + title; } private String formatPoint(String name, float x, float y) { return "point: " + name + ": (" + x + "," + y + ")"; } private String formatCurve(String name, float[] xs, float[] ys) { StringBuilder sb = new StringBuilder(); sb.append("curve: " + name + ": ["); int n = xs.length <= ys.length ? xs.length : ys.length; for (int i = 0; i < n; i++) { sb.append("(" + xs[i] + "," + ys[i] + "),"); } sb.append("]"); return sb.toString(); } private void write(String message) { emit("[PLOG " + mId + "] " + message); } /** * Emits a message (depending on the concrete Plog implementation). * * @param message The message. */ protected abstract void emit(String message); /** * A Plog that emits messages to the system log. */ public static class SystemPlog extends Plog { // The tag of the emitted messages in the system log. private final String mTag; /** * Returns a Plog instance that emits messages to the system log. * * @param tag The tag of the emitted messages in the system log. * @return A Plog instance that emits messages to the system log. */ public SystemPlog(String tag) { mTag = tag; } /** * Emits a message to the system log. * * @param message The message. */ protected void emit(String message) { Slog.d(mTag, message); } } }