yashsingh1/xdaforums huggingface dataset:
[MTCD Software Development] Bose321:
Hi there,

As you might have read on the PX5 board threads, I was struggling with the ease of use of the stock FM Radio app when driving. If you don't have to SWC you first have to press home from navigating, and open the radio app, or use the widgets, to switch channels. I didn't like that like, so I started to inspect the radio and radio widget .apk files. In there I found some pieces of code that remotely allow to control the FM Radio app.

What my app does is 'listen' to the information the stock FM Radio app is outputting. It can get the current frequency and channel. It shows this information on a notification on your HU. This notification also consists of three buttons to go to the previous channel, the next channel, and turn of the radio.

The current frequency and channel are also pushed to the Android Media Session with media button support. This means other apps (like AnyAutoAudio) or widgets can display the currently playing frequency and channel. You can also control the radio with the media buttons Android support. USB keyboards or BT devices that support these buttons should work! I haven't tested it, but this also means the FM Radio can be used in Android Auto. As soon as you open another media app (like Poweramp), that app will take over the media buttons (as expected). If you want to switch back to FM just press the power button on the notification and you're back.

This app is at an early stage right now. I'd like to see it as a proof of concept. It currently only works with FM. It can't show AM information yet. I am not an Android developer, so it might contain a few bugs and glitches. Let me know if you find anything.

I made a little video a few days ago when I had my first proof of concept working. This video does not display the media button support. Watch it here: https://youtu.be/JNUAi0KNGmM

Let me know what you think! Ideas and suggestions are always welcome.

Download: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk
[MTCD Software Development] Dec64:
So I gave this ago, it seems like it's nearly there for Android Auto. AnyAndroidAuto does pick it up and displays what station is on but AndroidAutos next/pause/previous buttons do not effect it. Also if I change radio station the widget in AndroidAuto does not update to reflect this. Any idea why this is?
[MTCD Software Development] Bose321:
That's too bad.

Does the info in the notification change when you switch channel? The media session which feeds info widgets etc. seem to be a bit flaky right now.

Do you have any other media widgets that show the current playing media?

edit: [MENTION=7602719]Dec64[/MENTION], gave it a try this morning. My widgets didn't make it control, or had the latest station displayed, but the native Android media buttons worked fine. Very strange... Do you happen to know what commands AnyAndroidAuto send? It should work for the next/previous/pause buttons. I'll see if I can make some changes today.
[MTCD Software Development] Dec64:
Yeah the info in the notification changed, and worked perfectly just didn't feed that information down to AA. I had no other media widgets at that time.

No unfortunately I don't know what commands are sent. What is weirder still is this morning on my way to work, after about 20mins the HU turned off the radio and changed menus in AA to the music menu and said nothing is playing...Yet i touched nothing. I put the radio back on and after 5mins it turned back off and I was sent to the phone menu. The only thing new running was your widget, very odd, I dont know how that is even possible.
[MTCD Software Development] Bose321:
Weird! I've rewritten a load of code, and it should be more stable now. I'm testing on an Android Emulator and and simulate some information the FM Radio would send, so I hope it's better now!

You can download the .apk again from the same URL in the first post. Let me know how it works on the HU. I'm gonna test it when I get home tonight.
[MTCD Software Development] Dec64:
Sweet, ill give it ago in 30mins on the way back from work.

[MENTION=8291382]Bose321[/MENTION] Perfect, works 100% better now, reports, shows station changes when I use SWC to do so, shows a stop button now though instead of pause/next track on the AA widget, and the stop button does nothing, but for AA integration it works
[MTCD Software Development] Nomader0:
this is encouraging.

can you help me with something mate:

i need to turn radio on/off via tasker.. do you think there is a way to do that.. i saw you do that via your app
[MTCD Software Development] Dec64:
You can user tasker or f1x's mtcdtools to do that, there's an intent to close the radio app.

intent action: com.microntek.finish

intent parameters: {"class":"com.microntek.radio"}
[MTCD Software Development] Bose321:
Can you show the AA interface? Not sure why there only is a stop button now, and why it doesn't work. I'll have to dig around in the code to see what causes that.

edit: I think I already know why there only is a stop button right now! Gonna push out a fix tomorrow! I also think why the stop button doesn't work. I only listen to the pause/play button, not the stop button. Thanks for testing, this is useful!

I use the intent "hct.radio.power.switch" to turn the radio on or off. This is different from the intent Dec64 posted. Mine only turns off the radio, it doesn't shut down the radio app. So use what fits the most.
[MTCD Software Development] Nomader0:
Thanks for your answers..

Which intent turns on the radio?

Maybe Com.microntek.radio.power?
[MTCD Software Development] Bose321:
I use the same one. It's a toggle. Send it once to turn it off, send it again to turn it back on.
[MTCD Software Development] Nomader0:
Thanks mate I will try that.
[MTCD Software Development] Bose321:
Can you give it another try? I've updated the link in the first post again. Should now show next/previous/play-pause buttons if I'm right!

Tried the version of yesterday in my car, and it works a lot better for sure!

Are you liking Android Auto on the HU? Is it fast? I'm hoping Sygic is able to build the navigation for AA soon, I don't like Google Maps for offline navigation. Are you always connected via your phone or something, or have you downloaded parts of maps?
[MTCD Software Development] Dec64:
I will try it on the way home from work again.

I like AA on my HU because it displays the info i need quickly and at all times, but the major draw backs where the radio not showing, and the phone menu not working properly.

I dislike google maps and prefer waze for the police/speed camera warnings as i drive a bit...spirited...but waze integration isn't working yet unless you have an AA specific HU. It also doesnt display speed limits/cameras.

Yeah I have 30gb of tethering on my phone so always connected using tasker to start tethering when BT is connected
[MTCD Software Development] Dec64:
tried updated app. Next/previous/stop now show on widget but do not work in AA, everything else works perfectly
[MTCD Software Development] Bose321:
Weird! I'll see if I can get AA on a device to test this. At least the right buttons are now showing. It's a start... :laugh:

Seems to be different from other widgets, because the ones I use seem to work fine (Ubiquity Music Widget).
[MTCD Software Development] aarick:
same issue just tested today...
[MTCD Software Development] Bose321:
Thanks for testing. I'll have to look into that. Can you try the native media buttons?
[MTCD Software Development] Dec64:
Just turned rds on my radio and noticed the widget doesn't pick station name or rds info. It would be amazing if it could and report that info?
[MTCD Software Development] Bose321:
I've been looking into that, but I believe the radio app doesn't 'share' that information. But I'll have another look.

But first gotta look into the AA issue.

What I did notice on my own HU, as soon as the Radio app starts, the sound goes on, and directly off again at boot. Did any of you notice that?
[MTCD Software Development] aarick:
Native button works..

---------- Post added at 11:07 AM ---------- Previous post was at 11:05 AM ----------

Yes, notice this started happening the last few days..wasn't sure what it was related to..
[MTCD Software Development] Bose321:
Thanks for letting me know. Guess I have some things to look into. I'll have to see if AA sends other commands to skip through songs. I'll post an update when I've found some news.
[MTCD Software Development] Dec64:
In one of the px5 threads there's a link to Graser's xposed module which does something with RDS on the radio..no idea what but it references grabbing rds info

"For RDS - simpler, method of receiving INT and returns STRING

type this

cb String the public (int i) {

return statement this.en.ec? this.en.fm (i): "";

}

"

Not sure if that's of any help.

Yes my radio starts/stops at boot, and/or when i run your app for the first time it stops the radio.
[MTCD Software Development] Bose321:
I can't imagine that that function would do anything in an app like mine. Do you have a link to the specific post perhaps? Thanks!
[MTCD Software Development] Dec64:
https://xdaforums.com/showpost.php?p=72622247&postcount=3

That's the thread it's on, i think it comes from 4pda.ru but not sure where. The pdf document attached has some more info but it's over my head.
[MTCD Software Development] Bose321:
Thanks for the link, but I'm not sure if I can do anything with it. I did find another intent which requests for data, maybe that contains station information or something.

I've updated the .apk in the first post. It should now work with Android Auto! I've installed my app and AA on my phone, and after some changes those buttons now also work. Let me know how it works for you.

Haven't found anything regarding the radio stopping on launch, maybe some debugging was still turned on, see if it's still there. I'm gonna try out some things after work regarding RDS or station info.
[MTCD Software Development] Bose321:
Updated the app again. Link is in first post. It now also displays the channel and frequency if you're tuned to AM. If anyone still uses that... :angel:

I think I also found something for the radio turning off when the app starts. Atleast, that's what I think.

No luck on the RDS information... :crying:
[MTCD Software Development] Dec64:
Great! don't use AM, on the off chance i need to know the sports scores i may i guess..haha but it all works really smooth on AA now. Shame about RDS but oh well
[MTCD Software Development] Bose321:
Great to hear! I'll do some further inspections regarding RDS. Would be really cool for sure.
[MTCD Software Development] Psy87:
Do you plan to build a solution for the stock media player as well? or maybe integrate that into your app? That would be gorgeus!

Btw, this also works for Intel Sofia, not onlx PX3 and 5
[MTCD Software Development] Bose321:
Actually I was thinking about that! Maybe I should have a look at this this week.

That's cool! Does that HU use the same radio and music player?
[MTCD Software Development] Bose321:
Worked a bit on the default music integration. It's still not done yet obviously, but I've got a proof of concept running on my HU right now. Switching between radio and music is a little tricky, but it's a good start. I hope to fix some bugs tomorrow and push out a version to test.

It seems that only the song name (filename.mp3) is only available, so that's a little crappy, but I'll see if I can get some more info somewhere... :good:
[MTCD Software Development] Bose321:
Can you download the .apk again? I've implemented some basic support for the music app.

I only get some ugly filename reported right now, I'll have to see if I can get more information somewhere... but for now you can try it.
[MTCD Software Development] Psy87:
Hey,

I tested and its working good so far :) nice update, thank you.
[MTCD Software Development] Bose321:
Great to hear. I haven't found time yet to improve the music part yet, but I have a nice update for the radio part!

Thanks to the help of [MENTION=8279131]AndHead[/MENTION] I have now found out how to retrieve the radio station name and RDS information from the current station. I've also worked on a little extra way of controlling the media in the form of a floating widget that overlaps the screen so you can use it in all screens. If you're familiar with the 'chat heads' from Facebook you might know what it can do. Because it's still experimental and looks ugly I've made a setting for it for people to try. I would like to hear what colors and layout you people would like to see for this for optimal usage!

I've updated the link in the first post: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk

Let me know how it works!
[MTCD Software Development] fma965:
is there anyway to make this work on a phone then connect to the radio on my headunit PX5 via head unit reloaded and android auto?
[MTCD Software Development] otromen02:
Hi, does it work with PX3? I tried installing it but got some parse error.
[MTCD Software Development] Bose321:
Don't think that will work, and it defeats the purpose of this app.

However, if you have my app installed you can install another app that does this. I've once tried an app that lets me send media commands via my phone to the HU via BT. My app then should catch these commands.

No idea. I don't know what would be different about it. I can't look into this since I don't have a PX3 unit. Should run on Android 6 fine. No idea about 5 or 7.
[MTCD Software Development] otromen02:
Disable RDS

I managed to get it working. Seems that it only works with Android 6 and above. Anyways this is a great program, at the moment the stock radio doesn't notify when I change preset radio channel. So when I combine this program with 'Heads Up! Notifications', it will popup notifications when I change the channel.

I only have one request, if you are able to add the option to disable the RDS. Reason being when ever the RDS info changes, it will appear the notifications, so it's best to make it a static info i.e. Radio Frequency. If you are able to add this, it would be a perfect program for me.

Thanks
[MTCD Software Development] Bose321:
Sounds possible. I think I could just add a checkbox (like for the experimental floating window) to enable/disable RDS. When I find some free time I'll work on that.
[MTCD Software Development] otromen02:
RDS Disable

Great! I also noticed the channel starts with 0, instead of 1. Could you look into that also. Thanks!
[MTCD Software Development] Bose321:
Oh yeah right, forgot about it. In programming collections start at 0 instead of 1. But that's an easy fix. :)
[MTCD Software Development] Bose321:
Can you try to download the .apk again? I've updated the app. Added a checkbox for RDS (default enabled), and the channel number should be good now.

You should open the app and disable RDS. Then change the frequency to fix the stuck station name.

Let me know if it works, I'm not near my car so haven't tested it.
[MTCD Software Development] otromen02:
RDS Disable

Perfect! Great work man.

But if you want another suggestion how to make this small program more interesting, if we can customize the channel name i.e.

HITZ FM - 92.9MHz

FM1 - Channel 1
[MTCD Software Development] Bose321:
That's good to hear.

I'm not sure if that's possible since I only the the RDS and channel information. Some radio apps allow naming the channels, but that's not shared across other apps.
[MTCD Software Development] otromen02:
I would get force close, especially after wake up from sleep. Any ideas?
[MTCD Software Development] Bose321:
Which unit and software are you running? Version of Android, MCU, ROM etc.
[MTCD Software Development] otromen02:
Build number

px5-userdebug 6.0.1 MXC89L user.hct.20170803.200456 test-keys

MCU version

MTCD_HA_V2.59_1

Aug 3 2017 10:58:49

CPU

8 core 64-bit CPU Coretex-A53@1.5G

Model number

A-MEDIA AUTO (1024x600 W)

Android version

6.0.1

Android security patch level

October 1, 2016

Kernel version

3.10.0

rocky@hct930 #1084

Tue Aug 1 20:30:13 CST 2017
[MTCD Software Development] Bose321:
Have you tried to run a whitelist app to prevent it from getting killed? Maybe that's the problem.
[MTCD Software Development] otromen02:
How do i do that?
[MTCD Software Development] Bose321:
I believe there's an app called Prefer app in Malysk ROM's that do this. I think the best thing is to search for it on the MTCD forums, there are plenty of posts about it.
[MTCD Software Development] otromen02:
Actually the stock radio doesn't allow changing the names of the preset channel, else you should be able to pickup and show it on your app. Do you think you're able to reverse engineering the stock radio app, and make it able to set the name for the preset channels? That would really be an awesome addition.

I actually found another stock radio app that allows the channels preset to be renamed, but the interface is a bit ugly, and the channels listing is 30 instead of 18, which is too many for me to fill up
[MTCD Software Development] Bose321:
Not sure if that's easy to do (for me), but I could have a look when I get some time. :)
[MTCD Software Development] Bose321:
I've updated the app again. Since I have installed my DAB receiver I missed that the DAB didn't send more information (like I miss from the music app and radio app), so I added support for it as well!

Note: You must use the realzoulou's app (version 170909 or higher). The stock DAB app will not work!

Download: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk
[MTCD Software Development] rigattoni:
There seems to be a parsing error in the download.
[MTCD Software Development] Bose321:
Tried another browser? Works fine on my pc, laptop and phone.
[MTCD Software Development] rigattoni:
Tried it with 3 different browser now... I always get a parsing error when I try to install the app.

PX5 with Android 6
[MTCD Software Development] Bose321:
Weird. Do you have the previous version installed? If so maybe try to remove it first.

Can anyone else try? I'm not near my car atm.
[MTCD Software Development] rigattoni:
Sorry to say, but there was no previous version installed. I just found your thread in the DAB+ thread and just wanted to give it a try as long my unit is on the bench.

In case the previous version would be installed I normally would get a message that the app could not be installed, but I always get this parsing error instead.
[MTCD Software Development] Bose321:
Does this link for? https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller-release.apk I recently updated my Android Studio version and maybe something changed.
[MTCD Software Development] rigattoni:
I´ll give it a try tonight when I´m back home. Thanks a lot. :)
[MTCD Software Development] rigattoni:
Sorry for the late reply...

I tested your newest build, but as before, there is no possibility to get the app installed.

It always fails with the same error message.
[MTCD Software Development] Bose321:
Damn... can anyone else try? I'll try again to see if I can install it on my car.
[MTCD Software Development] me.how:
Is it possible to make similar app for MTC Music? I am using Car Launcher AG and it would be lovely to control music player by built in controller
[MTCD Software Development] Bose321:
The default music and radio app are supported. Have you tried it?
[MTCD Software Development] me.how:
Yes, i did. Not working. Maybe I configured it incorrectly.
[MTCD Software Development] Bose321:
Have you enabled notifications for the app? Have you tried to radio app to see if it works at all? Maybe we can pinpoint the issue.
[MTCD Software Development] me.how:
Of course i did. I will try it tomorrow. When I selected power amp as a default player it worked well.
[MTCD Software Development] otromen02:
Ah shoot, updated my PX5 to Android 8 and now its not working anymore :(
[MTCD Software Development] Bose321:
The app or your HU?

In case of the app, doesn't it do anything at all? Maybe check for notification permissions?
[MTCD Software Development] typos1:
You flashed an Oreo ROM ?? Or bought a new SoM ??
[MTCD Software Development] otromen02:
I bought a new one. Actually i just ordered the same PX5, and was hoping I would get the same Android 6, but seems that the seller was kind enough to ship the latest Android 8
[MTCD Software Development] otromen02:
This is the error that I got
[MTCD Software Development] Bose321:
Ah okay! Seems like I need to use channels for Android 8. I'll try to get an update out soon. I don't have any Android 8 devices, so you'll have to test it. :)

Edit: Can you download it again from the link in the first post and let me know if it works now?
[MTCD Software Development] otromen02:
Just noticed you've updated the same post, so I didn't get the notification. Anyways, just tested. Still the same error.

Note: It would be great if you can put a version on the file name so I wont get confused. Look forward for your update, thanks!
[MTCD Software Development] MarcoB1979:
I have downloaded your app and installed it on my android headunit. I installed android auto on the headunit itself. I also installed anyautoaudio. In AA the notification shows with the currently playing radio station. But none of the buttons work, I see stop button, next and previous. When I use the notification system it does work correctly and also floating control most of the time work, but sometimes react slow. Am I forgetting something or did I do something wrong?
[MTCD Software Development] Bose321:
I forgot a small line in the code. Tested with an Android 8 emulator, and seems fine now.

Can you try again? I don't have a versioned download yet, but will do that someday perhaps.

Download: https://gerbenbol.com/android/com.gerbenbol.hctradiocontroller.apk

PS: Disabled the floating overlay, seems to be broken in Android 8. Don't think anyone used it, but if you liked it let me know.
[MTCD Software Development] kaise123:
[MENTION=8291382]Bose321[/MENTION] I have a question which I think is semi-related to your work here. I'm trying to use an external (USB) volume controller to change volume on my unit, but from my understanding this is also controlled by the Microntek/MCU part of the unit, so standard media key inputs do not work?

Is there a way your app could allow key inputs (In my case a USB keyboard with media keys) to change the volume on the unit? I'm pretty tech savvy so if you could even point me in the right direction I'm happy to 'help myself' if I knew where to start.

If you're interested, see my thread: https://xdaforums.com/android-auto/.../external-volume-knob-button-mapping-t3774138

Thanks!
[MTCD Software Development] Bose321:
Sorry for the late response, was on a trip to Thailand.

I see in your other thread that you've got something working now?
[MTCD Software Development] kaise123:
Thanks for the reply. Yeah I did manage to get it going in the end :)
[MTCD Software Development] Bose321:
Great!

Have you tested it again?
[MTCD Software Development] RogerClark:
Hi I started another thread, last week, about decompiling the radio app in my Oreo (Px5 GS) unit, ( https://xdaforums.com/android-auto/...ment/decompiiled-oreo-mtcd-radio-app-t3820434 ) but I've not got too far, but I stumbled across your thread once I found references to "com.microntek.radio.report"

I'm about to give your latest app a go on my Xtrons unit, but I suspect it won't work, as it looks like they have changed things in the different versions of these units :(
[MTCD Software Development] Bose321:
My app was built with the Xtrons radio app in mind (one from my stock Android 6 unit). So with a bit of luck it should work. I never user FM anymore since DAB, so let me know if it works. I could make some changes if needed.
[MTCD Software Development] RogerClark:
Thanks, I'll try your APK.

PS. Did you publish your source code anywhere?
[MTCD Software Development] Bose321:
Cool.

I haven't, and no plans ATM since it's a mess, but who knows for the future. I am not really working on this anymore since I don't think anyone is really using it.

But the concept is simple, my app listens to broadcast intents that some (not all!) radio apps send, and simply puts them in a notification banner.