Android OS Forum banner
1 - 20 of 20 Posts

·
Developer
Joined
·
380 Posts
A lot of you probably don't know me if you never owned a Thunderbolt, but somewhere along the line, I got the reputation as the guy that can port anything. I don't know how much truth there is to that, but I did make CDMA/LTE, WiFi, and Bluetooth work on a device using a base from a device that was GSM with a completely different chipset (TI vs. Broadcom). I also managed to get everything working on MIUI using a similar approach. This isn't a "tutorial" per se, more of just a brain dump. I'm not going to tell you every step to get things going, as I don't think there is a right answer for every situation.

Anyway, since the recent release of the Sense 4.0/ICS leaks, I've started getting PMs from everyone and their brother again about how I made these things work. While I don't mind the questions, I figure it's easier to just dump it all in one post rather than type it out 50 times to 50 different people and maybe help some folks who don't know me as well.

I'm going to do this working under the assumption you have some clue what you're doing. If you don't know smali, java, and how to read a logcat, you better just stop reading now. This will be geared more towards Sense based ROMs, but the same principles can be applied to AOSP and other vendor software as well, just keep in mind the files may be in different places. I'm also going to assume that at this point you have a booting ROM that is at least usable. If you don't, there are dozens of guides on porting floating around the interwebs.

On to the good stuff...

First, lets see what we're going to be dealing with.
  • build.prop
  • APKs
    • Bluetooth.apk
    • BrcmBluetoothServices.apk (Where applicable)
    • EPST.apk (for CDMA devices)
    • CdmaMccProvider.apk (sometimes)
    • Mms.apk (sometimes)
    • Phone.apk
    • Settings.apk
    • Stk.apk (SIM Toolkit)
    • TelephonyProvider.apk
  • Binaries
    • Bluetooth (bluetoothd, etc)
    • Wifi (wpa_supplicant, netcfg, netd, etc)
    • RIL/Data (ril, rild, netmgrd, etc)
  • etc - This mostly contains configuration files specific to your libs and binaries, so make sure they all match up
  • Framework
    • framework-res.apk
    • framework.jar
    • services.jar
  • lib - as with binaries, you'll need all the correct libraries for bluetooth, wifi, and the RIL to make it go.
This is by no means a complete list, and I don't think I could write one if my life depended on it. It takes a lot of trial and error with the libs and binaries to get it all going, so we're also going to assume you have the correct libs and binaries where they belong. If you're not sure on some of that, check the build.prop and init files in the ramdisk. It has some good indicators as to what files it is looking for.

Alright, so at this point, we have a booting ROM, and everything seems to be working, but one (or all three) of the big three (bluetooth, wifi, Data) isn't working. You've tried everything. You've moved binaries, apks, and libs around and changed every line in the build.prop and init files that you can think of and still it's not hooking up for you.

Time to play in the framework.
I don't know why this gets overlooked so much. Maybe it's a lack of understanding or just a general fear of smali, but 90% of the work I did to get Sense 3.5 and MIUI working on the Bolt was in the framework. I highly recommend you get a copy of Beyond Compare if you're going to continue any further into framework.

Bluetooth:

Bluetooth is really only a problem when the donor ROM has a different bluetooth chipset than the one you're porting too. ie. TI vs. Broadcom. We'll assume you have all the binaries, libs, and config files from etc moved over, as the file names are all basically the same.

Decompile your services.jar first. You'll need to move over the folders for ti and broadcom from your device. Generally, you can just move them with no changes, but you should always take a look first.

Now open up framework.jar. You're going to need to merge the following locations:
  • android/bluetooth
  • android/server/*bluetooth
  • com/broadcom
In system/app, make sure you replace Bluetooth.apk, and BrcmBluetoothServices.apk. You will also need to merge all the bluetooth classes inside Settings.apk and Phone.apk.

At this point, it's just going to take some fancy logcatting to track down any remaining errors and get them fixed through merging things in smali. Look for "dead code" exceptions to help you find missing classes and methods.

Wifi:

Like bluetooth, wifi isn't usually too big of an issue unless the chipsets are different.

In services.jar, open android/server and merge over the WifiService and WifiWatchDog classes.

In framework.jar navigate to android/net/wifi and merge those classes.

One catch, with some devices, is that you'll overlook the calibration file in /etc. Make sure it's there if you need it.

Data:

This is the fun one. If this is an HTC Device, running Sense 3+, the first place to look is framework.jar\com\android\internal\telephony\HtcBuildUtils.smali. This file contains a bunch of true/false flags for available features. There is the off chance you can just flip some of these switches and get things working. The best chances of this working would be on a device that has a GSM and CDMA version like the EVO 3D. Don't get your hopes up though. :)

Let's assume that didn't work and move on to the painful stuff.

Decompile services.jar. You're going to need to merge ConnectivityService, TelephonyRegistry, and everything in the Connectivity folder.

Now open up framework.jar. There is a LOT of stuff to merge here, and it's going to cause a lot of errors that will need to be found in logcat and fixed.
  • android/net - the ConnectivityManager classes and interfaces as well as all the NetworkStateTrackers.
  • android/telephony
  • com/android/internal/telephony
At this point, you will probably just have a huge mess of force closes if it even boots. The only real option is to use logcat and fix one error at a time. It's a terrible, awful, time-consuming process.

Once you get it booting again, and clear up most of the errors, you'll need to get Phone.apk, Settings.apk, MMS.apk and TelephonyProvider.apk talking to the framework again by merging the relevant classes over.

Follow-up:

Again, this is not the be-all-end-all definitive guide on how to do this, but just a breakdown of what I did. Hopefully it will help some of you and also reduce my PM count in the process.


I'll have a second post, where I can answer any questions that may arise. Feel free to post any issues you encounter, and I'll do my best to help you through them.
 

·
Dev In Training
Joined
·
180 Posts
Great Thread Eris! My only issue is that i have no idea what im looking at when i look at smali and java! If there are some good tutorials on that send them my way.
 

·
Registered
Joined
·
1 Posts
When you talk about merging all these smali files, do you actually mean merging like taking all the files and combining them into a single file?
 

·
Developer
Joined
·
380 Posts
Discussion Starter · #11 ·
When you talk about merging all these smali files, do you actually mean merging like taking all the files and combining them into a single file?
I mean if you have RIL.smali in the port and the original framework, you add/remove missing methods between the two.
 

·
Dev-in-Progress
Joined
·
607 Posts
Personally I think you should write a book or something on this. I have been trying ridiculously hard trying to get data on MIUI for the bolt on the newer ports and I simply cannot get it lol. That is what I really need haha
 

·
Carbon / Miui.us Developer
Joined
·
690 Posts
I mean if you have RIL.smali in the port and the original framework, you add/remove missing methods between the two.
thanks for this guide i have been doing miui v4 ports for droid 2 global and d2,dx i got pretty much everything working on the cdma side and gsm voice works dor the d2g but i have no data on the global, im curious if this should do the trick
 

·
Happy Trails Creator
Joined
·
237 Posts
I mean if you have RIL.smali in the port and the original framework, you add/remove missing methods between the two.
What exactly does that mean? Do you change the specific variables like "const v4" and such to match the working ROM's files? Do you remove lines that are not in the working files but in the ones you are working on? Do line numbers matter (.line 567)?
 

·
Developer
Joined
·
380 Posts
Discussion Starter · #15 ·
What exactly does that mean? Do you change the specific variables like "const v4" and such to match the working ROM's files? Do you remove lines that are not in the working files but in the ones you are working on? Do line numbers matter (.line 567)?
You have to make the new files behave like the old ones. If variables are different, or methods are missing, you have to add or remove them accordingly. You're going to need a basic understanding of java and reading up on smali won't hurt either.

Sent from my Galaxy Nexus using Tapatalk 2
 

·
Mad Source Themes
Joined
·
180 Posts
You have to make the new files behave like the old ones. If variables are different, or methods are missing, you have to add or remove them accordingly. You're going to need a basic understanding of java and reading up on smali won't hurt either.

Sent from my Galaxy Nexus using Tapatalk 2
any advice on reaching functional data when building from source?

I'm trying to dig into getting data working for the VZW 10.1 tab but have no clue what I am doing .. I don't think I would have a problem building then decompiling and looking through like you stated before but would prefer to have a functional build from source so that I can keep up with the joneses..
 

·
Developer
Joined
·
380 Posts
Discussion Starter · #17 ·
any advice on reaching functional data when building from source?

I'm trying to dig into getting data working for the VZW 10.1 tab but have no clue what I am doing .. I don't think I would have a problem building then decompiling and looking through like you stated before but would prefer to have a functional build from source so that I can keep up with the joneses..
You should, theoretically, be able to log your way through. It won't be pleasant, and probably take forever, but that's what I would do.

Sent from my Galaxy Nexus using Tapatalk 2
 

·
Mad Source Themes
Joined
·
180 Posts
Thanks sir. .. I don't know that I can accomplish it but I'm not opposed to trying

Sent from my Galaxy Nexus using RootzWiki
 

·
Registered
Joined
·
2 Posts
Nice tut..tnx
how should i fix sd-mounting bug(a sense 4.0 rom)?i remember one of devs fixed it in his ported rom by editing service.jar..if it's in the service jar..where should i look?

and also..another question..."merging"is confusing for me too...forexample in the ported rom rom..i notice lines that are compeletly new(in compare with the old ones)what should i do with those lines?

tnx
 
1 - 20 of 20 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top