Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1420)

Unified Diff: build/android/pylib/android_commands.py

Issue 12210036: Use 'pm clear' to clear application state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check package exists before calling pm clear Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 7a8c5e5687ec501088a8d7886a29aa2d7dc11ce8..51911d3a0635bc4d484c62f67300892fa13abb17 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -641,11 +641,13 @@ class AndroidCommands(object):
def ClearApplicationState(self, package):
"""Closes and clears all state for the given |package|."""
- self.CloseApplication(package)
- self.RunShellCommand('su -c rm -r /data/data/%s/app_*' % package)
- self.RunShellCommand('su -c rm -r /data/data/%s/cache/*' % package)
- self.RunShellCommand('su -c rm -r /data/data/%s/files/*' % package)
- self.RunShellCommand('su -c rm -r /data/data/%s/shared_prefs/*' % package)
+ # Check that the package exists before clearing it. Necessary because
+ # calling pm clear on a package that doesn't exist may never return.
+ pm_path_output = self.RunShellCommand('pm path ' + package)
+ # The path output only contains anything if and only if the package exists.
+ if pm_path_output:
+ self.CloseApplication(package)
+ self.RunShellCommand('pm clear ' + package)
def SendKeyEvent(self, keycode):
"""Sends keycode to the device.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698