Jul 4, 2015

Playing With Smartphone / Tablet Android Drivers

If you have an Android device like smartphone or tablet, good news! you can control directly some parameters of your device, accessing directly the driver layer. This is useful if you need more screen brightness while using your device outside with sun, for example, or can't find an App that works with your device. Look here an example of control the screen brightness and led buttons.

First a quick overview... any Android App (that you can download from Google Play), will use the Android API, that provides ways to access some of the hardware features, this is good and bad. Good because is easy to access them through an abstraction, but bad because you are tied to the available API methods (as a developer), App settings (as a user), values range and security/permission system.

The Android API access the hardware using the respective driver, but you can use the driver directly too! just be careful, don't exceed the values, otherwise you can damage your device permanently. To access the driver entries you will need a rooted device and a SSH connection, using the SSHDroid App for example (do this by yourself !).

Each device, due the Linux/Android/ROM/manufacturer and driver version, has a different driver entry/name, so you will need to find in your device the proper one, but the driver path will usually start at "/sys/class/". Using an LG Optimus 4x as example, the screen brightness can be controlled thorough this entry:

echo 100 > /sys/class/leds/lcd-backlight/brightness

To turn off the screen, just place a zero:

echo 0 > /sys/class/leds/lcd-backlight/brightness

To set the maximum brightness:

echo 255 > /sys/class/leds/lcd-backlight/brightness

Remember, these values can be different for your device, always look the actual value to understand the range and play with near numbers. Now to turn on and off respectively the led buttons:

echo 1 > /sys/class/leds/button-backlight/brightness
echo 0 > /sys/class/leds/button-backlight/brightness

The video below show the above examples, first playing with the led buttons and then with the screen brightness:



That's all, now play with the others drivers entries and discover by yourself new ways to change your device configurations, without the need of an App for your device!

About the versions
  • LG optimus 4x P880
  • Android 4.2.2 (CyanogenMod 10.1.3)
  • SSHDroid 2.0.8

2 comments :

  1. Thanks, I'm using nexus 4, with android 5.1 but on trying to set 0 in brightness there is no turn off, only darker scree. I'm struggling with it, but still have no clue. Thanks for any idea.

    ReplyDelete
    Replies
    1. Hello, each driver is different, and control different devices, so I can't help you from here, but just keep trying others driver entries and values, try negative numbers too!

      Delete