Android SU权限IOException
if (DownloadManager.STATUS_SUCCESSFUL == c .getInt(columnIndex)) { mProgress.setProgress(70); mStatus.setText(R.string.status_backup); File dl_path = new File(DownloadManager.COLUMN_LOCAL_URI); File og_path = new File("/system/app/app.apk"); String bu_path = "/sdcard/asdfgsd/backup/app.apk"; Process p; try { // Preform su to get root privledges p = Runtime.getRuntime().exec("su"); // Attempt to write a file to a root-only DataOutputStream os = new DataOutputStream(p.getOutputStream()); os.writeBytes("echo \"Do I have root?\" >/system/sd/temporary.txt\n"); // Close the terminal os.writeBytes("exit\n"); os.flush(); try { p.waitFor(); if (p.exitValue() != 255) { // Trying to remount system partition in read-write mode p.getOutputStream().write("mount -or,remount -t yaffs2 /dev/block/mtdblock3 /system".getBytes()); if (og_path.renameTo(new File(bu_path))) { mProgress.setProgress(90); mStatus.setText(R.string.status_install); dl_path.renameTo(og_path); } else { mStatus.setText(R.string.status_error_1); } } } catch (InterruptedException e) { mStatus.setText(R.string.status_error_2); } } catch (IOException e) { mStatus.setText(R.string.status_error_3); } }
所以这是一段代码,应该将应用程序从/ system / app替换为备份文件夹,然后它应该将通过DM API下载的副本替换为/ system / app。 一切都很完美,直到应用程序开始要求SU权限。 正如您所看到的,我在exception的情况下放置了一些错误字符串以使调试更容易,并且它似乎有一个IOexception(status_error_3)。 我的代码出了什么问题?
UPD:SU成功请求授予我的应用程序权限,因此它应该可以工作,但事实并非如此。
提前致谢!
- 没有源代码的Android应用程序中的方法覆盖
- 试图访问LauncherProvider
- 致命exception:android.view.WindowManager $ BadTokenException无法添加窗口 – 令牌无效; 你的活动在运行吗?
- android DialogFragment android:onClick =“buttonCancel”导致IllegalStateException无法找到方法
- 在Java中按时间对ArrayList进行排序
- Android:滚动视图中不可见的按钮
- 用于标签式菜单的Android Fragments
- 使用带有accountmanager令牌的imap访问gmail
- 如何在获取“无法解决放置符号”错误时向Hashmap添加键和值