修改framework.jar中的Java代码 [英] Modify java code in framework.jar
问题描述
我的手机上的rom存有MVNO(移动虚拟网络运营商)的问题.基本上,这意味着我的数据连接仅在漫游时有效.这是一个已知问题,已经在多个rom上得到了解决(但在我的rom上尚未解决).
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).
要解决此问题,我想修改framework.jar文件(/system/framework/framework.jar
)的源,更具体的文件是:/com/android/内部/电话/gsm/GsmServiceStateTracker.java
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
首先,我将列出要采取的步骤,向您展示我被困在哪里了:我已经完全清除了我的库存rom,在/system/framework/和/system/app中的JAR文件和APK文件
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
- 我已经下载了Deodexed framework.jar文件并解压缩了来自它的classes.dex文件
- 我已经使用baksmali反编译了classes.dex文件,最终得到了几个* .class文件
- 我已使用以下命令将这些* .class文件转换为.jar文件 dex2jar
- 我已经使用 jdqui 解压缩了这个jar文件,并最终打开了该文件几个* .java文件
- 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
这就是我要坚持的地方,我需要弄清楚如何编辑所需的Java文件并最终得到一个可以正常工作的framework.jar文件,然后将其上传到手机中.
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...
推荐答案
如果要进行修改,您将不希望在Java级别进行修改.您可以反编译为Java以大致了解正在发生的事情,但是您将需要直接修改Smali.
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.
修改了Smali后,您可以使用以下内容进行重建:
Once you have modified the Smali, you can rebuild with:
smali -o classes.dex frameworkSmaliDirectory
然后,将更新后的classes.dex添加回framework.jar.在Linux上,这很简单:
Then, add the updated classes.dex back to the framework.jar. On Linux this is simple:
zip framework.jar classes.dex
最后,重新挂载/system读写文件,并将更新的framework.jar推送到设备:
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.
这篇关于修改framework.jar中的Java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!