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

Unified Diff: build/android/pylib/device/device_utils.py

Issue 929603002: [Android] Add PIE support for ICS devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
Index: build/android/pylib/device/device_utils.py
diff --git a/build/android/pylib/device/device_utils.py b/build/android/pylib/device/device_utils.py
index a1b4117f7b963887e8516526ec0fc878ba5c1c8a..8ae40c1714f34998ac36061dd3ebb0c8d4dd46a5 100644
--- a/build/android/pylib/device/device_utils.py
+++ b/build/android/pylib/device/device_utils.py
@@ -412,7 +412,7 @@ class DeviceUtils(object):
@decorators.WithTimeoutAndRetriesFromInstance()
def RunShellCommand(self, cmd, check_return=False, cwd=None, env=None,
- as_root=False, single_line=False,
+ as_root=False, with_pie=False, single_line=False,
perezju 2015/02/16 10:25:23 Do we expect many clients needing this option? If
jbudorick 2015/02/17 15:15:10 I don't, though I do anticipate it being more than
perezju 2015/02/17 16:04:26 I'm not crazy about this. We're adding this option
jbudorick 2015/02/17 16:14:18 I suppose it makes sense to hold off on adding thi
timeout=None, retries=None):
"""Run an ADB shell command.
@@ -479,6 +479,9 @@ class DeviceUtils(object):
if not isinstance(cmd, basestring):
cmd = ' '.join(cmd_helper.SingleQuote(s) for s in cmd)
+ if with_pie and (self.build_version_sdk <
+ constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
+ cmd = '%s %s' % (self.GetDevicePieWrapper(), cmd)
if env:
env = ' '.join(env_quote(k, v) for k, v in env.iteritems())
cmd = '%s %s' % (env, cmd)
@@ -512,6 +515,42 @@ class DeviceUtils(object):
return output
@decorators.WithTimeoutAndRetriesFromInstance()
+ def GetDevicePieWrapper(self, timeout=None, retries=None):
jbudorick 2015/02/14 00:48:54 Maybe this should be done as a property, wdyt?
perezju 2015/02/16 10:25:23 I would lean a bit towards "No". I would reserve p
jbudorick 2015/02/17 15:15:10 Acknowledged.
+ """Gets the absolute path to the run_pie wrapper on the device.
+
+ We have to build our device executables to be PIE, but they need to be able
+ to run on versions of android that don't support PIE (i.e. ICS and below).
+ To do so, we push a wrapper to the device that lets older android versions
+ run PIE executables. This method pushes that wrapper to the device if
+ necessary and returns the path to it.
+
+ This is exposed publicly to allow clients to write scripts using run_pie
+ (e.g. md5sum.CalculateDeviceMd5Sum). However, in most cases,
+ RunShellCommand(..., with_pie=True) should suffice.
+
+ Args:
+ timeout: timeout in seconds
+ retries: number of retries
+
+ Returns:
+ The path to the PIE wrapper on the device, or an empty string if the
+ device does not require the wrapper.
+ """
+ if 'run_pie' not in self._cache:
+ pie = ''
+ if (self.build_version_sdk <
+ constants.ANDROID_SDK_VERSION_CODES.JELLY_BEAN):
+ host_pie_path = os.path.join(constants.GetOutDirectory(), 'run_pie')
+ if not os.path.exists(host_pie_path):
+ raise device_errors.CommandFailedError('Please build run_pie')
+ pie = '%s/run_pie' % constants.TEST_EXECUTABLE_DIR
+ self.adb.Push(host_pie_path, pie)
+
+ self._cache['run_pie'] = pie
+
+ return self._cache['run_pie']
+
+ @decorators.WithTimeoutAndRetriesFromInstance()
def KillAll(self, process_name, signum=9, as_root=False, blocking=False,
timeout=None, retries=None):
"""Kill all processes with the given name on the device.
« no previous file with comments | « no previous file | build/android/pylib/device/device_utils_test.py » ('j') | build/android/pylib/device/device_utils_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698