Could an example for "How to Clear App Cache/Data" be added to the uiautomator example
Im migrating to the new uiautomator version, but my existing method for clearing cache and data is no longer working. I think its because its the Java equivalent of an adb command, which I guess, will not work with the new uiautomator since the tests are running in an apk instead of through an adb shell. But that is just my guess. If you need any more info please let me know. Here is the code i used to use:
try {
Process process = Runtime.getRuntime().exec("system/bin/pm clear com.my.application");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
process.waitFor();
return true;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
I think this should be part of the test harness not UiAutomator, so this is more of a tools bug to be honest. for now can you just file a feature request here (https://code.google.com/p/android/issues/entry?template=Test%20Support%20Library%20feature) and we'll take a look.
I agree...Im not suggesting this be a part of UiAutomator...Im just asking for some help as a user of Uiautomator for a technique to clear cache and cookies...Including it in the samples would be helpful to everyone who will be using it, especially the users who are migrating from UiAutomator 1.0. - since the architecture for how the tests run is totally different now.
Closing this as not sample related, please file a feature request here: https://code.google.com/p/android/issues/entry?template=Test%20Support%20Library%20feature