Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify java code in framework.jar

Tags:

android

My stock rom on my phone has issues with MVNO's (mobile virtual network operator). Basically this means that my data connection only works when Roaming. This is a know issue that has already been fixed on several roms (but not on mine).

To fix this I would like to modify the source of the framework.jar file (/system/framework/framework.jar), more specific the file : /com/android/internal/telephony/gsm/GsmServiceStateTracker.java

To start I will list the steps I have take to show you where I'm stuck at the momoment: I have fully deodexed my stock rom, both the JAR files and the APK files in both /system/framework/ and /system/app

  • I have downloaded the deodexed framework.jar file and extracted the classes.dex file from it
  • I have decompiled the classes.dex file using baksmali to end up with several *.class files
  • I have converted these *.class files to a .jar file using dex2jar
  • I have unpacked opened this jar file using jdqui to end up with several *.java files

This is where I'm stuck, I need to figure out how to edit the java file I want and end up with a working framework.jar again that I can upload to my phone.

Am I doing this the wrong way? Any other way to resolve my issue? I hope to get some help from people who have experience in doing this...

like image 534
Kenny Avatar asked Nov 04 '22 08:11

Kenny


2 Answers

I also worked on the same approach to fetch the network related parameters like; BAND, BCCH etc. Once you got the *.class file after decompilation of framework.jar, You can use Java DCompiler or JDclipse to convert the .class file into .java file. Now modify the java file as per your requirement.

I modified the RIL.java but I am stuck on repacking. I am unable to convert RIL.java into RIL.class. It has many dependencies/import of framework's hidden files. Ref: http://www.mailinglistarchive.com/html/[email protected]/2010-02/msg00325.html

Android Gents, Please throw some lights if We are on wrong tack...

like image 144
Shravan Avatar answered Nov 15 '22 00:11

Shravan


If you want to make modifications, you will not want to do them at the Java level. You can decompile to Java to broadly understand what's going on, but you will need to modify the Smali directly.

Once you have modified the Smali, you can rebuild with:

smali -o classes.dex frameworkSmaliDirectory

Then, add the updated classes.dex back to the framework.jar. On Linux this is simple:

zip framework.jar classes.dex

Finally, remount /system read-write, and push updated framework.jar to device:

adb shell mount -o rw,remount /system
adb push framework.jar /system/framework/

Now cross your fingers and hope you didn't break anything.

like image 38
Caleb Fenton Avatar answered Nov 15 '22 00:11

Caleb Fenton