Brightness.getSystemBrightnessAsync() issue with Auto Brightness on Android

When using Auto Brightness on Android the function Brightness.getSystemBrightnessAsync() always returns the value of the brightness slider and not the value of the Auto Brightness. With Auto Brightness on the slider value has no usage as the system is controlling the brightness. Therefore it would be great if Brightness.getSystemBrightnessAsync() would return the real value.

Hey @0llum,

As mentioned in the docs, the getSystemBrightnessAsync() method is experimental: https://docs.expo.io/versions/v28.0.0/sdk/brightness#expobrightnessgetsystembrightnessasync

Would you be able to create a feature request on our Canny: https://expo.canny.io/feature-requests detailing exactly what you want to be able to get from the Brightness API?

Cheers,

Adam

Hey @0llum! thanks for writing in. fwiw, the implementation of Brightness.getSystemBrightnessAsync() is here: https://github.com/expo/expo/blob/master/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/BrightnessModule.java#L52

and we get Android’s exposed SCREEN_BRIGHTNESS https://developer.android.com/reference/android/provider/Settings.System.html#SCREEN_BRIGHTNESS

To clarify, you are getting the correct value if the user has screen brightness in manual mode (which is also the value shown on the slider), but not the correct value if the user has screen brightness in automatic mode (which is also not consistent with what is shown on the slider)?

hm… idk if theres a better way to implement what you are asking but it looks like Android has a hidden constant to get/set auto brightness https://stackoverflow.com/questions/29349153/change-adaptive-brightness-level-programatically

edit: looks there are 3 brightness types in android - foregrounded screen brightness, manual system brightness (consistent with the slider value) and auto system brightness :confused:

Thanks for the quick response. I created a feature request:
https://expo.canny.io/feature-requests/p/brightness-api-auto-brightness

Yes exactly, in manual mode it works just fine. I get the value corresponding to the slider. In automatic mode I also get the value of the slider, but that is not the value of the actual screen brightness.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.