| 130 | |
| 131 | |
| 132 | class AndroidDevice(Device): |
| 133 | def __init__(self, device_id, target_abi): |
| 134 | super(AndroidDevice, self).__init__(device_id, target_abi) |
| 135 | |
| 136 | @staticmethod |
| 137 | def list_devices(): |
| 138 | out = execute("adb devices", False) |
| 139 | serialno_list = out.strip().split('\n')[1:] |
| 140 | serialno_list = [tuple(pair.split('\t')) for pair in serialno_list] |
| 141 | devices = [] |
| 142 | for serialno in serialno_list: |
| 143 | if (len(serialno) < 2 or |
| 144 | serialno[1].startswith("no permissions") or |
| 145 | serialno[1].startswith("unauthorized")): |
| 146 | continue |
| 147 | devices.append(serialno[0]) |
| 148 | |
| 149 | return devices |
| 150 | |
| 151 | def install(self, target, install_dir, install_deps=False): |
| 152 | install_dir = os.path.abspath(install_dir) |
| 153 | sn = self._device_id |
| 154 | |
| 155 | execute("adb -s %s shell mkdir -p %s" % (sn, install_dir)) |
| 156 | if os.path.isdir(target.path): |
| 157 | execute("adb -s %s push %s/* %s" % (sn, target.path, install_dir), |
| 158 | False) |
| 159 | else: |
| 160 | execute("adb -s %s push %s %s" % (sn, target.path, install_dir), |
| 161 | False) |
| 162 | |
| 163 | for lib in target.libs: |
| 164 | execute("adb -s %s push %s %s" % (sn, lib, install_dir), False) |
| 165 | |
| 166 | device_target = copy.deepcopy(target) |
| 167 | device_target.path = "%s/%s" % (install_dir, |
| 168 | os.path.basename(target.path)) |
| 169 | device_target.libs = ["%s/%s" % (install_dir, os.path.basename(lib)) |
| 170 | for lib in target.libs] |
| 171 | device_target.envs.append("LD_LIBRARY_PATH=%s" % install_dir) |
| 172 | |
| 173 | if install_deps: |
| 174 | self.install_common_libs_for_target(target, install_dir) |
| 175 | |
| 176 | return device_target |
| 177 | |
| 178 | def install_common_libs_for_target(self, target, install_dir): |
| 179 | sn = self._device_id |
| 180 | abi = self._target_abi |
| 181 | lib_file = "%s/sources/cxx-stl/llvm-libc++/libs/" \ |
| 182 | "%s/libc++_shared.so" \ |
| 183 | % (os.environ["ANDROID_NDK_HOME"], abi) |
| 184 | ndk_depends_path = os.environ["ANDROID_NDK_HOME"] + "/ndk-depends" |
| 185 | if os.path.exists(ndk_depends_path): |
| 186 | dep_so_libs = execute(ndk_depends_path + " " + target.path) |
| 187 | for dep in dep_so_libs.split("\n"): |
| 188 | if dep == "libgnustl_shared.so": |
| 189 | lib_file = "%s/sources/cxx-stl/gnu-libstdc++/4.9/libs/" \ |
nothing calls this directly
no outgoing calls
no test coverage detected