phhusson / Superuser

Keeping koush's Superuser fresh
GNU General Public License v3.0
423 stars 50 forks source link

Writing to sysfs is broken (sometimes) #56

Closed paulie-g closed 7 years ago

paulie-g commented 7 years ago

Use case: Nexus 6P's touchscreen sensor exposes a parameter that enables double tap to wake via sysfs (/sys/devices/soc.0/f9924000.i2c/i2c-2/2-0070/input/input0/wake_gesture). Kernel Adiutor as well as a number of apps, some of them open source (for example https://github.com/manuelsc/DoubleTap-for-6P) allow the user to enable dt2w either interactively from within the app or on boot.

What's broken: While all of those apps work when toggling the parameter from within the app, none of them are able to do it on boot. In a root adb shell, 'echo 1 > /sys/devices/soc.0/f9924000.i2c/i2c-2/2-0070/input/input0/wake_gesture' either fails silently (sh) or reports EINVAL (ash).

Why I think it's phh superuser: There are no reports of this not working either via the shell or with the apps and it is widely used. Presumably, this means it works on SuperSU. It certainly worked for me on a custom ROM with SuperSU baked in.

Why no patch/fix from me: I'm a bit mystified by a number of things. I suspect this is your locked-down SELinux policy at work, but I'm seeing nothing in either dmesg or logcat when attempting to write with an su shell. If it is SELinux, would the context be different for an activity that runs on BOOT_COMPLETED compared to when it is started normally?

Frankly, although I'm prepared to debug it further myself, it would be a big help if someone who knows what they're doing with this stuff chimed in first to at the very least point me in the right direction.

paulie-g commented 7 years ago

I did debug it further and, it turns out, I was wrong. It turns out the synaptix touchscreen driver refuses to apply this setting when the device is in sleep mode. There's some sort of strange timing thing going on at boot, but it's unlikely to have anything to do with this su implementaiton.