简体   繁体   中英

Roottols is making me unable to open a file

I have an App that copies and modifies permissions of a file. But then when I try to read said file I get permission denied.

java.io.FileNotFoundException: /data/data/com.lstupenengo.primeraapp/files/xx: open failed: EACCES (Permission denied)

How can I know when RootTools is finished?

My code:

RootTools.copyFile("/data/data/com.xxx/" + file, getFilesDir() +"/"+ file, true, false);
        CommandCapture cmd = new CommandCapture(0,"chmod 777 "+getFilesDir()+"/"+file);
        try {
            RootTools.getShell(true).add(cmd);
        } catch (TimeoutException | RootDeniedException | IOException e) {
            e.printStackTrace();
            Log.e("Root "+file, "Fallo");
        }

       File fts = new File(getFilesDir()+"/"+file);
       FileInputStream fis = new FileInputStream(fts); //Here I get my error.

Logcat

12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ java.io.FileNotFoundException: /data/data/com.lstupenengo.primeraapp/files/xx: open failed: EACCES (Permission denied)
12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ at libcore.io.IoBridge.open(IoBridge.java:418)
12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ at java.io.FileInputStream.<init>(FileInputStream.java:78)
12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ at com.lstupenengo.primeraapp.myFTP.upload(myFTP.java:80)
12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ at com.lstupenengo.primeraapp.FirstRunService.upload(FirstRunService.java:75)
12-18 16:23:41.874  30092-30806/com.lstupenengo.primeraapp W/System.err﹕ at com.lstupenengo.primeraapp.FirstRunService.onHandleIntent(FirstRunService.java:47)

Added this code and now I get an exeption on the Chmod but it works.

 CommandCapture cmd = new CommandCapture(0,"chmod 777 "+getApplicationInfo().dataDir+"/databases/"+file);
        try {
            RootTools.getShell(true).add(cmd);
            while (!cmd.isFinished()) {

                synchronized (cmd) {
                    try {
                        if (!cmd.isFinished()) {
                            cmd.wait(100);
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        } catch (TimeoutException | RootDeniedException | IOException e) {
            Log.e(file, "Chmod fail");
            e.printStackTrace();
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM