mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 04:49:00 +00:00
android devices: updating executable install/uninstall work on unrooted devices
This commit is contained in:
parent
c550657912
commit
adefbb7b2c
@ -351,24 +351,14 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
|||||||
Updated in version 2.1.5 with ``with_name`` parameter.
|
Updated in version 2.1.5 with ``with_name`` parameter.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
self._ensure_binaries_directory_is_writable()
|
||||||
executable_name = with_name or os.path.basename(filepath)
|
executable_name = with_name or os.path.basename(filepath)
|
||||||
on_device_file = self.path.join(self.working_directory, executable_name)
|
on_device_file = self.path.join(self.working_directory, executable_name)
|
||||||
on_device_executable = self.path.join(self.binaries_directory, executable_name)
|
on_device_executable = self.path.join(self.binaries_directory, executable_name)
|
||||||
self.push_file(filepath, on_device_file)
|
self.push_file(filepath, on_device_file)
|
||||||
matched = []
|
self.execute('cp {} {}'.format(on_device_file, on_device_executable), as_root=self.is_rooted)
|
||||||
for entry in self.list_file_systems():
|
self.execute('chmod 0777 {}'.format(on_device_executable), as_root=self.is_rooted)
|
||||||
if self.binaries_directory.rstrip('/').startswith(entry.mount_point):
|
return on_device_executable
|
||||||
matched.append(entry)
|
|
||||||
|
|
||||||
if matched:
|
|
||||||
entry = sorted(matched, key=lambda x: len(x.mount_point))[-1]
|
|
||||||
if 'rw' not in entry.options:
|
|
||||||
self.execute('mount -o rw,remount {} {}'.format(entry.device, entry.mount_point), as_root=True)
|
|
||||||
self.execute('cp {} {}'.format(on_device_file, on_device_executable), as_root=True)
|
|
||||||
self.execute('chmod 0777 {}'.format(on_device_executable), as_root=True)
|
|
||||||
return on_device_executable
|
|
||||||
else:
|
|
||||||
raise DeviceError('Could not find mount point for binaries directory {}'.format(self.binaries_directory))
|
|
||||||
|
|
||||||
def uninstall(self, package):
|
def uninstall(self, package):
|
||||||
self._check_ready()
|
self._check_ready()
|
||||||
@ -382,11 +372,8 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
on_device_executable = self.path.join(self.binaries_directory, executable_name)
|
on_device_executable = self.path.join(self.binaries_directory, executable_name)
|
||||||
for entry in self.list_file_systems():
|
self._ensure_binaries_directory_is_writable()
|
||||||
if entry.mount_point == '/system':
|
self.delete_file(on_device_executable, as_root=self.is_rooted)
|
||||||
if 'rw' not in entry.options:
|
|
||||||
self.execute('mount -o rw,remount {} /system'.format(entry.device), as_root=True)
|
|
||||||
self.delete_file(on_device_executable)
|
|
||||||
|
|
||||||
def execute(self, command, timeout=default_timeout, check_exit_code=True, background=False,
|
def execute(self, command, timeout=default_timeout, check_exit_code=True, background=False,
|
||||||
as_root=False, busybox=False, **kwargs):
|
as_root=False, busybox=False, **kwargs):
|
||||||
@ -637,6 +624,18 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
|||||||
else:
|
else:
|
||||||
self.logger.warning('Could not parse version string.')
|
self.logger.warning('Could not parse version string.')
|
||||||
|
|
||||||
|
def _ensure_binaries_directory_is_writable(self):
|
||||||
|
matched = []
|
||||||
|
for entry in self.list_file_systems():
|
||||||
|
if self.binaries_directory.rstrip('/').startswith(entry.mount_point):
|
||||||
|
matched.append(entry)
|
||||||
|
if matched:
|
||||||
|
entry = sorted(matched, key=lambda x: len(x.mount_point))[-1]
|
||||||
|
if 'rw' not in entry.options:
|
||||||
|
self.execute('mount -o rw,remount {} {}'.format(entry.device, entry.mount_point), as_root=True)
|
||||||
|
else:
|
||||||
|
raise DeviceError('Could not find mount point for binaries directory {}'.format(self.binaries_directory))
|
||||||
|
|
||||||
|
|
||||||
class _LogcatPoller(threading.Thread):
|
class _LogcatPoller(threading.Thread):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user