[APP] Button Mapper - Customize your hardware buttons

Search This thread

DerkWehler

Member
Dec 24, 2010
10
1
p2142635636.jpg



Button Mapper allows you to remap any action you want to physical or capacitive hardware buttons. This includes volume buttons, camera button, home button on Samsung devices and capacitive home, back and recents, Bixby, Active Edge, LG assistant button and many buttons on game controllers and other hardware. It does NOT work with onscreen home, back and recents buttons (i.e. soft keys or the navigation bar).

You can launch shortcuts, apps or actions to single press, double tap and long press for hardware buttons.





Download on XDA Labs:
https://labs.xda-developers.com/store/app/flar2.homebutton

Limitations:
-does not work when the screen is off (unless rooted)
-only works with hardware buttons, not onscreen buttons (i.e. navigation bar)
-power button cannot be modified
-there can be quirks with some devices due to non-standard hardware and software implementations by various manufacturers. I try to fix them, but sometimes it's difficult if I don't have the device to test.




.

If I purchase this, will it remap the google assistant button on LG V50 ThinQ?
 

payas0

Senior Member
Hi, is there a way to remap a GTV remote button to launch android tv settings, specifically the connected devices side page?

I found the address to open this page: com.google.android.tv.btservices.settings.ConnectedDevicesSettingsActivity
Also I've managed to grant abd write secure settings.

But get the following errors with different tries using the com.google... link above:
  • Shortcuts - "cancelled by target app"
  • Shell command
    • adb shell am start -a com.google... - "toybox: unknown command adb"
    • or without adb shell am - "start: must be root"
  • Open URL - "no application can handle this action"
  • nothing else really works..
Would appreciate help to make this work
Cheers

Did you ever find a solution to this "toybox: Unknown command am" error when running am command?

Hi @flar2

I was trying to launch an activity using ButtonMapper Pro ut I can't make it work. Here are the things I've tried.

1. Used Shell command: am start -n "com.android.tv.settings/.<ActivityHere>"
But I was getting the toast "toybox: Unknown command am"

2. Used Shell command: adb shell am start -n "com.android.tv.settings/.<ActivityHere>"
But I was getting the toast "toybox: Unknown command adb"

3. I tried to broadcast the Intent with action "com.android.tv.settings.<ACTIVITY>" and checked the option to launch as activity but nothing happens

4. I tried to broadcast the Intent with action "com.android.tv.settings/.<ACTIVITY>" and checked the option to launch as activity but I was getting the toast "Not available"

I tried attempts 3 and 4 again as package and component values but I just get the same result.

Is there any documentation with examples on how to use the Shell and Broadcast Intent options? I tried looking it up but I had no luck.

When I connected my PC to the TV via adb shell, I was able to run the am start command it launches the activity.

But when I run the same shell command via ButtonMapper I get "toybox: Unknown command am"

Thanks!

EDIT:

I tried to call /system/bin/am instead but it gives me an error asking for the permission android.permission.INTERACT_ACROSS_USERS_FULL

EDIT2:

On getting "toybox: Unknown command am", it's weird because am is not under toybox. It's just android built in binary. Why does ButtonMapper think I was invoking toybox? I looked up toybox and it turns out it a port of unix tools to android like busybox.

Can confirm that /system/bin/am exists. I wonder why ButtonMapper can't invoke the am binary. Maybe ButtonMapper can only invoke unix tool binaries under toybox? I haven't tried but maybe Button Mapper can't invoke pm either. I'll try when I get the chance.

EDIT3:

I tried an app called Activity Launcher and it can launch the activity that I wanted. I am not and Android developer so I have no idea how to figure out how Activity Launcer is doing it. Is it invoking shell command and calling the android am (activity manager)? Or is it firing Intents?

Maybe they right option to use in Button Mapper is the Broadcast Intent but I just can't find a guide on how to use it.
 
Last edited:

payas0

Senior Member
Okay so I managed to make it work. In case anyone needs an idea how Broadcast Intent works here's my experience.

I wanted to go straight to a specific section in the settings. Here's how you can do it.

1. Figure out what the activity is. I have only one way of figuring this out and that's by installing Activity Launcher from the PlayStore, find the activity I wanted.

1.a. I wanted to go straight to the Picture settings. So inside Activity Launcher I searched Picture and I just tried to narrow it down. You can try to launch the listed activities so you know it's the right one.

1.b. When you try to launch the activity there will be a toast and watch it closely and remember what is written. In my case it said it started intent: com.android.tv.settings/.partnercustomizer.picture.PictureActivity

1.c. Take note of the activity class. It is written right there in the list. In my case it's com.android.tv.settings.partnercustomizer.picture.PictureActivity.

2. Once we have the activity class we can go to the Button Mapper app.

2.a. Go to the button you want to customize, pick the event you want to hook it into.

2.b. Pick Broadcast Intent. And here's how you will fill it in based in my example activity class in 1.c.

Action: /.partnercustomizer.picture.PictureActivity
Package: com.android.tv.settings
Component: com.android.tv.settings.partnercustomizer.picture.PictureActivity

Note: The action starts with the forward slash. You saw in 1.b. that when the intent was launched, there was that forward slash just right after the package name.

So that is it. That's how I managed to make it work and maybe it will be the same for other activities I'll want to launch by broadcasting an intent.

Thanks @flar2 for an amzing software. The Pro version is worth it for that price. It was a steal to be honest.
 
  • Like
Reactions: MarkLev and tiho5

MarkLev

Senior Member
Dec 24, 2019
85
80
Did you ever find a solution to this "toybox: Unknown command am" error when running am command?

Hi @flar2

I was trying to launch an activity using ButtonMapper Pro ut I can't make it work. Here are the things I've tried.

1. Used Shell command: am start -n "com.android.tv.settings/.<ActivityHere>"
But I was getting the toast "toybox: Unknown command am"

2. Used Shell command: adb shell am start -n "com.android.tv.settings/.<ActivityHere>"
But I was getting the toast "toybox: Unknown command adb"

3. I tried to broadcast the Intent with action "com.android.tv.settings.<ACTIVITY>" and checked the option to launch as activity but nothing happens

4. I tried to broadcast the Intent with action "com.android.tv.settings/.<ACTIVITY>" and checked the option to launch as activity but I was getting the toast "Not available"

I tried attempts 3 and 4 again as package and component values but I just get the same result.

Is there any documentation with examples on how to use the Shell and Broadcast Intent options? I tried looking it up but I had no luck.

When I connected my PC to the TV via adb shell, I was able to run the am start command it launches the activity.

But when I run the same shell command via ButtonMapper I get "toybox: Unknown command am"

Thanks!

EDIT:

I tried to call /system/bin/am instead but it gives me an error asking for the permission android.permission.INTERACT_ACROSS_USERS_FULL

EDIT2:

On getting "toybox: Unknown command am", it's weird because am is not under toybox. It's just android built in binary. Why does ButtonMapper think I was invoking toybox? I looked up toybox and it turns out it a port of unix tools to android like busybox.

Can confirm that /system/bin/am exists. I wonder why ButtonMapper can't invoke the am binary. Maybe ButtonMapper can only invoke unix tool binaries under toybox? I haven't tried but maybe Button Mapper can't invoke pm either. I'll try when I get the chance.

EDIT3:

I tried an app called Activity Launcher and it can launch the activity that I wanted. I am not and Android developer so I have no idea how to figure out how Activity Launcer is doing it. Is it invoking shell command and calling the android am (activity manager)? Or is it firing Intents?

Maybe they right option to use in Button Mapper is the Broadcast Intent but I just can't find a guide on how to use it.
If adb command works, and adb tcp/ip is enabled on your TV then another way to make it work is using adb on your androidTV instead of adb on computer.
From androidTV:
adb connect $androidTV_IP
adb -s $androidTV_IP shell...
 

payas0

Senior Member
If adb command works, and adb tcp/ip is enabled on your TV then another way to make it work is using adb on your androidTV instead of adb on computer.
From androidTV:
adb connect $androidTV_IP
adb -s $androidTV_IP shell...
Oh, do Android TVs have adb server built in? I didn't know.

Maybe when I need to run other commands, I'll give that a try. But for now, my purpose is to launch activities and the Broadcast Intent handles it so that should ve good for now.

Thanks for the tip though! I'll find uses for that in the future.

EDIT:

I may have misunderstood your comment. I checked and there's no adb binary in the /system/bin so that might not work.
 

ElBoonoS

New member
Apr 17, 2011
3
0
@flar2 Is there a way to support multiple profiles?
can profiles be activated through shell command?
I imagine creating some some profiles and can activate them quickly using termux:widget

Edit: or maybe restore a backup using shell command? This way is simple enough to implement and can easily achieve the above purpose.
Would also be very interested in this.

Doesn't seem to work on my second profile at all. (Kids profile) also cannot activate the pro mode on kids profile. Desperate for help @flar2
 

MarkLev

Senior Member
Dec 24, 2019
85
80
Oh, do Android TVs have adb server built in? I didn't know.

Maybe when I need to run other commands, I'll give that a try. But for now, my purpose is to launch activities and the Broadcast Intent handles it so that should ve good for now.

Thanks for the tip though! I'll find uses for that in the future.

EDIT:

I may have misunderstood your comment. I checked and there's no adb binary in the /system/bin so that might not work.
You can use Termux app, and install adb binary
 

Attachments

  • VID_20220620_171426.mp4
    717.6 KB · Views: 0
  • Like
Reactions: payas0

xgerryx

Senior Member
May 26, 2011
1,235
337
New Hampshire
Going through the ADB process to get screen off keys to work and it states that there was success in granting permissions, but the toggle for that won't stay on, and the off screen keys don't work.

I'm an A12 on a Galaxy s22 Ultra. Did Google remove this functionality?

Edit: seems like it works when the cable is connected to the computer but that's it.
 

flar2

Recognized Developer
Jun 11, 2012
18,799
87,777
Southwestern Ontario
elementalx.org
Going through the ADB process to get screen off keys to work and it states that there was success in granting permissions, but the toggle for that won't stay on, and the off screen keys don't work.

I'm an A12 on a Galaxy s22 Ultra. Did Google remove this functionality?

Edit: seems like it works when the cable is connected to the computer but that's it.
Screen off actions usually don't works on Samsung and Huawei devices. It's just the way they build the hardware
 

TraderJack

Senior Member
Oct 5, 2008
381
140
Google Pixel 3 XL
I need some help with intents and Tasker.
Should I be able to use the Public Intent or do I need PRO to broadcast? (And can you please explain the difference?)

I set my Pixel 3XL active edge squeeze with a Public Intent and it gives me "buttonmapper.pref_edge_single_tap"

I put that into Tasker receive intent to run an action but nothing triggers.

What am I doing wrong?
 

ThimSTR

New member
Jul 13, 2022
2
0
Trying to remap any of my buttons on my CCwGTV remote works but if I'm outside of the button mapper app it usually takes 4 seconds for it to run that specific command. Is there any way to fix this and have it respond almost immediately?
 

4umexdeeay

Senior Member
Hi there,

(Thanks very much for your efforts with this app.)

-> Just installed on Google TV (Android OS 11, build RTT2.220118.001) for the first time.

I was able to remap the Home button on the tv remote to trigger a couple of installed apps - working great 😁👍

- but haven't figured out how to trigger a specific input (example: "HDMI 1").

Is this possible?

So far I tried clicking on "+ Add Buttons", then selected the desired button on the remote, then checked out the customization options; I looked through "Actions", "Applications", "Shortcuts", "System", "Advanced", etc, and didn't notice anything that would work.

If I'm missing something, your/anyone's suggestions would be appreciated.

Thx in advance 🙂
 

TraderJack

Senior Member
Oct 5, 2008
381
140
Google Pixel 3 XL
@flar2

Possible BUGS?

1)

I've been combing through the thread here and everything I can find and am just not coming up with an answer on Tasker intents for ActiveEdge. (BTW it seems like old instructions for this were posted on G+ and some places link there, but I can't find those instructions anywhere else).

I have tested successfully creating a Tasker Intent Received for a volume down button push:

"buttonmapper.VOLDOWN_SINGLE_TAP"

This properly triggers my tasker profile set to receive this intent.
However, if I instead specify the intent for ActiveEdge squeeze:

"buttonmapper.pref_edge_single_tap"

Then nothing happens. I know that ButtonMapper is properly intercepting the squeeze, since I can get it to do other tasks (like launch an app directly). However it doesn't appear to be sending anything over to Tasker like it does with the volume button.

I purchased the PRO version thinking the "Broadcast intent" option may work instead of the "Public Intent" but I can't figure out how to configure that appropriately (too many fields and no directions).
EDIT: I did figure out how to send the "Broadcast Intent" to package "net.dinglisch.android.taskerm" with an action name I defined (I actually used the same action name from the "Public Intent" and it worked fine).


2)

The ActiveEdge intent seems a bit flaky even when configured working as above. I don't know how to describe it other than one of my use situations:

I use the intent to trigger a profile in Tasker which presents a sidebar scene when the screen is on/unlocked. If the screen is off/locked the squeeze toggles the flashlight.

The sidebar seems to work fine, but the flashlight trigger is spotty. When I squeeze it sometimes it works normal (maybe 30% of the time), but usually it flickers the light multiple times sometimes ending on the proper state (on/off), but often not.

I have tried my exact same BM/Tasker configuration using the Volume Down button instead of ActiveEdge and do not have this problem. If I use the built-in toggle flashlight option it appears not to have this issue with screen on or off.
My guess (?) is that the intent is actually firing more than once when squeezing the device even though I only feel the squeeze vibration once.

I have had to resort to using a logcat event to capture the squeeze in Tasker with the screen off because BM appears to be unreliable.


Would really appreciate any tips/insight regarding the ActiveEdge issues mentioned above.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 142
    p2142635636.jpg



    Button Mapper allows you to remap any action you want to physical or capacitive hardware buttons. This includes volume buttons, camera button, home button on Samsung devices and capacitive home, back and recents, Bixby, Active Edge, LG assistant button and many buttons on game controllers and other hardware. It does NOT work with onscreen home, back and recents buttons (i.e. soft keys or the navigation bar).

    You can launch shortcuts, apps or actions to single press, double tap and long press for hardware buttons.





    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    Limitations:
    -does not work when the screen is off (unless rooted)
    -only works with hardware buttons, not onscreen buttons (i.e. navigation bar)
    -power button cannot be modified
    -there can be quirks with some devices due to non-standard hardware and software implementations by various manufacturers. I try to fix them, but sometimes it's difficult if I don't have the device to test.




    .
    31
    Examples of things you can do with this app:

    -Lockscreen peek: press and hold the home button to quickly check your lockscreen messages, release to turn off the screen (requires PRO VERSION)
    -Launch an app by long pressing the home button
    -Swap the back and recents buttons (capacitive buttons only, like on Samsung Galaxy or Asus Zenfone or One Plus One)
    -Use the home button to the turn the screen off from the homescreen on your Samsung Galaxy (requires PRO VERSION)
    -Control the button lights on your Samsung Galaxy. Turn them on or off, or change the length of time they light up
    18
    Big update!


    After many weeks of work, I've released an update that adds many new features and improvements, and fixes some longstanding bugs.

    The new version is rolling out to a small number of users on the Google Play Store.
    You can download the new version now on XDA Labs.



    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    Pixel 2 Active Edge
    The Pixel 2 battery drain was caused by remapping Active Edge with root and not enabling screen off actions. It has nothing to do with the method that I use to remap the Edge squeeze, it was caused by a typo in the options logic. There are a lot of myths about how this app handles Active Edge. First of all, it does not consume battery and does not slow down your system. Such claims are false (notwithstanding the bug, which is now fixed). The method for remapping Active Edge does not scan through every logcat message. With root, it's 100% reliable and you will never see the Assistant and will remain in your current app. Without root, you will occasionally see the Assistant and it may bring you to the homescreen. The only limitation is you need to use English language until Google enables the Assistant for other languages.

    Root Command
    You can now remap buttons to a root command. This offers unlimited possibilities for power users. Obviously this requires root! It's available in the Pro version only

    Custom Key Codes
    You can also remap buttons to custom key codes. This means you can fully remap game controllers, tv remotes and other hardware attached to your device. I've compiled a list of key codes that are recognized by Android here. This requires root, unfortunately. It's available in the Pro version only.

    MIUI
    MIUI does some really stupid things to Android. In order for Button Mapper to work correctly, you need to grant the "Autostart" permission and disable battery optimization. If you do not grant the autostart permission, swiping Button Mapper away in recents will kill the service. If you do not set battery optimization to "No restrictions", then Button Mapper's service will be killed every 10 minutes or so.

    To grant these permissions, in go to the menu at upper right in Button Mapper and select "Introduction." Swipe to the screen title Permissions and follow the instructions.

    Samsung volume bug
    I tracked down a few obscure bugs on Samsung phones, including the volume scaling bug that I could never reproduce. This occurred when the volume buttons were remapped and then later the "Bixby only" option was selected without rebooting.

    Pirating this app
    Don't install pirated versions of this app (or any app that uses Accessibility or root), even just to try for a few minutes. Because it uses Accessibility Service and root, you must fully trust the developer. Using a pirated version of any root app gives hackers carte blanche on your device.



    • New actions:
      -toggle BlueTooth
      -headset key press
      -change keyboard
      -root command (requres root and PRO)
      -custom keycodes (requires root and PRO)
    • Android TV support
    • Screen off only option (requires root and PRO)
    • Fix battery drain on rooted Pixel 2
    • Update translations
    • Fix volume change for screen off actions
    • Improve Bixby handling
    • Fix volume bug on S8/Note8
    • Improve UI
    • Add 180 rotation to swap volume orientation setting
    • Improve root handling
    • Improve MIUI behaviour
    • New intro
    • Add feedback form
    • Speed and memory optimizations
    • Many other bug fixes and improvements



    .
    15
    Button Mapper update!

    There is an awesome new update for Button Mapper rolling out. You can get it on XDA Labs now, and on the Play Store in the coming days. This update improves volume button behavior, has fixes for Android Pie, improves Bixby remapping, lots of updates for Blackberry devices and adds a bunch of new actions, such as fullscreen mode, invert colors, toggles for NFC, airplane mode and mobile data, broadcast intents, Greek and Arabic languages, plus the usual bugfixes.

    Download on XDA Labs:
    https://labs.xda-developers.com/store/app/flar2.homebutton

    I want to highlight two important new features.

    First, the broadcast intent action (pro version only!). With this action, you can use a button press to broadcast an intent, which is Android's way of communicating between apps. This opens up literally endless possibilities. For example, if you have my High Brightness Mode app installed, you could enter flar2.hbmwidget.TOGGLE_HBM for long-press of volume button to toggle high brightness mode.

    The second feature is a new option to disable volume button remapping when the volume panel is showing. For example, if you have long press volume down mapped to toggle the flashlight, when the volume panel is showing, holding down volume will turn the volume down rather than turning on the flashlight. Once the volume panel disappears, holding the volume button will once again toggle the flashlight. I think this makes the volume button behavior more intuitive, so it's enabled by default. This can be turned off if you don't like it, the option is in Advanced options->Volume panel bypass.

    Please enjoy, and don't forget to leave a positive review if you find Button Mapper useful.
    12
    Version 0.66 is now released. It will roll out slowly on the Play Store, if you want it now, get it from XDA Labs
    https://labs.xda-developers.com/store/app/flar2.homebutton

    This version has tons of small fixups: volume button behavior is vastly improved, activities open right away after pressing home, everything is faster, and there are more options. Also quite a few UI improvements. New actions include toggle mobile data (root only), toggle wifi hotspot (Nougat and lower only), toggle autobrightness and clearn notifications. There is a new option to enable pocket detection, so actions won't occur while the phone is in your pocket (requires pro version).

    For Android P users, I've fixed the volume buttons to default to media and added an option to force them to control ring volume like older versions of Android.

    There is now an option to lock the screen in a way that allows you to unlock with the fingerprint. Rooted users could always do that, now unrooted users can too.

    I've also added an option to force audio routing through the speaker while Pressy, MiKey or other headphone jack buttons are plugged in. I don't have one of these devices, but it should all work.


    Changes:
    Pocket detection (pro)
    Toggle auto brightness
    Toggle Wifi hotspot (Android 7 and lower)
    Toggle mobile data (root)
    Clear notifications
    Compatibility with Android P
    Option to use speaker with Pressy, MiKey, etc
    Global bypass option
    More long press duration options
    Receive incoming phone calls with home button (Samsung)
    Add Spanish
    Update translations
    UI improvements
    Optional lock method that allows fingerprint unlocking
    Fix AOD crash with screenshot action (Samsung)
    Optimizations and bugfixes