Question Override hardware keys?

Search This thread

EthanG_1988

Senior Member
May 17, 2010
194
136
indianapolis, indiana
Google Pixel 6
Has anyone tried this yet? Seems so simple compared to the tasker/autowear solution.
I just installed it, and it is significantly faster than the autowear solution since there is no waiting for tasker on the phone to respond with what to do. I made a clone of the project and changed the targets to overwrite bixby with ultimate alexa (I use alexa more than google assistant), but there is an unfortunate 1-2 second delay after opening bixby before alexa opens....maybe it is because google pay is a "lightweight" program to open directly on the watch, but ultimate alexa has to reach out to the phone for a connection to the amazon servers? I might make another clone and see how google assistant go opens on top of bixby.

Edit: Google Assistant Go exhibits the same behavior. From the time that bixby launches until Google Assistant/Bixby launches is ~3 seconds (timed using phone stopwatch, so my time is not 100% accurate).

In any event, this solution is cleaner and certainly easier to setup than Autowear for launching Gpay with the Spay hardware button. Unless someone has additional uses for autowear, then this solution is free and easy.
 
Last edited:
  • Like
Reactions: adfree
I just installed it, and it is significantly faster than the autowear solution since there is no waiting for tasker on the phone to respond with what to do. I made a clone of the project and changed the targets to overwrite bixby with ultimate alexa (I use alexa more than google assistant), but there is an unfortunate 1-2 second delay after opening bixby before alexa opens....maybe it is because google pay is a "lightweight" program to open directly on the watch, but ultimate alexa has to reach out to the phone for a connection to the amazon servers? I might make another clone and see how google assistant go opens on top of
bixby.
Edit: Google Assistant Go exhibits the same behavior. From the time that bixby launches until Google Assistant/Bixby launches is ~3 seconds (timed using phone stopwatch, so my time is not 100% accurate).

In any event, this solution is cleaner and certainly easier to setup than Autowear for launching Gpay with the Spay hardware button. Unless someone has additional uses for autowear, then this solution is free and easy.
Just to confirm that my eyes aren't deceiving me, you're able to long press the power button (Bixby) and launch Ultimate Alexa or Google Assistant Go without Bixby showing up at all?

Eeeeeeek!! This is so exciting!
 

EthanG_1988

Senior Member
May 17, 2010
194
136
indianapolis, indiana
Google Pixel 6
Just to confirm that my eyes aren't deceiving me, you're able to long press the power button (Bixby) and bring ultimate Alexa without Bixby showing up at all? A little delay is understood.

Eeeeeeek!! This is so exciting!
Unfortunately Bixby does open, but within a couple seconds it closes and then Ultimate Alexa opens. I use Alexa to turn on various lights an other things in my house, so I prefer Alexa most of the time. I am not an Android developer, but I do dabble in android studio from time to time. I downloaded the source that bigboot93 linked, and refactored the project two times with new names (one for Alexa, and one for Google). I changed the project name everywhere to the new names, and I changed the target strings in strings.xml to overwrite bixby with either Ultimate Alexa or Google Assistant Go. If me uploading the files here offends anyone, please let me know so that I can remove them.
 

Attachments

  • app-debug_Alexa.apk
    6 MB · Views: 26
  • app-debug_google.apk
    6 MB · Views: 46

adfree

Senior Member
Jun 14, 2008
10,549
6,129
Samsung Galaxy Watch 4
Samsung Galaxy S22
Why would you assume that I didn't research the topic first?

@bingblop

IMHO 2 examples for users understand what I wrote...

He was able to deliver Log...


User BigBoot93 is able to release APK + Source Code...


{Mod edit}


Best Regards
 
Last edited by a moderator:
  • Haha
Reactions: EthanG_1988
@bingblop

IMHO 2 examples for users understand what I wrote...

He was able to deliver Log...


User BigBoot93 is able to release APK + Source Code...


Maybe read my post with open eyes again...


Best Regards
{Mod edit}

I've spent hours scouring the web for information regarding this. There is no direct answer front and center for everybody to see. {Mod edit}
 
Last edited by a moderator:
  • Like
Reactions: EthanG_1988
Unfortunately Bixby does open, but within a couple seconds it closes and then Ultimate Alexa opens. I use Alexa to turn on various lights an other things in my house, so I prefer Alexa most of the time. I am not an Android developer, but I do dabble in android studio from time to time. I downloaded the source that bigboot93 linked, and refactored the project two times with new names (one for Alexa, and one for Google). I changed the project name everywhere to the new names, and I changed the target strings in strings.xml to overwrite bixby with either Ultimate Alexa or Google Assistant Go. If me uploading the files here offends anyone, please let me know so that I can remove them.
This is great stuff, thank you. I'm fixing to try out this workaround now.
 
  • Like
Reactions: EthanG_1988

Aethera

Senior Member
Feb 18, 2012
297
89
Bay Area
LG V20
Samsung Galaxy Watch 5
There are guides on remapping buttons in Android such as this and this. They involve changing /system/usr/keylayout/Generic.kl

Here is a guide for displaying keypresses.

I tried to remap buttons on a tablet once and had unintended results and had to revert.
I hope this works out. It would be great to actually have an app that lets you choose which apps to map to which keypresses.
 
Last edited:
  • Like
Reactions: adfree

BigBoot93

Senior Member
What about uninstalling Bixby using ADB? Think that might speed up the time it takes for GA to launch ? The question is, is the code just designed to launch when the button is held down? If so, Bixby would override everything given that it's code is literally embedded into the system core, that's why it GA/Alexa doesn't get launched until after Bixby disappears. So maybe disabling or uninstalling Bixby might be the ticket. ill try this later when I get home.

Is it possible to change the behavior to trigger off the button being pushed and not off Bixby? I mean it's getting accessibility access for a reason. If so, Bixby could be disabled using ADB commands and then GA will launch solo.
Unfortunately the hardware buttons are completely bypassing the accessability service, so intercepting them in the service isn't an option.

Reading the system logcat from an app requires root, so listening for AKEY_EVENT_FLAG_LONG_PRESS is not an option either (and there's no way to know which button was long pressed anyway)

One solution could be initiating a local ADB connection from the app and then calling `getevent` through it. I'm not sure how ADB connections interact with device sleep and stuff though, so this would need further investigation. Plus i'm not sure keeping ADB active all the time is really a good idea. (I guess this is what AutoWear is doing?)
 
  • Like
Reactions: adfree
Moderator Announcement

I enjoy to see how vivid and helpful the discussion and exchange of experiences in this thread is. However, as quite often when temper overheats for whatever reasons I'd to recognise that one conversation derails into personal attacks. As much as we encourage vivid discussions including off-topic contributions (as long as the OP accepts them) as little we accept and tolerate personal attacks or deviations from the expected member conduct stipulated by rule no. 2 of the XDA Forum Rules.
2. Member conduct.

2.1
Language: XDA is a worldwide community. As a result, what may be OK to say in your part of the world, may not be OK elsewhere. Please don't direct profanity, sexually explicit language or other offensive content toward Members or their work. Conversely, while reading posts from other members, remember that the word you find offensive may not be offensive to the writer. Tolerance is a two-way street.

2.2 Nudity: XDA is used by people of all ages, including minors. It is unacceptable to post nude or pornographic imagery, which includes the exposure of male or female genitalia and / or female breasts.

2.3 Flaming / Lack of respect: XDA is about sharing and this does not involve virtual yelling (flaming) or rudeness. Flaming or posting with a lack of respect is unacceptable. Treat new members in the manner in which you would like to have been treated when you were a new member. When dealing with any member, provide them with guidance, advice and instructions when you can, showing them respect and courtesy. Never post in a demanding, argumentative, disrespectful or self-righteous manner.

2.4 Personal attacks, racial, political and / or religious discussions: XDA is a discussion forum about certain mobile phones. Mobile phones are not racial, political, religious or personally offensive and therefore, none of these types of discussions are permitted on XDA.

2.5 All members are expected to read and adhere to the XDA rules.
Statements like "A search engine is your best friend" generally doesn't add any value to a thread. Let's agree that our members do a search before they post, not only because the rules request it but in a very personal interest: They have an issue that they want to solve and to find a solution. I'm convinced it's valid to assume that a search was unsuccessful at the time a thread was created.

For the above mentioned reasons, I've edited a few posts and deleted a few other ones. Those members who got affected by my action will certainly recognise it. Please do not hesitate to contact me by a personal message in case of any question.

Last but not least a personal request: If anybody of you recognises a rule violation or feels to be offensively engaged, please only report such a post but do not reply or react to it. Any reply just lights the fire, fuels the rant and ensures that the thread derails. Just let the moderators deal with it from the very first beginning - it also eases our life.

Thanks for your cooperation! I wish everybody a great weekend. And stay safe and healthy!
Regards
Oswald Boelcke
Senior Moderator
 
Unfortunately the hardware buttons are completely bypassing the accessability service, so intercepting them in the service isn't an option.

Reading the system logcat from an app requires root, so listening for AKEY_EVENT_FLAG_LONG_PRESS is not an option either (and there's no way to know which button was long pressed anyway)

One solution could be initiating a local ADB connection from the app and then calling `getevent` through it. I'm not sure how ADB connections interact with device sleep and stuff though, so this would need further investigation. Plus i'm not sure keeping ADB active all the time is really a good idea. (I guess this is what AutoWear is doing?)
Thanks for the info. Currently, I disabled the Bixby Agent and Wakeup so nothing happens when I press the hold down the Bixby Button. I wonder if I can install a dummy Bixby package that trips the flag to think it's launching Bixby.. something along those lines? Like a modded Bixby wakeup app

Also, is it possible to trigger an app when the power menu is shown?
 

EthanG_1988

Senior Member
May 17, 2010
194
136
indianapolis, indiana
Google Pixel 6
Thanks for the info. Currently, I disabled the Bixby Agent and Wakeup so nothing happens when I press the hold down the Bixby Button. I wonder if I can install a dummy Bixby package that trips the flag to think it's launching Bixby.. something along those lines? Like a modded Bixby wakeup app

Also, is it possible to trigger an app when the power menu is shown?
These small apps are triggering off the targeted packages being opened (spay or Bixby). In order to trigger off the power menu, you would have to know the package name or possibly the system activity that is being opened, but I am not sure that the power menu would have a package/activity name that you could utilize.

Bigboot93 is your best hope for coming up with a faster or different way of doing this, since he wrote the app.

One thing that I have noticed is that my watch screen starts rotating in whatever orientation my wrist is in when I have a wireless adb connection with my phone. This usually requires a restart to fix after closing the adb connection and disabling USB debugging on the watch. I am not sure if a local adb connection on the watch would trigger this as well. This has only been a minor annoyance since I only use adb to sideload apps.
 

BigBoot93

Senior Member
I've added the ability to define custom rules now.
Theres also a bunch of predefined applications included (as entering the package/activity names on the watch is a pain):

As sources:
  • Bixby
  • Samsung Pay
  • Power Menu (this one is using special logic)
As targets:
  • Google Pay
  • Google Assistant Go
Please tell me if there's something missing you'd like to see added.

Screenshot_20220108_163134_watch4payswitch.png
 
Last edited:

BigBoot93

Senior Member
Thanks for the info. Currently, I disabled the Bixby Agent and Wakeup so nothing happens when I press the hold down the Bixby Button. I wonder if I can install a dummy Bixby package that trips the flag to think it's launching Bixby.. something along those lines? Like a modded Bixby wakeup app

Also, is it possible to trigger an app when the power menu is shown?
Unfortunately you can't do this, there's no way to completely uninstall bixby, all you can do is disable or "uninstall" it for the user, but the system will still prevent your from installing a "dummy" package or modified version of the originals (as the signature will be invalid)
 

EthanG_1988

Senior Member
May 17, 2010
194
136
indianapolis, indiana
Google Pixel 6
I've added the ability to define custom rules now.
Theres also a bunch of predefined applications included (as entering the package/activity names on the watch is a pain):

As sources:
  • Bixby
  • Samsung Pay
  • Power Menu (this one is using special logic)
As targets:
  • Google Pay
  • Google Assistant Go
Please tell me if there's something missing you'd like to see added.

View attachment 5503375
Awesome! I notice that opening the assistant is much faster when having the button set to the power menu vs. Bixby...I think this will make people very happy.

I would say if you could add Ultimate Alexa, then this would be the perfect solution for a lot of people, and honestly there aren't that many people using Alexa, so not a big deal if you want to be done...you have already helped provide a great workaround for a complaint that so many people have for this watch.

Package Name for Ultimate Alexa : com.customsolutions.android.alexa
Activity Name for Ultimate Alexa : com.customsolutions.android.alexa.MainActivity

It worked well for me by modifying only the strings.xml and the AppPreferences.kt files.

1641669079772.png

1641669095553.png
 
  • Like
Reactions: adfree
Moderator Announcement

I enjoy to see how vivid and helpful the discussion and exchange of experiences in this thread is. However, as quite often when temper overheats for whatever reasons I'd to recognise that one conversation derails into personal attacks. As much as we encourage vivid discussions including off-topic contributions (as long as the OP accepts them) as little we accept and tolerate personal attacks or deviations from the expected member conduct stipulated by rule no. 2 of the XDA Forum Rules.
2. Member conduct.

2.1
Language: XDA is a worldwide community. As a result, what may be OK to say in your part of the world, may not be OK elsewhere. Please don't direct profanity, sexually explicit language or other offensive content toward Members or their work. Conversely, while reading posts from other members, remember that the word you find offensive may not be offensive to the writer. Tolerance is a two-way street.

2.2 Nudity: XDA is used by people of all ages, including minors. It is unacceptable to post nude or pornographic imagery, which includes the exposure of male or female genitalia and / or female breasts.

2.3 Flaming / Lack of respect: XDA is about sharing and this does not involve virtual yelling (flaming) or rudeness. Flaming or posting with a lack of respect is unacceptable. Treat new members in the manner in which you would like to have been treated when you were a new member. When dealing with any member, provide them with guidance, advice and instructions when you can, showing them respect and courtesy. Never post in a demanding, argumentative, disrespectful or self-righteous manner.

2.4 Personal attacks, racial, political and / or religious discussions: XDA is a discussion forum about certain mobile phones. Mobile phones are not racial, political, religious or personally offensive and therefore, none of these types of discussions are permitted on XDA.

2.5 All members are expected to read and adhere to the XDA rules.
Statements like "A search engine is your best friend" generally doesn't add any value to a thread. Let's agree that our members do a search before they post, not only because the rules request it but in a very personal interest: They have an issue that they want to solve and to find a solution. I'm convinced it's valid to assume that a search was unsuccessful at the time a thread was created.

For the above mentioned reasons, I've edited a few posts and deleted a few other ones. Those members who got affected by my action will certainly recognise it. Please do not hesitate to contact me by a personal message in case of any question.

Last but not least a personal request: If anybody of you recognises a rule violation or feels to be offensively engaged, please only report such a post but do not reply or react to it. Any reply just lights the fire, fuels the rant and ensures that the thread derails. Just let the moderators deal with it from the very first beginning - it also eases our life.

Thanks for your cooperation! I wish everybody a great weekend. And stay safe and healthy!
Regards
Oswald Boelcke
Senior Moderator
Thank you for your prompt response and action in this. I agree my subsequent replies to the post in question did only serve to fan the fire so lessons were learned.
 
I've added the ability to define custom rules now.
Theres also a bunch of predefined applications included (as entering the package/activity names on the watch is a pain):

As sources:
  • Bixby
  • Samsung Pay
  • Power Menu (this one is using special logic)
As targets:
  • Google Pay
  • Google Assistant Go
Please tell me if there's something missing you'd like to see added.

View attachment 5503375
You're awesome. Thank you so much.

Edit: So I just tried it and oh my goodness it works so well. I don't think it could get much better. Can't believe somebody didn't think of this sooner.
 
Last edited:

Wilazn

Senior Member
Nov 23, 2014
193
41
OnePlus 8T
Samsung Galaxy Watch 4
I've added the ability to define custom rules now.
Theres also a bunch of predefined applications included (as entering the package/activity names on the watch is a pain):

As sources:
  • Bixby
  • Samsung Pay
  • Power Menu (this one is using special logic)
As targets:
  • Google Pay
  • Google Assistant Go
Please tell me if there's something missing you'd like to see added.

View attachment 5503375
you're a legend. thank you so much.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    Small update:
    • Added Ultimate Alexa as a predefined target
    • Changed the name to GW4 Remap (Please uninstall the old version manually)
    5
    Moderator Announcement

    I enjoy to see how vivid and helpful the discussion and exchange of experiences in this thread is. However, as quite often when temper overheats for whatever reasons I'd to recognise that one conversation derails into personal attacks. As much as we encourage vivid discussions including off-topic contributions (as long as the OP accepts them) as little we accept and tolerate personal attacks or deviations from the expected member conduct stipulated by rule no. 2 of the XDA Forum Rules.
    2. Member conduct.

    2.1
    Language: XDA is a worldwide community. As a result, what may be OK to say in your part of the world, may not be OK elsewhere. Please don't direct profanity, sexually explicit language or other offensive content toward Members or their work. Conversely, while reading posts from other members, remember that the word you find offensive may not be offensive to the writer. Tolerance is a two-way street.

    2.2 Nudity: XDA is used by people of all ages, including minors. It is unacceptable to post nude or pornographic imagery, which includes the exposure of male or female genitalia and / or female breasts.

    2.3 Flaming / Lack of respect: XDA is about sharing and this does not involve virtual yelling (flaming) or rudeness. Flaming or posting with a lack of respect is unacceptable. Treat new members in the manner in which you would like to have been treated when you were a new member. When dealing with any member, provide them with guidance, advice and instructions when you can, showing them respect and courtesy. Never post in a demanding, argumentative, disrespectful or self-righteous manner.

    2.4 Personal attacks, racial, political and / or religious discussions: XDA is a discussion forum about certain mobile phones. Mobile phones are not racial, political, religious or personally offensive and therefore, none of these types of discussions are permitted on XDA.

    2.5 All members are expected to read and adhere to the XDA rules.
    Statements like "A search engine is your best friend" generally doesn't add any value to a thread. Let's agree that our members do a search before they post, not only because the rules request it but in a very personal interest: They have an issue that they want to solve and to find a solution. I'm convinced it's valid to assume that a search was unsuccessful at the time a thread was created.

    For the above mentioned reasons, I've edited a few posts and deleted a few other ones. Those members who got affected by my action will certainly recognise it. Please do not hesitate to contact me by a personal message in case of any question.

    Last but not least a personal request: If anybody of you recognises a rule violation or feels to be offensively engaged, please only report such a post but do not reply or react to it. Any reply just lights the fire, fuels the rant and ensures that the thread derails. Just let the moderators deal with it from the very first beginning - it also eases our life.

    Thanks for your cooperation! I wish everybody a great weekend. And stay safe and healthy!
    Regards
    Oswald Boelcke
    Senior Moderator
    4
    I've added the ability to define custom rules now.
    Theres also a bunch of predefined applications included (as entering the package/activity names on the watch is a pain):

    As sources:
    • Bixby
    • Samsung Pay
    • Power Menu (this one is using special logic)
    As targets:
    • Google Pay
    • Google Assistant Go
    Please tell me if there's something missing you'd like to see added.

    Screenshot_20220108_163134_watch4payswitch.png
    4
    I haven't done Android stuff for quite some time so I decided to quickly throw something together.
    This doesn't require a connection to the phone.
    Seems to work nicely for now (though I haven't tested actually paying with it yet)

    Source and instructions are available here:
    3
    i found these in logcat entries, this is what happens when the back button is long pressed

    screenshot.png


    i don't have samsung pay in my country so long pressing is useless. maybe someone could implement a listener for this AKEY_EVENT_FLAG_LONG_PRESS thing and have it do something else