Friday, September 9, 2016

RootTools vs Read-only file system

Hi guys!

I am using RootTools to create a root application. I am trying to access the SystemUI folder of my emulator/phone. I don't understand why it is not working and I would be grateful for some pointers.

This is what I start with in my logcat:
Quote:

Root available: true
Root access given: true
This is what I end with in my logcat:
Quote:

java.io.FileNotFoundException: /system/priv-app/SystemUI/mydata1.txt: open failed: EROFS (Read-only file system)
And this is my code:
Code:

public void write(View view) {
        String data = editText.getText().toString();
        File folder = Environment.getRootDirectory();
        File myFile = new File(folder, "/priv-app/SystemUI/mydata1.txt");
        FileOutputStream fileOutputStream = null;
        if (RootTools.isRootAvailable() && RootTools.isAccessGiven()) {
            Command command1 = new Command(0, "mount -o rw,remount" + myFile.toString());
            try {
                RootTools.getShell(false).add(command1);
                try {
                    fileOutputStream = new FileOutputStream(myFile);
                    fileOutputStream.write(data.getBytes());
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    if (fileOutputStream != null) {
                        try {
                            fileOutputStream.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            } catch (TimeoutException e) {
                e.printStackTrace();
            } catch (RootDeniedException e) {
                e.printStackTrace();
            }
          }

Thanks for your help!:)


from xda-developers http://ift.tt/2c3Q71K
via IFTTT

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home