diff --git a/wlauto/common/android/device.py b/wlauto/common/android/device.py index 9488cd43..7444b435 100644 --- a/wlauto/common/android/device.py +++ b/wlauto/common/android/device.py @@ -24,6 +24,8 @@ import threading from subprocess import CalledProcessError from wlauto.core.extension import Parameter +from wlauto.common.resources import Executable +from wlauto.core.resource import NO_ONE from wlauto.common.linux.device import BaseLinuxDevice, PsEntry from wlauto.exceptions import DeviceError, WorkerThreadError, TimeoutError, DeviceNotRespondingError from wlauto.utils.misc import convert_new_lines @@ -193,6 +195,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 self._is_ready = True def initialize(self, context): + self.sqlite = self.deploy_sqlite3(context) # pylint: disable=attribute-defined-outside-init if self.is_rooted: self.disable_screen_lock() self.disable_selinux() @@ -529,6 +532,11 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 return props[prop] return props + def deploy_sqlite3(self, context): + host_file = context.resolver.get(Executable(NO_ONE, self.abi, 'sqlite3')) + target_file = self.install_if_needed(host_file) + return target_file + # Android-specific methods. These either rely on specifics of adb or other # Android-only concepts in their interface and/or implementation. @@ -629,7 +637,7 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223 """ lockdb = '/data/system/locksettings.db' sqlcommand = "update locksettings set value='0' where name='screenlock.disabled';" - self.execute('sqlite3 {} "{}"'.format(lockdb, sqlcommand), as_root=True) + self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), 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/common/bin/arm64/sqlite3 b/wlauto/common/bin/arm64/sqlite3 new file mode 100644 index 00000000..dd87689f Binary files /dev/null and b/wlauto/common/bin/arm64/sqlite3 differ diff --git a/wlauto/common/bin/armeabi/sqlite3 b/wlauto/common/bin/armeabi/sqlite3 new file mode 100644 index 00000000..fe491840 Binary files /dev/null and b/wlauto/common/bin/armeabi/sqlite3 differ diff --git a/wlauto/devices/android/gem5/__init__.py b/wlauto/devices/android/gem5/__init__.py index 853d06ba..caadad63 100644 --- a/wlauto/devices/android/gem5/__init__.py +++ b/wlauto/devices/android/gem5/__init__.py @@ -207,7 +207,7 @@ class Gem5AndroidDevice(BaseGem5Device, AndroidDevice): """ lockdb = '/data/system/locksettings.db' sqlcommand = "update locksettings set value=\'0\' where name=\'screenlock.disabled\';" - self.execute('sqlite3 {} "{}"'.format(lockdb, sqlcommand), as_root=True) + self.execute('{} {} "{}"'.format(self.sqlite, lockdb, sqlcommand), as_root=True) def capture_screen(self, filepath): if BaseGem5Device.capture_screen(self, filepath): diff --git a/wlauto/external/sqlite/README b/wlauto/external/sqlite/README new file mode 100644 index 00000000..0f130c7e --- /dev/null +++ b/wlauto/external/sqlite/README @@ -0,0 +1,11 @@ +For WA we use a slightly modified version of sqlite3 so that it can +be built statically. We used the amalgamated sqlite3 version 3.12.2. +which is under the public domain. + +https://www.sqlite.org/download.html + +Build command: +gcc shell.c sqlite3.c -lpthread -ldl -static -O2 -fPIC -DPIC -DSQLITE_OMIT_LOAD_EXTENSION + +You will need to apply the diff in static.patch + diff --git a/wlauto/external/sqlite/static.patch b/wlauto/external/sqlite/static.patch new file mode 100644 index 00000000..e9f2b978 --- /dev/null +++ b/wlauto/external/sqlite/static.patch @@ -0,0 +1,20 @@ +--- shell.c 2016-05-09 15:35:26.952309563 +0100 ++++ shell.c.bak 2016-05-09 15:33:41.991259588 +0100 +@@ -4503,7 +4503,7 @@ + static char *home_dir = NULL; + if( home_dir ) return home_dir; + ++/*#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \ +-#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \ + && !defined(__RTP__) && !defined(_WRS_KERNEL) + { + struct passwd *pwent; +@@ -4512,7 +4512,7 @@ + home_dir = pwent->pw_dir; + } + } ++#endif*/ +-#endif + + #if defined(_WIN32_WCE) + /* Windows CE (arm-wince-mingw32ce-gcc) does not provide getenv()