diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-10 07:29:17 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-10 07:29:17 +0000 |
commit | 567eb2dde4e4b3253b3ca72ce39d822a24469c4d (patch) | |
tree | d66f34940f0a20862fe97a3cf155447bf911378c | |
parent | 3852e9ded8dd6e9192ba7a6d58f9c8a36c61231d (diff) | |
parent | e828f33713a4a9103f10fdc1affe21e144635c16 (diff) | |
download | base-567eb2dde4e4b3253b3ca72ce39d822a24469c4d.tar.gz |
Merge cherrypicks of [17106563, 17106564, 17106565, 17106566] into sc-d2-release.
Change-Id: Ifd727d5064de25b553aa423fd2453aa3055eb2e0
9 files changed, 28 insertions, 348 deletions
diff --git a/services/core/java/com/android/server/display/BrightnessTracker.java b/services/core/java/com/android/server/display/BrightnessTracker.java index 17215e5ae4ad..2c2a2bf24cfd 100644 --- a/services/core/java/com/android/server/display/BrightnessTracker.java +++ b/services/core/java/com/android/server/display/BrightnessTracker.java @@ -131,7 +131,6 @@ public class BrightnessTracker { private static final int MSG_STOP_SENSOR_LISTENER = 2; private static final int MSG_START_SENSOR_LISTENER = 3; private static final int MSG_BRIGHTNESS_CONFIG_CHANGED = 4; - private static final int MSG_SENSOR_CHANGED = 5; private static final SimpleDateFormat FORMAT = new SimpleDateFormat("MM-dd HH:mm:ss.SSS"); @@ -159,7 +158,6 @@ public class BrightnessTracker { // These members should only be accessed on the mBgHandler thread. private BroadcastReceiver mBroadcastReceiver; private SensorListener mSensorListener; - private Sensor mLightSensor; private SettingsObserver mSettingsObserver; private DisplayListener mDisplayListener; private boolean mSensorRegistered; @@ -329,14 +327,6 @@ public class BrightnessTracker { m.sendToTarget(); } - /** - * Updates the light sensor to use. - */ - public void setLightSensor(Sensor lightSensor) { - mBgHandler.obtainMessage(MSG_SENSOR_CHANGED, 0 /*unused*/, 0/*unused*/, lightSensor) - .sendToTarget(); - } - private void handleBrightnessChanged(float brightness, boolean userInitiated, float powerBrightnessFactor, boolean isUserSetBrightness, boolean isDefaultBrightnessConfig, long timestamp, String uniqueDisplayId) { @@ -438,28 +428,13 @@ public class BrightnessTracker { } } - private void handleSensorChanged(Sensor lightSensor) { - if (mLightSensor != lightSensor) { - mLightSensor = lightSensor; - stopSensorListener(); - synchronized (mDataCollectionLock) { - mLastSensorReadings.clear(); - } - // Attempt to restart the sensor listener. It will check to see if it should be running - // so there is no need to also check here. - startSensorListener(); - } - } - private void startSensorListener() { if (!mSensorRegistered - && mLightSensor != null - && mAmbientBrightnessStatsTracker != null && mInjector.isInteractive(mContext) && mInjector.isBrightnessModeAutomatic(mContentResolver)) { mAmbientBrightnessStatsTracker.start(); mSensorRegistered = true; - mInjector.registerSensorListener(mContext, mSensorListener, mLightSensor, + mInjector.registerSensorListener(mContext, mSensorListener, mInjector.getBackgroundHandler()); } } @@ -761,7 +736,6 @@ public class BrightnessTracker { pw.println("BrightnessTracker state:"); synchronized (mDataCollectionLock) { pw.println(" mStarted=" + mStarted); - pw.println(" mLightSensor=" + mLightSensor); pw.println(" mLastBatteryLevel=" + mLastBatteryLevel); pw.println(" mLastBrightness=" + mLastBrightness); pw.println(" mLastSensorReadings.size=" + mLastSensorReadings.size()); @@ -1043,9 +1017,6 @@ public class BrightnessTracker { disableColorSampling(); } break; - case MSG_SENSOR_CHANGED: - handleSensorChanged((Sensor) msg.obj); - break; } } @@ -1074,8 +1045,9 @@ public class BrightnessTracker { @VisibleForTesting static class Injector { public void registerSensorListener(Context context, - SensorEventListener sensorListener, Sensor lightSensor, Handler handler) { + SensorEventListener sensorListener, Handler handler) { SensorManager sensorManager = context.getSystemService(SensorManager.class); + Sensor lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); sensorManager.registerListener(sensorListener, lightSensor, SensorManager.SENSOR_DELAY_NORMAL, handler); } diff --git a/services/core/java/com/android/server/display/BrightnessUtils.java b/services/core/java/com/android/server/display/BrightnessUtils.java deleted file mode 100644 index 84fa0cccbd10..000000000000 --- a/services/core/java/com/android/server/display/BrightnessUtils.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2022 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; - -import android.util.MathUtils; - -/** - * Utility class providing functions to convert between linear and perceptual gamma space. - * - * Internally, this implements the Hybrid Log Gamma electro-optical transfer function, which is a - * slight improvement to the typical gamma transfer function for displays whose max brightness - * exceeds the 120 nit reference point, but doesn't set a specific reference brightness like the PQ - * function does. - * - * Note that this transfer function is only valid if the display's backlight value is a linear - * control. If it's calibrated to be something non-linear, then a different transfer function - * should be used. - * - * Note: This code is based on the same class in the com.android.settingslib.display package. - */ -public class BrightnessUtils { - - // Hybrid Log Gamma constant values - private static final float R = 0.5f; - private static final float A = 0.17883277f; - private static final float B = 0.28466892f; - private static final float C = 0.55991073f; - - /** - * A function for converting from the gamma space into the linear space. - * - * @param val The value in the gamma space [0 .. 1.0] - * @return The corresponding value in the linear space [0 .. 1.0]. - */ - public static final float convertGammaToLinear(float val) { - final float ret; - if (val <= R) { - ret = MathUtils.sq(val / R); - } else { - ret = MathUtils.exp((val - C) / A) + B; - } - - // HLG is normalized to the range [0, 12], ensure that value is within that range, - // it shouldn't be out of bounds. - final float normalizedRet = MathUtils.constrain(ret, 0, 12); - - // Re-normalize to the range [0, 1] - // in order to derive the correct setting value. - return normalizedRet / 12; - } - - /** - * A function for converting from the linear space into the gamma space. - * - * @param val The value in linear space [0 .. 1.0] - * @return The corresponding value in gamma space [0 .. 1.0] - */ - public static final float convertLinearToGamma(float val) { - // For some reason, HLG normalizes to the range [0, 12] rather than [0, 1] - final float normalizedVal = val * 12; - final float ret; - if (normalizedVal <= 1f) { - ret = MathUtils.sqrt(normalizedVal) * R; - } else { - ret = A * MathUtils.log(normalizedVal - B) + C; - } - return ret; - } -} diff --git a/services/core/java/com/android/server/display/DisplayDeviceConfig.java b/services/core/java/com/android/server/display/DisplayDeviceConfig.java index 255494f98667..2ae5cbbbf24b 100644 --- a/services/core/java/com/android/server/display/DisplayDeviceConfig.java +++ b/services/core/java/com/android/server/display/DisplayDeviceConfig.java @@ -31,7 +31,6 @@ import android.view.DisplayAddress; import com.android.internal.R; import com.android.internal.display.BrightnessSynchronizer; -import com.android.server.display.config.BrightnessThresholds; import com.android.server.display.config.DisplayConfiguration; import com.android.server.display.config.DisplayQuirks; import com.android.server.display.config.HbmTiming; @@ -41,7 +40,6 @@ import com.android.server.display.config.Point; import com.android.server.display.config.RefreshRateRange; import com.android.server.display.config.SensorDetails; import com.android.server.display.config.ThermalStatus; -import com.android.server.display.config.Thresholds; import com.android.server.display.config.XmlParser; import org.xmlpull.v1.XmlPullParserException; @@ -117,10 +115,6 @@ public class DisplayDeviceConfig { private float mBrightnessRampFastIncrease = Float.NaN; private float mBrightnessRampSlowDecrease = Float.NaN; private float mBrightnessRampSlowIncrease = Float.NaN; - private float mScreenBrighteningMinThreshold = 0.0f; // Retain behaviour as though there is - private float mScreenDarkeningMinThreshold = 0.0f; // no minimum threshold for change in - private float mAmbientLuxBrighteningMinThreshold = 0.0f; // screen brightness or ambient - private float mAmbientLuxDarkeningMinThreshold = 0.0f; // brightness. private Spline mBrightnessToBacklightSpline; private Spline mBacklightToBrightnessSpline; private Spline mBacklightToNitsSpline; @@ -288,22 +282,6 @@ public class DisplayDeviceConfig { return mBrightnessRampSlowIncrease; } - public float getScreenBrighteningMinThreshold() { - return mScreenBrighteningMinThreshold; - } - - public float getScreenDarkeningMinThreshold() { - return mScreenDarkeningMinThreshold; - } - - public float getAmbientLuxBrighteningMinThreshold() { - return mAmbientLuxBrighteningMinThreshold; - } - - public float getAmbientLuxDarkeningMinThreshold() { - return mAmbientLuxDarkeningMinThreshold; - } - SensorData getAmbientLightSensor() { return mAmbientLightSensor; } @@ -359,10 +337,6 @@ public class DisplayDeviceConfig { + ", mBrightnessRampFastIncrease=" + mBrightnessRampFastIncrease + ", mBrightnessRampSlowDecrease=" + mBrightnessRampSlowDecrease + ", mBrightnessRampSlowIncrease=" + mBrightnessRampSlowIncrease - + ", mScreenDarkeningMinThreshold=" + mScreenDarkeningMinThreshold - + ", mScreenBrighteningMinThreshold=" + mScreenBrighteningMinThreshold - + ", mAmbientLuxDarkeningMinThreshold=" + mAmbientLuxDarkeningMinThreshold - + ", mAmbientLuxBrighteningMinThreshold=" + mAmbientLuxBrighteningMinThreshold + ", mAmbientLightSensor=" + mAmbientLightSensor + ", mProximitySensor=" + mProximitySensor + ", mRefreshRateLimitations= " + Arrays.toString(mRefreshRateLimitations.toArray()) @@ -418,7 +392,6 @@ public class DisplayDeviceConfig { loadBrightnessRamps(config); loadAmbientLightSensorFromDdc(config); loadProxSensorFromDdc(config); - loadBrightnessChangeThresholds(config); } else { Slog.w(TAG, "DisplayDeviceConfig file is null"); } @@ -773,45 +746,6 @@ public class DisplayDeviceConfig { } } - private void loadBrightnessChangeThresholds(DisplayConfiguration config) { - Thresholds displayBrightnessThresholds = config.getDisplayBrightnessChangeThresholds(); - Thresholds ambientBrightnessThresholds = config.getAmbientBrightnessChangeThresholds(); - - if (displayBrightnessThresholds != null) { - BrightnessThresholds brighteningScreen = - displayBrightnessThresholds.getBrighteningThresholds(); - BrightnessThresholds darkeningScreen = - displayBrightnessThresholds.getDarkeningThresholds(); - - final BigDecimal screenBrighteningThreshold = brighteningScreen.getMinimum(); - final BigDecimal screenDarkeningThreshold = darkeningScreen.getMinimum(); - - if (screenBrighteningThreshold != null) { - mScreenBrighteningMinThreshold = screenBrighteningThreshold.floatValue(); - } - if (screenDarkeningThreshold != null) { - mScreenDarkeningMinThreshold = screenDarkeningThreshold.floatValue(); - } - } - - if (ambientBrightnessThresholds != null) { - BrightnessThresholds brighteningAmbientLux = - ambientBrightnessThresholds.getBrighteningThresholds(); - BrightnessThresholds darkeningAmbientLux = - ambientBrightnessThresholds.getDarkeningThresholds(); - - final BigDecimal ambientBrighteningThreshold = brighteningAmbientLux.getMinimum(); - final BigDecimal ambientDarkeningThreshold = darkeningAmbientLux.getMinimum(); - - if (ambientBrighteningThreshold != null) { - mAmbientLuxBrighteningMinThreshold = ambientBrighteningThreshold.floatValue(); - } - if (ambientDarkeningThreshold != null) { - mAmbientLuxDarkeningMinThreshold = ambientDarkeningThreshold.floatValue(); - } - } - } - private @PowerManager.ThermalStatus int convertThermalStatus(ThermalStatus value) { if (value == null) { return PowerManager.THERMAL_STATUS_NONE; diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java index 77c1fc031598..22dd2c05c157 100644 --- a/services/core/java/com/android/server/display/DisplayPowerController.java +++ b/services/core/java/com/android/server/display/DisplayPowerController.java @@ -795,6 +795,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call private void loadFromDisplayDeviceConfig(IBinder token, DisplayDeviceInfo info) { // All properties that depend on the associated DisplayDevice and the DDC must be // updated here. + loadAmbientLightSensor(); loadBrightnessRampRates(); loadProximitySensor(); loadNitsRange(mContext.getResources()); @@ -879,14 +880,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call com.android.internal.R.array.config_ambientDarkeningThresholds); int[] ambientThresholdLevels = resources.getIntArray( com.android.internal.R.array.config_ambientThresholdLevels); - float ambientDarkeningMinThreshold = - mDisplayDeviceConfig.getAmbientLuxDarkeningMinThreshold(); - float ambientBrighteningMinThreshold = - mDisplayDeviceConfig.getAmbientLuxBrighteningMinThreshold(); HysteresisLevels ambientBrightnessThresholds = new HysteresisLevels( ambientBrighteningThresholds, ambientDarkeningThresholds, - ambientThresholdLevels, ambientDarkeningMinThreshold, - ambientBrighteningMinThreshold); + ambientThresholdLevels); int[] screenBrighteningThresholds = resources.getIntArray( com.android.internal.R.array.config_screenBrighteningThresholds); @@ -894,13 +890,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call com.android.internal.R.array.config_screenDarkeningThresholds); int[] screenThresholdLevels = resources.getIntArray( com.android.internal.R.array.config_screenThresholdLevels); - float screenDarkeningMinThreshold = - mDisplayDeviceConfig.getScreenDarkeningMinThreshold(); - float screenBrighteningMinThreshold = - mDisplayDeviceConfig.getScreenBrighteningMinThreshold(); HysteresisLevels screenBrightnessThresholds = new HysteresisLevels( - screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels, - screenDarkeningMinThreshold, screenBrighteningMinThreshold); + screenBrighteningThresholds, screenDarkeningThresholds, screenThresholdLevels); long brighteningLightDebounce = resources.getInteger( com.android.internal.R.integer.config_autoBrightnessBrighteningLightDebounce); @@ -924,9 +915,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } loadAmbientLightSensor(); - if (mBrightnessTracker != null) { - mBrightnessTracker.setLightSensor(mLightSensor); - } if (mAutomaticBrightnessController != null) { mAutomaticBrightnessController.stop(); diff --git a/services/core/java/com/android/server/display/HysteresisLevels.java b/services/core/java/com/android/server/display/HysteresisLevels.java index 7a932ce6d7cf..2b565698ff8c 100644 --- a/services/core/java/com/android/server/display/HysteresisLevels.java +++ b/services/core/java/com/android/server/display/HysteresisLevels.java @@ -30,13 +30,17 @@ import java.util.Arrays; public class HysteresisLevels { private static final String TAG = "HysteresisLevels"; + // Default hysteresis constraints for brightening or darkening. + // The recent value must have changed by at least this fraction relative to the + // current value before a change will be considered. + private static final float DEFAULT_BRIGHTENING_HYSTERESIS = 0.10f; + private static final float DEFAULT_DARKENING_HYSTERESIS = 0.20f; + private static final boolean DEBUG = false; private final float[] mBrighteningThresholds; private final float[] mDarkeningThresholds; private final float[] mThresholdLevels; - private final float mMinDarkening; - private final float mMinBrightening; /** * Creates a {@code HysteresisLevels} object with the given equal-length @@ -44,12 +48,9 @@ public class HysteresisLevels { * @param brighteningThresholds an array of brightening hysteresis constraint constants. * @param darkeningThresholds an array of darkening hysteresis constraint constants. * @param thresholdLevels a monotonically increasing array of threshold levels. - * @param minBrighteningThreshold the minimum value for which the brightening value needs to - * return. - * @param minDarkeningThreshold the minimum value for which the darkening value needs to return. */ HysteresisLevels(int[] brighteningThresholds, int[] darkeningThresholds, - int[] thresholdLevels, float minDarkeningThreshold, float minBrighteningThreshold) { + int[] thresholdLevels) { if (brighteningThresholds.length != darkeningThresholds.length || darkeningThresholds.length != thresholdLevels.length + 1) { throw new IllegalArgumentException("Mismatch between hysteresis array lengths."); @@ -57,8 +58,6 @@ public class HysteresisLevels { mBrighteningThresholds = setArrayFormat(brighteningThresholds, 1000.0f); mDarkeningThresholds = setArrayFormat(darkeningThresholds, 1000.0f); mThresholdLevels = setArrayFormat(thresholdLevels, 1.0f); - mMinDarkening = minDarkeningThreshold; - mMinBrightening = minBrighteningThreshold; } /** @@ -66,13 +65,11 @@ public class HysteresisLevels { */ public float getBrighteningThreshold(float value) { final float brightConstant = getReferenceLevel(value, mBrighteningThresholds); - float brightThreshold = value * (1.0f + brightConstant); + final float brightThreshold = value * (1.0f + brightConstant); if (DEBUG) { Slog.d(TAG, "bright hysteresis constant=" + brightConstant + ", threshold=" + brightThreshold + ", value=" + value); } - - brightThreshold = Math.max(brightThreshold, value + mMinBrightening); return brightThreshold; } @@ -81,13 +78,12 @@ public class HysteresisLevels { */ public float getDarkeningThreshold(float value) { final float darkConstant = getReferenceLevel(value, mDarkeningThresholds); - float darkThreshold = value * (1.0f - darkConstant); + final float darkThreshold = value * (1.0f - darkConstant); if (DEBUG) { Slog.d(TAG, "dark hysteresis constant=: " + darkConstant + ", threshold=" + darkThreshold + ", value=" + value); } - darkThreshold = Math.min(darkThreshold, value - mMinDarkening); - return Math.max(darkThreshold, 0.0f); + return darkThreshold; } /** diff --git a/services/core/java/com/android/server/display/RampAnimator.java b/services/core/java/com/android/server/display/RampAnimator.java index d8672fc07619..ed3b15fb2661 100644 --- a/services/core/java/com/android/server/display/RampAnimator.java +++ b/services/core/java/com/android/server/display/RampAnimator.java @@ -23,8 +23,6 @@ import android.view.Choreographer; /** * A custom animator that progressively updates a property value at * a given variable rate until it reaches a particular target value. - * The ramping at the given rate is done in the perceptual space using - * the HLG transfer functions. */ class RampAnimator<T> { private final T mObject; @@ -59,9 +57,7 @@ class RampAnimator<T> { * @param rate The convergence rate in units per second, or 0 to set the value immediately. * @return True if the target differs from the previous target. */ - public boolean animateTo(float targetLinear, float rate) { - // Convert the target from the linear into the HLG space. - final float target = BrightnessUtils.convertLinearToGamma(targetLinear); + public boolean animateTo(float target, float rate) { // Immediately jump to the target the first time. if (mFirstTime || rate <= 0) { @@ -70,7 +66,7 @@ class RampAnimator<T> { mRate = 0; mTargetValue = target; mCurrentValue = target; - setPropertyValue(target); + mProperty.setValue(mObject, target); if (mAnimating) { mAnimating = false; cancelAnimationCallback(); @@ -125,15 +121,6 @@ class RampAnimator<T> { mListener = listener; } - /** - * Sets the brightness property by converting the given value from HLG space - * into linear space. - */ - private void setPropertyValue(float val) { - final float linearVal = BrightnessUtils.convertGammaToLinear(val); - mProperty.setValue(mObject, linearVal); - } - private void postAnimationCallback() { mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, mAnimationCallback, null); } @@ -169,7 +156,7 @@ class RampAnimator<T> { final float oldCurrentValue = mCurrentValue; mCurrentValue = mAnimatedValue; if (oldCurrentValue != mCurrentValue) { - setPropertyValue(mCurrentValue); + mProperty.setValue(mObject, mCurrentValue); } if (mTargetValue != mCurrentValue) { postAnimationCallback(); @@ -214,14 +201,14 @@ class RampAnimator<T> { * If this is the first time the property is being set or if the rate is 0, * the value jumps directly to the target. * - * @param linearFirstTarget The first target value in linear space. - * @param linearSecondTarget The second target value in linear space. + * @param firstTarget The first target value. + * @param secondTarget The second target value. * @param rate The convergence rate in units per second, or 0 to set the value immediately. * @return True if either target differs from the previous target. */ - public boolean animateTo(float linearFirstTarget, float linearSecondTarget, float rate) { - final boolean firstRetval = mFirst.animateTo(linearFirstTarget, rate); - final boolean secondRetval = mSecond.animateTo(linearSecondTarget, rate); + public boolean animateTo(float firstTarget, float secondTarget, float rate) { + final boolean firstRetval = mFirst.animateTo(firstTarget, rate); + final boolean secondRetval = mSecond.animateTo(secondTarget, rate); return firstRetval && secondRetval; } diff --git a/services/core/xsd/display-device-config/display-device-config.xsd b/services/core/xsd/display-device-config/display-device-config.xsd index a98483c6d03b..429edf175be4 100644 --- a/services/core/xsd/display-device-config/display-device-config.xsd +++ b/services/core/xsd/display-device-config/display-device-config.xsd @@ -34,8 +34,7 @@ <xs:annotation name="nonnull"/> <xs:annotation name="final"/> </xs:element> - <xs:element type="highBrightnessMode" name="highBrightnessMode" minOccurs="0" - maxOccurs="1"/> + <xs:element type="highBrightnessMode" name="highBrightnessMode" minOccurs="0" maxOccurs="1"/> <xs:element type="displayQuirks" name="quirks" minOccurs="0" maxOccurs="1" /> <xs:element type="nonNegativeDecimal" name="screenBrightnessRampFastDecrease"> <xs:annotation name="final"/> @@ -55,19 +54,6 @@ <xs:element type="sensorDetails" name="proxSensor"> <xs:annotation name="final"/> </xs:element> - - <!-- Set of thresholds that dictate the change needed for screen brightness - adaptations --> - <xs:element type="thresholds" name="displayBrightnessChangeThresholds"> - <xs:annotation name="nonnull"/> - <xs:annotation name="final"/> - </xs:element> - <!-- Set of thresholds that dictate the change needed for ambient brightness - adaptations --> - <xs:element type="thresholds" name="ambientBrightnessChangeThresholds"> - <xs:annotation name="nonnull"/> - <xs:annotation name="final"/> - </xs:element> </xs:sequence> </xs:complexType> </xs:element> @@ -82,8 +68,7 @@ <xs:complexType name="highBrightnessMode"> <xs:all> - <xs:element name="transitionPoint" type="nonNegativeDecimal" minOccurs="1" - maxOccurs="1"> + <xs:element name="transitionPoint" type="nonNegativeDecimal" minOccurs="1" maxOccurs="1"> <xs:annotation name="nonnull"/> <xs:annotation name="final"/> </xs:element> @@ -112,8 +97,7 @@ <xs:complexType name="hbmTiming"> <xs:all> - <xs:element name="timeWindowSecs" type="xs:nonNegativeInteger" minOccurs="1" - maxOccurs="1"> + <xs:element name="timeWindowSecs" type="xs:nonNegativeInteger" minOccurs="1" maxOccurs="1"> <xs:annotation name="nonnull"/> <xs:annotation name="final"/> </xs:element> @@ -197,31 +181,5 @@ </xs:sequence> </xs:complexType> - <!-- Thresholds for brightness changes. --> - <xs:complexType name="thresholds"> - <xs:sequence> - <!-- Brightening thresholds. --> - <xs:element name="brighteningThresholds" type="brightnessThresholds" minOccurs="0" - maxOccurs="1" > - <xs:annotation name="nonnull"/> - <xs:annotation name="final"/> - </xs:element> - <!-- Darkening thresholds. --> - <xs:element name="darkeningThresholds" type="brightnessThresholds" minOccurs="0" - maxOccurs="1" > - <xs:annotation name="nonnull"/> - <xs:annotation name="final"/> - </xs:element> - </xs:sequence> - </xs:complexType> - - <!-- Brightening and darkening minimum change thresholds. --> - <xs:complexType name="brightnessThresholds"> - <!-- Minimum brightness change needed. --> - <xs:element name="minimum" type="nonNegativeDecimal" minOccurs="0" maxOccurs="1" > - <xs:annotation name="nonnull"/> - <xs:annotation name="final"/> - </xs:element> - </xs:complexType> </xs:schema> diff --git a/services/core/xsd/display-device-config/schema/current.txt b/services/core/xsd/display-device-config/schema/current.txt index df468d41fdef..ad186026d30c 100644 --- a/services/core/xsd/display-device-config/schema/current.txt +++ b/services/core/xsd/display-device-config/schema/current.txt @@ -1,16 +1,8 @@ // Signature format: 2.0 package com.android.server.display.config { - public class BrightnessThresholds { - ctor public BrightnessThresholds(); - method @NonNull public final java.math.BigDecimal getMinimum(); - method public final void setMinimum(@NonNull java.math.BigDecimal); - } - public class DisplayConfiguration { ctor public DisplayConfiguration(); - method @NonNull public final com.android.server.display.config.Thresholds getAmbientBrightnessChangeThresholds(); - method @NonNull public final com.android.server.display.config.Thresholds getDisplayBrightnessChangeThresholds(); method public com.android.server.display.config.HighBrightnessMode getHighBrightnessMode(); method public final com.android.server.display.config.SensorDetails getLightSensor(); method public final com.android.server.display.config.SensorDetails getProxSensor(); @@ -21,8 +13,6 @@ package com.android.server.display.config { method public final java.math.BigDecimal getScreenBrightnessRampFastIncrease(); method public final java.math.BigDecimal getScreenBrightnessRampSlowDecrease(); method public final java.math.BigDecimal getScreenBrightnessRampSlowIncrease(); - method public final void setAmbientBrightnessChangeThresholds(@NonNull com.android.server.display.config.Thresholds); - method public final void setDisplayBrightnessChangeThresholds(@NonNull com.android.server.display.config.Thresholds); method public void setHighBrightnessMode(com.android.server.display.config.HighBrightnessMode); method public final void setLightSensor(com.android.server.display.config.SensorDetails); method public final void setProxSensor(com.android.server.display.config.SensorDetails); @@ -110,14 +100,6 @@ package com.android.server.display.config { enum_constant public static final com.android.server.display.config.ThermalStatus shutdown; } - public class Thresholds { - ctor public Thresholds(); - method @NonNull public final com.android.server.display.config.BrightnessThresholds getBrighteningThresholds(); - method @NonNull public final com.android.server.display.config.BrightnessThresholds getDarkeningThresholds(); - method public final void setBrighteningThresholds(@NonNull com.android.server.display.config.BrightnessThresholds); - method public final void setDarkeningThresholds(@NonNull com.android.server.display.config.BrightnessThresholds); - } - public class XmlParser { ctor public XmlParser(); method public static com.android.server.display.config.DisplayConfiguration read(java.io.InputStream) throws javax.xml.datatype.DatatypeConfigurationException, java.io.IOException, org.xmlpull.v1.XmlPullParserException; diff --git a/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java b/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java index 356600d84099..bdf94f3a2882 100644 --- a/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java +++ b/services/tests/servicestests/src/com/android/server/display/BrightnessTrackerTest.java @@ -33,7 +33,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ParceledListSlice; import android.database.ContentObserver; -import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.display.AmbientBrightnessDayStats; @@ -43,7 +42,6 @@ import android.hardware.display.ColorDisplayManager; import android.hardware.display.DisplayManager; import android.hardware.display.DisplayedContentSample; import android.hardware.display.DisplayedContentSamplingAttributes; -import android.hardware.input.InputSensorInfo; import android.os.BatteryManager; import android.os.Handler; import android.os.HandlerThread; @@ -65,8 +63,6 @@ import com.android.internal.R; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -88,11 +84,8 @@ public class BrightnessTrackerTest { private static final String DEFAULT_DISPLAY_ID = "123"; private static final float FLOAT_DELTA = 0.01f; - @Mock private InputSensorInfo mInputSensorInfoMock; - private BrightnessTracker mTracker; private TestInjector mInjector; - private Sensor mLightSensorFake; private static Object sHandlerLock = new Object(); private static Handler sHandler; @@ -115,12 +108,9 @@ public class BrightnessTrackerTest { @Before public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); mInjector = new TestInjector(ensureHandler()); - mLightSensorFake = new Sensor(mInputSensorInfoMock); mTracker = new BrightnessTracker(InstrumentationRegistry.getContext(), mInjector); - mTracker.setLightSensor(mLightSensorFake); mDefaultNightModeColorTemperature = InstrumentationRegistry.getContext().getResources().getInteger( R.integer.config_nightDisplayColorTemperatureDefault); @@ -844,47 +834,6 @@ public class BrightnessTrackerTest { mTracker.stop(); } - @Test - public void testLightSensorChange() { - // verify the tracker started correctly and a listener registered - startTracker(mTracker); - assertNotNull(mInjector.mSensorListener); - assertEquals(mInjector.mLightSensor, mLightSensorFake); - - // Setting the sensor to null should stop the registered listener. - mTracker.setLightSensor(null); - mInjector.waitForHandler(); - assertNull(mInjector.mSensorListener); - assertNull(mInjector.mLightSensor); - - // Resetting sensor should start listener again - mTracker.setLightSensor(mLightSensorFake); - mInjector.waitForHandler(); - assertNotNull(mInjector.mSensorListener); - assertEquals(mInjector.mLightSensor, mLightSensorFake); - - Sensor secondSensor = new Sensor(mInputSensorInfoMock); - // Setting a different listener should keep things working - mTracker.setLightSensor(secondSensor); - mInjector.waitForHandler(); - assertNotNull(mInjector.mSensorListener); - assertEquals(mInjector.mLightSensor, secondSensor); - } - - @Test - public void testSetLightSensorDoesntStartListener() { - mTracker.setLightSensor(mLightSensorFake); - assertNull(mInjector.mSensorListener); - } - - @Test - public void testNullLightSensorWontRegister() { - mTracker.setLightSensor(null); - startTracker(mTracker); - assertNull(mInjector.mSensorListener); - assertNull(mInjector.mLightSensor); - } - private InputStream getInputStream(String data) { return new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); } @@ -975,7 +924,6 @@ public class BrightnessTrackerTest { private class TestInjector extends BrightnessTracker.Injector { SensorEventListener mSensorListener; - Sensor mLightSensor; BroadcastReceiver mBroadcastReceiver; DisplayManager.DisplayListener mDisplayListener; Map<String, Integer> mSecureIntSettings = new HashMap<>(); @@ -1026,16 +974,14 @@ public class BrightnessTrackerTest { @Override public void registerSensorListener(Context context, - SensorEventListener sensorListener, Sensor lightSensor, Handler handler) { + SensorEventListener sensorListener, Handler handler) { mSensorListener = sensorListener; - mLightSensor = lightSensor; } @Override public void unregisterSensorListener(Context context, SensorEventListener sensorListener) { mSensorListener = null; - mLightSensor = null; } @Override |