android - 通过java重新挂载An​​droid文件系统

标签 android android-source

我需要将 android 文件系统重新挂载为读写而不是只读。我知道如何通过命令提示符进行操作,也知道如何进行应用程序开发。

但我正在调整 android 源代码,如果我使用的话

Process proc=Runtime.getRuntime.exec("su"); 

它不起作用。因此我需要使用 android.os.process 对象,我被困在这里任何人都可以帮助我。

最佳答案

  1. 尝试此代码以获得 super 用户访问权限(您需要安装了 super 用户的root 手机):

    try {
        // Perform su to get root privledges
        Process p = Runtime.getRuntime().exec("su");
    
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
    
        os.writeBytes("<..... here you may write commands ....>\n");
    
        // Close the terminal
        os.writeBytes("exit\n");
        os.flush();
    } catch (IOException e) {
        toastMessage("not root");
    }
    
  2. 一旦您拥有 super 用户访问权限,您就可以启动 adbd 监听一些 TCP 端口,使用:

    setprop service.adb.tcp.port 5555
    adbd &
    setprop service.adb.tcp.port -1
    
  3. 打开到所选端口的 TCP 连接并发出remount 命令。

关于android - 通过java重新挂载An​​droid文件系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10528090/

相关文章:

android构建系统根据包名获取源代码路径

android - 将自定义 SO 文件导入 AOSP

android - 未声明的标识符 'setfscreation' AOSP

android - 在 Flutter 中获取 Android Activity 结果

android - 调整方向变化的 View

android - 如何在屏幕上按比例显示 4 个图像

android - 构建 AOSP,vendor_module_check.mk 失败

android - android源代码中存在的测试有什么用?

android - Google TV 插件在应用程序上使用直播电视

android - Activity 布局继承