【问题标题】:Why RootTools cp command don't work?为什么 RootTools cp 命令不起作用?
【发布时间】:2013-09-15 20:16:59
【问题描述】:

我正在尝试复制 etc 文件夹中的文件,为此我使用按钮中的下一个代码:

changeNTP.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    File exists = new File("/etc/gps.conf");
                    if (exists.exists()) {
                        // We make a backup first
                        CommandCapture command = new CommandCapture(0, "cp -f /etc/gps.conf /etc/gps" + System.currentTimeMillis() + ".conf");
                        try {
                            RootTools.getShell(true).add(command);
                        } catch (IOException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (TimeoutException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        } catch (RootDeniedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                        // Last time that file was modified
                        //Date filedate = new Date(exists.lastModified());
                    }
                }

            });

嗯,问题是它没有复制任何东西。可能是什么问题?

谢谢。

【问题讨论】:

  • 我认为这是挂载时的问题。如果我执行 cat /proc/mounts,则不会出现 etc 文件夹。我不知道我能做什么:(

标签: android command backup roottools


【解决方案1】:

好的,接下来是最好的解决方案:

int date = (int) System.currentTimeMillis();
String source = "/system/etc/gps.conf";
String destination = "/system/etc/gps" + date + ".conf";

if(RootTools.remount("/system/etc/", "rw")){
   RootTools.copyFile(source, destination, true, true);
}

问题是我之前指向/etc,但是这个位置是一个符号链接,真正的路径是/system/etc。显然我们不能改变符号链接的挂载类型,所以,我刚刚发布的之前的代码是很好的答案。

谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多