Loading core/java/android/hardware/display/BrightnessChangeEvent.java +26 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays; import java.util.Objects; /** Loading Loading @@ -233,6 +234,31 @@ public final class BrightnessChangeEvent implements Parcelable { dest.writeLong(colorSampleDuration); } @Override public String toString() { return "BrightnessChangeEvent{" + "brightness: " + brightness + ", timeStamp: " + timeStamp + ", packageName: " + packageName + ", userId: " + userId + ", uniqueDisplayId: " + uniqueDisplayId + ", luxValues: " + Arrays.toString(luxValues) + ", luxTimestamps: " + Arrays.toString(luxTimestamps) + ", batteryLevel: " + batteryLevel + ", powerBrightnessFactor: " + powerBrightnessFactor + ", nightMode: " + nightMode + ", colorTemperature: " + colorTemperature + ", reduceBrightColors: " + reduceBrightColors + ", reduceBrightColorsStrength: " + reduceBrightColorsStrength + ", reduceBrightColorsOffset: " + reduceBrightColorsOffset + ", lastBrightness: " + lastBrightness + ", isDefaultBrightnessConfig: " + isDefaultBrightnessConfig + ", isUserSetBrightness: " + isUserSetBrightness + ", colorValueBuckets: " + Arrays.toString(colorValueBuckets) + ", colorSampleDuration: " + colorSampleDuration + "}"; } /** @hide */ public static class Builder { private float mBrightness; Loading services/core/java/com/android/server/display/BrightnessTracker.java +4 −4 Original line number Diff line number Diff line Loading @@ -316,7 +316,9 @@ public class BrightnessTracker { } /** * Notify the BrightnessTracker that the user has changed the brightness of the display. * Notify the BrightnessTracker that the brightness of the display has changed. * We pass both the user change and system changes, so that we know the starting point * of the next user interaction. Only user interactions are then sent as BrightnessChangeEvents. */ public void notifyBrightnessChanged(float brightness, boolean userInitiated, float powerBrightnessFactor, boolean wasShortTermModelActive, Loading Loading @@ -352,10 +354,8 @@ public class BrightnessTracker { // Not currently gathering brightness change information return; } float previousBrightness = mLastBrightness; mLastBrightness = brightness; if (!userInitiated) { // We want to record what current brightness is so that we know what the user // changed it from, but if it wasn't user initiated then we don't want to record it Loading Loading @@ -429,7 +429,7 @@ public class BrightnessTracker { BrightnessChangeEvent event = builder.build(); if (DEBUG) { Slog.d(TAG, "Event " + event.brightness + " " + event.packageName); Slog.d(TAG, "Event: " + event.toString()); } synchronized (mEventsLock) { mEventsDirty = true; Loading services/core/java/com/android/server/display/DisplayPowerController.java +37 −29 Original line number Diff line number Diff line Loading @@ -1908,21 +1908,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } // Report brightness to brightnesstracker: // If brightness is not temporary (ie the slider has been released) // AND if we are not in idle screen brightness mode. if (!brightnessIsTemporary && (mAutomaticBrightnessController != null && !mAutomaticBrightnessController.isInIdleMode())) { if (userInitiatedChange && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiatedChange = false; } notifyBrightnessTrackerChanged(brightnessState, userInitiatedChange, wasShortTermModelActive); } wasShortTermModelActive, autoBrightnessEnabled, brightnessIsTemporary); // We save the brightness info *after* the brightness setting has been changed and // adjustments made so that the brightness info reflects the latest value. Loading Loading @@ -2758,10 +2745,32 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } private void notifyBrightnessTrackerChanged(float brightness, boolean userInitiated, boolean wasShortTermModelActive) { boolean wasShortTermModelActive, boolean autobrightnessEnabled, boolean brightnessIsTemporary) { final float brightnessInNits = convertToAdjustedNits(brightness); if (mUseAutoBrightness && brightnessInNits >= 0.0f && mAutomaticBrightnessController != null && mBrightnessTracker != null) { // Don't report brightness to brightnessTracker: // If brightness is temporary (ie the slider has not been released) // or if we are in idle screen brightness mode. // or display is not on // or we shouldn't be using autobrightness // or the nits is invalid. if (brightnessIsTemporary || mAutomaticBrightnessController == null || mAutomaticBrightnessController.isInIdleMode() || !autobrightnessEnabled || mBrightnessTracker == null || !mUseAutoBrightness || brightnessInNits < 0.0f) { return; } if (userInitiated && !mAutomaticBrightnessController.hasValidAmbientLux()) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiated = false; } // We only want to track changes on devices that can actually map the display backlight // values into a physical brightness unit since the value provided by the API is in // nits and not using the arbitrary backlight units. Loading @@ -2774,7 +2783,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mAutomaticBrightnessController.getLastSensorValues(), mAutomaticBrightnessController.getLastSensorTimestamps()); } } private float convertToNits(float brightness) { if (mAutomaticBrightnessController == null) { Loading services/core/java/com/android/server/display/DisplayPowerController2.java +39 −29 Original line number Diff line number Diff line Loading @@ -1539,21 +1539,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } // Report brightness to brightnesstracker: // If brightness is not temporary (ie the slider has been released) // AND if we are not in idle screen brightness mode. if (!brightnessIsTemporary && (mAutomaticBrightnessController != null && !mAutomaticBrightnessController.isInIdleMode())) { if (userInitiatedChange && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiatedChange = false; } notifyBrightnessTrackerChanged(brightnessState, userInitiatedChange, wasShortTermModelActive); } wasShortTermModelActive, mAutomaticBrightnessStrategy.isAutoBrightnessEnabled(), brightnessIsTemporary); // We save the brightness info *after* the brightness setting has been changed and // adjustments made so that the brightness info reflects the latest value. Loading Loading @@ -2215,11 +2203,34 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } private void notifyBrightnessTrackerChanged(float brightness, boolean userInitiated, boolean wasShortTermModelActive) { boolean wasShortTermModelActive, boolean autobrightnessEnabled, boolean brightnessIsTemporary) { final float brightnessInNits = mDisplayBrightnessController.convertToAdjustedNits(brightness); if (mAutomaticBrightnessStrategy.shouldUseAutoBrightness() && brightnessInNits >= 0.0f && mAutomaticBrightnessController != null && mBrightnessTracker != null) { // Don't report brightness to brightnessTracker: // If brightness is temporary (ie the slider has not been released) // or if we are in idle screen brightness mode. // or display is not on // or we shouldn't be using autobrightness // or the nits is invalid. if (brightnessIsTemporary || mAutomaticBrightnessController == null || mAutomaticBrightnessController.isInIdleMode() || !autobrightnessEnabled || mBrightnessTracker == null || !mAutomaticBrightnessStrategy.shouldUseAutoBrightness() || brightnessInNits < 0.0f) { return; } if (userInitiated && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiated = false; } // We only want to track changes on devices that can actually map the display backlight // values into a physical brightness unit since the value provided by the API is in // nits and not using the arbitrary backlight units. Loading @@ -2232,7 +2243,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mAutomaticBrightnessController.getLastSensorValues(), mAutomaticBrightnessController.getLastSensorTimestamps()); } } @Override public void addDisplayBrightnessFollower(DisplayPowerControllerInterface follower) { Loading Loading
core/java/android/hardware/display/BrightnessChangeEvent.java +26 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.annotation.SystemApi; import android.os.Parcel; import android.os.Parcelable; import java.util.Arrays; import java.util.Objects; /** Loading Loading @@ -233,6 +234,31 @@ public final class BrightnessChangeEvent implements Parcelable { dest.writeLong(colorSampleDuration); } @Override public String toString() { return "BrightnessChangeEvent{" + "brightness: " + brightness + ", timeStamp: " + timeStamp + ", packageName: " + packageName + ", userId: " + userId + ", uniqueDisplayId: " + uniqueDisplayId + ", luxValues: " + Arrays.toString(luxValues) + ", luxTimestamps: " + Arrays.toString(luxTimestamps) + ", batteryLevel: " + batteryLevel + ", powerBrightnessFactor: " + powerBrightnessFactor + ", nightMode: " + nightMode + ", colorTemperature: " + colorTemperature + ", reduceBrightColors: " + reduceBrightColors + ", reduceBrightColorsStrength: " + reduceBrightColorsStrength + ", reduceBrightColorsOffset: " + reduceBrightColorsOffset + ", lastBrightness: " + lastBrightness + ", isDefaultBrightnessConfig: " + isDefaultBrightnessConfig + ", isUserSetBrightness: " + isUserSetBrightness + ", colorValueBuckets: " + Arrays.toString(colorValueBuckets) + ", colorSampleDuration: " + colorSampleDuration + "}"; } /** @hide */ public static class Builder { private float mBrightness; Loading
services/core/java/com/android/server/display/BrightnessTracker.java +4 −4 Original line number Diff line number Diff line Loading @@ -316,7 +316,9 @@ public class BrightnessTracker { } /** * Notify the BrightnessTracker that the user has changed the brightness of the display. * Notify the BrightnessTracker that the brightness of the display has changed. * We pass both the user change and system changes, so that we know the starting point * of the next user interaction. Only user interactions are then sent as BrightnessChangeEvents. */ public void notifyBrightnessChanged(float brightness, boolean userInitiated, float powerBrightnessFactor, boolean wasShortTermModelActive, Loading Loading @@ -352,10 +354,8 @@ public class BrightnessTracker { // Not currently gathering brightness change information return; } float previousBrightness = mLastBrightness; mLastBrightness = brightness; if (!userInitiated) { // We want to record what current brightness is so that we know what the user // changed it from, but if it wasn't user initiated then we don't want to record it Loading Loading @@ -429,7 +429,7 @@ public class BrightnessTracker { BrightnessChangeEvent event = builder.build(); if (DEBUG) { Slog.d(TAG, "Event " + event.brightness + " " + event.packageName); Slog.d(TAG, "Event: " + event.toString()); } synchronized (mEventsLock) { mEventsDirty = true; Loading
services/core/java/com/android/server/display/DisplayPowerController.java +37 −29 Original line number Diff line number Diff line Loading @@ -1908,21 +1908,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } } // Report brightness to brightnesstracker: // If brightness is not temporary (ie the slider has been released) // AND if we are not in idle screen brightness mode. if (!brightnessIsTemporary && (mAutomaticBrightnessController != null && !mAutomaticBrightnessController.isInIdleMode())) { if (userInitiatedChange && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiatedChange = false; } notifyBrightnessTrackerChanged(brightnessState, userInitiatedChange, wasShortTermModelActive); } wasShortTermModelActive, autoBrightnessEnabled, brightnessIsTemporary); // We save the brightness info *after* the brightness setting has been changed and // adjustments made so that the brightness info reflects the latest value. Loading Loading @@ -2758,10 +2745,32 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } private void notifyBrightnessTrackerChanged(float brightness, boolean userInitiated, boolean wasShortTermModelActive) { boolean wasShortTermModelActive, boolean autobrightnessEnabled, boolean brightnessIsTemporary) { final float brightnessInNits = convertToAdjustedNits(brightness); if (mUseAutoBrightness && brightnessInNits >= 0.0f && mAutomaticBrightnessController != null && mBrightnessTracker != null) { // Don't report brightness to brightnessTracker: // If brightness is temporary (ie the slider has not been released) // or if we are in idle screen brightness mode. // or display is not on // or we shouldn't be using autobrightness // or the nits is invalid. if (brightnessIsTemporary || mAutomaticBrightnessController == null || mAutomaticBrightnessController.isInIdleMode() || !autobrightnessEnabled || mBrightnessTracker == null || !mUseAutoBrightness || brightnessInNits < 0.0f) { return; } if (userInitiated && !mAutomaticBrightnessController.hasValidAmbientLux()) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiated = false; } // We only want to track changes on devices that can actually map the display backlight // values into a physical brightness unit since the value provided by the API is in // nits and not using the arbitrary backlight units. Loading @@ -2774,7 +2783,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mAutomaticBrightnessController.getLastSensorValues(), mAutomaticBrightnessController.getLastSensorTimestamps()); } } private float convertToNits(float brightness) { if (mAutomaticBrightnessController == null) { Loading
services/core/java/com/android/server/display/DisplayPowerController2.java +39 −29 Original line number Diff line number Diff line Loading @@ -1539,21 +1539,9 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } } // Report brightness to brightnesstracker: // If brightness is not temporary (ie the slider has been released) // AND if we are not in idle screen brightness mode. if (!brightnessIsTemporary && (mAutomaticBrightnessController != null && !mAutomaticBrightnessController.isInIdleMode())) { if (userInitiatedChange && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiatedChange = false; } notifyBrightnessTrackerChanged(brightnessState, userInitiatedChange, wasShortTermModelActive); } wasShortTermModelActive, mAutomaticBrightnessStrategy.isAutoBrightnessEnabled(), brightnessIsTemporary); // We save the brightness info *after* the brightness setting has been changed and // adjustments made so that the brightness info reflects the latest value. Loading Loading @@ -2215,11 +2203,34 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal } private void notifyBrightnessTrackerChanged(float brightness, boolean userInitiated, boolean wasShortTermModelActive) { boolean wasShortTermModelActive, boolean autobrightnessEnabled, boolean brightnessIsTemporary) { final float brightnessInNits = mDisplayBrightnessController.convertToAdjustedNits(brightness); if (mAutomaticBrightnessStrategy.shouldUseAutoBrightness() && brightnessInNits >= 0.0f && mAutomaticBrightnessController != null && mBrightnessTracker != null) { // Don't report brightness to brightnessTracker: // If brightness is temporary (ie the slider has not been released) // or if we are in idle screen brightness mode. // or display is not on // or we shouldn't be using autobrightness // or the nits is invalid. if (brightnessIsTemporary || mAutomaticBrightnessController == null || mAutomaticBrightnessController.isInIdleMode() || !autobrightnessEnabled || mBrightnessTracker == null || !mAutomaticBrightnessStrategy.shouldUseAutoBrightness() || brightnessInNits < 0.0f) { return; } if (userInitiated && (mAutomaticBrightnessController == null || !mAutomaticBrightnessController.hasValidAmbientLux())) { // If we don't have a valid lux reading we can't report a valid // slider event so notify as if the system changed the brightness. userInitiated = false; } // We only want to track changes on devices that can actually map the display backlight // values into a physical brightness unit since the value provided by the API is in // nits and not using the arbitrary backlight units. Loading @@ -2232,7 +2243,6 @@ final class DisplayPowerController2 implements AutomaticBrightnessController.Cal mAutomaticBrightnessController.getLastSensorValues(), mAutomaticBrightnessController.getLastSensorTimestamps()); } } @Override public void addDisplayBrightnessFollower(DisplayPowerControllerInterface follower) { Loading