Loading services/core/java/com/android/server/display/DisplayModeDirector.java +3 −2 Original line number Diff line number Diff line Loading @@ -49,8 +49,9 @@ import android.view.DisplayInfo; import com.android.internal.os.BackgroundThread; import com.android.internal.R; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory; import com.android.server.display.whitebalance.AmbientFilter; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -970,7 +971,7 @@ public class DisplayModeDirector { if (lightSensor != null) { final Resources res = mContext.getResources(); mAmbientFilter = DisplayWhiteBalanceFactory.createBrightnessFilter(res); mAmbientFilter = AmbientFilterFactory.createBrightnessFilter(TAG, res); mLightSensor = lightSensor; onScreenOn(isDefaultDisplayOn()); Loading services/core/java/com/android/server/display/whitebalance/AmbientFilter.java→services/core/java/com/android/server/display/utils/AmbientFilter.java +1 −4 Original line number Diff line number Diff line Loading @@ -14,13 +14,10 @@ * limitations under the License. */ package com.android.server.display.whitebalance; package com.android.server.display.utils; import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.server.display.utils.RollingBuffer; import java.io.PrintWriter; import java.util.Arrays; Loading services/core/java/com/android/server/display/utils/AmbientFilterFactory.java 0 → 100644 +105 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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 android.content.res.Resources; import android.content.res.TypedArray; import android.util.TypedValue; public class AmbientFilterFactory { /** * Creates a temporal filter which functions as a weighted moving average buffer for recent * sensor values. * @param tag * The tag used for dumping and logging. * @param horizon * How long ambient value changes are kept and taken into consideration. * @param intercept * Recent changes are prioritised by integrating their duration over y = x + intercept * (the higher it is, the less prioritised recent changes are). * * @return * An AmbientFiler. * * @throws IllegalArgumentException * - Horizon is not positive. * - Intercept not configured. */ public static AmbientFilter createAmbientFilter(String tag, int horizon, float intercept) { if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter(tag, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceBrightnessFilterIntercept"); } /** * Helper to create a default BrightnessFilter which has configuration in the resource file. * @param tag * The tag used for dumping and logging. * @param resources * The resources used to configure the various components. * * @return * An AmbientFilter. */ public static AmbientFilter createBrightnessFilter(String tag, Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceBrightnessFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen.config_displayWhiteBalanceBrightnessFilterIntercept); return createAmbientFilter(tag, horizon, intercept); } /** * Helper to creates a default ColorTemperatureFilter which has configuration in the resource * file. * @param tag * The tag used for dumping and logging. * @param resources * The resources used to configure the various components. * * @return * An AmbientFilter. */ public static AmbientFilter createColorTemperatureFilter(String tag, Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer .config_displayWhiteBalanceColorTemperatureFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen .config_displayWhiteBalanceColorTemperatureFilterIntercept); return createAmbientFilter(tag, horizon, intercept); } // Instantiation is disabled. private AmbientFilterFactory() { } private static float getFloat(Resources resources, int id) { TypedValue value = new TypedValue(); resources.getValue(id, value, true /* resolveRefs */); if (value.type != TypedValue.TYPE_FLOAT) { return Float.NaN; } return value.getFloat(); } } services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.display.color.ColorDisplayService.ColorDisplayServiceInternal; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.History; import java.io.PrintWriter; Loading services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceFactory.java +6 −34 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.os.Handler; import android.util.TypedValue; import com.android.internal.annotations.VisibleForTesting; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; /** * The DisplayWhiteBalanceFactory creates and configures an DisplayWhiteBalanceController. Loading Loading @@ -58,10 +60,12 @@ public class DisplayWhiteBalanceFactory { SensorManager sensorManager, Resources resources) { final AmbientSensor.AmbientBrightnessSensor brightnessSensor = createBrightnessSensor(handler, sensorManager, resources); final AmbientFilter brightnessFilter = createBrightnessFilter(resources); final AmbientFilter brightnessFilter = AmbientFilterFactory.createBrightnessFilter(BRIGHTNESS_FILTER_TAG, resources); final AmbientSensor.AmbientColorTemperatureSensor colorTemperatureSensor = createColorTemperatureSensor(handler, sensorManager, resources); final AmbientFilter colorTemperatureFilter = createColorTemperatureFilter(resources); final AmbientFilter colorTemperatureFilter = AmbientFilterFactory .createColorTemperatureFilter(COLOR_TEMPERATURE_FILTER_TAG, resources); final DisplayWhiteBalanceThrottler throttler = createThrottler(resources); final float[] displayWhiteBalanceLowLightAmbientBrightnesses = getFloatArray(resources, com.android.internal.R.array Loading Loading @@ -111,23 +115,6 @@ public class DisplayWhiteBalanceFactory { return new AmbientSensor.AmbientBrightnessSensor(handler, sensorManager, rate); } /** * Creates a BrightnessFilter which functions as a weighted moving average buffer for recent * brightness values. */ public static AmbientFilter createBrightnessFilter(Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceBrightnessFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen.config_displayWhiteBalanceBrightnessFilterIntercept); if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter( BRIGHTNESS_FILTER_TAG, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceBrightnessFilterIntercept"); } /** * Creates an ambient color sensor instance to redirect sensor data to callbacks. */ Loading @@ -143,21 +130,6 @@ public class DisplayWhiteBalanceFactory { return new AmbientSensor.AmbientColorTemperatureSensor(handler, sensorManager, name, rate); } private static AmbientFilter createColorTemperatureFilter(Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer .config_displayWhiteBalanceColorTemperatureFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen .config_displayWhiteBalanceColorTemperatureFilterIntercept); if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter( COLOR_TEMPERATURE_FILTER_TAG, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceColorTemperatureFilterIntercept"); } private static DisplayWhiteBalanceThrottler createThrottler(Resources resources) { final int increaseDebounce = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceDecreaseDebounce); Loading Loading
services/core/java/com/android/server/display/DisplayModeDirector.java +3 −2 Original line number Diff line number Diff line Loading @@ -49,8 +49,9 @@ import android.view.DisplayInfo; import com.android.internal.os.BackgroundThread; import com.android.internal.R; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; import com.android.server.display.whitebalance.DisplayWhiteBalanceFactory; import com.android.server.display.whitebalance.AmbientFilter; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -970,7 +971,7 @@ public class DisplayModeDirector { if (lightSensor != null) { final Resources res = mContext.getResources(); mAmbientFilter = DisplayWhiteBalanceFactory.createBrightnessFilter(res); mAmbientFilter = AmbientFilterFactory.createBrightnessFilter(TAG, res); mLightSensor = lightSensor; onScreenOn(isDefaultDisplayOn()); Loading
services/core/java/com/android/server/display/whitebalance/AmbientFilter.java→services/core/java/com/android/server/display/utils/AmbientFilter.java +1 −4 Original line number Diff line number Diff line Loading @@ -14,13 +14,10 @@ * limitations under the License. */ package com.android.server.display.whitebalance; package com.android.server.display.utils; import android.util.Slog; import com.android.internal.annotations.VisibleForTesting; import com.android.server.display.utils.RollingBuffer; import java.io.PrintWriter; import java.util.Arrays; Loading
services/core/java/com/android/server/display/utils/AmbientFilterFactory.java 0 → 100644 +105 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 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 android.content.res.Resources; import android.content.res.TypedArray; import android.util.TypedValue; public class AmbientFilterFactory { /** * Creates a temporal filter which functions as a weighted moving average buffer for recent * sensor values. * @param tag * The tag used for dumping and logging. * @param horizon * How long ambient value changes are kept and taken into consideration. * @param intercept * Recent changes are prioritised by integrating their duration over y = x + intercept * (the higher it is, the less prioritised recent changes are). * * @return * An AmbientFiler. * * @throws IllegalArgumentException * - Horizon is not positive. * - Intercept not configured. */ public static AmbientFilter createAmbientFilter(String tag, int horizon, float intercept) { if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter(tag, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceBrightnessFilterIntercept"); } /** * Helper to create a default BrightnessFilter which has configuration in the resource file. * @param tag * The tag used for dumping and logging. * @param resources * The resources used to configure the various components. * * @return * An AmbientFilter. */ public static AmbientFilter createBrightnessFilter(String tag, Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceBrightnessFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen.config_displayWhiteBalanceBrightnessFilterIntercept); return createAmbientFilter(tag, horizon, intercept); } /** * Helper to creates a default ColorTemperatureFilter which has configuration in the resource * file. * @param tag * The tag used for dumping and logging. * @param resources * The resources used to configure the various components. * * @return * An AmbientFilter. */ public static AmbientFilter createColorTemperatureFilter(String tag, Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer .config_displayWhiteBalanceColorTemperatureFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen .config_displayWhiteBalanceColorTemperatureFilterIntercept); return createAmbientFilter(tag, horizon, intercept); } // Instantiation is disabled. private AmbientFilterFactory() { } private static float getFloat(Resources resources, int id) { TypedValue value = new TypedValue(); resources.getValue(id, value, true /* resolveRefs */); if (value.type != TypedValue.TYPE_FLOAT) { return Float.NaN; } return value.getFloat(); } }
services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceController.java +1 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.display.color.ColorDisplayService.ColorDisplayServiceInternal; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.History; import java.io.PrintWriter; Loading
services/core/java/com/android/server/display/whitebalance/DisplayWhiteBalanceFactory.java +6 −34 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.os.Handler; import android.util.TypedValue; import com.android.internal.annotations.VisibleForTesting; import com.android.server.display.utils.AmbientFilter; import com.android.server.display.utils.AmbientFilterFactory; /** * The DisplayWhiteBalanceFactory creates and configures an DisplayWhiteBalanceController. Loading Loading @@ -58,10 +60,12 @@ public class DisplayWhiteBalanceFactory { SensorManager sensorManager, Resources resources) { final AmbientSensor.AmbientBrightnessSensor brightnessSensor = createBrightnessSensor(handler, sensorManager, resources); final AmbientFilter brightnessFilter = createBrightnessFilter(resources); final AmbientFilter brightnessFilter = AmbientFilterFactory.createBrightnessFilter(BRIGHTNESS_FILTER_TAG, resources); final AmbientSensor.AmbientColorTemperatureSensor colorTemperatureSensor = createColorTemperatureSensor(handler, sensorManager, resources); final AmbientFilter colorTemperatureFilter = createColorTemperatureFilter(resources); final AmbientFilter colorTemperatureFilter = AmbientFilterFactory .createColorTemperatureFilter(COLOR_TEMPERATURE_FILTER_TAG, resources); final DisplayWhiteBalanceThrottler throttler = createThrottler(resources); final float[] displayWhiteBalanceLowLightAmbientBrightnesses = getFloatArray(resources, com.android.internal.R.array Loading Loading @@ -111,23 +115,6 @@ public class DisplayWhiteBalanceFactory { return new AmbientSensor.AmbientBrightnessSensor(handler, sensorManager, rate); } /** * Creates a BrightnessFilter which functions as a weighted moving average buffer for recent * brightness values. */ public static AmbientFilter createBrightnessFilter(Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceBrightnessFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen.config_displayWhiteBalanceBrightnessFilterIntercept); if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter( BRIGHTNESS_FILTER_TAG, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceBrightnessFilterIntercept"); } /** * Creates an ambient color sensor instance to redirect sensor data to callbacks. */ Loading @@ -143,21 +130,6 @@ public class DisplayWhiteBalanceFactory { return new AmbientSensor.AmbientColorTemperatureSensor(handler, sensorManager, name, rate); } private static AmbientFilter createColorTemperatureFilter(Resources resources) { final int horizon = resources.getInteger( com.android.internal.R.integer .config_displayWhiteBalanceColorTemperatureFilterHorizon); final float intercept = getFloat(resources, com.android.internal.R.dimen .config_displayWhiteBalanceColorTemperatureFilterIntercept); if (!Float.isNaN(intercept)) { return new AmbientFilter.WeightedMovingAverageAmbientFilter( COLOR_TEMPERATURE_FILTER_TAG, horizon, intercept); } throw new IllegalArgumentException("missing configurations: " + "expected config_displayWhiteBalanceColorTemperatureFilterIntercept"); } private static DisplayWhiteBalanceThrottler createThrottler(Resources resources) { final int increaseDebounce = resources.getInteger( com.android.internal.R.integer.config_displayWhiteBalanceDecreaseDebounce); Loading