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

Unified Diff: devil/devil/android/device_utils.py

Issue 2815573003: Fix force stop using wrong "ps" cmd. (Closed)
Patch Set: Fix force stop using wrong "ps" cmd. Created 3 years, 8 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 | devil/devil/android/device_utils_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: devil/devil/android/device_utils.py
diff --git a/devil/devil/android/device_utils.py b/devil/devil/android/device_utils.py
index 50f362c3839974e7d296ff08c6cc7669b63b3a85..de7cc5cc87e06f4d1014e3f06323394388cbf380 100644
--- a/devil/devil/android/device_utils.py
+++ b/devil/devil/android/device_utils.py
@@ -1181,8 +1181,9 @@ class DeviceUtils(object):
CommandTimeoutError on timeout.
DeviceUnreachableError on missing device.
"""
- cmd = 'p=%s;if [[ "$(ps)" = *$p* ]]; then am force-stop $p; fi'
- self.RunShellCommand(cmd % package, shell=True, check_return=True)
+ cmd = ('p=%s;if [[ "$(%s)" = *$p* ]]; then am force-stop $p; fi' %
jbudorick 2017/04/11 23:47:24 I'm wondering if maintaining the hotrolled script
perezju 2017/04/12 09:13:20 +1
+ (package, self._GetPsCommand()))
+ self.RunShellCommand(cmd, shell=True, check_return=True)
@decorators.WithTimeoutAndRetriesFromInstance()
def ClearApplicationState(
@@ -2153,11 +2154,7 @@ class DeviceUtils(object):
"""
procs_pids = collections.defaultdict(list)
try:
- ps_cmd = 'ps'
- # ps behavior was changed in Android above N, http://crbug.com/686716
- if (self.build_version_sdk >= version_codes.NOUGAT_MR1
- and self.build_id[0] > 'N'):
- ps_cmd = 'ps -e'
+ ps_cmd = self._GetPsCommand()
if process_name:
ps_output = self._RunPipedShellCommand(
'%s | grep -F %s' % (ps_cmd, cmd_helper.SingleQuote(process_name)))
@@ -2638,3 +2635,16 @@ class DeviceUtils(object):
return
self.SendKeyEvent(keyevent.KEYCODE_POWER)
timeout_retry.WaitFor(screen_test, wait_period=1)
+
+ def _GetPsCommand(self):
+ """Returns command to get list of processes.
+
+ Command to get list of processes is different for differnet Android
+ versions.
+ """
+ ps_cmd = 'ps'
+ # ps behavior was changed in Android above N, http://crbug.com/686716
+ if (self.build_version_sdk >= version_codes.NOUGAT_MR1
+ and self.build_id[0] > 'N'):
+ ps_cmd = 'ps -e'
+ return ps_cmd
« no previous file with comments | « no previous file | devil/devil/android/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698