Android: setting automatic brightness adaptation speed

I would like to change how quickly the screen brightness changes on Android if Auto Brightness is turned on in Android settings.

The problem is that it is very annoying if the brightness of the screen changes quickly, because if the light sensor is accidentally closed by the user's hand.

Unable to turn off auto brightness.

I found this: Change the brightness according to the ambient light in android But I would prefer not to chop it manually ...

Are there any nicer options?

+4
source share
2 answers

You can take a look at these constants

private static final int BRIGHTNESS_RAMP_RATE_FAST = 200; private static final int BRIGHTNESS_RAMP_RATE_SLOW = 40; 

and how they are used in the DisplayPowerController class, which

  Controls the power state of the display. Handles the proximity sensor, light sensor, and animations between states including the screen off animation. 

You can also look at the rate parameter public boolean registerListener (SensorListener listener, int sensors, int rate) , as described here

  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. 
+3
source

You cannot change the automatic delay of the brightness change in the DisplayManager and you cannot change the curve. You can install one of the market applications that control brightness and give you more control over how this is done. Check here: https://play.google.com/store/search?q=auto+brightness&c=apps

From here: 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 }; 

As you can see, LIGHT_SENSOR_DELAY is

 private static final int LIGHT_SENSOR_DELAY = 2000; 
+1
source

Source: https://habr.com/ru/post/1495194/


All Articles