LightBlog

mardi 22 août 2017

Android Oreo System Apps Can Set Volume Key Long-Press Listeners

Adding additional functionality to various hardware and software buttons on our devices is something Android enthusiasts have been doing for a while. Most people know about applications such as Button Mapper from XDA Recognized Developer flar2, and we even spoke about other remapper solutions back when the Galaxy S8 was released. While those solutions handled these actions in a certain way, Google looks to be implementing a listener in Android Oreo for long-pressing the volume keys. This means that potentially, applications in the future might be able to react to volume key long presses even while the screen is off, which could be used to bring an often-requested feature over from custom ROMs – music track control with volume key presses.

We do want to mention that this feature isn’t actually enabled in the user-facing build that we have available to us right now. Support for it is there though, as evidenced by the commit we found, and that means it can be enabled by the OEM for your specific device. As mentioned, traditional remapping applications work by detecting if a KeyEvent has been sent (even with long-presses and double presses), but these are only sent while the screen is on and also typically require the use of an Accessibility Service which can be taxing on the performance.

Your typical button remap solution can be considered to be a workaround to be used to toggle the torch on or off, opening an application, pulling down the notification panel and so on. However, what Google has implemented into Android Oreo takes this a step further with letting system applications themselves set up these volume button long-press listeners. This could allow the user to trigger something within the application itself once the platform detects a volume button has been held down for a few seconds.

The way Google has included support for this in Android Oreo, this will only work for “privileged” (aka pre-installed system) applications out of the box. The OEM just needs to allow the privileged application to have the android.permission.SET_VOLUME_KEY_LONG_PRESS_LISTENER permission in order to set the listener. However, we’ve been able to grant permissions like these with ADB commands so it’s possible that those of us in the know could manually set this for a 3rd-party applications too.



from xda-developers http://ift.tt/2imzgfq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire