【问题标题】:Install .zip in clockwork from app?从应用程序在发条中安装 .zip?
【发布时间】:2011-06-29 09:07:46
【问题描述】:

所以在我的应用程序中,我试图使用它在发条恢复中闪烁一个 .zip

 Runtime run = Runtime.getRuntime();
                      Process p = null;
                      DataOutputStream out = null;
                      try{
                          p = run.exec("su");
                          out = new DataOutputStream(p.getOutputStream());
                          out.writeBytes("echo install_zip SDCARD:" +clickedFile.toString() +" > /cache/recovery/extendedcommand\n");
                          out.writeBytes("reboot recovery\n"); // testing
                          out.flush();

                      }catch(Exception e){
                          Log.e("FLASH", "Unable to reboot into recovery mode:", e);
                          e.printStackTrace();

                      }

它会启动恢复,但不会刷新 .zip.. 有什么问题.. 哦,如果您需要整个 .java 文件,它是:

http://pastebin.com/NpiSLz90

【问题讨论】:

  • 我会尝试用分号将 echo 和 reboot 写在一行上,例如:echo ... ; reboot ...。这应该保证序列化。

标签: java android root


【解决方案1】:
out.writeBytes("echo 'install_zip(\""+ SDCARD:" +clickedFile.toString()+"\");'" +" > /cache/recovery/extendedcommand\n");

adb 命令看起来像:

adb shell
echo 'install_zip("/sdcard/update.zip");' > /cache/recovery/extendedcommand

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,但我使用 ListView 和 ArrayAdapter 来返回文件的完整路径。当我尝试将路径传递为“SDCARD:”后跟文件路径时,它无法找到该文件,因为较新版本的 CWM Recovery 似乎不再支持该方法。不过,我找到了一个简单的解决方法:

        public boolean installPackage(String pos) throws InterruptedException {
        final String location = "/emmc/" + pos.substring(11);
        Process process = null;
        try {
            process = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(process.getOutputStream());
            os = new DataOutputStream(process.getOutputStream());
            os.writeBytes("echo 'install_zip(\"" + location + "\");'" + " > /cache/recovery/extendedcommand\n");
            os.writeBytes("reboot recovery\n");
            os.writeBytes("exit\n");
            os.flush();
            return (process.waitFor() == 0);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            Log.e("FLASH:", "Unable to boot into recovery");
            e.printStackTrace();
        }
            return false;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-11-07
      • 1970-01-01
      • 1970-01-01
      • 2015-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多