在Android应用程序中安装R/W系统以编辑只读文件
如何在我的应用程序中编辑 /system/
目录中的文件?
我必须使系统可读写吗?
我尝试过:
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("mount -o remount,rw /system\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
以及许多其他方法,但没有成功。
如果有人可以帮助我,我将不胜感激! :)
另外,如果我最终成功了,它适用于所有 root 的手机吗?或者有些手机有什么不同?
How can I, within my application, edit a file in the /system/
directory?
Do I have to make the system R/W accessible?
I ve tried:
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes("mount -o remount,rw /system\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
and many other ways, without success.
If anybody can help me, I'd greatly appreciated it! :)
Also, if i finally made it, will it worked with all rooted phones? Or is it different with some phones?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用:
这使我能够成功安装。
如果之后就退出,当然不行。您必须保持在同一进程中并使用 linux 命令来编辑文件。
我不知道如何编辑这些文件,但我建议谷歌搜索如何在 Linux 终端中执行操作,然后将正确的代码放入 os.writeBytes("CODE_HERE");
不过,就就安装过程而言,我不知道该命令是否通用。幸运的是它可以在我的设备上运行。
编辑:
我现在使用 RootTools:http://code.google.com/p/roottools/downloads/列表
这是 Wiki 页面:
http://code.google.com/p/roottools/w/list
但我现在正在使用:
我相信这是普遍的
I use:
And that allows me to successfully mount.
If you exit right after that, of course it will not work. You have to stay within the same process and use the linux commands to edit the file.
I have no idea how to edit the files, but I suggest googling how to do things in linux terminal, and then putting the proper code in
os.writeBytes("CODE_HERE");
Though, as far as the mounting process is concerned, I don't know if that command will work universally. It may just fortunately work on my device.
EDIT:
I now use RootTools: http://code.google.com/p/roottools/downloads/list
And here is the Wiki page:
http://code.google.com/p/roottools/w/list
But I now am using:
I believe that is universal
编辑:以下代码的所有版本都不会将系统安装为 RW。
*阅读下面的评论以了解原因。
解决这个问题不是一个简单的命令。
Edit1:我进入超级用户 apk、“设置”选项卡,并在最后一项“点击”,以更新 su 二进制文件。更新后,下面的所有内容都不起作用。
Edit2:在这里开始与我自己进行完整的对话。当前最新二进制文件的修复位于帖子底部
========================================= ===============================================
找到了该怎么做它!经过第二天的努力,终于找到了!!!!
尝试了几件事,答案是一个简单的更改模式,
我所做的:
第一个版本代码:(不起作用)
我没有粘贴一些 try catch 案例。
我还遇到了另一个问题..我在版本2中解决了它。小问题是,我要求一个特定的su命令,而用户必须接受RO的SU cmd,RW的SU cmd。 。还有时间讨论我的程序中的其他内容。
在第二个版本中,我使用通用 su 命令,因此用户必须仅接受一次 SU 权限,并且我使用输出流。
代码版本 2(推荐)(不起作用):
只是它挂载了built.prop RW,然后挂载它回到RO。
但如果你改变它,你的设备可能会变砖!保重!
Edit: All version of codes below DOES NOT mount system as RW.
*Read comments below to see why.
Solution of this is not a simple command.
Edit1: I went on Super User apk, Settings tab, and "tapped" at the last item, to update the su binary. With that update, everything below isnt working.
Edit2: started a whole conversation with my self here. Fix for the current latest binary is at the bottom of the post
==================================================================================
Found out how to do it! Second day of efforts, and finally found it!!!!!
Tried several things, and answer was to a simple change mode,
what i have done:
First Version Code:(doesnt work)
I didnt paste some try catch cases.
Also i got another problem.. And i solved it in Version 2. THe little problem was, that, i was asking for a specific for a su command, and the user, had to accept SU cmd for RO, SU cmd for RW.. and another time for other stuff in my program.
In 2nd version i m using the generic su command, so user has to accept SU privileges only ONE time, and i m using output stream.
Code Version 2(Recomended) (doesnt work):
Only it mounts built.prop RW, and then mounts it back to RO.
Although if you change it, you may brick your device! Take care!