yashsingh1/xdaforums huggingface dataset:
[Nexus One Android Development] stonner:
Thanks for the response , i appericiate this , i was hoping that there was some app and kernel to work on Custom ROMs FROYO for Nexus One , some how i dont like SENSE Roms , so do u think there will be any hope of any CUSTOM ROM fully functional FM Radio for Nexus One in near future , apart from SENSE ROM (which is still WIP)
[Nexus One Android Development] bewA:
there's certainly hope, there's some good people working on this its just a matter of time.

The kernel is sorted otherwise Radio wouldn't work on the new R23 so that's good :)
[Nexus One Android Development] osugsxr:
becoming more interested in the fm radio support, on the mlb app you can listen to live radio feeds from games. Looking forward to fm support
[Nexus One Android Development] theophile2:
You do know that the MLB app and the FM radio have nothing to do with each other, right?
[Nexus One Android Development] osugsxr:
Yes, do you
[Nexus One Android Development] cyanogen:
HTC linked a bunch of proprietary code into libandroid_runtime, so it would need to be reverse engineered to use on a non-Sense rom. It also seems tightly coupled to the proprietary bleutooth stack that they use.
[Nexus One Android Development] bewA:
Do you think its going to be possible to get this working?

Sounds like a lot of complex work!

Sent from my Nexus One
[Nexus One Android Development] martin0285:
Don't like the sounds of all the "proprietary" code.... I'd hate to have to start running a sense rom.....
[Nexus One Android Development] tjsimmons:
This could be what's driving me crazy, then. I've got this thing off Sense (as far as I can tell), but having a hell of a time getting it to start the FM service. I've got the FM files for the Broadcom bluetooth chip, I'm just now working on getting those into the right spot on the phone.
[Nexus One Android Development] bewA:
good luck!! :)
[Nexus One Android Development] tjsimmons:
I think I need magic, not luck. I'm getting an FC every time the app launches due to "Cannot setBand() mService is null" but can't figure out just why it's null. It's got to do with the BT stack, I think, but as far as I can tell, I put that into framework.jar. Any thoughts?
[Nexus One Android Development] bewA:
Is it worth looking into the other FM apps?

Only thing is I don't know what other fones use the bluez bluetooth stack :S
[Nexus One Android Development] Devastatin:
The bluetooth stack currently employed within the nexus one is http://www.bluez.org/ .

This bluetooth stack does not have FM support. To enable FM on any rom you either need to replace and rehook an entirely different bluetooth stack or add FM support to bluez.

This was previously discussed on this server in the thread

http://xdaforums.com/showthread.php?t=697983
[Nexus One Android Development] bewA:
ok so the next question is can we rip the broadcom stack from the desire?
[Nexus One Android Development] :
Might want to read through the thread, you seem to be a little late.
[Nexus One Android Development] martin0285:
It's been done.... Theres audio on desire rom.... Just a matter of proper app not tied into sense framework
[Nexus One Android Development] rohandhruva:
No, it's not. Only the kernel supports FM now, which proves that hardware is capable of it. The software part has not been tackled yet, and it's looking difficult. On a stock N1 I mean, not desire rom.
[Nexus One Android Development] tjsimmons:
Difficult doesn't start to cover it, I don't think. I'm far from an expert in this, but I think I've removed most of the Sense stuff. The only thing preventing the app for launching for me right now is the lack of mService, which I'm taking to be the FMService. The app calls for it and finds it to be null, and crashes.

Drives me insane. I'm at a loss right now of what to do.
[Nexus One Android Development] rohandhruva:
We all thank you for your efforts :)

This is so irritating. To use a cliche, it's like having a Porsche in your garage, but unable to take it out of the driveway :)
[Nexus One Android Development] CMUKyle:
What makes you think it's FMService? It could be any old service that's not getting instantiated due to a mix-up somewhere.
[Nexus One Android Development] tjsimmons:
Just because of the name. It's calling to setBand() and getting a null mService. I'll have time this weekend to flash a Desire ROM and trace the call stack when the app launches, to try and see where that's coming from.
[Nexus One Android Development] Chopes:
Sounds like a plan :D
[Nexus One Android Development] zeb crs:
I have followed this project for quite a while now and have an idea as I'm not a programmer but have worked a bit with reverse engineering. On the xbox when we got the dvdplayer working we gave up on the program and wrote a new program and reversed most of the library calls and setup routines instead.

Make a flow on how to enable radio, how to set stations and how to get audio and start building a new application from scratch.
[Nexus One Android Development] CMUKyle:
Not that I've looked into this particular case at all, but that's Google's naming scheme for generic things such as Activities, Contexts, and Services.

i.e. mContext or mService.
[Nexus One Android Development] bewA:
That's probably true but this is HTC not Google :-)

Sent from my Nexus One
[Nexus One Android Development] tjsimmons:
Ah, really? I know very little about how to develop for Android; I've been working in the bytecode for all this, which is part of the problem, I think. When I have the time, as I said, I plan on trying to trace it and see what service that is.
[Nexus One Android Development] imfloflo:
We need to share all we have for the moment.

To not let this thread dead.
[Nexus One Android Development] pandabear:
bump... :) keep this alive please
[Nexus One Android Development] midnjerry:
This is the reason why you're getting NULL.

Fm Radio Service is based on the following files on the phone:

/system/framework/framework.odex

/system/app/HtcFMRadio.odex

/system/bin/btld (executable)

/system/lib/libandroid_runtime.so

When you smali HtcFMRadio.odex you'll see that the app calls for com.broadcom.bt.service.fm.FMReceiverService. This class is located in a package in the framework.odex file.

If you smali framework.odex you'll find package: com/broadcom/bt/service/fm. In here is the FMReceiverService, but it doesn't stop there. It goes deeper. FmReceiverService is merely a java layer with methods calling its native equivalents (in C). I haven't looked at it in a while so this function name is not accurate, but setVolume() would just call nativeSetVolume(). Guess what, the code for nativeSetVolume() is located in libandroid_runtime.so as binary! Yea, good luck reading it.

Since you "removed Sense" from libandroid_runtime.so, you pretty much stripped the meat of the FM Radio app! All of the native functions it needs are in the htc version of libandroid_runtime.so.

Normally, libandroid_runtime.so is compiled from AndroidRuntime.cpp, but the htc version of libandroid_runtime.so also uses com_broadcom_bt_service_fm_FmReceiverService.cpp. If you really want to remove "Sense" you have to find a way to mimic the behavior of this file or find the source code for it. Then you can compile com_broadcom_bt_service_fm_FmReceiverService.cpp as its own .so file and then you can include it as a JNI library from the HTCFMRadio app.

By doing this, you have found a way to sidestep libandroid_runtime.so so you can put in your own "non-Sense" version.

So here are options to remove Sense:

1.) Find source code: com_broadcom_bt_service_fm_FmReceiverService.cpp and recompile as its own library (I think its proprietary, so will be difficult to get)

2.) Make your own version of com_broadcom_bt_service_fm_FmReceiverService.cpp API by implementing the Bluetooth drivers (source released by HTC). Make it an .so library and have it called from FM_Radio App through JNI.

3.) Decompile libandroid_runtime.so to get the binary com_broadcom_bt_service_fm_FmReceiverService.cpp creates, and reverse engineer it to make as your own library, that you can then call from HTCFMRadio.

All three seem like difficult undertakings. Number 2 sadly seems like best option :(

I'm fairly new to the scene, but from what I've been learning about HTCFMRadio, I think these are the only ways to go without coding a new radio app from scratch. Anybody else want to correct me?

Can anyone give us a detailed listing of what each of the driver source files do? http://developer.htc.com/

Can anyone explain in detail the FM Radio aspect of the Broadcom BCM4329 chip? http://pdf.eccn.com/pdfs/Datasheets/Broadcom/BCM4329.pdf

Like where is the HCI implemented in the driver files?

Where are the uart and I2S ports controlled in the driver files?
[Nexus One Android Development] Vovan888:
I think the answer is in btld.

I think FM radio is controlled with special HCI commands:

BTA_FmDisable	1C01

BTA_FmTuneFreq	1C04

BTA_FmComboSearch	1C11

BTA_FmSearchFreq	1C03

BTA_FmSetScanStep	1C07

BTA_FmSetRDSMode	1C08

BTA_FmSearchAbort	1C1D

BTA_FmSetAudioMode	1C05

BTA_FmReadRDS	1C02

BTA_FmConfigDeemphasis	1C0B

BTA_FmMute	1C06

BTA_FmReadAudioQuality	1C0A

BTA_FmSetRegion	1C0C

BTA_FmSetRdsRbds	1C0E

BTA_FmEstNoiseFloor	1C0D

BTA_FmConfigBlendSoftMuteParams	1C0F

BTA_FmVolumeControl	1C10

So there should be a way to send them from Android app via usual Bluez stack.
[Nexus One Android Development] midnjerry:
yea, maybe functions in libandroid_runtime.so are simply function calls to BTA calls.

I've seen nativeEstimateNoiseFloor() in android_runtime.so, maybe it tells btld to call BTA_FmEstNoiseFloor?

How does it do this? What kind of code can be written in java (i.e. eclipse) that would call on btld?

When you say "via usual Bluez stack", what do you mean? Would it be calling functions in /lib/module/bcm4329.ko?
[Nexus One Android Development] Vovan888:
There should be a new Android API, that controls FM radio via bluez and keeps BT disabled while FM is on and vice versa. Thats why HTC used custom Broadcom BT stack instead of Bluez.

Another option - port Broadcom stack from Desire to Nexus without HTC Sense.
[Nexus One Android Development] bewA:
Not that I fully understand everything I'm getting the distinct impression we are screwed! :(

We are going to need a lot of collaboration on this!

Hopefully the people that read this the more can help!

Sent from my Nexus One
[Nexus One Android Development] Lordjinji:
If there's a will, there's a way!

Keep up the good work guys! I know that some day this will work ;)
[Nexus One Android Development] bewA:
Yea this is true I still have faith :)

Sent from my Nexus One
[Nexus One Android Development] imfloflo:
I hope so, if some devs can read this and add some support to avoid this thread death
[Nexus One Android Development] xseaplus:
FM Radio is working, tested...

RoDrIgUeZsTyLe MCR r6 Port [v1.1] Sense/Apps2ext/FMRadio/BT [07/28/10] , Release v1.1

Thanks for Rodriguez
[Nexus One Android Development] rac2030:
This thread doesn't go about a rom...

Your rom has sense so nothing new
[Nexus One Android Development] cpm:
Yes, radio is now reportedly working in several Sense roms.

But I gather some people would prefer it to work without having to install Sense. I do anyhow :)
[Nexus One Android Development] imfloflo:
@cpm i would prefere to not have a SENSE rom cause there isn't any memory for all lmy apps on this one.

Waiting a good dev to post a POC on a non sense rom ...
[Nexus One Android Development] cpm:
Hopefully we don't have to wait too long, although I'd imagine it's difficult enough to figure out. Fingers crossed anyhow.
[Nexus One Android Development] martin0285:
we need broadcom to open source the code.... Aren't they required to under the GLP, Apache license crap??
[Nexus One Android Development] bewA:
I don't think that's necessarily the issue. its now down to how the FM Radio app is tied into the framework etc...
[Nexus One Android Development] :
Open source what code, their driver code? They don't have to as it's proprietary code.

Qualcomm has chosen to open up other code because it benefits them.

As of right now I believe they are the only people with an integrated fm/wifi/bluetooth chipset. If a company wants to use FM they can pay qualcomm for the drivers.
[Nexus One Android Development] dookie23:
Broadcom has released source code!

Broadcom has released source code!

http://linux.slashdot.org/story/10/09/09/1925214/Broadcom-Releases-Source-Code-For-Drivers
[Nexus One Android Development] bewA:
i'm not sure that matters now, its the app/framework we need to fix!
[Nexus One Android Development] midnjerry:
I"ve been working with c code regarding the radio (for EVO 4g)

The devices for the Radio should be referred in AudioSystem.h (if you download from AOSP, these values are missing) as:

enum audio_devices {

...

FM_SPEAKER 0x1000

FM_HEADSET 0x800

....

}

Using AudioSystem::setParameters and an io_handle of 1, you can turn on / off the FM Radio by calling AudioSystem::setParameters(1, parameter); with parameter equal to: routing=AudioSystem::FM_SPEAKER or routing=AudioSystem::FM_HEADSET

If you use an io_handle other than 1, you'll rout audio to the headphones and automatically close the FM Radio connection.

This isn't a lot of info, but it could get someone started.
[Nexus One Android Development] thanzm:
There are atleast 2 other threads going on for this same thing. Why cant you guys work it out together.
[Nexus One Android Development] pwvandeursen:
At least give a link if the two so everybody knows which they are....
[Nexus One Android Development] ~semsem~:
Other thread URL is under the following:

http://xdaforums.com/showthread.php?t=724749

Please also check Enom's reply under the following:

http://xdaforums.com/showpost.php?p=7879897&postcount=168

~Samy~
[Nexus One Android Development] imfloflo:
Another usefull post in the EVO section where you can find a HOWTO to reverse the FM Radio on the HTC EVO maybe this could help

http://xdaforums.com/showthread.php?t=725870
[Nexus One Android Development] zmalach:
Nexus One FM Radio

Is there any update on the Nexus One FM Radio? Have anyone get it working yet?
[Nexus One Android Development] imfloflo:
@zmalach we are still waiting new progress, but with the new MUi rom maybe we are going to see it soon on other roms
[Nexus One Android Development] zmalach:
Nexus one FM radio

Thanks! what is the MUi by the way? :confused:
[Nexus One Android Development] imfloflo:
A little bit out of topic but here : http://xdaforums.com/showthread.php?t=789566

Still waiting news from mui team to know if we can port FM to other roms ?
[Nexus One Android Development] intersectRaven:
When they release the source it should be trivial for ROM developers and kernel developers to integrate the changes. :)
[Nexus One Android Development] imfloflo:
My hidden question is , will they release it or not ?

i have my answer : http://xdaforums.com/showpost.php?p=8303155&postcount=541
[Nexus One Android Development] flipper203:
That s good news!!!
[Nexus One Android Development] bewA:
Seen this?? :D

http://bit.ly/aaES7K
[Nexus One Android Development] rickytenzer:
http://github.com/CyanogenMod/android_packages_apps_FM/blob/froyo/README

This confirms that it's the MIUI FM app! Now we just need the kernel code.
[Nexus One Android Development] theloginwithnoname:
OMG. I feel a rush of downloads for Intersect's kernel and the next CM nightly, and lots of comments here!!
[Nexus One Android Development] wildchild048:
Any news on getting fm radio working on none sense roms?
[Nexus One Android Development] rickytenzer:
Basically, the MIUI ROM has a working FM app that Cyanogen is getting ported over to his ROM. I don't think it's a question of "if" as he's already put in some of the roots into his source. Give it a few more weeks and I'm sure it'll be in!
[Nexus One Android Development] tonyx3:
The MIUI rom is a Chinese rom, right? So some crafty Chinese coders managed to get a working radio app without Sense, eh? Did they build it from scratch, or??
[Nexus One Android Development] intersectRaven:
According to Cyan, they adapted Qualcomm's FM source and app to work with our BCM chips. Nifty I say. :)
[Nexus One Android Development] tonyx3:
Nifty indeed!
[Nexus One Android Development] wakeborder556:
Any update to this endeavor?
[Nexus One Android Development] onesavior:
Just saw on twitter that the Droid 2 will have FM radio through a hack

http://i.engadget.com/2010/09/29/confirmed-droid-2-hack-brings-fm-radio-in-one-ear-and-out-the/

Can this be used on the n1?
[Nexus One Android Development] gongoila:
Tried it.. doesn't work though doesn't crash either...

You just don't hear a thing..

maybe other ROM other then CM6?
[Nexus One Android Development] martin0285:
maybe try it with intersects FM kernel?? Prob wont work but what the hell, why not try!! HAHA
[Nexus One Android Development] imfloflo:
http://xdaforums.com/showthread.php?p=8483177#post8483177

Htc desire kernel maybe some good stuff for us in it
[Nexus One Android Development] ghost77:
FM radio works with [ROM] RoDrIgUeZsTyLe´s MIUI-MOD
[Nexus One Android Development] cbkitt:
The New MIUI ROM Rodriquez has modified has a FM Radio using Blue Tooth. Its for the Desire and the Nexus????

Whay cant we can we get something on the Nexus??

Thanks
[Nexus One Android Development] DBBGBA:
Those crazy chinese really showed how to make a custom rom! I'm using the RoDrIgUeZsTyLe´s MIUI-MOD and it works fine. I love the radio, I know it sounds stupid but it's the only thing I was missing from my N95. Also the squareish icons are not that bad, if I could only tweak the colors of the backgrounds!
[Nexus One Android Development] b1337z0r:
?? it is for the nexus open your eyeballs man!
[Nexus One Android Development] gmadajczak:
I tried to run FM radio apk from MIUI ROM on CM nightly (197 ver.) with intersectRaven's Kernel. I just copied the apk to /system/app. As ou can expect - it doesn't work.

Here you are logs:

10-10 08:27:48.179: ERROR/AndroidRuntime(4146): java.lang.NoClassDefFoundError: android.hardware.fmradio.FmConfig
10-10 08:27:48.179: ERROR/AndroidRuntime(4146): at com.android.fm.radio.FmSharedPreferences.<init>(FmSharedPreferences.java:168)
10-10 08:27:48.179: ERROR/AndroidRuntime(4146): at com.android.fm.radio.FMRadio.onCreate(FMRadio.java:279)
[Nexus One Android Development] intersectRaven:
They used a different way for accessing the FM chip. And unfortunately for us, it seems the MIUI guys stopped talking with Cyan so we'll have to wait longer since Cyan has other things in line to work on right now to try and enable FM by adapting CodeAurora's source. :(
[Nexus One Android Development] imfloflo:
Tought they stop talking in here too must wait another week before they come back.

Tmobile G2 haven't Sense rom and have radio ? Maybe we can find some interesting files in it.
[Nexus One Android Development] midnjerry:
They used their own .cpp files to create a custom .so library file to call on bluetooth. That's why simply installing the apk on intersect's kernel doesn't work. It's these .cpp files that everyone is salivating for. I looked at the java code, they have "transmitter" functions as well. I don't know if they actually implemented that feature in the native code or not, but that would be sweet.

You can view the internal java code by baksmali'ing the MIUI framework.odex and looking in android/fm/radio

THis stuff doesn't help, though, unless you have the original source code they used to create the library files. I'm crossing my fingers that the developers will contact Cyan soon.
[Nexus One Android Development] martin0285:
To bad can't rev engineer...
[Nexus One Android Development] jfwfreo:
Assuming the drivers have been properly ported to the N1, there is no reason you couldnt reverse engineer the ARM assembly for the android runtime shared library (whatever its called) and figure out what its doing.

ARM reverse engineering isnt rocket science.

Reverse engineer the library code and produce a shared library say libfm.so and a java wrapper for it and then produce a FM radio app that sits on top of that.

Another way forward might be to run a kernel and romset (on a Deezire, N1 or otherwise) that has both working FM and working strace and then run a strace on the radio app whilst it runs. This lets you see what system calls are used for the FM radio.

I have no idea though whether Android kernels can support strace though.
[Nexus One Android Development] tech338:
From what I read at the MIUI forum (google translation http://translate.google.com/transla...p://www.miui.com/thread-1914-1-1.html&act=url) It seems they are still trying to work with Cyanogen. It seems we misunderstood them and they have been unavailable because of the holidays... It seems they are still interested in helping... Although it is hard to follow what they are saying.

Anyone understand Chinese enough to read exactly what they are saying?
[Nexus One Android Development] cyanogen:
The code for FM was just uploaded to our Gerrit instance by Omomo from MIUI. We need to do a little work so that it doesn't adversely affect other devices that CM6 supports, then it'll be merged for 6.1.

This is the kind of thing that defines *why* opensource is so awesome.

They are targeting N1 and Desire, but we'll port it to all the other devices that have this chipset too.
[Nexus One Android Development] MarkM83:
Hell yeah :) GREAT :)
[Nexus One Android Development] charnsingh_online:
Only news - froyo got released, updating the 720p mod
[Nexus One Android Development] bewA:
How about asking Paul @ MoDaCo seeing how he's done quite a lot of work on the Desire ROM :)
[Nexus One Android Development] notxel21:
Yes! I've been patiently waiting to hear this! :D

Thank you sir!! :cool:
[Nexus One Android Development] greyrc51:
Not sure if this will help or not but I just installed the Droid X radio app on my nexus and it works i just cant pick up any stations though.
[Nexus One Android Development] Daneshm90:
Did u happen to install fmradioservice.apk ? Yes i know it doesnt let u install it, but here try this one i removed the shared uid which allows it to be installed but most prolly it wont work since im guessing they use this communicate between the apps.

Link
[Nexus One Android Development] greyrc51:
lol yeah it didnt let me install but ill try yours right now thanks.
[Nexus One Android Development] greyrc51:
it said there was a problem parsing the package.
[Nexus One Android Development] Daneshm90:
Really ? wierd let me take a look again.
[Nexus One Android Development] Daneshm90:
Try this Link
[Nexus One Android Development] MarcusMaximus04@gmail.com:
Have a link to that droid x radio app?
[Nexus One Android Development] Daneshm90:
Its in the dump :) if u just want tht apk here Link
[Nexus One Android Development] MarcusMaximus04@gmail.com:
Thanks. Running that, with the original fmradioservice apk you posted installed, I get a force close in FMRadioService, unsatisfiedlinkerror in Lcom/motorola/android/fmradio/FMRadioPlayer
[Nexus One Android Development] Daneshm90:
Yea see radioservice cannot be installed if u dont modify it, it gives u error stating the uid keys dont match. I've removed the uid, hmm wait let me try the same thing i did with droid's mtt keyboard, uninstall radioservice n try this one im uploading. Hold up.
[Nexus One Android Development] greyrc51:
That one didn't work either.have you had any luck with the Droid X music app by chance.it installed fine but force closes once the music starts playing
[Nexus One Android Development] Daneshm90:
Here try this one. Link
[Nexus One Android Development] Daneshm90:
Yup samething here. Although i didnt put effort since it just looks like stock music app. :cool:
[Nexus One Android Development] MarcusMaximus04@gmail.com:
Nope, same result.
[Nexus One Android Development] greyrc51:
To the naked eye yes but if you go into settings Motorola had added the ability to change the audio settings such as 3d surround and Bass boost.
[Nexus One Android Development] MarkM83:
I installed it, how do i try it...its not showing in app drawer