4

如果在 Android 设置中启用了自动亮度,我想修改 Android 更改屏幕亮度的速度。

问题是如果屏幕亮度快速变化会很烦人,因为如果用户的手不小心遮住了光传感器。

禁用自动亮度不是一个选项。

我发现了这个:根据android中的周围光线改变亮度 但我不想手动破解它......

有更好的选择吗?

4

2 回答 2

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参数public boolean registerListener (SensorListener listener, int sensors, int rate)

 The rate sensor events are delivered at. This is only a hint to the system. 
 Events may be received faster or slower than the specified rate. 
 Usually events are received faster. The value must be one of SENSOR_DELAY_NORMAL,
 SENSOR_DELAY_UI, SENSOR_DELAY_GAME, or SENSOR_DELAY_FASTEST or, the desired delay
 between events in microseconds. 
 Specifying the delay in microseconds only works from
 Android 2.3 (API level 9) onwards. For earlier releases, you must use one of the 
 SENSOR_DELAY_* constants.
于 2013-08-15T13:29:40.933 回答
1

您无法更改 DisplayManager 中的自动亮度更改延迟,也无法更改曲线。您可以安装控制亮度的市场应用程序之一,并让您更好地控制它的完成方式。在这里查看:https ://play.google.com/store/search?q=auto+brightness&c=apps

从这里: http: //grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/2.3_r1/com/android/server/PowerManagerService.java#PowerManagerService.getAutoBrightnessValue%28int% 2Cint%5B%5D%29

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;
于 2013-08-11T08:38:37.293 回答