[APP] Button Mapper - Customize your hardware buttons

Search This thread

MarkLev

Senior Member
Dec 24, 2019
127
95
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
127
95
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,345
404
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,897
87,868
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
533
345
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
533
345
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:

Talon

Senior Member
But it will require a rooted phone
strangely enough - but this function works on my Sony TV ...
- and now it very lacking ... - ( for closes the applications... and, most importantly, it return to the android launcher from other HDMI inputs screens - it just simply killing them :) )

and Flar please - make the 'volume panel bypass' worked on Sony TV.... - look for the posibility for normally adjust the volume on the Sony TV ... - it's hellish torture to adjust volume one by one step for each press (and in my case it twice - bcs the step is 0.5 due to CEC incompatibility with the receiver)
...
 

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 🙂

anyone-answer.gif
 

kwyjibo2000

New member
Aug 13, 2022
2
0
I've just bought a Philips Android TV (OLED806) and would like to use Button Mapper to directly select an HDMI input source. I am able to execute the following adb command to successfully swithch to HDMI1:

Code:
adb shell am start -a android.intent.action.VIEW -d content://android.media.tv/passthrough/com.mediatek.tvinput%2F.hdmi.HDMIInputService%2FHW5 -n org.droidtv.playtv/.PlayTvActivity -f 0x10000000

How do I convert this into an action that can be mapped to a button? I have seen this question more on this forum but haven't seen an answer. It seems that it should somehow be converted into a Broadcast intent, but I have no idea what information to fill out where in the 'Intent to Broadcast' button mapper section. Any help on how to accomplish this (if possible) would be greatly appreciated, thanks!

Edit: my best guess is the following:
Action: android.intent.action.VIEW
Package: org.droidtv.playtv
Component: org.droidtv.playtv.PlayTvActivity
Data: content://android.media.tv/passthrough/com.mediatek.tvinput/.hdmi.HDMIInputService/HW5

This results in a black screen when pushing the button (not an actual switch to the HDMI input). Some questions I have:
- The adb command sends flag 0x10000000, where would I put that in the button mapper broadcast?
- The adb command uses the %2F escape code for forward slash in two locations, and the post where I found this command (https://community.home-assistant.io/t/android-tv-hdmi/234411/27) indicates this is important. I tried entering %2F into button mapper but it changed them into a forward slash. Could this affect the outcome?
 
Last edited:

discapacidad5

Member
Dec 25, 2016
8
0
If it's Bluetooth, it probably won't work. Not sure why, but a lot of Bluetooth devices handle button presses internally. If they are not detected by the add buttons dialog, there is no ability to remap them at all.
hello I have bluetooth headphones that have three Play buttons forward and back, the funny thing is that the buttons are recognized by the music player they are also recognized by Zello workie talkie,which by the way has an option to add custom buttons very similar to renaper and the buttons recognize it perfectly I think it would be good if they did a review,because I am sure that the buttons work well and are recognized by other applications, I think there is something that they are not doing well so that the bluetooth buttons are recognized
 

flar2

Recognized Developer
Jun 11, 2012
18,897
87,868
Southwestern Ontario
elementalx.org
hello I have bluetooth headphones that have three Play buttons forward and back, the funny thing is that the buttons are recognized by the music player they are also recognized by Zello workie talkie,which by the way has an option to add custom buttons very similar to renaper and the buttons recognize it perfectly I think it would be good if they did a review,because I am sure that the buttons work well and are recognized by other applications, I think there is something that they are not doing well so that the bluetooth buttons are recognized
That's different, those apps are responding to the media commands issued by those buttons, not suppressing the original action and doing something else. My app Next Track works like that but is very limited compared to Button Mapper.

But the main reason I can't have that in button Mapper is the remapping would only work if Button Mapper continuously played a media file or was actively recording. It would kill the battery.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    The desired behavior could

    The desired long press to skip can be achieved by macrodroid without any issue. Maybe you could look into it 😉 thanks


    Button Mapper does in fact offer complete remapping while the screen is off, I just disabled it on certain Samsung devices because the button presses are only detected while music is playing and not while the phone is in deep sleep. This was confusing to users, as skipping tracks is only one of many possible actions, leading to negative reviews, so I dropped it. On non-Samsung devices you can do anything with the screen off, even in deep sleep, and Button Mapper is the only app out there that can do that. I added those dedicated skip track options as a convenience using another very simple method. I could technically expand them to handle long press too, but it would just add a lot of complexity. I mean I could just keep adding stuff until Button Mapper is essentially Tasker, but then Button Mapper would no longer be the simple and light app that has been successful.
  • 148
    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.




    .
    32
    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