yashsingh1/xdaforums huggingface dataset:
[FYT Android Head Units] surfer63:
Version 1.4.0 Beta

Beta due to insufficient testing possibilities as I myself have a unit with only HOME/BACK/Vol+/Vol- buttons

In previous versions you could only start an app by package name like: com.syu.radio if you wanted to start the FYT radio (BAND) app.

Currently there are 3 options to "start something" with the "Call method"

by package name

by intent (package name / intent)

by system call (terminal command(s) or script)

by package name: This is NOT the name of the apk but the internal package name. How do you get this "package name"?

Use the "List all Installed apps" option in the main screen of the settings. It shows the app icon, the app name and the package name. This package name is what you need. You can select it and copy & paste it into the field.

Search in play.google.com for the app you want to start. Say you want to start the navigation app "Magic Earth" and you have selected that one in the play store (in a browser, not the android app). In the address bar you will then see "https://play.google.com/store/apps/details?id=com.generalmagic.magicearth". The bold part behind the "id=" is your package name.

by intent: Every app has a "launch" intent to start the app. Some apps can also be started with other intents to immediately start a specific function. Google Search can be started with the launch intent, but you can also start it with the Google Voice search option intent. The Google (Search) package name is "com.google.android.googlequicksearchbox", the specific intent for google voice search is com.google.android.googlequicksearchbox.VoiceSearchActivity. The combined "String to be used" is therefore com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity.

Another example is the Joying Bluetooth apk having intents for the dialer (default launch), the call receiver, the bluetooth streaming, the pairing and a few more.

by system call: A system call can be a direct (linux) command or a shell script or a binary (to do something).

= Commands can be a single command as in:

ls -l > /sdcard/some_file.txt to capture a directory listing to a file

input keyevent 3 => Go to the Home screen (of the default launcher)

am start -a android.intent.action.MAIN -c android.intent.category.HOME => Go to the Home screen (of the default launcher)

input keyevent 127 => pause active media player (any media player)

input key event 126 => (re)start last used media player.

am start com.syu.radio/com.syu.radio.Launch => Start the radio app with the default launch intent (or better use "by package name": com.syu.radio; Or use "by intent": com.syu.radio/com.syu.radio.Launch)

As you can see from the 2nd and 3rd example, there are multiple ways to do something.

From the 6th example you can see that you can start an app (the radio) from the command line with "am start <full intent>", or by package name, or by intent directly.

(See post #1 for screenshots)
[FYT Android Head Units] Oceloti:
I have an iDoing Android 10 UIS7862 and this apk worked perfectly to remap carplay/android auto onto one of my unused steering wheel buttons. Super easy to use and worked perfectly first time.

Thank you.
[FYT Android Head Units] surfer63:
Thanks for mentioning. I didn't know iDoing is a FYT compatible but looking at the Settings screen and some other screens it indeed is.
[FYT Android Head Units] knad78:
Thank you for updating the app, but 3rd "by system call" option doesn't work for me.

I am changing radio button. I can start 3rd party app using 1st option, but not the 3rd.

I tried both "input keyevent 127" and "am start com.syu.radio/com.syu.radio.Launch" - both doesn't do anything.

I am on Android 10 UIS7862 unrooted.

Can anyone confirm that 3rd option is working?

Thanks.
[FYT Android Head Units] gottahavit:
I will give this a shot tomorrow, just ran across this. Was trying to map an unused SWC to an app today. The built in is very good and easy to setup, but would like a couple more complex actions. I read through this thread but didn't see if you can map to double or long press? Have you tried to add this? So Quick click volume down, long press or quick double press is mute? IDoing, UIS7862 9". I do have a canbus but I think it's just for the HK Audio

I ended up using macrodroid automate some actions, and while that works some would be better on buttons.
[FYT Android Head Units] surfer63:
@warata also asked this, but unfortunately in the wrong thread.

The answer is no.

See extended answer and explanation is here: https://xdaforums.com/t/q-a-tips-info-roll-up-joying-fyt-sc9853i.3979377/page-3#post-84713407
[FYT Android Head Units] gottahavit:
Thanks for the answer, will set it up and check it out later, I haven't looked at your code yet, but couldn't you do the time based check for double click in you app or does FYT eat these "extra" presses?

Regardless, thanks for the app.
[FYT Android Head Units] gottahavit:
Interesting, it works only with my Source button on my SWC, not with any of the others. All of them work with the built in app. Never Mind, I looked at your code and now I see how it works(you have to map the key to some unwanted intent in the SWC app and then you capture that event and call something else). Given that what I would really like to do it set up the source button to do exactly what it was meant for which is to toggle through different app on the HU. I'm going to try to mod your app to do that.

Update: So I can basically do the app switching on the SWC buttons(going to make it configurable), Sort of made Double Click work, but the intents really don't come fast enough or reliably enough to get a decent double click(will look more later). As for starting playback on a media app once switched to it, the basic media controls don't recognize the app switch so they start playback on whatever was plying last. I'm going to look into adding specific intent data for specific media apps.

My goal would be to have the one button toggle and resume playback on a sequence of media apps, and to have another button toggle through a set of other apps(AA, Settings,...).
[FYT Android Head Units] surfer63:
I hope you succeed, really, because everyone will benefit.

I never mentioned I'm a good programmer, always the opposite. I do program because nobody else does it for what I want.
[FYT Android Head Units] gottahavit:
I'm a bit of a hacker when it comes to android, won't claim to be very good either but I can usually make stuff work. I never would have thought of doing what you did to make this work, so you have a great start here.

Has anyone pulled the SWC builtin app off? is the interface to the raw controls protected?
[FYT Android Head Units] IG_Vasilich:
SWC buttons are handled by MCU, and then MCU sends those to SofiaServer over /dev/ttyS0 with 38400 baud (at least in my case with resistive SW buttons, no CAN bus).

To get what you want we basically need to patch SofiaServer (again 8) ), because MCU sends both KeyUp and KeyDown events properly, it is only SofiaServer that ignores those and reacts only on KeyDown.

There are some code for handling long presses, but this code is only for

PowerButton (short press for mute, press 2 seconds for screen off, and 10 seconds long press for reboot),

eject button,

DVD button.

If you could get SofiaServer code patched (e.g. with Smali, or manage to do it with DexPatcher) - then we can do almost everything we need (like fixing GPS date problem, remapping/using any button, changing some interface elements, etc.).
[FYT Android Head Units] gottahavit:
I'm referring to the setup app on the HU. It not only interrupts current mapping, but reacts to both key up and key down.. I'll pull this package tonight and rip it apart, unless someone already has it. I'm curious if the events it's tied into are protect to system apks or not.

My goal is to not root my HU. Smali is easy enough to deal with if the libs are needing to be system apks.
[FYT Android Head Units] IG_Vasilich:
OK, i was off-topic here with my last post (or its part concerning SofiaServer). All this stuff isn't possible without root, because SofiaServer is a system apk, so you need root rights to be able to replace it with patched version.
[FYT Android Head Units] gottahavit:
i don't want to replace it, I want to do what it does(just better). As soon as I get this what I'm doing now working I'll poke around in the apks
[FYT Android Head Units] gottahavit:
So here's a test if some daring soul is interested. All package launch options, with the exception of EQ options as that had some special operations I haven't looked at yet, now support multiple package name separated by a "," NO SPACES!

ex. org.videolan.vlc,com.neutroncode.mp,com.spotify.music

If there are multiple packages in a setting then they will be tracked and each push will cycle to the next app on the next button push.

In addition packages mapped in the Band setting will trigger playback after launched(tested with several apps). I was annoyed that I only needed to pause for 5 seconds to issue playback command if the app was not resident in memory, so I now have code to interogate if the app about to be launched is already resident and if so it will only pause for 1 second(will prob change to 1/2 later) before issue playback command.

I have only tested a couple buttons as I don't have all these activities in my SWC setup(or I have found them all). I have tested Band(issues play), and AVBT(which just toggles).

No Double click functionality.

this probably won't properly upgrade the current version as I have different debug signing keys.

Back up you settings if they matter to you!!!!

This was tested on my UIS7862 9" IDoing on my 2018 WRX LTD with canbus.

USE AT YOUR OWN RISK!

On a side note, thinking of adding a couple of connectivity option launchers to this. I want to launch AA when a phone is connected to USB, I want to start music when data available and UDB is disconnected. I have been floundering with macrodroid and tasker on these attempts. Macrodroid cant differentiate devices, and Tasker just refuses to see USB event.
[FYT Android Head Units] mariodantas:
Hi fellows

I have a question as my Android headunit MODE button only supports send to 4 positions

com.syu.radio

com.syu.bt

com.syu.music

com.syu.video

So when I press the MODE button, it switches between position 1,2,3,4.... 1,2,3,4 and so on....

But

If I replace com.syu.music by org.videolan.vlc then my MODE button switches between 1,2,3...1,2,3 and so on..... no more 4th position (com.syu.video)

It whappens even if i replace 2dn position parameter, MODE button only switches between 1,2..... 1,2 and so on

Can anyone help me with this ?

uis7862 (ums512) Android HeadUnit

Thanks in advance !
[FYT Android Head Units] gottahavit:
I'm not sure what you mean by switches position?
[FYT Android Head Units] mariodantas:
I mean whezn I press the MODE button, it toggles between 1, then 2, then 3, then 4 and go back to 1, then 2, then 3, then 4, and that's the cycle

Meaning:

1 = com.syu.radio

2 = com.syu.bt

3 = com.syu.music

4 = com.syu.video

But if I replace (i.e.) the com.syu.music (toggle 3) by another package then my MODE button don't reach the 4th position, it toggles only 1, then 2, then 3 and go back to 1
[FYT Android Head Units] gottahavit:
ok so you're using the apk I posted to cycle apps and have the preference set with ","s and no space? which activity is the button mapped to? Media? Band?.....
[FYT Android Head Units] mariodantas:
Band
[FYT Android Head Units] mariodantas:
The only key recognized is MODE key, toggling as follows: BAND, BT, MUSIC, VIDEO (in original FytHWOneKey)

I'd liuke to caught the big rotary with enter button to simulate keyboard left/right/enter keys also

MENU return to main launcher

OFF = shuts down the screen
[FYT Android Head Units] gottahavit:
Oh sorry now I understand, that's really interesting, I would try mapping them differently in the SWC control set up so each mode had different intent mapping in FYT, see if the issue is that one mode or a specific app causing the issue.
[FYT Android Head Units] gottahavit:
None of you other buttons work in the SWC built in app?
[FYT Android Head Units] gottahavit:
Updated to not lock the button when waiting for app to load before hitting play. It will now cancel the pending play and let you move on to next app immediately.

No Luck with USB triggers yet.

Want to try to support launching split screen app pair.
[FYT Android Head Units] mariodantas:
No, the only button that works is the MODE one
[FYT Android Head Units] mariodantas:
Here the 4 apks that are called by the MODE button of my hardware, only FYI
[FYT Android Head Units] gottahavit:
i would try remapping them to other activities in the HU SWC module then reset the apps you want in FYT.
[FYT Android Head Units] mariodantas:
HU SWC module ?, I'm a newbieon Android development, sorry don understand what "HU SWC module" means (HU = Headunit)
[FYT Android Head Units] gottahavit:
With your android head unit there should be an app to let you do the basic Steering Wheel Control Setup. YOu can map volumes and mute and such. Some buttons will map to radio, musc and such. All FYT app does is take some of those mappings(the ones mapped to apps in the SWC) and remap to difference(any) app in android.
[FYT Android Head Units] mariodantas:
Ok got it fellow, thanks SWC = Steering Wheel Control, so I'll decompile that APK and search inside, nice idea, many thanks for that
[FYT Android Head Units] mariodantas:
That's horrible to decompile these APKs, with APKTOOL is ok but we obtain smali code, that's good for modify arrays and strings (for translation etc...) but not for add / delete / modify java code (at least for me)
[FYT Android Head Units] gottahavit:
no all I was suggesting is running that and mapping your buttons to different actions
[FYT Android Head Units] gottahavit:
New version with the following changes:

1) You can now specify the delays for resident and non resident apps for issuing the play command

2) You can set whether you want the Band action to trigger the Media Play event at all

3) Experimental( in the package list if you place a "|[Some Tex]" after the package name and before the "," it will read it using TTS. Still need to work on fade in and out of any playing audio. example "com.wazw|Starting Waze" will say "Starting Waze" when you press the button.
[FYT Android Head Units] mariodantas:
Will try your app fellow, many thanks
[FYT Android Head Units] mariodantas:
@gottahavit you did an excellent APK, thank you for that excellent work, and also @surfer63 who is the creator of that code

Tell me something, do you have a github repo ?, I'd like (if you don't mind of course) to take a look into your java code
[FYT Android Head Units] gottahavit:
Surfuer Post #1 created the app I'm just trying to build some new functions in. I'll post my version of the code here as soon as I get it cleaned up and Surfer can update his github if he wants.

Were you able to get your mode to work? Right now I'm trying to fix the Audio Focus for announcing apps, and I have one more surprise feature I'd like to build in.
[FYT Android Head Units] mariodantas:
LoL, in this moment I'm waiting for another new uis7862 unit comes from china (but via DHL so it will be delivered fast) to continue developments here in home instead of compile and run to my car to test it LoL
[FYT Android Head Units] mariodantas:
I'm loosing weight because a run to my car and back home a hundred times per day LoL
[FYT Android Head Units] gottahavit:
LOL, I'm doing the same, That's ok I need the exercise.
[FYT Android Head Units] mariodantas:
@gottahavit I have a question (as I'm a newbie in Android Dev and more in uis7862 platform)

Do you know what is the responsable package for the physical touch handling ?

I know that com.syu.steer can liste to steer buttons, but what about buttons belong to unit itself ?, some units have touch buttons and other have physical buttons (like mine) and I'd like to understant how they are listened in the platform

My physical MODE key (as I said previously) switches between 4 APKs

1 Radio^(com.syu.radio)

2 Bt + BTav (com.syu.bt main + btav intent)

3 Media (com.syu.music)

4 Video (com.syu.video)

When I press MODE key, it calls "com.syu.radio", and I think that "com.syu.radio" injects some kind of litener for the MODE key.

Sso when I press MODE key again it calls "com.syu.bt" which inject some kind of listener that make the next press of the MODE key to jump to "com.syu.music" which inject some kind of listener that makes the next press of MODE buton to jump to "com.syu.video" which inject some kind of listener that makes the next press of MODE key to jump to "com.syu.radio" and that's the loop

So, as an exemple, if I replace 3rd option (com.syu.music) with VLC (org.videolan.vlc) when inside VLC and I press the MODE key, it should jump to 4th option but it will NOT call the 4th option (com.syu.video) as org.videolan.vlc DON'T put any kind of listener for that damn MODE key, that's why FytHWOneKey return to 1st option (com.syu.radio) instead of jump to the 4th option (com.syu.video) That's my theory

I'd like to override that MODE key hardware handler

I installed keyevent app to caught the event when pressed but it is not visible by the application
[FYT Android Head Units] gottahavit:
Pretty sure the all just call startActivity,I don't think the apps know anything about your MODE button. what's going on is that in the SWC app you have each Mode mapped to a different activity. If you don't remap in FYT app then those are the apps that launch. FYT intercepts the intents, it doesn't do any specific "cycling" it's jut that each mode is mapped to an intent and each intent in FYT is remampped to new action. If you are on activity 3 and you press the Mode and FYT moves you to activity 1 not Activity 4, then that activity out of the SWC app issued the next command.

Let me ask you something, if you are on activity 3(VLC) and you press mode does it immediate go to activity 1? or do you have to press it again?
[FYT Android Head Units] mariodantas:
Imediatly to 1
[FYT Android Head Units] gottahavit:
very odd, try putting non syu apps in all spots.
[FYT Android Head Units] gottahavit:
ok here is something to play with,

1) Fixed AudioFocus when announcing app, it should now lower background app, announce, and then reset background volume.

2) You can now set up splitscreen pairs if your app and HU support splitscreen. Simple put a ";" between 2 apps you want in splitscreen("com.waze;com.android.chrome|My split screen,com.spotify|Spotify")

May still be some glitches with splitcreen, first app should be on the left, but seems I may need a reset in there somewhere as it sometimes swaps them. If the apps don't com up splitscreen try switching the app order. For some reason I haven't figured out some apps like to come up one side or the other in split screen. It may have to do with history of openning app in split screen, still trying to work this out.

FYI other than some clean up this is probably all the features I could come up with, but open to suggestions. Otherwise I'll probably start ripping apart the built in SWC app to see how much control we can get.
[FYT Android Head Units] mariodantas:
Did it already, the MODE Key jumps to 1st option (Radio) and stay there when pressed (Reload Radio on each hardware keypress), means doesn't switch to 2nd option, nor 3rd nor 4th
[FYT Android Head Units] gottahavit:
that's very strange. Unfortunately without having it front of my I'm out of ideas. You could try installing an intent logger. Not sure they will work on the HU, but worth a shot
[FYT Android Head Units] mariodantas:
Yeah don't worry fellow, you provided me enough help, and waste your time to help me with this, I'll finally find it one day and then I'll post here the solution (if interested of course)

Many thanks for all
[FYT Android Head Units] TorstenH:
On Junsun devices the app doesn't work. E.g. activiy to start Bluetooth music app is com.ts.bt.BtMusicActivity.

Attached you can find the manifest file of the MainUI.apk
[FYT Android Head Units] gottahavit:
Yes unfortunately right now if the main SWC doesn't map to a know SYU activity you can't remap. I'll take a look later, I can maybe build you a version that will do the same for you activities
[FYT Android Head Units] TorstenH:
Looking forward to hear from you.

Maybe best chance with

com.ts.main.navi.NaviMainActivity

because navi and carousel can be started by SWC.
[FYT Android Head Units] gottahavit:
Give this a shot, if it works there are other activities I can try mapping for you. For now I mapped your com.ts.bt.BtMusicActivity to BTAV and

com.ts.main.navi.NaviMainActivity to OneKeyDVD

see if either of those give you control you want.
[FYT Android Head Units] TorstenH:
You uploaded to git or if just the attachment missing?

Thank you very much.
[FYT Android Head Units] gottahavit:
oops
[FYT Android Head Units] gottahavit:
odd it's removing my attachments today. I tried to PM you and it did the same

FInally, something was wrong now it isn't wwho knows.
[FYT Android Head Units] gottahavit:
New version which will use Split Screen Launcher if installed and you tell it to. Rather than just pulling all this apps code into FYT, I decided(at least for now) to use that app if it's installed to gain improve split screen options.

The fallback code I had is still there if you tell it not to use Split Screen Launcher, but it is unreliable.

Split Screen Launcher: https://play.google.com/store/apps/details?id=com.fb.splitscreenlauncher&hl=en_US&gl=US

also including source code as I am approaching the end of my needs for this app.
[FYT Android Head Units] TorstenH:
Thank you very much for your help. I tried the app but it doesn't work. Maybe the apps are started by the steering wheel keys in another way. But that's not a huge problem because my solution with Automate is running without problems.
[FYT Android Head Units] gottahavit:
ok sorry it didn't work. what do you use as a trigger in Automate?
[FYT Android Head Units] TorstenH:
https://xdaforums.com/t/use-swc-to-switch-between-navi-and-radio.4259683/
[FYT Android Head Units] gottahavit:
I see, my guess is your SWC is targeting the startActivity directly at the requested package and therefor FYT can't get the request. This could be done with and app similar to the way you are using Automate, but since that is working for you.... ;-)

The difference with FYT is that they can't be mapped to apps directly only predefined options.
[FYT Android Head Units] gottahavit:
New version, minor tweak to fix an audio focus issue when announcing apps and toggling too fast.
[FYT Android Head Units] gottahavit:
anyone ever figure out if the physical rotary buttons have interceptable events? I can't map them in either panel keys or SWC setup. Mine came mapped to volume, mute and tune/next play/pause.

I'll start digging but figured I'd ask here first. If they are coded into system level actions, there's not much without root. honestly the only thing I'd change is I want the PUSH of the volume to do next song
[FYT Android Head Units] IG_Vasilich:
on my Joying the push button for volume is coded in Sofia server app so, that it handles down-up as mute, down-2000ms-up as MCU on, and down-10000ms-up as reboot. So for changing that we need to patch Sofia Server app code.
[FYT Android Head Units] gottahavit:
ok that's what I was afraid of. Thanks for the Info.
[FYT Android Head Units] Allan_Hun:
Thank you for this brilliant app!

I'm trying to get the intent: com.google.android.googlequicksearchbox/com.google.android.googlequicksearchbox.VoiceSearchActivity

To work -but nothing happens.

but Package name:

com.google.android.googlequicksearchbox

Works fine, but then I have to press the voice button...

Did google change the intent or why isn't it working?
[FYT Android Head Units] surfer63:
Yes, Google changed something as multiple apps used this "shortcut"/intent as if they were offering voice services. Google didn't like that.

Edit: Moreover: Google now wants you to pay if you want to use it directly from your app. So somehow it should be possible, but I guess with some sort of online license/certificate (as you need to be online anyway when using Google voice)