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

Side by Side Diff: build/android/devil/android/device_utils.py

Issue 1398613002: DeviceUtils.ForceStop: no-op if the app isn't running (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides a variety of device interactions based on adb. 5 """Provides a variety of device interactions based on adb.
6 6
7 Eventually, this will be based on adb_wrapper. 7 Eventually, this will be based on adb_wrapper.
8 """ 8 """
9 # pylint: disable=unused-argument 9 # pylint: disable=unused-argument
10 10
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 1002
1003 Args: 1003 Args:
1004 package: A string containing the name of the package to stop. 1004 package: A string containing the name of the package to stop.
1005 timeout: timeout in seconds 1005 timeout: timeout in seconds
1006 retries: number of retries 1006 retries: number of retries
1007 1007
1008 Raises: 1008 Raises:
1009 CommandTimeoutError on timeout. 1009 CommandTimeoutError on timeout.
1010 DeviceUnreachableError on missing device. 1010 DeviceUnreachableError on missing device.
1011 """ 1011 """
1012 self.RunShellCommand(['am', 'force-stop', package], check_return=True) 1012 cmd = 'p=%s;if [[ "$(ps)" = *$p* ]]; then am force-stop $p; fi'
1013 self.RunShellCommand(cmd % package, check_return=True)
1013 1014
1014 @decorators.WithTimeoutAndRetriesFromInstance() 1015 @decorators.WithTimeoutAndRetriesFromInstance()
1015 def ClearApplicationState( 1016 def ClearApplicationState(
1016 self, package, permissions=None, timeout=None, retries=None): 1017 self, package, permissions=None, timeout=None, retries=None):
1017 """Clear all state for the given package. 1018 """Clear all state for the given package.
1018 1019
1019 Args: 1020 Args:
1020 package: A string containing the name of the package to stop. 1021 package: A string containing the name of the package to stop.
1021 permissions: List of permissions to set after clearing data. 1022 permissions: List of permissions to set after clearing data.
1022 timeout: timeout in seconds 1023 timeout: timeout in seconds
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions 2057 if ('android.permission.WRITE_EXTERNAL_STORAGE' in permissions
2057 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions): 2058 and 'android.permission.READ_EXTERNAL_STORAGE' not in permissions):
2058 permissions.append('android.permission.READ_EXTERNAL_STORAGE') 2059 permissions.append('android.permission.READ_EXTERNAL_STORAGE')
2059 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions) 2060 cmd = ';'.join('pm grant %s %s' %(package, p) for p in permissions)
2060 if cmd: 2061 if cmd:
2061 output = self.RunShellCommand(cmd) 2062 output = self.RunShellCommand(cmd)
2062 if output: 2063 if output:
2063 logging.warning('Possible problem when granting permissions. Blacklist ' 2064 logging.warning('Possible problem when granting permissions. Blacklist '
2064 'may need to be updated.') 2065 'may need to be updated.')
2065 logging.warning(output) 2066 logging.warning(output)
OLDNEW
« no previous file with comments | « no previous file | build/android/devil/android/device_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698