本文介绍了Android的:如何从我的APK安装在文件系统中RW? (当然扎根,)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个应用程序拷贝一些东​​西到/系统分区在运行时。我已经实现了通过请求SU的权限运行终端命令为根的能力。我可以(授予以超级用户权限请求后)成功运行了很多的命令。但是,当我尝试重新安装/系统的读/写,没有任何反应。我没有得到一个错误或崩溃,并且命令似乎要经过就好了,但分区保持为只读。下面是我在运行命令(Droid X的):安装邻RW,重新挂载-t EXT3的/ dev /块/ mmcblk1p21 /系统,以及它工作得很好,如果我运行终端相同的命令。这是我的code,从内我的应用程序执行根命令:

I'm trying to write an app that copies something to the /system partition at run time. I've already implemented the ability to run terminal commands as root by requesting SU permissions. I can run a lot of commands successfully (after granting the permission request with SuperUser). However, when I try to remount /system as read/write, nothing happens. I don't get an error or a crash, and the command seems to go through just fine, but the partition stays as read-only. Here's the command I'm running (Droid X): mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system, and it works just fine if I run the same command from Terminal. And here's my code to execute root commands from within my app:

String cmd = "mount -o rw,remount -t ext3 /dev/block/mmcblk1p21 /system";
Process p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes(cmd + "\n");
os.writeBytes("exit\n");
os.flush();

然后,我有一些code,检查的输出和错误streamd,看看发生了什么事。谁能给我一个想法,为什么这不起作用?

And then I have some code that checks the stdout and stderr streamd to see what happened. Can anyone give me an idea why this doesn't work?

推荐答案

我想通了 - 命令实际上是成功的,但现在看来,该RW状态只适用于在其被应用的会话。使后一组命令被苏下执行,则下一组命令获取/系统中的RO的状态。我所要做的就是添加命令将文件离开苏会话之前复制。

I figured it out -- the command was actually successful, but it appears that the RW status only applies to the session in which it was applied. So that after one set of commands was executed under SU, the next set of commands gets the /system in RO state. All I had to do was add the command to copy the files before exiting the SU session.

这篇关于Android的:如何从我的APK安装在文件系统中RW? (当然扎根,)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:47
查看更多