[MOD] Headset Control on Stock ROM - G2 Android Development

This MOD will allow for Wired headset controls with your headset so that you can control volume, and track control. It will also allow for using the mic for voice control through Google Voice Search. I created this thread because on KitKat ROMs, headset control works automatically, but the KitKat ROMs have worse performance because they are not optimized for the Snapdragon 800 SoC or HTML5. Now you can go back to stock and have all the features you like, such as KnockOn and HTML5 support, and Headset Control. No more Call / redial when pressing middle click button.
Step 1
Go into /system/usr/keylayouts/Generic.kl and edit the line "key 226 HEADSETHOOK" to "key 226 MEDIA_PLAY_PAUSE"
This will make the middle click button on your headset play or pause tracks.
Note: You can replace the "HEADSETHOOK" with whatever action you wish such as MEDIA_NEXT or MEDIA_PREVIOUS. In order to stop the redial from occurring whenever you press the middle button on the headset you have to change the key 226 value. If you leave the key 226 blank then you won't be able to use Xposed Additions but you will have successfully disabled redial.
You will have to reboot for effect to take place of course.
Option Step (For more configurability)
Download and install Xposed Framework
Open the Framework, and download the Xposed Additions under Modules. Enable the Module, and reboot for changes to take effect.
Open the Xposed Additions module, under "Re-map Settings" option, select "Add new button." Plug in headphones. Press the headphone button (middle button) and it will recognize it as a key.
Xposed additons allows you to configure settings for when the screen is off and when it is on. You should configure both "Screen Off" and "Screen On" so that headset control works when screen is on or off. By default, "Screen On" is set to be configured.
Configure the "Click Action" as Media Play/Pause.
Final Step ( This step allows you to configure long press to open voice control, and to do volume and Next/Previous Track Control)
Now the middle click button on your headset will be able to play and pause music. To add volume control and enable voice control, you can then download JAYS Headset Control which is free from the Google Play Store.
Also download Voice Search Shortcut (If you do not then when you configure JAYS Headset Control, you will only have the option to launch the regular Google Voice Search, which requires saying "Ok Google" first. But if you configure it to launch this VS Shortcut app, then when you activate the app it will begin listening for dictation directly.)
Once installed, open the JAYS Headset Control app. You must select 3-button controller, not 1-button. Then set it to Advanced Mode.
Under "Button Actions" configure "Click and Hold" which alows you to configure the long press action. Configure it to "Launch App" and select "VS Shortcut" so that when you long press it will immediately allow for voice dictation to make calls, ask for weather, stocks, sport scores, set alarms, etc.
Configure and explore the other options as you see fit to meet your needs. You can configure the "Double Click and Hold" and "Triple Click and Hold" to do volume control.
Using JAYS Headset Control will disable the ability control tracks using the hardware volume buttons (that's if you have enabled this option in Gravity Box or G2 Xposed) You should disable the volume key control in Gravity Box or Xposed if you are using JAYS Headset Control otherwise when you press the volume key when the screen is off, the volume down will increase volume and the volume up will register as volume down. It's a weird result of enabling headset control, but a necessary sacrifice. Unless... you read more below for another solution.
Enable Volume Key for Track Control ------------------------------------------------------
If you wish to be able to have hardware volume key track control and headset control, then follow this method.
Option 1
Disable JAYS Headset Control. Enable Volume Key Control using Gravity Box or Xposed. Download Ultimate HeadSet Controller, a free app from the Google Play Store. Using this app you can lower and raise volume, and get the ability to have triple click as previous track. However this means that there is no way to do a long press and have the voice search come up. If you would rather voice search, then continue reading.
Option 2
Disable JAYS Headset Control. Enable Volume Key Control using Gravity Box or Xposed. Get Xposed Additions Pro. You can find it floating around the internet with a simple google search "Xposed Additions Pro apk"
(Allows Double Click setting and Long Click)
Once installed, make sure the module is enabled in Xposed, then set "Double Click" for Next Track and "Long Press" as Previous. For the "Screen On" you can set "Long Press" to be Search and have the indirect voice search whereby you have to first pause the music before it will allow you to use the mic, and if you did not pause before you did the long press, then pausing the music after the long press won't activate the mic. For the "Screen Off" unfortunately there is no option to do select Search as the action therefore you can use Previous as the action since there is no triple click setting in this app. If you must have the option to go to previous track, then set "Long Press" for "Screen On" and "Screen Off" to Previous but you sacrifice voice search.

Related

Two hacks wanted

Is it possible to wake the device with trackpad or any other button than the power button? I know it is achievable through custom lock screens etc, but there has to be a cleaner way to do it. Cyanogenmod has this option under settings...
Is there a hack to double press the mic button (play) button on the headphones to skip songs? I am using Apple headphones (play-stop button works).
Thanks
I found a solution for headphones control. bTunes and Meridian can be used just like iPod.app on iPhone. YAY
Just need to find how to wake my Desire without reaching for power button...
Download "No lock" from the market, which does what you want but disables the lock screen.
Thanks, I did find that and will use it if i don't find anything better...

[Q] Is there anyone or an app which can change the volume rocker to skip music?

Is there any app or customization out there that can skip music with long press on the volume rocker? This is a feature I miss, which the iPhones had, I hate having to press the unlock button (which is already annoying) and then change music, I want to be able to change music without touching the damn screen, any info would help.
Thank You
Tazur Rahman
hmmm good idea
panyan said:
hmmm good idea
Click to expand...
Click to collapse
At times like this I wish I knew how to create/modify ROMs.
does anyone found a solution? i miss the remote control function from my iphone, is there a tool that can do the same behavior like on iphone?
(middle button)
one click -> stop/play
fast double click -> next track
borzo83 said:
does anyone found a solution? i miss the remote control function from my iphone, is there a tool that can do the same behavior like on iphone?
(middle button)
one click -> stop/play
fast double click -> next track
Click to expand...
Click to collapse
The only option was to go on a custom ROM, Cyanogen ROM 6.1 RC2, which I have done, it's awesome.
You could always just use the headphones that come with the phone
Sent from my Desire HD using XDA App
First you would need to install a nolock app or widget, I use Lock Screen Switch widget but No Lock is good also if you prefer an app. Then you would need to install the button remapper or one like it in this thread, http://forum.xda-developers.com/showthread.php?t=850464 . I think then you would be able to do it.
thanks, i will try
i've found a better solution,
just download the "Headset Volume Controller" Widget, than put it on your home screen and activate the Widget
than in the htc music player, the controlls are working as follow:
middle klick
play/pause
top/bottom klick
while playing->volume control
while pausing->last/next track
so if you want to skip a track, just click once on the middle button to pause, and the up/down keys work as track control, otherwise while playing the keys work as volume control
works with my htc desire hd and the standard music player.
now there is a much better solution, now it acts exact like the iPhone headset control.
just download the "Headset Volume Controller" Widget, than put it on your home screen and activate the Widget
after that download and just install this app "Headset Button Controller"
now the headset control works like on the iphone:
1x (middle button) play/pause
2x (middle button) skip track
3x (middle button) last track
+/- Volume Up/Down

Phone has system-wide headset controls and it sucks. How do I turn it off?

The system responds very late to single presses of the headset button and skips two songs when I double press the button (wanting to only skip one). How can it be fixed? If it's not possible, how can it be turned off, so I can use app-specific headset controls?
I've tested on another phone: OnePlus 2, it doesn't even have system-wide controls and app-specific controls are very snappy. Also, the system-wide headset controls are always there (on the Nokia) and no app seems to be able to take priority.

Volume up headset triggers google assistant

Hi!
Sometimes I use my OnePlus Icons headset (metal headset, https://www.androidcentral.com/oneplus-icons-earbuds-review) with the phone, and when I push the volume up button it triggers the google assistant, which is very very annoying...
I tried some remapper apps but when I want to add the button, I push the button and it triggers the google assistant and the app doesn't manage to find the button.
Anyone got a solution to avoid the google assistant besides deactivating google assistant? Not even sure how to deactivate it so can't really test it and see if the remapper app works. An idea would be to deactivate it and check the logs to see if there is indeed a button, but when I check I can't see a button, just see :
mStatusBarWindow : com.android.systemui.statusbar.phone.StatusBarWindowViews{28ebb7dV.ED..... ....... 0,0-1440,171}canPanelBeCollapsed(): false
writeEvent dismiss_dialog volume_controller
So it seems like it's normal, that it closes the volume rocker and launches the google assistant window...
Thanks for your help!
matssa said:
Hi!
Sometimes I use my OnePlus Icons headset (metal headset, https://www.androidcentral.com/oneplus-icons-earbuds-review) with the phone, and when I push the volume up button it triggers the google assistant, which is very very annoying...
I tried some remapper apps but when I want to add the button, I push the button and it triggers the google assistant and the app doesn't manage to find the button.
Anyone got a solution to avoid the google assistant besides deactivating google assistant? Not even sure how to deactivate it so can't really test it and see if the remapper app works. An idea would be to deactivate it and check the logs to see if there is indeed a button, but when I check I can't see a button, just see :
mStatusBarWindow : com.android.systemui.statusbar.phone.StatusBarWindowViews{28ebb7dV.ED..... ....... 0,0-1440,171}canPanelBeCollapsed(): false
writeEvent dismiss_dialog volume_controller
So it seems like it's normal, that it closes the volume rocker and launches the google assistant window...
Thanks for your help!
Click to expand...
Click to collapse
I am using a Pixel 4a (running on Android 11) and I have the same problem when I use my SoundMagic E11C wired headset. When I press the volume up button on the headset, it triggers the Google Assistant instead of increasing the volume. The volume down button on the headset works perfectly. The play/pause headset button also works fine.
What is very weird is that this headset works fine on all the other phones that I have tried. I have an old SoundMagic E11C wired headset and it works fine my Pixel 4a. In other words, the particular combination of my new Pixel 4a and new SoundMagic E11C does not work. However, every other combination with these devices and the other devices/headsets that I have work fine.
I can't even pinpoint whether it is an issue on my phone or on my headset. I disabled Google Assistant for my headset and tried again. Still doesn't work. Volume up does not trigger any response if Google Assistant is disabled. It is almost as if the volume up button is hardwired exclusively for Google Assistant. Which is impossible.
I also checked the logs using logcat. When volume down is pressed, I see some logs that indicate that media volume has been decreased. However, when volume up is pressed, I don't see any logs related to volume.
I have no idea what the problem is. I can try replacing the headset, but I don't think that is gonna solve the issue.
Did you ever figure out what the problem was with your phone/headset?

application for changing remote control keys

Now i have button remap.
But i bought a remote control and it works like a mouse. Has only a few buttons and I can't configure them in this application.
https://m.pl.aliexpress.com/item/32...y3jdO8trRbdy2I1MiyEaAljYEALw_wcB&gclsrc=aw.ds
---------------------------
why after enabling in the accessibility options, the button remaps application, the ok button works like holding the ok button? and instead of opening installed applications, it opens the menu.

Categories

Resources