如果在Android设置中启用自动亮度,我想修改Android更改屏幕亮度的速度。
问题在于,如果屏幕亮度快速变化,则会非常烦人,因为如果用户的手意外覆盖了光线传感器。
禁用自动亮度不是一个选项。
我发现了这个:Change brightness according to surrounding light in android 但我宁愿不要手动破解它......
有更好的选择吗?
答案 0 :(得分:3)
您可能想看一下这些常量
private static final int BRIGHTNESS_RAMP_RATE_FAST = 200;
private static final int BRIGHTNESS_RAMP_RATE_SLOW = 40;
以及它们如何在DisplayPowerController类中使用
Controls the power state of the display. Handles the proximity sensor, light sensor,
and animations between states including the screen off animation.
您可能还想查看rate
的{{1}}参数here
public boolean registerListener (SensorListener listener, int sensors, int rate)
答案 1 :(得分:1)
您无法在DisplayManager中更改自动亮度变化延迟,也无法更改曲线。您可以安装一个控制亮度的市场应用程序,并让您更好地控制它的工作方式。点击此处:https://play.google.com/store/search?q=auto+brightness&c=apps
SensorEventListener mLightListener = new SensorEventListener() {
2971 public void More ...onSensorChanged(SensorEvent event) {
2972 synchronized (mLocks) {
2973 // ignore light sensor while screen is turning off
2974 if (isScreenTurningOffLocked()) {
2975 return;
2976 }
2977
2978 int value = (int)event.values[0];
2979 long milliseconds = SystemClock.elapsedRealtime();
2980 if (mDebugLightSensor) {
2981 Slog.d(TAG, "onSensorChanged: light value: " + value);
2982 }
2983 mHandler.removeCallbacks(mAutoBrightnessTask);
2984 if (mLightSensorValue != value) {
2985 if (mLightSensorValue == -1 ||
2986 milliseconds < mLastScreenOnTime + mLightSensorWarmupTime) {
2987 // process the value immediately if screen has just turned on
2988 lightSensorChangedLocked(value);
2989 } else {
2990 // delay processing to debounce the sensor
2991 mLightSensorPendingValue = value;
2992 mHandler.postDelayed(mAutoBrightnessTask, LIGHT_SENSOR_DELAY);
2993 }
2994 } else {
2995 mLightSensorPendingValue = -1;
2996 }
2997 }
2998 }
2999
3000 public void More ...onAccuracyChanged(Sensor sensor, int accuracy) {
3001 // ignore
3002 }
3003 };
如您所见,LIGHT_SENSOR_DELAY是
private static final int LIGHT_SENSOR_DELAY = 2000;