Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

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?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top