phhusson / treble_experimentations

Notes about tinkering with Android Project Treble
3.38k stars 655 forks source link

[S10/S10+/S10E] Auto-brightness non-functional #492

Open DrRambone opened 5 years ago

DrRambone commented 5 years ago

Auto-brightness non-functional

phhusson commented 5 years ago

Create an overlay, see https://github.com/phhusson/treble_experimentations/wiki/How-to-create-an-overlay%3F

uvitor commented 5 years ago

I did https://github.com/uvitor/vendor_hardware_overlay/tree/master/Samsung/beyond2ltexx

When I run test script it returns a lot of issues saying it doesn't corresponds to an available option(or something like that)even so I built it and it doesn't show me any new option to choose (cmd overlay list).

uvitor commented 5 years ago

0422-3800.zip Here are the original stock framework res, and the apk overlay made by me following yours instructions.

elmkzgirxp commented 5 years ago

Tried enabling automatic brightness using an overlay and I was stuck on bootloop. I investigated further and found this in the logcat:

06-14 23:23:27.717  5616  5616 W SystemServer: ***********************************************
06-14 23:23:27.718  5616  5616 E SystemServer: BOOT FAILURE making Power Manager Service ready
06-14 23:23:27.718  5616  5616 E SystemServer: java.lang.IllegalArgumentException: backlight[256] is out of range of [0, 255] (too high)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.internal.util.Preconditions.checkArrayElementsInRange(Preconditions.java:524)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.display.BrightnessMappingStrategy$PhysicalMappingStrategy.<init>(BrightnessMappingStrategy.java:598)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.display.BrightnessMappingStrategy.create(BrightnessMappingStrategy.java:82)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.display.DisplayPowerController.<init>(DisplayPowerController.java:477)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.display.DisplayManagerService$LocalService.initPowerManagement(DisplayManagerService.java:2186)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.power.PowerManagerService.systemReady(PowerManagerService.java:783)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.SystemServer.startOtherServices(SystemServer.java:1703)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.SystemServer.run(SystemServer.java:437)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.server.SystemServer.main(SystemServer.java:296)
06-14 23:23:27.718  5616  5616 E SystemServer:  at java.lang.reflect.Method.invoke(Native Method)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
06-14 23:23:27.718  5616  5616 E SystemServer:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:838)

Apparently, com.android.server.display.BrightnessMappingStrategy$PhysicalMappingStrategy checks if the backlight values are within the range set by PowerManager.BRIGHTNESS_OFF and PowerManager.BRIGHTNESS_ON. The S10's backlight values go up to 486 at 800 nits, when PowerManager.BRIGHTNESS_ON is set to only 255.

I removed the excess values from Samsung's overlay and limited it to 255 at 420 nits, and the system booted fine with auto-brightness fully working, although we can't utilize peak brightness anymore.

One solution I could think of is to create a resource like config_screenBrightnessExtendedMaximum (this is what Samsung actually did) and use that instead of PowerManager.BRIGHTNESS_ON. This way, other devices that have a different implementation for HBM won't be affected and we can just create an overlay for any devices' usage.

References

phhusson commented 5 years ago

You should already be able to go to the higher brightness values by going in treble settings and ticking samsung high brightness

elmkzgirxp commented 5 years ago

Ah, didn't notice that. Regarding the overlay, it's possible to override it, right? Since the vendor overlay's priority is 0.

I'll get started on creating an overlay for the S10 then.

Flatty11 commented 5 years ago

Ah, didn't notice that. Regarding the overlay, it's possible to override it, right? Since the vendor overlay's priority is 0.

I'll get started on creating an overlay for the S10 then.

Hello, can you share your overlay?

ktshikotshi commented 5 years ago

@elmkzgirxp did you get your overlay working? mine does nothing at all.

elmkzgirxp commented 5 years ago

Yes, it's working as expected. Try this: framework-res__auto_generated_rro.zip

I currently don't have time to make an overlay repository for the S10, so I just decompiled Samsung's RRO and signed it.

Sn0whax commented 5 years ago

@phhusson @Flatty11 On the S10 SM-G9730 the Autobrightess works well. Sometimes upon waking (I think from doze) the brightness is very high.

Is there a specific file I can turn off battery optimization? On Samsungs/Pixels stock android, this fell under "Device health services".

I believe the doze turns off the light sensor and forgets its ambient light setting.

Sn0whax commented 4 years ago

The app "YAAB" appears to add auto brightness without much issue.