3

I'm working on a simple root app for clearing browser localstore, and maybe later add other features that aren't possible with built-in apps. I'm using roottools, root seems to be working, but it won't remove the directory properly:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        RootTools.debugMode = true;

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.buttonClearBrowser).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                if (RootTools.isAccessGiven()) {
                    RootTools.remount("/data/data/com.android.browser/app_databases/", "RW");
                    Command command = new Command(0,"rm -rf /data/data/com.android.browser/app_databases/") {
                        @Override
                        public void output(int arg0, String arg1) {
                            System.out.println(arg1);
                        }
                    };
                    try {
                        RootTools.getShell(true).add(command).waitForFinish();
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (TimeoutException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

This should clear the HTML5 localstorage in Android (which you can't clear from the browser app). However it only gives error message:

11-05 21:40:06.650: D/RootTools v2.4(22778): Remounting /data as rw
11-05 21:40:06.650: I/RootTools v2.4(22778): [nodev, relatime, nosuid, rw] AND rw
11-05 21:40:06.650: D/RootTools v2.4(22778): [nodev, relatime, nosuid, rw]
11-05 21:40:06.650: D/RootTools v2.4(22778): Using Existing Root Shell!
11-05 21:40:06.650: D/RootTools v2.4(22778): Sending command(s): rm -rf /data/data/com.android.browser/app_databases/
11-05 21:40:06.660: I/System.out(22778): rm failed for -rf, Read-only file system
11-05 21:40:06.660: D/RootTools v2.4(22778): Command 0finished.

I get the same error on adb shell, by the way:

$ su
su
# rm -rf /data/data/com.android.browser/app_databases/http_m.bing.com_0
rm -rf /data/data/com.android.browser/app_databases/http_m.bing.com_0
rm failed for -rf, Read-only file system

/data shouldn't be read only, since that's where app settings are. Is something wrong with the phone? This is Android 2.2.2 if that matters. Ironically, I CAN browse to and remove the files with Ghost Commander in root mode.

Community
  • 1
  • 1
NoBugs
  • 9,310
  • 13
  • 80
  • 146
  • 1
    You don't need to remount if you have root AFAIK. `/data/data` is not mounted RO. – zapl Dec 01 '12 at 02:01

2 Answers2

2

I believe the option -f is not accepted by rmcommand in android.

To confirm it, try from command line the same command without -f:

rm -r /data/data/com.android.browser/app_databases/http_m.bing.com_0

Regards.

Luis
  • 11,978
  • 3
  • 27
  • 35
  • Nice! For future reference is there any complete list of which options can or can't be used on Android, or man pages specifically for Android? – NoBugs Dec 06 '12 at 15:28
  • No that I know. I got used to do some try and error for valid command options, after a couple of surprises :-( – Luis Dec 06 '12 at 16:51
  • Ha, so it was trying to delete the `f` file in root or whatever then, hence the 'read-only' message? The built-in `toolbox` binary indeed doesn't recognize `-f`, but I think busybox does (not 100% sure though). – Nikolay Elenkov Dec 11 '12 at 06:36
1

As stated above, you don't need to remount /data, it is already mounted rw. Generally, when mounting/remounting you need to give the path to the mount point as a parameter: /system, /data/, /mnt/sdcard, etc. Giving the full path /data/data/com.foobar.app/files/foobaz.txt will produce an error when passed to the mount command.

There is, of course the question of why /data seems to be ro. Did you do something special before running this code?

Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84