From ef61f16896fd8f7153ca844e66ecf756e4480e4d Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Fri, 6 May 2016 13:18:32 +0100 Subject: [PATCH] AndroidDevice: Fixed screen lock disable Due to the previous commits, this command no longer works properly. It turns out there is an issue with using multiple levels of escaping. It seems that bash handles the backslashes and single quotes separately incorrectly processing our escaping. To get around this we are writing the sqlite command to a shell script file and running that. This seems to be the only case in WA at the moment that requires this, if more show up/when WA moves to devlib it should use the devlib shutil mechanism. --- wlauto/common/android/device.py | 10 +++++++++- wlauto/devices/android/gem5/__init__.py | 10 ---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py index 7444b435..9bab60d9 100644 --- a/wlauto/common/android/device.py +++ b/wlauto/common/android/device.py @@ -637,7 +637,15 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 """ lockdb = '/data/system/locksettings.db' sqlcommand = "update locksettings set value='0' where name='screenlock.disabled';" - self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True) + f = tempfile.NamedTemporaryFile() + try: + f.write('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand)) + f.flush() + on_device_executable = self.install_executable(f.name, + with_name="disable_screen_lock") + finally: + f.close() + self.execute(on_device_executable, as_root=True) def disable_selinux(self): # This may be invoked from intialize() so we can't use execute() or the diff --git a/wlauto/devices/android/gem5/__init__.py b/wlauto/devices/android/gem5/__init__.py index caadad63..e5371e00 100644 --- a/wlauto/devices/android/gem5/__init__.py +++ b/wlauto/devices/android/gem5/__init__.py @@ -199,16 +199,6 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice): props = self._get_android_properties(context) return props - def disable_screen_lock(self): - """ - Attempts to disable he screen lock on the device. - - Overridden here as otherwise we have issues with too many backslashes. - """ - lockdb = '/data/system/locksettings.db' - sqlcommand = "update locksettings set value=\'0\' where name=\'screenlock.disabled\';" - self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True) - def capture_screen(self, filepath): if BaseGem5Device.capture_screen(self, filepath): return