TrebleDroid / treble_experimentations

Scripts to automatically build/CI/Release TrebleDroid GSI
Other
222 stars 31 forks source link

[Samsung] brightness stuck until kick-started #8

Closed ildar closed 1 year ago

ildar commented 1 year ago

Current Behavior:

Primary brightness control doesn't change it.

Smartphone (please complete the following information):

Additional context

The LOS is TD-based. The brightness is stuck at 131 level:

# cat /sys/class/backlight/panel0-backlight/brightness 131

The following command makes brightness work:

# echo 1 > /sys/class/backlight/panel0-backlight/brightness

ildar commented 1 year ago

More info:

  1. I made a little overlay but that didn't help
  2. logcat has lines like these:
    02-01 02:41:46.764  1193  1193 W composer-servic: type=1400 audit(0.0:1666): avc: denied { write } for name="brightness" dev="sysfs" ino=45865 scontext=u:r:hal_graphics_composer_default:s0 tcontext=u:object_r:sysfs_lcd_writable:s0 tclass=file permissive=0
    02-01 02:41:46.767  1193  1193 E SDM     : HWPeripheralDRM::SetPanelBrightness: Failed to open node = /sys/class/backlight/panel0-backlight/brightness, error = Permission denied

    the ls -alZ:

    -rw-r--r-- 1 system system u:object_r:vendor_sysfs_graphics:s0 4096 2023-02-01 13:46 /sys/class/backlight/panel0-backlight/brightness

phhusson commented 1 year ago

Does the errors in the log disappear after the kickstart?

Does the result of ls -alZ change before/after the kickstart?

Can you remove /system/bin/rw-system.sh and see the result? also provide a ls -alZ

ildar commented 1 year ago

On Thu, Feb 2, 2023 at 3:51 AM Pierre-Hugues HUSSON wrote:

Does the errors in the log disappear after the kickstart?

The error does not appear when /system/bin/rw-system.sh removed.

Does the result of ls -alZ change before/after the kickstart?

before it.

Can you remove /system/bin/rw-system.sh and see the result? also provide a ls -alZ

Wow! the brightness works after removing /system/bin/rw-system.sh ! The ls -alZ is same: -rw-r--r-- 1 system system u:object_r:vendor_sysfs_graphics:s0 4096 1972-05-18 22:33 /sys/class/backlight/panel0-backlight/brightness

ildar commented 1 year ago

also:

Does the errors in the log disappear after the kickstart?

Yes.

Does the result of ls -alZ change before/after the kickstart?

Yes. Before and After: -rw-r--r-- 1 system system u:object_r:sysfs_lcd_writable:s0 4096 1972-05-18 22:43 /sys/class/backlight/panel0-backlight/brightness :/data/data # echo 1 > /sys/class/backlight/panel0-backlight/brightness :/data/data # ls -alZ /sys/class/backlight/panel0-backlight/brightness -rw-r--r-- 1 system system u:object_r:vendor_sysfs_graphics:s0 4096 2023-02-03 00:38 /sys/class/backlight/panel0-backlight/brightness

These all with the /system/bin/rw-system.sh in place.

phhusson commented 1 year ago

Ok, so the issue is that rw-system.sh sets the context to sysfs_lcd_writable, while it shouldn't. Thing is, it will do that under exactly one condition, which is that the file is u:object_r:sysfs:s0. Which according to your logs, it isn't, so I don't quite understand.

So please do grep vendor_sysfs_graphics -r /vendor and send me all the files that match this. Same for grep /sys/class/backlight -r /vendor

On my side I'll check the code again to check if there might be a bug there.

ildar commented 1 year ago

greetings! somehow I cannot reproduce the problem anymore. I tried to debug the issue with the rw-system.sh. After it "fixed itself" I reverted back all the changes but the bug disappeared. Tried with and without my overlay. Sorry. You can look at the full transcript here: https://defuse.ca/b/EudfZXlqESOV44t5plqMKX