@devicefarmer/adbkit 2.11.3 → 3.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/.github/dependabot.yml +46 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/README.md +749 -759
  4. package/bin/adbkit +1 -1
  5. package/dist/index.d.ts +24 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +19 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/package.json +84 -0
  10. package/dist/src/Callback.d.ts +2 -0
  11. package/dist/src/Callback.d.ts.map +1 -0
  12. package/dist/src/Callback.js +3 -0
  13. package/dist/src/Callback.js.map +1 -0
  14. package/dist/src/ClientOptions.d.ts +6 -0
  15. package/dist/src/ClientOptions.d.ts.map +1 -0
  16. package/dist/src/ClientOptions.js +3 -0
  17. package/dist/src/ClientOptions.js.map +1 -0
  18. package/dist/src/CpuStats.d.ts +17 -0
  19. package/dist/src/CpuStats.d.ts.map +1 -0
  20. package/dist/src/CpuStats.js +3 -0
  21. package/dist/src/CpuStats.js.map +1 -0
  22. package/dist/src/Device.d.ts +5 -0
  23. package/dist/src/Device.d.ts.map +1 -0
  24. package/dist/src/Device.js +3 -0
  25. package/dist/src/Device.js.map +1 -0
  26. package/dist/src/DeviceWithPath.d.ts +9 -0
  27. package/dist/src/DeviceWithPath.d.ts.map +1 -0
  28. package/dist/src/DeviceWithPath.js +3 -0
  29. package/dist/src/DeviceWithPath.js.map +1 -0
  30. package/dist/src/ExtendedPublicKey.d.ts +7 -0
  31. package/dist/src/ExtendedPublicKey.d.ts.map +1 -0
  32. package/dist/src/ExtendedPublicKey.js +3 -0
  33. package/dist/src/ExtendedPublicKey.js.map +1 -0
  34. package/dist/src/Features.d.ts +2 -0
  35. package/dist/src/Features.d.ts.map +1 -0
  36. package/dist/src/Features.js +3 -0
  37. package/dist/src/Features.js.map +1 -0
  38. package/dist/src/Forward.d.ts +6 -0
  39. package/dist/src/Forward.d.ts.map +1 -0
  40. package/dist/src/Forward.js +3 -0
  41. package/dist/src/Forward.js.map +1 -0
  42. package/dist/src/FramebufferMeta.d.ts +60 -0
  43. package/dist/src/FramebufferMeta.d.ts.map +1 -0
  44. package/dist/src/FramebufferMeta.js +3 -0
  45. package/dist/src/FramebufferMeta.js.map +1 -0
  46. package/dist/src/FramebufferStreamWithMeta.d.ts +10 -0
  47. package/dist/src/FramebufferStreamWithMeta.d.ts.map +1 -0
  48. package/dist/src/FramebufferStreamWithMeta.js +3 -0
  49. package/dist/src/FramebufferStreamWithMeta.js.map +1 -0
  50. package/dist/src/Properties.d.ts +2 -0
  51. package/dist/src/Properties.d.ts.map +1 -0
  52. package/dist/src/Properties.js +3 -0
  53. package/dist/src/Properties.js.map +1 -0
  54. package/dist/src/Reverse.d.ts +5 -0
  55. package/dist/src/Reverse.d.ts.map +1 -0
  56. package/dist/src/Reverse.js +3 -0
  57. package/dist/src/Reverse.js.map +1 -0
  58. package/dist/src/SocketOptions.d.ts +6 -0
  59. package/dist/src/SocketOptions.d.ts.map +1 -0
  60. package/dist/src/SocketOptions.js +3 -0
  61. package/dist/src/SocketOptions.js.map +1 -0
  62. package/dist/src/StartActivityOptions.d.ts +12 -0
  63. package/dist/src/StartActivityOptions.d.ts.map +1 -0
  64. package/dist/src/StartActivityOptions.js +3 -0
  65. package/dist/src/StartActivityOptions.js.map +1 -0
  66. package/dist/src/StartServiceOptions.d.ts +57 -0
  67. package/dist/src/StartServiceOptions.d.ts.map +1 -0
  68. package/dist/src/StartServiceOptions.js +3 -0
  69. package/dist/src/StartServiceOptions.js.map +1 -0
  70. package/dist/src/TrackerChangeSet.d.ts +7 -0
  71. package/dist/src/TrackerChangeSet.d.ts.map +1 -0
  72. package/dist/src/TrackerChangeSet.js +3 -0
  73. package/dist/src/TrackerChangeSet.js.map +1 -0
  74. package/dist/src/WithToString.d.ts +4 -0
  75. package/dist/src/WithToString.d.ts.map +1 -0
  76. package/dist/src/WithToString.js +3 -0
  77. package/dist/src/WithToString.js.map +1 -0
  78. package/dist/src/adb/DeviceClient.d.ts +376 -0
  79. package/dist/src/adb/DeviceClient.d.ts.map +1 -0
  80. package/dist/src/adb/DeviceClient.js +517 -0
  81. package/dist/src/adb/DeviceClient.js.map +1 -0
  82. package/dist/src/adb/auth.d.ts +8 -0
  83. package/dist/src/adb/auth.d.ts.map +1 -0
  84. package/dist/src/adb/auth.js +87 -0
  85. package/dist/src/adb/auth.js.map +1 -0
  86. package/dist/src/adb/client.d.ts +29 -0
  87. package/dist/src/adb/client.d.ts.map +1 -0
  88. package/dist/src/adb/client.js +73 -0
  89. package/dist/src/adb/client.js.map +1 -0
  90. package/dist/src/adb/command/host/connect.d.ts +6 -0
  91. package/dist/src/adb/command/host/connect.d.ts.map +1 -0
  92. package/dist/src/adb/command/host/connect.js +36 -0
  93. package/dist/src/adb/command/host/connect.js.map +1 -0
  94. package/dist/src/adb/command/host/devices.d.ts +10 -0
  95. package/dist/src/adb/command/host/devices.d.ts.map +1 -0
  96. package/dist/src/adb/command/host/devices.js +40 -0
  97. package/dist/src/adb/command/host/devices.js.map +1 -0
  98. package/dist/src/adb/command/host/deviceswithpaths.d.ts +9 -0
  99. package/dist/src/adb/command/host/deviceswithpaths.d.ts.map +1 -0
  100. package/dist/src/adb/command/host/deviceswithpaths.js +46 -0
  101. package/dist/src/adb/command/host/deviceswithpaths.js.map +1 -0
  102. package/dist/src/adb/command/host/disconnect.d.ts +6 -0
  103. package/dist/src/adb/command/host/disconnect.d.ts.map +1 -0
  104. package/dist/src/adb/command/host/disconnect.js +35 -0
  105. package/dist/src/adb/command/host/disconnect.js.map +1 -0
  106. package/dist/src/adb/command/host/index.d.ts +9 -0
  107. package/dist/src/adb/command/host/index.d.ts.map +1 -0
  108. package/dist/src/adb/command/host/index.js +23 -0
  109. package/dist/src/adb/command/host/index.js.map +1 -0
  110. package/dist/src/adb/command/host/kill.d.ts +6 -0
  111. package/dist/src/adb/command/host/kill.d.ts.map +1 -0
  112. package/dist/src/adb/command/host/kill.js +24 -0
  113. package/dist/src/adb/command/host/kill.js.map +1 -0
  114. package/dist/src/adb/command/host/trackdevices.d.ts +6 -0
  115. package/dist/src/adb/command/host/trackdevices.d.ts.map +1 -0
  116. package/dist/src/adb/command/host/trackdevices.js +27 -0
  117. package/dist/src/adb/command/host/trackdevices.js.map +1 -0
  118. package/dist/src/adb/command/host/transport.d.ts +6 -0
  119. package/dist/src/adb/command/host/transport.d.ts.map +1 -0
  120. package/dist/src/adb/command/host/transport.js +24 -0
  121. package/dist/src/adb/command/host/transport.js.map +1 -0
  122. package/dist/src/adb/command/host/version.d.ts +7 -0
  123. package/dist/src/adb/command/host/version.d.ts.map +1 -0
  124. package/dist/src/adb/command/host/version.js +29 -0
  125. package/dist/src/adb/command/host/version.js.map +1 -0
  126. package/dist/src/adb/command/host-serial/forward.d.ts +6 -0
  127. package/dist/src/adb/command/host-serial/forward.d.ts.map +1 -0
  128. package/dist/src/adb/command/host-serial/forward.js +33 -0
  129. package/dist/src/adb/command/host-serial/forward.js.map +1 -0
  130. package/dist/src/adb/command/host-serial/getdevicepath.d.ts +6 -0
  131. package/dist/src/adb/command/host-serial/getdevicepath.d.ts.map +1 -0
  132. package/dist/src/adb/command/host-serial/getdevicepath.js +26 -0
  133. package/dist/src/adb/command/host-serial/getdevicepath.js.map +1 -0
  134. package/dist/src/adb/command/host-serial/getserialno.d.ts +6 -0
  135. package/dist/src/adb/command/host-serial/getserialno.d.ts.map +1 -0
  136. package/dist/src/adb/command/host-serial/getserialno.js +24 -0
  137. package/dist/src/adb/command/host-serial/getserialno.js.map +1 -0
  138. package/dist/src/adb/command/host-serial/getstate.d.ts +6 -0
  139. package/dist/src/adb/command/host-serial/getstate.d.ts.map +1 -0
  140. package/dist/src/adb/command/host-serial/getstate.js +24 -0
  141. package/dist/src/adb/command/host-serial/getstate.js.map +1 -0
  142. package/dist/src/adb/command/host-serial/index.d.ts +7 -0
  143. package/dist/src/adb/command/host-serial/index.d.ts.map +1 -0
  144. package/dist/src/adb/command/host-serial/index.js +19 -0
  145. package/dist/src/adb/command/host-serial/index.js.map +1 -0
  146. package/dist/src/adb/command/host-serial/listforwards.d.ts +8 -0
  147. package/dist/src/adb/command/host-serial/listforwards.d.ts.map +1 -0
  148. package/dist/src/adb/command/host-serial/listforwards.js +34 -0
  149. package/dist/src/adb/command/host-serial/listforwards.js.map +1 -0
  150. package/dist/src/adb/command/host-serial/waitfordevice.d.ts +6 -0
  151. package/dist/src/adb/command/host-serial/waitfordevice.d.ts.map +1 -0
  152. package/dist/src/adb/command/host-serial/waitfordevice.js +33 -0
  153. package/dist/src/adb/command/host-serial/waitfordevice.js.map +1 -0
  154. package/dist/src/adb/command/host-transport/clear.d.ts +6 -0
  155. package/dist/src/adb/command/host-transport/clear.d.ts.map +1 -0
  156. package/dist/src/adb/command/host-transport/clear.js +39 -0
  157. package/dist/src/adb/command/host-transport/clear.js.map +1 -0
  158. package/dist/src/adb/command/host-transport/framebuffer.d.ts +12 -0
  159. package/dist/src/adb/command/host-transport/framebuffer.d.ts.map +1 -0
  160. package/dist/src/adb/command/host-transport/framebuffer.js +113 -0
  161. package/dist/src/adb/command/host-transport/framebuffer.js.map +1 -0
  162. package/dist/src/adb/command/host-transport/getfeatures.d.ts +8 -0
  163. package/dist/src/adb/command/host-transport/getfeatures.d.ts.map +1 -0
  164. package/dist/src/adb/command/host-transport/getfeatures.js +35 -0
  165. package/dist/src/adb/command/host-transport/getfeatures.js.map +1 -0
  166. package/dist/src/adb/command/host-transport/getpackages.d.ts +7 -0
  167. package/dist/src/adb/command/host-transport/getpackages.d.ts.map +1 -0
  168. package/dist/src/adb/command/host-transport/getpackages.js +45 -0
  169. package/dist/src/adb/command/host-transport/getpackages.js.map +1 -0
  170. package/dist/src/adb/command/host-transport/getproperties.d.ts +8 -0
  171. package/dist/src/adb/command/host-transport/getproperties.d.ts.map +1 -0
  172. package/dist/src/adb/command/host-transport/getproperties.js +37 -0
  173. package/dist/src/adb/command/host-transport/getproperties.js.map +1 -0
  174. package/dist/src/adb/command/host-transport/index.d.ts +28 -0
  175. package/dist/src/adb/command/host-transport/index.d.ts.map +1 -0
  176. package/dist/src/adb/command/host-transport/index.js +61 -0
  177. package/dist/src/adb/command/host-transport/index.js.map +1 -0
  178. package/dist/src/adb/command/host-transport/install.d.ts +6 -0
  179. package/dist/src/adb/command/host-transport/install.d.ts.map +1 -0
  180. package/dist/src/adb/command/host-transport/install.js +42 -0
  181. package/dist/src/adb/command/host-transport/install.js.map +1 -0
  182. package/dist/src/adb/command/host-transport/isinstalled.d.ts +6 -0
  183. package/dist/src/adb/command/host-transport/isinstalled.d.ts.map +1 -0
  184. package/dist/src/adb/command/host-transport/isinstalled.js +37 -0
  185. package/dist/src/adb/command/host-transport/isinstalled.js.map +1 -0
  186. package/dist/src/adb/command/host-transport/listreverses.d.ts +8 -0
  187. package/dist/src/adb/command/host-transport/listreverses.d.ts.map +1 -0
  188. package/dist/src/adb/command/host-transport/listreverses.js +38 -0
  189. package/dist/src/adb/command/host-transport/listreverses.js.map +1 -0
  190. package/dist/src/adb/command/host-transport/local.d.ts +8 -0
  191. package/dist/src/adb/command/host-transport/local.d.ts.map +1 -0
  192. package/dist/src/adb/command/host-transport/local.js +24 -0
  193. package/dist/src/adb/command/host-transport/local.js.map +1 -0
  194. package/dist/src/adb/command/host-transport/log.d.ts +8 -0
  195. package/dist/src/adb/command/host-transport/log.d.ts.map +1 -0
  196. package/dist/src/adb/command/host-transport/log.js +24 -0
  197. package/dist/src/adb/command/host-transport/log.js.map +1 -0
  198. package/dist/src/adb/command/host-transport/logcat.d.ts +9 -0
  199. package/dist/src/adb/command/host-transport/logcat.d.ts.map +1 -0
  200. package/dist/src/adb/command/host-transport/logcat.js +37 -0
  201. package/dist/src/adb/command/host-transport/logcat.js.map +1 -0
  202. package/dist/src/adb/command/host-transport/monkey.d.ts +8 -0
  203. package/dist/src/adb/command/host-transport/monkey.d.ts.map +1 -0
  204. package/dist/src/adb/command/host-transport/monkey.js +50 -0
  205. package/dist/src/adb/command/host-transport/monkey.js.map +1 -0
  206. package/dist/src/adb/command/host-transport/reboot.d.ts +6 -0
  207. package/dist/src/adb/command/host-transport/reboot.d.ts.map +1 -0
  208. package/dist/src/adb/command/host-transport/reboot.js +24 -0
  209. package/dist/src/adb/command/host-transport/reboot.js.map +1 -0
  210. package/dist/src/adb/command/host-transport/remount.d.ts +6 -0
  211. package/dist/src/adb/command/host-transport/remount.d.ts.map +1 -0
  212. package/dist/src/adb/command/host-transport/remount.js +24 -0
  213. package/dist/src/adb/command/host-transport/remount.js.map +1 -0
  214. package/dist/src/adb/command/host-transport/reverse.d.ts +6 -0
  215. package/dist/src/adb/command/host-transport/reverse.d.ts.map +1 -0
  216. package/dist/src/adb/command/host-transport/reverse.js +33 -0
  217. package/dist/src/adb/command/host-transport/reverse.js.map +1 -0
  218. package/dist/src/adb/command/host-transport/root.d.ts +6 -0
  219. package/dist/src/adb/command/host-transport/root.d.ts.map +1 -0
  220. package/dist/src/adb/command/host-transport/root.js +32 -0
  221. package/dist/src/adb/command/host-transport/root.js.map +1 -0
  222. package/dist/src/adb/command/host-transport/screencap.d.ts +8 -0
  223. package/dist/src/adb/command/host-transport/screencap.d.ts.map +1 -0
  224. package/dist/src/adb/command/host-transport/screencap.js +36 -0
  225. package/dist/src/adb/command/host-transport/screencap.js.map +1 -0
  226. package/dist/src/adb/command/host-transport/shell.d.ts +9 -0
  227. package/dist/src/adb/command/host-transport/shell.d.ts.map +1 -0
  228. package/dist/src/adb/command/host-transport/shell.js +27 -0
  229. package/dist/src/adb/command/host-transport/shell.js.map +1 -0
  230. package/dist/src/adb/command/host-transport/startactivity.d.ts +13 -0
  231. package/dist/src/adb/command/host-transport/startactivity.d.ts.map +1 -0
  232. package/dist/src/adb/command/host-transport/startactivity.js +166 -0
  233. package/dist/src/adb/command/host-transport/startactivity.js.map +1 -0
  234. package/dist/src/adb/command/host-transport/startservice.d.ts +7 -0
  235. package/dist/src/adb/command/host-transport/startservice.d.ts.map +1 -0
  236. package/dist/src/adb/command/host-transport/startservice.js +17 -0
  237. package/dist/src/adb/command/host-transport/startservice.js.map +1 -0
  238. package/dist/src/adb/command/host-transport/sync.d.ts +7 -0
  239. package/dist/src/adb/command/host-transport/sync.d.ts.map +1 -0
  240. package/dist/src/adb/command/host-transport/sync.js +25 -0
  241. package/dist/src/adb/command/host-transport/sync.js.map +1 -0
  242. package/dist/src/adb/command/host-transport/tcp.d.ts +8 -0
  243. package/dist/src/adb/command/host-transport/tcp.d.ts.map +1 -0
  244. package/dist/src/adb/command/host-transport/tcp.js +24 -0
  245. package/dist/src/adb/command/host-transport/tcp.js.map +1 -0
  246. package/dist/src/adb/command/host-transport/tcpip.d.ts +6 -0
  247. package/dist/src/adb/command/host-transport/tcpip.d.ts.map +1 -0
  248. package/dist/src/adb/command/host-transport/tcpip.js +32 -0
  249. package/dist/src/adb/command/host-transport/tcpip.js.map +1 -0
  250. package/dist/src/adb/command/host-transport/trackjdwp.d.ts +7 -0
  251. package/dist/src/adb/command/host-transport/trackjdwp.d.ts.map +1 -0
  252. package/dist/src/adb/command/host-transport/trackjdwp.js +25 -0
  253. package/dist/src/adb/command/host-transport/trackjdwp.js.map +1 -0
  254. package/dist/src/adb/command/host-transport/uninstall.d.ts +6 -0
  255. package/dist/src/adb/command/host-transport/uninstall.d.ts.map +1 -0
  256. package/dist/src/adb/command/host-transport/uninstall.js +40 -0
  257. package/dist/src/adb/command/host-transport/uninstall.js.map +1 -0
  258. package/dist/src/adb/command/host-transport/usb.d.ts +6 -0
  259. package/dist/src/adb/command/host-transport/usb.d.ts.map +1 -0
  260. package/dist/src/adb/command/host-transport/usb.js +32 -0
  261. package/dist/src/adb/command/host-transport/usb.js.map +1 -0
  262. package/dist/src/adb/command/host-transport/waitbootcomplete.d.ts +6 -0
  263. package/dist/src/adb/command/host-transport/waitbootcomplete.d.ts.map +1 -0
  264. package/dist/src/adb/command/host-transport/waitbootcomplete.js +27 -0
  265. package/dist/src/adb/command/host-transport/waitbootcomplete.js.map +1 -0
  266. package/dist/src/adb/command.d.ts +17 -0
  267. package/dist/src/adb/command.d.ts.map +1 -0
  268. package/dist/src/adb/command.js +43 -0
  269. package/dist/src/adb/command.js.map +1 -0
  270. package/dist/src/adb/connection.d.ts +24 -0
  271. package/dist/src/adb/connection.d.ts.map +1 -0
  272. package/dist/src/adb/connection.js +115 -0
  273. package/dist/src/adb/connection.js.map +1 -0
  274. package/dist/src/adb/dump.d.ts +4 -0
  275. package/dist/src/adb/dump.d.ts.map +1 -0
  276. package/dist/src/adb/dump.js +38 -0
  277. package/dist/src/adb/dump.js.map +1 -0
  278. package/dist/src/adb/framebuffer/rgbtransform.d.ts +16 -0
  279. package/dist/src/adb/framebuffer/rgbtransform.d.ts.map +1 -0
  280. package/dist/src/adb/framebuffer/rgbtransform.js +47 -0
  281. package/dist/src/adb/framebuffer/rgbtransform.js.map +1 -0
  282. package/dist/src/adb/jdwptracker.d.ts +41 -0
  283. package/dist/src/adb/jdwptracker.d.ts.map +1 -0
  284. package/dist/src/adb/jdwptracker.js +85 -0
  285. package/dist/src/adb/jdwptracker.js.map +1 -0
  286. package/dist/src/adb/keycode.d.ts +292 -0
  287. package/dist/src/adb/keycode.d.ts.map +1 -0
  288. package/dist/src/adb/keycode.js +298 -0
  289. package/dist/src/adb/keycode.js.map +1 -0
  290. package/dist/src/adb/linetransform.d.ts +17 -0
  291. package/dist/src/adb/linetransform.d.ts.map +1 -0
  292. package/dist/src/adb/linetransform.js +93 -0
  293. package/dist/src/adb/linetransform.js.map +1 -0
  294. package/dist/src/adb/parser.d.ts +37 -0
  295. package/dist/src/adb/parser.d.ts.map +1 -0
  296. package/dist/src/adb/parser.js +269 -0
  297. package/dist/src/adb/parser.js.map +1 -0
  298. package/dist/src/adb/proc/stat.d.ts +30 -0
  299. package/dist/src/adb/proc/stat.d.ts.map +1 -0
  300. package/dist/src/adb/proc/stat.js +131 -0
  301. package/dist/src/adb/proc/stat.js.map +1 -0
  302. package/dist/src/adb/protocol.d.ts +17 -0
  303. package/dist/src/adb/protocol.d.ts.map +1 -0
  304. package/dist/src/adb/protocol.js +29 -0
  305. package/dist/src/adb/protocol.js.map +1 -0
  306. package/dist/src/adb/sync/entry.d.ts +8 -0
  307. package/dist/src/adb/sync/entry.d.ts.map +1 -0
  308. package/dist/src/adb/sync/entry.js +16 -0
  309. package/dist/src/adb/sync/entry.js.map +1 -0
  310. package/dist/src/adb/sync/pulltransfer.d.ts +10 -0
  311. package/dist/src/adb/sync/pulltransfer.d.ts.map +1 -0
  312. package/dist/src/adb/sync/pulltransfer.js +24 -0
  313. package/dist/src/adb/sync/pulltransfer.js.map +1 -0
  314. package/dist/src/adb/sync/pushtransfer.d.ts +13 -0
  315. package/dist/src/adb/sync/pushtransfer.d.ts.map +1 -0
  316. package/dist/src/adb/sync/pushtransfer.js +30 -0
  317. package/dist/src/adb/sync/pushtransfer.js.map +1 -0
  318. package/dist/src/adb/sync/stats.d.ts +23 -0
  319. package/dist/src/adb/sync/stats.d.ts.map +1 -0
  320. package/dist/src/adb/sync/stats.js +54 -0
  321. package/dist/src/adb/sync/stats.js.map +1 -0
  322. package/dist/src/adb/sync.d.ts +31 -0
  323. package/dist/src/adb/sync.d.ts.map +1 -0
  324. package/dist/src/adb/sync.js +322 -0
  325. package/dist/src/adb/sync.js.map +1 -0
  326. package/dist/src/adb/tcpusb/packet.d.ts +27 -0
  327. package/dist/src/adb/tcpusb/packet.d.ts.map +1 -0
  328. package/dist/src/adb/tcpusb/packet.js +94 -0
  329. package/dist/src/adb/tcpusb/packet.js.map +1 -0
  330. package/dist/src/adb/tcpusb/packetreader.d.ts +26 -0
  331. package/dist/src/adb/tcpusb/packetreader.d.ts.map +1 -0
  332. package/dist/src/adb/tcpusb/packetreader.js +100 -0
  333. package/dist/src/adb/tcpusb/packetreader.js.map +1 -0
  334. package/dist/src/adb/tcpusb/rollingcounter.d.ts +8 -0
  335. package/dist/src/adb/tcpusb/rollingcounter.d.ts.map +1 -0
  336. package/dist/src/adb/tcpusb/rollingcounter.js +17 -0
  337. package/dist/src/adb/tcpusb/rollingcounter.js.map +1 -0
  338. package/dist/src/adb/tcpusb/server.d.ts +19 -0
  339. package/dist/src/adb/tcpusb/server.d.ts.map +1 -0
  340. package/dist/src/adb/tcpusb/server.js +78 -0
  341. package/dist/src/adb/tcpusb/server.js.map +1 -0
  342. package/dist/src/adb/tcpusb/service.d.ts +37 -0
  343. package/dist/src/adb/tcpusb/service.d.ts.map +1 -0
  344. package/dist/src/adb/tcpusb/service.js +173 -0
  345. package/dist/src/adb/tcpusb/service.js.map +1 -0
  346. package/dist/src/adb/tcpusb/servicemap.d.ts +10 -0
  347. package/dist/src/adb/tcpusb/servicemap.d.ts.map +1 -0
  348. package/dist/src/adb/tcpusb/servicemap.js +42 -0
  349. package/dist/src/adb/tcpusb/servicemap.js.map +1 -0
  350. package/dist/src/adb/tcpusb/socket.d.ts +45 -0
  351. package/dist/src/adb/tcpusb/socket.d.ts.map +1 -0
  352. package/dist/src/adb/tcpusb/socket.js +284 -0
  353. package/dist/src/adb/tcpusb/socket.js.map +1 -0
  354. package/dist/src/adb/tracker.d.ts +17 -0
  355. package/dist/src/adb/tracker.d.ts.map +1 -0
  356. package/dist/src/adb/tracker.js +72 -0
  357. package/dist/src/adb/tracker.js.map +1 -0
  358. package/dist/src/adb/util.d.ts +10 -0
  359. package/dist/src/adb/util.d.ts.map +1 -0
  360. package/dist/src/adb/util.js +17 -0
  361. package/dist/src/adb/util.js.map +1 -0
  362. package/dist/src/adb.d.ts +13 -0
  363. package/dist/src/adb.d.ts.map +1 -0
  364. package/dist/src/adb.js +28 -0
  365. package/dist/src/adb.js.map +1 -0
  366. package/dist/src/cli.d.ts +2 -0
  367. package/dist/src/cli.d.ts.map +1 -0
  368. package/dist/src/cli.js +86 -0
  369. package/dist/src/cli.js.map +1 -0
  370. package/dist/src/index.d.ts +19 -0
  371. package/dist/src/index.d.ts.map +1 -0
  372. package/dist/src/index.js +12 -0
  373. package/dist/src/index.js.map +1 -0
  374. package/package.json +53 -33
  375. package/.semaphore/publish.yml +0 -19
  376. package/.semaphore/semaphore.yml +0 -27
  377. package/index.js +0 -4
  378. package/lib/adb/auth.js +0 -78
  379. package/lib/adb/client.js +0 -576
  380. package/lib/adb/command/host/connect.js +0 -46
  381. package/lib/adb/command/host/devices.js +0 -64
  382. package/lib/adb/command/host/deviceswithpaths.js +0 -70
  383. package/lib/adb/command/host/disconnect.js +0 -46
  384. package/lib/adb/command/host/kill.js +0 -36
  385. package/lib/adb/command/host/trackdevices.js +0 -40
  386. package/lib/adb/command/host/transport.js +0 -36
  387. package/lib/adb/command/host/version.js +0 -42
  388. package/lib/adb/command/host-serial/forward.js +0 -45
  389. package/lib/adb/command/host-serial/getdevicepath.js +0 -38
  390. package/lib/adb/command/host-serial/getserialno.js +0 -38
  391. package/lib/adb/command/host-serial/getstate.js +0 -38
  392. package/lib/adb/command/host-serial/listforwards.js +0 -56
  393. package/lib/adb/command/host-serial/waitfordevice.js +0 -45
  394. package/lib/adb/command/host-transport/clear.js +0 -45
  395. package/lib/adb/command/host-transport/framebuffer.js +0 -114
  396. package/lib/adb/command/host-transport/getfeatures.js +0 -51
  397. package/lib/adb/command/host-transport/getpackages.js +0 -51
  398. package/lib/adb/command/host-transport/getproperties.js +0 -51
  399. package/lib/adb/command/host-transport/install.js +0 -48
  400. package/lib/adb/command/host-transport/isinstalled.js +0 -47
  401. package/lib/adb/command/host-transport/listreverses.js +0 -55
  402. package/lib/adb/command/host-transport/local.js +0 -36
  403. package/lib/adb/command/host-transport/log.js +0 -36
  404. package/lib/adb/command/host-transport/logcat.js +0 -48
  405. package/lib/adb/command/host-transport/monkey.js +0 -42
  406. package/lib/adb/command/host-transport/reboot.js +0 -36
  407. package/lib/adb/command/host-transport/remount.js +0 -36
  408. package/lib/adb/command/host-transport/reverse.js +0 -45
  409. package/lib/adb/command/host-transport/root.js +0 -46
  410. package/lib/adb/command/host-transport/screencap.js +0 -52
  411. package/lib/adb/command/host-transport/shell.js +0 -39
  412. package/lib/adb/command/host-transport/startactivity.js +0 -184
  413. package/lib/adb/command/host-transport/startservice.js +0 -33
  414. package/lib/adb/command/host-transport/sync.js +0 -38
  415. package/lib/adb/command/host-transport/tcp.js +0 -36
  416. package/lib/adb/command/host-transport/tcpip.js +0 -46
  417. package/lib/adb/command/host-transport/trackjdwp.js +0 -120
  418. package/lib/adb/command/host-transport/uninstall.js +0 -44
  419. package/lib/adb/command/host-transport/usb.js +0 -46
  420. package/lib/adb/command/host-transport/waitbootcomplete.js +0 -42
  421. package/lib/adb/command.js +0 -56
  422. package/lib/adb/connection.js +0 -117
  423. package/lib/adb/dump.js +0 -15
  424. package/lib/adb/framebuffer/rgbtransform.js +0 -55
  425. package/lib/adb/keycode.js +0 -225
  426. package/lib/adb/linetransform.js +0 -87
  427. package/lib/adb/parser.js +0 -291
  428. package/lib/adb/proc/stat.js +0 -137
  429. package/lib/adb/protocol.js +0 -45
  430. package/lib/adb/sync/entry.js +0 -23
  431. package/lib/adb/sync/pulltransfer.js +0 -31
  432. package/lib/adb/sync/pushtransfer.js +0 -40
  433. package/lib/adb/sync/stats.js +0 -54
  434. package/lib/adb/sync.js +0 -343
  435. package/lib/adb/tcpusb/packet.js +0 -112
  436. package/lib/adb/tcpusb/packetreader.js +0 -121
  437. package/lib/adb/tcpusb/rollingcounter.js +0 -21
  438. package/lib/adb/tcpusb/server.js +0 -79
  439. package/lib/adb/tcpusb/service.js +0 -203
  440. package/lib/adb/tcpusb/servicemap.js +0 -48
  441. package/lib/adb/tcpusb/socket.js +0 -312
  442. package/lib/adb/tracker.js +0 -89
  443. package/lib/adb/util.js +0 -13
  444. package/lib/adb.js +0 -29
  445. package/lib/cli.js +0 -66
package/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # adbkit
2
2
 
3
- _**Interested in helping to convert the CoffeeScript codebase to plain JavaScript? [Help us](https://github.com/openstf/adbkit/issues/48)!**_
4
-
5
3
  **adbkit** is a pure [Node.js][nodejs] client for the [Android Debug Bridge][adb-site] server. It can be used either as a library in your own application, or simply as a convenient utility for playing with your device.
6
4
 
7
5
  Most of the `adb` command line tool's functionality is supported (including pushing/pulling files, installing APKs and processing logs), with some added functionality such as being able to generate touch/key events and take screenshots. Some shims are provided for older devices, but we have not and will not test anything below Android 2.3.
@@ -10,8 +8,8 @@ Internally, we use this library to drive a multitude of Android devices from a v
10
8
 
11
9
  ## Requirements
12
10
 
13
- * [Node.js][nodejs] >= 0.10
14
- * The `adb` command line tool
11
+ - [Node.js][nodejs] >= 0.10
12
+ - The `adb` command line tool
15
13
 
16
14
  Please note that although it may happen at some point, **this project is NOT an implementation of the ADB _server_**. The target host (where the devices are connected) must still have ADB installed and either already running (e.g. via `adb start-server`) or available in `$PATH`. An attempt will be made to start the server locally via the aforementioned command if the initial connection fails. This is the only case where we fall back to the `adb` binary.
17
15
 
@@ -19,192 +17,171 @@ When targeting a remote host, starting the server is entirely your responsibilit
19
17
 
20
18
  Alternatively, you may want to consider using the Chrome [ADB][chrome-adb] extension, as it includes the ADB server and can be started/stopped quite easily.
21
19
 
20
+ For Linux users, adb need `plugdev` group acess, So you may need to add your current user to `plugdev` group.
21
+ `sudo usermod -a -G plugdev $USER`
22
+
22
23
  ## Getting started
23
24
 
24
25
  Install via NPM:
25
26
 
26
27
  ```bash
27
- npm install --save adbkit
28
+ npm install --save @devicefarmer/adbkit
28
29
  ```
29
30
 
30
31
  We use [debug][node-debug], and our debug namespace is `adb`. Some of the dependencies may provide debug output of their own. To see the debug output, set the `DEBUG` environment variable. For example, run your program with `DEBUG=adb:* node app.js`.
31
32
 
32
- Note that even though the module is written in [CoffeeScript][coffeescript], only the compiled JavaScript is published to [NPM][npm], which means that it can easily be used with pure JavaScript codebases, too.
33
-
34
33
  ### Examples
35
34
 
36
35
  The examples may be a bit verbose, but that's because we're trying to keep them as close to real-life code as possible, with flow control and error handling taken care of.
37
36
 
38
37
  #### Checking for NFC support
39
38
 
40
- ```js
41
- var Promise = require('bluebird')
42
- var adb = require('adbkit')
43
- var client = adb.createClient()
44
-
45
- client.listDevices()
46
- .then(function(devices) {
47
- return Promise.filter(devices, function(device) {
48
- return client.getFeatures(device.id)
49
- .then(function(features) {
50
- return features['android.hardware.nfc']
51
- })
52
- })
53
- })
54
- .then(function(supportedDevices) {
55
- console.log('The following devices support NFC:', supportedDevices)
56
- })
57
- .catch(function(err) {
58
- console.error('Something went wrong:', err.stack)
59
- })
39
+ ```typescript
40
+ import Bluebird from 'bluebird';
41
+ import Adb from '@devicefarmer/adbkit';
42
+
43
+ const client = Adb.createClient();
44
+
45
+ const test = async () => {
46
+ try {
47
+ const devices = await client.listDevices();
48
+ const supportedDevices = await Bluebird.filter(devices, async (device) => {
49
+ const features = await client.getFeatures(device.id);
50
+ return features['android.hardware.nfc'];
51
+ });
52
+ console.log('The following devices support NFC:', supportedDevices);
53
+ } catch (err) {
54
+ console.error('Something went wrong:', err.stack);
55
+ }
56
+ };
60
57
  ```
61
58
 
62
59
  #### Installing an APK
63
60
 
64
- ```js
65
- var Promise = require('bluebird')
66
- var adb = require('adbkit')
67
- var client = adb.createClient()
68
- var apk = 'vendor/app.apk'
69
-
70
- client.listDevices()
71
- .then(function(devices) {
72
- return Promise.map(devices, function(device) {
73
- return client.install(device.id, apk)
74
- })
75
- })
76
- .then(function() {
77
- console.log('Installed %s on all connected devices', apk)
78
- })
79
- .catch(function(err) {
80
- console.error('Something went wrong:', err.stack)
81
- })
61
+ ```typescript
62
+ import Bluebird from 'bluebird';
63
+ import Adb from '@devicefarmer/adbkit';
64
+
65
+ const client = Adb.createClient();
66
+ const apk = 'vendor/app.apk';
67
+
68
+ const test = async () => {
69
+ try {
70
+ const devices = await client.listDevices();
71
+ await Bluebird.map(devices, (device) => client.install(device.id, apk));
72
+ console.log(`Installed ${apk} on all connected devices`);
73
+ } catch (err) {
74
+ console.error('Something went wrong:', err.stack);
75
+ }
76
+ };
82
77
  ```
83
78
 
84
79
  #### Tracking devices
85
80
 
86
- ```js
87
- var adb = require('adbkit')
88
- var client = adb.createClient()
89
-
90
- client.trackDevices()
91
- .then(function(tracker) {
92
- tracker.on('add', function(device) {
93
- console.log('Device %s was plugged in', device.id)
94
- })
95
- tracker.on('remove', function(device) {
96
- console.log('Device %s was unplugged', device.id)
97
- })
98
- tracker.on('end', function() {
99
- console.log('Tracking stopped')
100
- })
101
- })
102
- .catch(function(err) {
103
- console.error('Something went wrong:', err.stack)
104
- })
81
+ ```typescript
82
+ import Adb from '@devicefarmer/adbkit';
83
+
84
+ const client = Adb.createClient();
85
+ const test = async () => {
86
+ try {
87
+ const tracker = await client.trackDevices();
88
+ tracker.on('add', (device) => console.log('Device %s was plugged in', device.id));
89
+ tracker.on('remove', (device) => console.log('Device %s was unplugged', device.id));
90
+ tracker.on('end', () => console.log('Tracking stopped'));
91
+ } catch (err) {
92
+ console.error('Something went wrong:', err.stack);
93
+ }
94
+ };
105
95
  ```
106
96
 
107
97
  #### Pulling a file from all connected devices
108
98
 
109
- ```js
110
- var Promise = require('bluebird')
111
- var fs = require('fs')
112
- var adb = require('adbkit')
113
- var client = adb.createClient()
114
-
115
- client.listDevices()
116
- .then(function(devices) {
117
- return Promise.map(devices, function(device) {
118
- return client.pull(device.id, '/system/build.prop')
119
- .then(function(transfer) {
120
- return new Promise(function(resolve, reject) {
121
- var fn = '/tmp/' + device.id + '.build.prop'
122
- transfer.on('progress', function(stats) {
123
- console.log('[%s] Pulled %d bytes so far',
124
- device.id,
125
- stats.bytesTransferred)
126
- })
127
- transfer.on('end', function() {
128
- console.log('[%s] Pull complete', device.id)
129
- resolve(device.id)
130
- })
131
- transfer.on('error', reject)
132
- transfer.pipe(fs.createWriteStream(fn))
133
- })
134
- })
135
- })
136
- })
137
- .then(function() {
138
- console.log('Done pulling /system/build.prop from all connected devices')
139
- })
140
- .catch(function(err) {
141
- console.error('Something went wrong:', err.stack)
142
- })
99
+ ```typescript
100
+ import Bluebird from 'bluebird';
101
+ import fs from 'fs';
102
+ import Adb from '@devicefarmer/adbkit';
103
+ const client = Adb.createClient();
104
+
105
+ const test = async () => {
106
+ try {
107
+ const devices = await client.listDevices();
108
+ await Bluebird.map(devices, async (device) => {
109
+ const transfer = await client.pull(device.id, '/system/build.prop');
110
+ const fn = `/tmp/${device.id}.build.prop`;
111
+ await new Bluebird((resolve, reject) => {
112
+ transfer.on('progress', (stats) =>
113
+ console.log(`[${device.id}] Pulled ${stats.bytesTransferred} bytes so far`),
114
+ );
115
+ transfer.on('end', () => {
116
+ console.log(`[${device.id}] Pull complete`);
117
+ resolve(device.id);
118
+ });
119
+ transfer.on('error', reject);
120
+ transfer.pipe(fs.createWriteStream(fn));
121
+ });
122
+ });
123
+ console.log('Done pulling /system/build.prop from all connected devices');
124
+ } catch (err) {
125
+ console.error('Something went wrong:', err.stack);
126
+ }
127
+ };
143
128
  ```
144
129
 
145
130
  #### Pushing a file to all connected devices
146
131
 
147
- ```js
148
- var Promise = require('bluebird')
149
- var adb = require('adbkit')
150
- var client = adb.createClient()
151
-
152
- client.listDevices()
153
- .then(function(devices) {
154
- return Promise.map(devices, function(device) {
155
- return client.push(device.id, 'temp/foo.txt', '/data/local/tmp/foo.txt')
156
- .then(function(transfer) {
157
- return new Promise(function(resolve, reject) {
158
- transfer.on('progress', function(stats) {
159
- console.log('[%s] Pushed %d bytes so far',
160
- device.id,
161
- stats.bytesTransferred)
162
- })
163
- transfer.on('end', function() {
164
- console.log('[%s] Push complete', device.id)
165
- resolve()
166
- })
167
- transfer.on('error', reject)
168
- })
169
- })
170
- })
171
- })
172
- .then(function() {
173
- console.log('Done pushing foo.txt to all connected devices')
174
- })
175
- .catch(function(err) {
176
- console.error('Something went wrong:', err.stack)
177
- })
132
+ ```typescript
133
+ import Bluebird from 'bluebird';
134
+ import Adb from '@devicefarmer/adbkit';
135
+ const client = Adb.createClient();
136
+
137
+ const test = async () => {
138
+ try {
139
+ const devices = await client.listDevices();
140
+ await Bluebird.map(devices, async (device) => {
141
+ const transfer = await client.push(device.id, 'temp/foo.txt', '/data/local/tmp/foo.txt');
142
+ await new Bluebird(function (resolve, reject) {
143
+ transfer.on('progress', (stats) =>
144
+ console.log(`[${device.id}] Pushed ${stats.bytesTransferred} bytes so far`),
145
+ );
146
+ transfer.on('end', () => {
147
+ console.log('[${device.id}] Push complete');
148
+ resolve();
149
+ });
150
+ transfer.on('error', reject);
151
+ });
152
+ });
153
+ console.log('Done pushing foo.txt to all connected devices');
154
+ } catch (err) {
155
+ console.error('Something went wrong:', err.stack);
156
+ }
157
+ };
178
158
  ```
179
159
 
180
160
  #### List files in a folder
181
161
 
182
- ```js
183
- var Promise = require('bluebird')
184
- var adb = require('adbkit')
185
- var client = adb.createClient()
186
-
187
- client.listDevices()
188
- .then(function(devices) {
189
- return Promise.map(devices, function(device) {
190
- return client.readdir(device.id, '/sdcard')
191
- .then(function(files) {
192
- // Synchronous, so we don't have to care about returning at the
193
- // right time
194
- files.forEach(function(file) {
195
- if (file.isFile()) {
196
- console.log('[%s] Found file "%s"', device.id, file.name)
197
- }
198
- })
199
- })
200
- })
201
- })
202
- .then(function() {
203
- console.log('Done checking /sdcard files on connected devices')
204
- })
205
- .catch(function(err) {
206
- console.error('Something went wrong:', err.stack)
207
- })
162
+ ```typescript
163
+ import Bluebird from 'bluebird';
164
+ import Adb from '@devicefarmer/adbkit';
165
+ const client = Adb.createClient();
166
+
167
+ const test = async () => {
168
+ try {
169
+ const devices = await client.listDevices();
170
+ await Bluebird.map(devices, async (device) => {
171
+ const files = await client.readdir(device.id, '/sdcard');
172
+ // Synchronous, so we don't have to care about returning at the
173
+ // right time
174
+ files.forEach((file) => {
175
+ if (file.isFile()) {
176
+ console.log(`[${device.id}] Found file "${file.name}"`);
177
+ }
178
+ });
179
+ });
180
+ console.log('Done checking /sdcard files on connected devices');
181
+ } catch (err) {
182
+ console.error('Something went wrong:', err.stack);
183
+ }
184
+ };
208
185
  ```
209
186
 
210
187
  ## API
@@ -215,524 +192,535 @@ client.listDevices()
215
192
 
216
193
  Creates a client instance with the provided options. Note that this will not automatically establish a connection, it will only be done when necessary.
217
194
 
218
- * **options** An object compatible with [Net.connect][net-connect]'s options:
219
- - **port** The port where the ADB server is listening. Defaults to `5037`.
220
- - **host** The host of the ADB server. Defaults to `'localhost'`.
221
- - **bin** As the sole exception, this option provides the path to the `adb` binary, used for starting the server locally if initial connection fails. Defaults to `'adb'`.
222
- * Returns: The client instance.
195
+ - **options** An object compatible with [Net.connect][net-connect]'s options:
196
+ - **port** The port where the ADB server is listening. Defaults to `5037`.
197
+ - **host** The host of the ADB server. Defaults to `'127.0.0.1'`.
198
+ - **bin** As the sole exception, this option provides the path to the `adb` binary, used for starting the server locally if initial connection fails. Defaults to `'adb'`.
199
+ - Returns: The client instance.
223
200
 
224
- #### adb.util.parsePublicKey(androidKey[, callback])
201
+ #### adb.util.parsePublicKey(androidKey)
225
202
 
226
203
  Parses an Android-formatted mincrypt public key (e.g. `~/.android/adbkey.pub`).
227
204
 
228
- * **androidKey** The key String or [`Buffer`][node-buffer] to parse. Not a filename.
229
- * **callback(err, output)** Optional. Use this or the returned `Promise`.
230
- - **err** `null` when successful, `Error` otherwise.
231
- - **key** The key as a [forge.pki](https://github.com/digitalbazaar/forge#rsa) public key. You may need [node-forge](https://github.com/digitalbazaar/forge) for complicated operations. Additionally the following properties are present:
232
- * **fingerprint** The key fingerprint, like it would display on a device. Note that this is different than the one you'd get from `forge.ssh.getPublicKeyFingerprint(key)`, because the device fingerprint is based on the original format.
233
- * **comment** The key comment, if any.
234
- * Returns: `Promise`
235
- * Resolves with: `key` (see callback)
205
+ - **androidKey** The key String or [`Buffer`][node-buffer] to parse. Not a filename.
206
+ - **callback(err, output)** Optional. Use this or the returned `Promise`.
207
+ - **err** `null` when successful, `Error` otherwise.
208
+ - **key** The key as a [forge.pki](https://github.com/digitalbazaar/forge#rsa) public key. You may need [node-forge](https://github.com/digitalbazaar/forge) for complicated operations. Additionally the following properties are present:
209
+ - **fingerprint** The key fingerprint, like it would display on a device. Note that this is different than the one you'd get from `forge.ssh.getPublicKeyFingerprint(key)`, because the device fingerprint is based on the original format.
210
+ - **comment** The key comment, if any.
211
+ - Returns: `Promise`
212
+ - Resolves with: `key` (see callback)
236
213
 
237
- #### adb.util.readAll(stream[, callback])
214
+ #### adb.util.readAll(stream)
238
215
 
239
216
  Takes a [`Stream`][node-stream] and reads everything it outputs until the stream ends. Then it resolves with the collected output. Convenient with `client.shell()`.
240
217
 
241
- * **stream** The [`Stream`][node-stream] to read.
242
- * **callback(err, output)** Optional. Use this or the returned `Promise`.
243
- - **err** `null` when successful, `Error` otherwise.
244
- - **output** All the output as a [`Buffer`][node-buffer]. Use `output.toString('utf-8')` to get a readable string from it.
245
- * Returns: `Promise`
246
- * Resolves with: `output` (see callback)
218
+ - **stream** The [`Stream`][node-stream] to read.
219
+ - **callback(err, output)** Optional. Use this or the returned `Promise`.
220
+ - **err** `null` when successful, `Error` otherwise.
221
+ - **output** All the output as a [`Buffer`][node-buffer]. Use `output.toString('utf-8')` to get a readable string from it.
222
+ - Returns: `Promise`
223
+ - Resolves with: `output` (see callback)
247
224
 
248
225
  ### Client
249
226
 
250
- #### client.clear(serial, pkg[, callback])
251
227
 
252
- Deletes all data associated with a package from the device. This is roughly analogous to `adb shell pm clear <pkg>`.
228
+ #### client.version()
229
+
230
+ Queries the ADB server for its version. This is mainly useful for backwards-compatibility purposes.
231
+
232
+ - **callback(err, version)** Optional. Use this or the returned `Promise`.
233
+ - **err** `null` when successful, `Error` otherwise.
234
+ - **version** The version of the ADB server.
235
+ - Returns: `Promise`
236
+ - Resolves with: `version` (see callback)
253
237
 
254
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
255
- * **pkg** The package name. This is NOT the APK.
256
- * **callback(err)** Optional. Use this or the returned `Promise`.
257
- - **err** `null` when successful, `Error` otherwise.
258
- * Returns: `Promise`
259
- * Resolves with: `true`
260
238
 
261
- #### client.connect(host[, port]&#91;, callback])
239
+ #### client.connect(host[, port])
262
240
 
263
241
  Connects to the given device, which must have its ADB daemon running in tcp mode (see `client.tcpip()`) and be accessible on the same network. Same as `adb connect <host>:<port>`.
264
242
 
265
- * **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped.
266
- * **port** Optional. The target port. Defaults to `5555`.
267
- * **callback(err, id)** Optional. Use this or the returned `Promise`.
268
- - **err** `null` when successful, `Error` otherwise.
269
- - **id** The connected device ID. Can be used as `serial` in other commands.
270
- * Returns: `Promise`
271
- * Resolves with: `id` (see callback)
243
+ - **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped.
244
+ - **port** Optional. The target port. Defaults to `5555`.
245
+ - **callback(err, id)** Optional. Use this or the returned `Promise`.
246
+ - **err** `null` when successful, `Error` otherwise.
247
+ - **id** The connected device ID. Can be used as `serial` in other commands.
248
+ - Returns: `Promise`
249
+ - Resolves with: `id` (see callback)
272
250
 
273
251
  ##### Example - switch to TCP mode and set up a forward for Chrome devtools
274
252
 
275
253
  Note: be careful with using `client.listDevices()` together with `client.tcpip()` and other similar methods that modify the connection with ADB. You might have the same device twice in your device list (i.e. one device connected via both USB and TCP), which can cause havoc if run simultaneously.
276
254
 
277
- ```javascript
278
- var Promise = require('bluebird')
279
- var client = require('adbkit').createClient()
280
-
281
- client.listDevices()
282
- .then(function(devices) {
283
- return Promise.map(devices, function(device) {
284
- return client.tcpip(device.id)
285
- .then(function(port) {
286
- // Switching to TCP mode causes ADB to lose the device for a
287
- // moment, so let's just wait till we get it back.
288
- return client.waitForDevice(device.id).return(port)
289
- })
290
- .then(function(port) {
291
- return client.getDHCPIpAddress(device.id)
292
- .then(function(ip) {
293
- return client.connect(ip, port)
294
- })
295
- .then(function(id) {
296
- // It can take a moment for the connection to happen.
297
- return client.waitForDevice(id)
298
- })
299
- .then(function(id) {
300
- return client.forward(id, 'tcp:9222', 'localabstract:chrome_devtools_remote')
301
- .then(function() {
302
- console.log('Setup devtools on "%s"', id)
303
- })
304
- })
305
- })
306
- })
307
- })
255
+ ```typescript
256
+ import Bluebird from 'bluebird';
257
+ import Adb from '@devicefarmer/adbkit';
258
+ const client = Adb.createClient();
259
+
260
+ const test = async () => {
261
+ try {
262
+ const devices = await client.listDevices();
263
+ await Bluebird.map(devices, async (device) => {
264
+ const device = client.getDevice(device.id);
265
+ const port = await device.tcpip();
266
+ // Switching to TCP mode causes ADB to lose the device for a
267
+ // moment, so let's just wait till we get it back.
268
+ await device.waitForDevice();
269
+ const ip = await device.getDHCPIpAddress();
270
+ const deviceTCP = await client.connect(ip, port);
271
+ // It can take a moment for the connection to happen.
272
+ await deviceTCP.waitForDevice();
273
+ await deviceTCP.forward('tcp:9222', 'localabstract:chrome_devtools_remote');
274
+ console.log(`Setup devtools on "${id}"`);
275
+ });
276
+ } catch (err) {
277
+ console.error('Something went wrong:', err.stack);
278
+ }
279
+ };
308
280
  ```
309
281
 
310
- #### client.disconnect(host[, port]&#91;, callback])
282
+ #### client.disconnect(host[, port])
311
283
 
312
284
  Disconnects from the given device, which should have been connected via `client.connect()` or just `adb connect <host>:<port>`.
313
285
 
314
- * **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped. In other words you can just put the `id` you got from `client.connect()` here and it will be fine.
315
- * **port** Optional. The target port. Defaults to `5555`.
316
- * **callback(err, id)** Optional. Use this or the returned `Promise`.
317
- - **err** `null` when successful, `Error` otherwise.
318
- - **id** The disconnected device ID. Will no longer be usable as a `serial` in other commands until you've connected again.
319
- * Returns: `Promise`
320
- * Resolves with: `id` (see callback)
286
+ - **host** The target host. Can also contain the port, in which case the port argument is not used and can be skipped. In other words you can just put the `id` you got from `client.connect()` here and it will be fine.
287
+ - **port** Optional. The target port. Defaults to `5555`.
288
+ - **callback(err, id)** Optional. Use this or the returned `Promise`.
289
+ - **err** `null` when successful, `Error` otherwise.
290
+ - **id** The disconnected device ID. Will no longer be usable as a `serial` in other commands until you've connected again.
291
+ - Returns: `Promise`
292
+ - Resolves with: `id` (see callback)
293
+
294
+
295
+ #### client.kill()
296
+
297
+ This kills the ADB server. Note that the next connection will attempt to start the server again when it's unable to connect.
298
+ - Returns: `Promise<true>`
299
+ - Resolves with: `true`
300
+
301
+
302
+ #### client.listDevices()
303
+
304
+ Gets the list of currently connected devices and emulators.
305
+ - Returns: `Promise<devices>` An array of device objects. The device objects are plain JavaScript objects with two properties: `id` and `type`.
306
+ - **id** The ID of the device. For real devices, this is usually the USB identifier.
307
+ - **type** The device type. Values include `'emulator'` for emulators, `'device'` for devices, and `'offline'` for offline devices. `'offline'` can occur for example during boot, in low-battery conditions or when the ADB connection has not yet been approved on the device.- Resolves with: `devices` (see callback)
308
+
309
+ #### client.listDevicesWithPaths()
310
+
311
+ Like `client.listDevices()`, but includes the "path" of every device.
312
+ - Returns: `Promise<devices>` An array of device objects. The device objects are plain JavaScript objects with the following properties:
313
+ - **id** See `client.listDevices()`.
314
+ - **type** See `client.listDevices()`.
315
+ - **path** The device path. This can be something like `usb:FD120000` for real devices.
316
+
317
+
318
+ #### client.trackDevices()
319
+
320
+ Gets a device tracker. Events will be emitted when devices are added, removed, or their type changes (i.e. to/from `offline`). Note that the same events will be emitted for the initially connected devices also, so that you don't need to use both `client.listDevices()` and `client.trackDevices()`.
321
+
322
+ Note that as the tracker will keep a connection open, you must call `tracker.end()` if you wish to stop tracking devices.
323
+
324
+ - **callback(err, tracker)** Optional. Use this or the returned `Promise`.
325
+ - **err** `null` when successful, `Error` otherwise.
326
+ - **tracker** The device tracker, which is an [`EventEmitter`][node-events]. The following events are available:
327
+ - **add** **(device)** Emitted when a new device is connected, once per device. See `client.listDevices()` for details on the device object.
328
+ - **remove** **(device)** Emitted when a device is unplugged, once per device. This does not include `offline` devices, those devices are connected but unavailable to ADB. See `client.listDevices()` for details on the device object.
329
+ - **change** **(device)** Emitted when the `type` property of a device changes, once per device. The current value of `type` is the new value. This event usually occurs the type changes from `'device'` to `'offline'` or the other way around. See `client.listDevices()` for details on the device object and the `'offline'` type.
330
+ - **changeSet** **(changes)** Emitted once for all changes reported by ADB in a single run. Multiple changes can occur when, for example, a USB hub is connected/unplugged and the device list changes quickly. If you wish to process all changes at once, use this event instead of the once-per-device ones. Keep in mind that the other events will still be emitted, though.
331
+ - **changes** An object with the following properties always present:
332
+ - **added** An array of added device objects, each one as in the `add` event. Empty if none.
333
+ - **removed** An array of removed device objects, each one as in the `remove` event. Empty if none.
334
+ - **changed** An array of changed device objects, each one as in the `change` event. Empty if none.
335
+ - **end** Emitted when the underlying connection ends.
336
+ - **error** **(err)** Emitted if there's an error.
337
+ - Returns: `Promise`
338
+ - Resolves with: `tracker` (see callback)
339
+
340
+
341
+
342
+ ### DeviceClient
343
+
344
+ #### device.clear(pkg)
345
+
346
+ Deletes all data associated with a package from the device. This is roughly analogous to `adb shell pm clear <pkg>`.
347
+
348
+ - **pkg** The package name. This is NOT the APK.
349
+ - **callback(err)** Optional. Use this or the returned `Promise`.
350
+ - **err** `null` when successful, `Error` otherwise.
351
+ - Returns: `Promise`
352
+ - Resolves with: `true`
353
+
321
354
 
322
- #### client.forward(serial, local, remote[, callback])
355
+ #### device.forward(local, remote)
323
356
 
324
357
  Forwards socket connections from the ADB server host (local) to the device (remote). This is analogous to `adb forward <local> <remote>`. It's important to note that if you are connected to a remote ADB server, the forward will be created on that host.
325
358
 
326
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
327
- * **local** A string representing the local endpoint on the ADB host. At time of writing, can be one of:
328
- - `tcp:<port>`
329
- - `localabstract:<unix domain socket name>`
330
- - `localreserved:<unix domain socket name>`
331
- - `localfilesystem:<unix domain socket name>`
332
- - `dev:<character device name>`
333
- * **remote** A string representing the remote endpoint on the device. At time of writing, can be one of:
334
- - Any value accepted by the `local` argument
335
- - `jdwp:<process pid>`
336
- * **callback(err)** Optional. Use this or the returned `Promise`.
337
- - **err** `null` when successful, `Error` otherwise.
338
- * Returns: `Promise`
339
- * Resolves with: `true`
340
-
341
- #### client.framebuffer(serial[, format]&#91;, callback])
359
+ - **local** A string representing the local endpoint on the ADB host. At time of writing, can be one of:
360
+ - `tcp:<port>`
361
+ - `localabstract:<unix domain socket name>`
362
+ - `localreserved:<unix domain socket name>`
363
+ - `localfilesystem:<unix domain socket name>`
364
+ - `dev:<character device name>`
365
+ - **remote** A string representing the remote endpoint on the device. At time of writing, can be one of:
366
+ - Any value accepted by the `local` argument
367
+ - `jdwp:<process pid>`
368
+ - **callback(err)** Optional. Use this or the returned `Promise`.
369
+ - **err** `null` when successful, `Error` otherwise.
370
+ - Returns: `Promise`
371
+ - Resolves with: `true`
372
+
373
+ #### device.framebuffer([format])
342
374
 
343
375
  Fetches the current **raw** framebuffer (i.e. what is visible on the screen) from the device, and optionally converts it into something more usable by using [GraphicsMagick][graphicsmagick]'s `gm` command, which must be available in `$PATH` if conversion is desired. Note that we don't bother supporting really old framebuffer formats such as RGB_565. If for some mysterious reason you happen to run into a `>=2.3` device that uses RGB_565, let us know.
344
376
 
345
377
  Note that high-resolution devices can have quite massive framebuffers. For example, a device with a resolution of 1920x1080 and 32 bit colors would have a roughly 8MB (`1920*1080*4` byte) RGBA framebuffer. Empirical tests point to about 5MB/s bandwidth limit for the ADB USB connection, which means that it can take ~1.6 seconds for the raw data to arrive, or even more if the USB connection is already congested. Using a conversion will further slow down completion.
346
378
 
347
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
348
- * **format** The desired output format. Any output format supported by [GraphicsMagick][graphicsmagick] (such as `'png'`) is supported. Defaults to `'raw'` for raw framebuffer data.
349
- * **callback(err, framebuffer)** Optional. Use this or the returned `Promise`.
350
- - **err** `null` when successful, `Error` otherwise.
351
- - **framebuffer** The possibly converted framebuffer stream. The stream also has a `meta` property with the following values:
352
- * **version** The framebuffer version. Useful for patching possible backwards-compatibility issues.
353
- * **bpp** Bits per pixel (i.e. color depth).
354
- * **size** The raw byte size of the framebuffer.
355
- * **width** The horizontal resolution of the framebuffer. This SHOULD always be the same as screen width. We have not encountered any device with incorrect framebuffer metadata, but according to rumors there might be some.
356
- * **height** The vertical resolution of the framebuffer. This SHOULD always be the same as screen height.
357
- * **red_offset** The bit offset of the red color in a pixel.
358
- * **red_length** The bit length of the red color in a pixel.
359
- * **blue_offset** The bit offset of the blue color in a pixel.
360
- * **blue_length** The bit length of the blue color in a pixel.
361
- * **green_offset** The bit offset of the green color in a pixel.
362
- * **green_length** The bit length of the green color in a pixel.
363
- * **alpha_offset** The bit offset of alpha in a pixel.
364
- * **alpha_length** The bit length of alpha in a pixel. `0` when not available.
365
- * **format** The framebuffer format for convenience. This can be one of `'bgr'`, `'bgra'`, `'rgb'`, `'rgba'`.
366
- * Returns: `Promise`
367
- * Resolves with: `framebuffer` (see callback)
368
-
369
- #### client.getDevicePath(serial[, callback])
379
+ - **format** The desired output format. Any output format supported by [GraphicsMagick][graphicsmagick] (such as `'png'`) is supported. Defaults to `'raw'` for raw framebuffer data.
380
+ - **callback(err, framebuffer)** Optional. Use this or the returned `Promise`.
381
+ - **err** `null` when successful, `Error` otherwise.
382
+ - **framebuffer** The possibly converted framebuffer stream. The stream also has a `meta` property with the following values:
383
+ - **version** The framebuffer version. Useful for patching possible backwards-compatibility issues.
384
+ - **bpp** Bits per pixel (i.e. color depth).
385
+ - **size** The raw byte size of the framebuffer.
386
+ - **width** The horizontal resolution of the framebuffer. This SHOULD always be the same as screen width. We have not encountered any device with incorrect framebuffer metadata, but according to rumors there might be some.
387
+ - **height** The vertical resolution of the framebuffer. This SHOULD always be the same as screen height.
388
+ - **red_offset** The bit offset of the red color in a pixel.
389
+ - **red_length** The bit length of the red color in a pixel.
390
+ - **blue_offset** The bit offset of the blue color in a pixel.
391
+ - **blue_length** The bit length of the blue color in a pixel.
392
+ - **green_offset** The bit offset of the green color in a pixel.
393
+ - **green_length** The bit length of the green color in a pixel.
394
+ - **alpha_offset** The bit offset of alpha in a pixel.
395
+ - **alpha_length** The bit length of alpha in a pixel. `0` when not available.
396
+ - **format** The framebuffer format for convenience. This can be one of `'bgr'`, `'bgra'`, `'rgb'`, `'rgba'`.
397
+ - Returns: `Promise`
398
+ - Resolves with: `framebuffer` (see callback)
399
+
400
+ #### device.getDevicePath()
370
401
 
371
402
  Gets the device path of the device identified by the given serial number.
372
403
 
373
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
374
- * **callback(err, path)** Optional. Use this or the returned `Promise`.
375
- - **err** `null` when successful, `Error` otherwise.
376
- - **path** The device path. This corresponds to the device path in `client.listDevicesWithPaths()`.
377
- * Returns: `Promise`
378
- * Resolves with: `path` (see callback)
404
+ - **callback(err, path)** Optional. Use this or the returned `Promise`.
405
+ - **err** `null` when successful, `Error` otherwise.
406
+ - **path** The device path. This corresponds to the device path in `client.listDevicesWithPaths()`.
407
+ - Returns: `Promise`
408
+ - Resolves with: `path` (see callback)
379
409
 
380
- #### client.getDHCPIpAddress(serial[, iface]&#91;, callback])
410
+ #### device.getDHCPIpAddress([iface])
381
411
 
382
412
  Attemps to retrieve the IP address of the device. Roughly analogous to `adb shell getprop dhcp.<iface>.ipaddress`.
383
413
 
384
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
385
- * **iface** Optional. The network interface. Defaults to `'wlan0'`.
386
- * **callback(err, ip)** Optional. Use this or the returned `Promise`.
387
- - **err** `null` when successful, `Error` otherwise.
388
- - **ip** The IP address as a `String`.
389
- * Returns: `Promise`
390
- * Resolves with: `ip` (see callback)
414
+ - **iface** Optional. The network interface. Defaults to `'wlan0'`.
415
+ - **callback(err, ip)** Optional. Use this or the returned `Promise`.
416
+ - **err** `null` when successful, `Error` otherwise.
417
+ - **ip** The IP address as a `String`.
418
+ - Returns: `Promise`
419
+ - Resolves with: `ip` (see callback)
391
420
 
392
- #### client.getFeatures(serial[, callback])
421
+ #### device.getFeatures()
393
422
 
394
423
  Retrieves the features of the device identified by the given serial number. This is analogous to `adb shell pm list features`. Useful for checking whether hardware features such as NFC are available (you'd check for `'android.hardware.nfc'`).
395
424
 
396
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
397
- * **callback(err, features)** Optional. Use this or the returned `Promise`.
398
- - **err** `null` when successful, `Error` otherwise.
399
- - **features** An object of device features. Each key corresponds to a device feature, with the value being either `true` for a boolean feature, or the feature value as a string (e.g. `'0x20000'` for `reqGlEsVersion`).
400
- * Returns: `Promise`
401
- * Resolves with: `features` (see callback)
402
-
403
- #### client.getPackages(serial[, callback])
425
+ **flags** Flags to pass to the `pm list packages` command to filter the list
426
+ ```
427
+ -d: filter to only show disabled packages
428
+ -e: filter to only show enabled packages
429
+ -s: filter to only show system packages
430
+ -3: filter to only show third party packages
431
+ ```
432
+ - **callback(err, features)** Optional. Use this or the returned `Promise`.
433
+ - **err** `null` when successful, `Error` otherwise.
434
+ - **features** An object of device features. Each key corresponds to a device feature, with the value being either `true` for a boolean feature, or the feature value as a string (e.g. `'0x20000'` for `reqGlEsVersion`).
435
+ - Returns: `Promise`
436
+ - Resolves with: `features` (see callback)
437
+
438
+ #### device.getPackages()
404
439
 
405
440
  Retrieves the list of packages present on the device. This is analogous to `adb shell pm list packages`. If you just want to see if something's installed, consider using `client.isInstalled()` instead.
406
441
 
407
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
408
- * **callback(err, packages)** Optional. Use this or the returned `Promise`.
409
- - **err** `null` when successful, `Error` otherwise.
410
- - **packages** An array of package names.
411
- * Returns: `Promise`
412
- * Resolves with: `packages` (see callback)
442
+ - **callback(err, packages)** Optional. Use this or the returned `Promise`.
443
+ - **err** `null` when successful, `Error` otherwise.
444
+ - **packages** An array of package names.
445
+ - Returns: `Promise`
446
+ - Resolves with: `packages` (see callback)
413
447
 
414
- #### client.getProperties(serial[, callback])
448
+ #### device.getProperties()
415
449
 
416
450
  Retrieves the properties of the device identified by the given serial number. This is analogous to `adb shell getprop`.
417
451
 
418
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
419
- * **callback(err, properties)** Optional. Use this or the returned `Promise`.
420
- - **err** `null` when successful, `Error` otherwise.
421
- - **properties** An object of device properties. Each key corresponds to a device property. Convenient for accessing things like `'ro.product.model'`.
422
- * Returns: `Promise`
423
- * Resolves with: `properties` (see callback)
452
+ - **callback(err, properties)** Optional. Use this or the returned `Promise`.
453
+ - **err** `null` when successful, `Error` otherwise.
454
+ - **properties** An object of device properties. Each key corresponds to a device property. Convenient for accessing things like `'ro.product.model'`.
455
+ - Returns: `Promise`
456
+ - Resolves with: `properties` (see callback)
424
457
 
425
- #### client.getSerialNo(serial[, callback])
458
+ #### device.getSerialNo()
426
459
 
427
460
  Gets the serial number of the device identified by the given serial number. With our API this doesn't really make much sense, but it has been implemented for completeness. _FYI: in the raw ADB protocol you can specify a device in other ways, too._
428
461
 
429
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
430
- * **callback(err, serial)** Optional. Use this or the returned `Promise`.
431
- - **err** `null` when successful, `Error` otherwise.
432
- - **serial** The serial number of the device.
433
- * Returns: `Promise`
434
- * Resolves with: `serial` (see callback)
462
+ - **callback(err, serial)** Optional. Use this or the returned `Promise`.
463
+ - **err** `null` when successful, `Error` otherwise.
464
+ - **serial** The serial number of the device.
465
+ - Returns: `Promise`
466
+ - Resolves with: `serial` (see callback)
435
467
 
436
- #### client.getState(serial[, callback])
468
+ #### device.getState()
437
469
 
438
470
  Gets the state of the device identified by the given serial number.
439
471
 
440
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
441
- * **callback(err, state)** Optional. Use this or the returned `Promise`.
442
- - **err** `null` when successful, `Error` otherwise.
443
- - **state** The device state. This corresponds to the device type in `client.listDevices()`.
444
- * Returns: `Promise`
445
- * Resolves with: `state` (see callback)
472
+ - **callback(err, state)** Optional. Use this or the returned `Promise`.
473
+ - **err** `null` when successful, `Error` otherwise.
474
+ - **state** The device state. This corresponds to the device type in `client.listDevices()`.
475
+ - Returns: `Promise`
476
+ - Resolves with: `state` (see callback)
446
477
 
447
- #### client.install(serial, apk[, callback])
478
+ #### device.install(apk)
448
479
 
449
480
  Installs the APK on the device, replacing any previously installed version. This is roughly analogous to `adb install -r <apk>`.
450
481
 
451
482
  Note that if the call seems to stall, you may have to accept a dialog on the phone first.
452
483
 
453
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
454
- * **apk** When `String`, interpreted as a path to an APK file. When [`Stream`][node-stream], installs directly from the stream, which must be a valid APK.
455
- * **callback(err)** Optional. Use this or the returned `Promise`.
456
- - **err** `null` when successful, `Error` otherwise. It may have a `.code` property containing the error code reported by the device.
457
- * Returns: `Promise`
458
- * Resolves with: `true`
484
+ - **apk** When `String`, interpreted as a path to an APK file. When [`Stream`][node-stream], installs directly from the stream, which must be a valid APK.
485
+ - **callback(err)** Optional. Use this or the returned `Promise`.
486
+ - **err** `null` when successful, `Error` otherwise. It may have a `.code` property containing the error code reported by the device.
487
+ - Returns: `Promise`
488
+ - Resolves with: `true`
459
489
 
460
490
  ##### Example - install an APK from a URL
461
491
 
462
492
  This example requires the [request](https://www.npmjs.org/package/request) module. It also doesn't do any error handling (404 responses, timeouts, invalid URLs etc).
463
493
 
464
- ```javascript
465
- var client = require('adbkit').createClient()
466
- var request = require('request')
467
- var Readable = require('stream').Readable
494
+ ```typescript
495
+ import Adb from '@devicefarmer/adbkit';
496
+ import request from 'request';
497
+ import { Readable } from 'stream';
468
498
 
469
- // The request module implements old-style streams, so we have to wrap it.
470
- client.install('<serial>', new Readable().wrap(request('http://example.org/app.apk')))
471
- .then(function() {
499
+ const client = Adb.createClient();
500
+
501
+ const test = async () => {
502
+ // The request module implements old-style streams, so we have to wrap it.
503
+ try {
504
+ // request is deprecated
505
+ const device = client.getClient('<serial>');
506
+ await device.install(new Readable().wrap(request('http://example.org/app.apk') as any) as any)
472
507
  console.log('Installed')
473
- })
508
+ } catch (err) {
509
+ console.error('Something went wrong:', err.stack)
510
+ }
511
+ }
474
512
  ```
475
513
 
476
- #### client.installRemote(serial, apk[, callback])
514
+ #### device.installRemote(apk)
477
515
 
478
516
  Installs an APK file which must already be located on the device file system, and replaces any previously installed version. Useful if you've previously pushed the file to the device for some reason (perhaps to have direct access to `client.push()`'s transfer stats). This is roughly analogous to `adb shell pm install -r <apk>` followed by `adb shell rm -f <apk>`.
479
517
 
480
518
  Note that if the call seems to stall, you may have to accept a dialog on the phone first.
481
519
 
482
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
483
- * **apk** The path to the APK file on the device. The file will be removed when the command completes.
484
- * **callback(err)** Optional. Use this or the returned `Promise`.
485
- - **err** `null` when successful, `Error` otherwise.
486
- * Returns: `Promise`
487
- * Resolves with: `true`
520
+ - **apk** The path to the APK file on the device. The file will be removed when the command completes.
521
+ - **callback(err)** Optional. Use this or the returned `Promise`.
522
+ - **err** `null` when successful, `Error` otherwise.
523
+ - Returns: `Promise`
524
+ - Resolves with: `true`
488
525
 
489
- #### client.isInstalled(serial, pkg[, callback])
526
+ #### device.isInstalled(pkg)
490
527
 
491
528
  Tells you if the specific package is installed or not. This is analogous to `adb shell pm path <pkg>` and some output parsing.
492
529
 
493
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
494
- * **pkg** The package name. This is NOT the APK.
495
- * **callback(err, installed)** Optional. Use this or the returned `Promise`.
496
- - **err** `null` when successful, `Error` otherwise.
497
- - **installed** `true` if the package is installed, `false` otherwise.
498
- * Returns: `Promise`
499
- * Resolves with: `installed` (see callback)
500
-
501
- #### client.kill([callback])
502
-
503
- This kills the ADB server. Note that the next connection will attempt to start the server again when it's unable to connect.
504
-
505
- * **callback(err)** Optional. Use this or the returned `Promise`.
506
- - **err** `null` when successful, `Error` otherwise.
507
- * Returns: `Promise`
508
- * Resolves with: `true`
509
-
510
- #### client.listDevices([callback])
511
-
512
- Gets the list of currently connected devices and emulators.
513
-
514
- * **callback(err, devices)** Optional. Use this or the returned `Promise`.
515
- - **err** `null` when successful, `Error` otherwise.
516
- - **devices** An array of device objects. The device objects are plain JavaScript objects with two properties: `id` and `type`.
517
- * **id** The ID of the device. For real devices, this is usually the USB identifier.
518
- * **type** The device type. Values include `'emulator'` for emulators, `'device'` for devices, and `'offline'` for offline devices. `'offline'` can occur for example during boot, in low-battery conditions or when the ADB connection has not yet been approved on the device.
519
- * Returns: `Promise`
520
- * Resolves with: `devices` (see callback)
521
-
522
- #### client.listDevicesWithPaths([callback])
523
-
524
- Like `client.listDevices()`, but includes the "path" of every device.
525
-
526
- * **callback(err, devices)** Optional. Use this or the returned `Promise`.
527
- - **err** `null` when successful, `Error` otherwise.
528
- - **devices** An array of device objects. The device objects are plain JavaScript objects with the following properties:
529
- * **id** See `client.listDevices()`.
530
- * **type** See `client.listDevices()`.
531
- * **path** The device path. This can be something like `usb:FD120000` for real devices.
532
- * Returns: `Promise`
533
- * Resolves with: `devices` (see callback)
530
+ - **pkg** The package name. This is NOT the APK.
531
+ - **callback(err, installed)** Optional. Use this or the returned `Promise`.
532
+ - **err** `null` when successful, `Error` otherwise.
533
+ - **installed** `true` if the package is installed, `false` otherwise.
534
+ - Returns: `Promise`
535
+ - Resolves with: `installed` (see callback)
534
536
 
535
- #### client.listForwards(serial[, callback])
537
+ #### device.listForwards()
536
538
 
537
539
  Lists forwarded connections on the device. This is analogous to `adb forward --list`.
538
540
 
539
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
540
- * **callback(err, forwards)** Optional. Use this or the returned `Promise`.
541
- - **err** `null` when successful, `Error` otherwise.
542
- - **forwards** An array of forward objects with the following properties:
543
- * **serial** The device serial.
544
- * **local** The local endpoint. Same format as `client.forward()`'s `local` argument.
545
- * **remote** The remote endpoint on the device. Same format as `client.forward()`'s `remote` argument.
546
- * Returns: `Promise`
547
- * Resolves with: `forwards` (see callback)
541
+ - **callback(err, forwards)** Optional. Use this or the returned `Promise`.
542
+ - **err** `null` when successful, `Error` otherwise.
543
+ - **forwards** An array of forward objects with the following properties:
544
+ - **serial** The device serial.
545
+ - **local** The local endpoint. Same format as `client.forward()`'s `local` argument.
546
+ - **remote** The remote endpoint on the device. Same format as `client.forward()`'s `remote` argument.
547
+ - Returns: `Promise`
548
+ - Resolves with: `forwards` (see callback)
548
549
 
549
- #### client.listReverses(serial[, callback])
550
+ #### device.listReverses()
550
551
 
551
552
  Lists forwarded connections on the device. This is analogous to `adb reverse --list`.
552
553
 
553
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
554
- * **callback(err, forwards)** Optional. Use this or the returned `Promise`.
555
- - **err** `null` when successful, `Error` otherwise.
556
- - **reverses** An array of reverse objects with the following properties:
557
- * **remote** The remote endpoint on the device. Same format as `client.reverse()`'s `remote` argument.
558
- * **local** The local endpoint on the host. Same format as `client.reverse()`'s `local` argument.
554
+ - **callback(err, forwards)** Optional. Use this or the returned `Promise`.
555
+
556
+ - **err** `null` when successful, `Error` otherwise.
557
+ - **reverses** An array of reverse objects with the following properties:
558
+ - **remote** The remote endpoint on the device. Same format as `client.reverse()`'s `remote` argument.
559
+ - **local** The local endpoint on the host. Same format as `client.reverse()`'s `local` argument.
559
560
 
560
- * Returns: `Promise`
561
- * Resolves with: `reverses` (see callback)
561
+ - Returns: `Promise`
562
+ - Resolves with: `reverses` (see callback)
562
563
 
563
- #### client.openLocal(serial, path[, callback])
564
+ #### device.openLocal(path)
564
565
 
565
566
  Opens a direct connection to a unix domain socket in the given path.
566
567
 
567
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
568
- * **path** The path to the socket. Prefixed with `'localfilesystem:'` by default, include another prefix (e.g. `'localabstract:'`) in the path to override.
569
- * **callback(err, conn)** Optional. Use this or the returned `Promise`.
570
- - **err** `null` when successful, `Error` otherwise.
571
- - **conn** The connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
572
- * Returns: `Promise`
573
- * Resolves with: `conn` (see callback)
568
+ - **path** The path to the socket. Prefixed with `'localfilesystem:'` by default, include another prefix (e.g. `'localabstract:'`) in the path to override.
569
+ - **callback(err, conn)** Optional. Use this or the returned `Promise`.
570
+ - **err** `null` when successful, `Error` otherwise.
571
+ - **conn** The connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
572
+ - Returns: `Promise`
573
+ - Resolves with: `conn` (see callback)
574
574
 
575
- #### client.openLog(serial, name[, callback])
575
+ #### device.openLog(name)
576
576
 
577
577
  Opens a direct connection to a binary log file, providing access to the raw log data. Note that it is usually much more convenient to use the `client.openLogcat()` method, described separately.
578
578
 
579
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
580
- * **name** The name of the log. Available logs include `'main'`, `'system'`, `'radio'` and `'events'`.
581
- * **callback(err, log)** Optional. Use this or the returned `Promise`.
582
- - **err** `null` when successful, `Error` otherwise.
583
- - **log** The binary log stream. Call `log.end()` when you wish to stop receiving data.
584
- * Returns: `Promise`
585
- * Resolves with: `log` (see callback)
579
+ - **name** The name of the log. Available logs include `'main'`, `'system'`, `'radio'` and `'events'`.
580
+ - **callback(err, log)** Optional. Use this or the returned `Promise`.
581
+ - **err** `null` when successful, `Error` otherwise.
582
+ - **log** The binary log stream. Call `log.end()` when you wish to stop receiving data.
583
+ - Returns: `Promise`
584
+ - Resolves with: `log` (see callback)
586
585
 
587
- #### client.openLogcat(serial[, options]&#91;, callback])
586
+ #### device.openLogcat([options])
588
587
 
589
588
  Calls the `logcat` utility on the device and hands off the connection to [adbkit-logcat][adbkit-logcat], a pure Node.js Logcat client. This is analogous to `adb logcat -B`, but the event stream will be parsed for you and a separate event will be emitted for every log entry, allowing for easy processing.
590
589
 
591
590
  For more information, check out the [adbkit-logcat][adbkit-logcat] documentation.
592
591
 
593
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
594
- * **options** Optional. The following options are supported:
595
- - **clear** When `true`, clears logcat before opening the reader. Not set by default.
596
- * **callback(err, logcat)** Optional. Use this or the returned `Promise`.
597
- - **err** `null` when successful, `Error` otherwise.
598
- - **logcat** The Logcat client. Please see the [adbkit-logcat][adbkit-logcat] documentation for details.
599
- * Returns: `Promise`
600
- * Resolves with: `logcat` (see callback)
592
+ - **options** Optional. The following options are supported:
593
+ - **clear** When `true`, clears logcat before opening the reader. Not set by default.
594
+ - **callback(err, logcat)** Optional. Use this or the returned `Promise`.
595
+ - **err** `null` when successful, `Error` otherwise.
596
+ - **logcat** The Logcat client. Please see the [adbkit-logcat][adbkit-logcat] documentation for details.
597
+ - Returns: `Promise`
598
+ - Resolves with: `logcat` (see callback)
601
599
 
602
- #### client.openMonkey(serial[, port]&#91;, callback])
600
+ #### device.openMonkey([port])
603
601
 
604
602
  Starts the built-in `monkey` utility on the device, connects to it using `client.openTcp()` and hands the connection to [adbkit-monkey][adbkit-monkey], a pure Node.js Monkey client. This allows you to create touch and key events, among other things.
605
603
 
606
604
  For more information, check out the [adbkit-monkey][adbkit-monkey] documentation.
607
605
 
608
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
609
- * **port** Optional. The device port where you'd like Monkey to run at. Defaults to `1080`.
610
- * **callback(err, monkey)** Optional. Use this or the returned `Promise`.
611
- - **err** `null` when successful, `Error` otherwise.
612
- - **monkey** The Monkey client. Please see the [adbkit-monkey][adbkit-monkey] documentation for details.
613
- * Returns: `Promise`
614
- * Resolves with: `monkey` (see callback)
606
+ - **port** Optional. The device port where you'd like Monkey to run at. Defaults to `1080`.
607
+ - **callback(err, monkey)** Optional. Use this or the returned `Promise`.
608
+ - **err** `null` when successful, `Error` otherwise.
609
+ - **monkey** The Monkey client. Please see the [adbkit-monkey][adbkit-monkey] documentation for details.
610
+ - Returns: `Promise`
611
+ - Resolves with: `monkey` (see callback)
615
612
 
616
- #### client.openProcStat(serial[, callback])
613
+ #### device.openProcStat()
617
614
 
618
615
  Tracks `/proc/stat` and emits useful information, such as CPU load. A single sync service instance is used to download the `/proc/stat` file for processing. While doing this does consume some resources, it is very light and should not be a problem.
619
616
 
620
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
621
- * **callback(err, stats)** Optional. Use this or the returned `Promise`.
622
- - **err** `null` when successful, `Error` otherwise.
623
- - **stats** The `/proc/stat` tracker, which is an [`EventEmitter`][node-events]. Call `stat.end()` to stop tracking. The following events are available:
624
- * **load** **(loads)** Emitted when a CPU load calculation is available.
625
- - **loads** CPU loads of **online** CPUs. Each key is a CPU id (e.g. `'cpu0'`, `'cpu1'`) and the value an object with the following properties:
626
- * **user** Percentage (0-100) of ticks spent on user programs.
627
- * **nice** Percentage (0-100) of ticks spent on `nice`d user programs.
628
- * **system** Percentage (0-100) of ticks spent on system programs.
629
- * **idle** Percentage (0-100) of ticks spent idling.
630
- * **iowait** Percentage (0-100) of ticks spent waiting for IO.
631
- * **irq** Percentage (0-100) of ticks spent on hardware interrupts.
632
- * **softirq** Percentage (0-100) of ticks spent on software interrupts.
633
- * **steal** Percentage (0-100) of ticks stolen by others.
634
- * **guest** Percentage (0-100) of ticks spent by a guest.
635
- * **guestnice** Percentage (0-100) of ticks spent by a `nice`d guest.
636
- * **total** Total. Always 100.
637
- * Returns: `Promise`
638
- * Resolves with: `stats` (see callback)
639
-
640
- #### client.openTcp(serial, port[, host]&#91;, callback])
617
+ - **callback(err, stats)** Optional. Use this or the returned `Promise`.
618
+ - **err** `null` when successful, `Error` otherwise.
619
+ - **stats** The `/proc/stat` tracker, which is an [`EventEmitter`][node-events]. Call `stat.end()` to stop tracking. The following events are available:
620
+ - **load** **(loads)** Emitted when a CPU load calculation is available.
621
+ - **loads** CPU loads of **online** CPUs. Each key is a CPU id (e.g. `'cpu0'`, `'cpu1'`) and the value an object with the following properties:
622
+ - **user** Percentage (0-100) of ticks spent on user programs.
623
+ - **nice** Percentage (0-100) of ticks spent on `nice`d user programs.
624
+ - **system** Percentage (0-100) of ticks spent on system programs.
625
+ - **idle** Percentage (0-100) of ticks spent idling.
626
+ - **iowait** Percentage (0-100) of ticks spent waiting for IO.
627
+ - **irq** Percentage (0-100) of ticks spent on hardware interrupts.
628
+ - **softirq** Percentage (0-100) of ticks spent on software interrupts.
629
+ - **steal** Percentage (0-100) of ticks stolen by others.
630
+ - **guest** Percentage (0-100) of ticks spent by a guest.
631
+ - **guestnice** Percentage (0-100) of ticks spent by a `nice`d guest.
632
+ - **total** Total. Always 100.
633
+ - Returns: `Promise`
634
+ - Resolves with: `stats` (see callback)
635
+
636
+ #### device.openTcp(port[, host])
641
637
 
642
638
  Opens a direct TCP connection to a port on the device, without any port forwarding required.
643
639
 
644
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
645
- * **port** The port number to connect to.
646
- * **host** Optional. The host to connect to. Allegedly this is supposed to establish a connection to the given host from the device, but we have not been able to get it to work at all. Skip the host and everything works great.
647
- * **callback(err, conn)** Optional. Use this or the returned `Promise`.
648
- - **err** `null` when successful, `Error` otherwise.
649
- - **conn** The TCP connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
650
- * Returns: `Promise`
651
- * Resolves with: `conn` (see callback)
640
+ - **port** The port number to connect to.
641
+ - **host** Optional. The host to connect to. Allegedly this is supposed to establish a connection to the given host from the device, but we have not been able to get it to work at all. Skip the host and everything works great.
642
+ - **callback(err, conn)** Optional. Use this or the returned `Promise`.
643
+ - **err** `null` when successful, `Error` otherwise.
644
+ - **conn** The TCP connection (i.e. [`net.Socket`][node-net]). Read and write as you please. Call `conn.end()` to end the connection.
645
+ - Returns: `Promise`
646
+ - Resolves with: `conn` (see callback)
652
647
 
653
- #### client.pull(serial, path[, callback])
648
+ #### device.pull(path)
654
649
 
655
650
  A convenience shortcut for `sync.pull()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
656
651
 
657
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
658
- * **path** See `sync.pull()` for details.
659
- * **callback(err, transfer)** Optional. Use this or the returned `Promise`.
660
- - **err** `null` when successful, `Error` otherwise.
661
- - **transfer** A `PullTransfer` instance (see below)
662
- * Returns: `Promise`
663
- * Resolves with: `transfer` (see callback)
652
+ - **path** See `sync.pull()` for details.
653
+ - **callback(err, transfer)** Optional. Use this or the returned `Promise`.
654
+ - **err** `null` when successful, `Error` otherwise.
655
+ - **transfer** A `PullTransfer` instance (see below)
656
+ - Returns: `Promise`
657
+ - Resolves with: `transfer` (see callback)
664
658
 
665
- #### client.push(serial, contents, path[, mode]&#91;, callback])
659
+ #### device.push(contents, path[, mode])
666
660
 
667
661
  A convenience shortcut for `sync.push()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
668
662
 
669
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
670
- * **contents** See `sync.push()` for details.
671
- * **path** See `sync.push()` for details.
672
- * **mode** See `sync.push()` for details.
673
- * **callback(err, transfer)** Optional. Use this or the returned `Promise`.
674
- - **err** `null` when successful, `Error` otherwise.
675
- - **transfer** A `PushTransfer` instance (see below)
676
- * Returns: `Promise`
677
- * Resolves with: `transfer` (see callback)
663
+ - **contents** See `sync.push()` for details.
664
+ - **path** See `sync.push()` for details.
665
+ - **mode** See `sync.push()` for details.
666
+ - **callback(err, transfer)** Optional. Use this or the returned `Promise`.
667
+ - **err** `null` when successful, `Error` otherwise.
668
+ - **transfer** A `PushTransfer` instance (see below)
669
+ - Returns: `Promise`
670
+ - Resolves with: `transfer` (see callback)
678
671
 
679
- #### client.readdir(serial, path[, callback])
672
+ #### device.readdir(path)
680
673
 
681
674
  A convenience shortcut for `sync.readdir()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
682
675
 
683
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
684
- * **path** See `sync.readdir()` for details.
685
- * **callback(err, files)** Optional. Use this or the returned `Promise`. See `sync.readdir()` for details.
686
- * Returns: `Promise`
687
- * Resolves with: See `sync.readdir()` for details.
676
+ - **path** See `sync.readdir()` for details.
677
+ - **callback(err, files)** Optional. Use this or the returned `Promise`. See `sync.readdir()` for details.
678
+ - Returns: `Promise`
679
+ - Resolves with: See `sync.readdir()` for details.
688
680
 
689
- #### client.reboot(serial[, callback])
681
+ #### device.reboot()
690
682
 
691
683
  Reboots the device. Similar to `adb reboot`. Note that the method resolves when ADB reports that the device has been rebooted (i.e. the reboot command was successful), not when the device becomes available again.
692
684
 
693
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
694
- * **callback(err)** Optional. Use this or the returned `Promise`.
695
- - **err** `null` when successful, `Error` otherwise.
696
- * Returns: `Promise`
697
- * Resolves with: `true`
685
+ - **callback(err)** Optional. Use this or the returned `Promise`.
686
+ - **err** `null` when successful, `Error` otherwise.
687
+ - Returns: `Promise`
688
+ - Resolves with: `true`
698
689
 
699
- #### client.remount(serial[, callback])
690
+ #### device.remount()
700
691
 
701
692
  Attempts to remount the `/system` partition in read-write mode. This will usually only work on emulators and developer devices.
702
693
 
703
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
704
- * **callback(err)** Optional. Use this or the returned `Promise`.
705
- - **err** `null` when successful, `Error` otherwise.
706
- * Returns: `Promise`
707
- * Resolves with: `true`
694
+ - **callback(err)** Optional. Use this or the returned `Promise`.
695
+ - **err** `null` when successful, `Error` otherwise.
696
+ - Returns: `Promise`
697
+ - Resolves with: `true`
708
698
 
709
- #### client.reverse(serial, remote, local[, callback])
699
+ #### device.reverse(remote, local)
710
700
 
711
701
  Reverses socket connections from the device (remote) to the ADB server host (local). This is analogous to `adb reverse <remote> <local>`. It's important to note that if you are connected to a remote ADB server, the reverse will be created on that host.
712
702
 
713
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
714
- * **remote** A string representing the remote endpoint on the device. At time of writing, can be one of:
715
- - `tcp:<port>`
716
- - `localabstract:<unix domain socket name>`
717
- - `localreserved:<unix domain socket name>`
718
- - `localfilesystem:<unix domain socket name>`
719
- * **local** A string representing the local endpoint on the ADB host. At time of writing, can be any value accepted by the `remote` argument.
720
- * **callback(err)** Optional. Use this or the returned `Promise`.
721
- - **err** `null` when successful, `Error` otherwise.
722
- * Returns: `Promise`
723
- * Resolves with: `true`
703
+ - **remote** A string representing the remote endpoint on the device. At time of writing, can be one of:
704
+ - `tcp:<port>`
705
+ - `localabstract:<unix domain socket name>`
706
+ - `localreserved:<unix domain socket name>`
707
+ - `localfilesystem:<unix domain socket name>`
708
+ - **local** A string representing the local endpoint on the ADB host. At time of writing, can be any value accepted by the `remote` argument.
709
+ - **callback(err)** Optional. Use this or the returned `Promise`.
710
+ - **err** `null` when successful, `Error` otherwise.
711
+ - Returns: `Promise`
712
+ - Resolves with: `true`
724
713
 
725
- #### client.root(serial[, callback])
714
+ #### device.root()
726
715
 
727
- Puts the device into root mode which may be needed by certain shell commands. A remount is generally required after a successful root call. **Note that this will only work if your device supports this feature. Production devices almost never do.**
716
+ Puts the device into root mode which may be needed by certain shell commands. A remount is generally required after a successful root call. **Note that this will only work if your device supports this feature. Production devices almost never do.**
728
717
 
729
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
730
- * **callback(err)** Optional. Use this or the returned `Promise`.
731
- - **err** `null` when successful, `Error` otherwise.
732
- * Returns: `Promise`
733
- * Resolves with: `true`
718
+ - **callback(err)** Optional. Use this or the returned `Promise`.
719
+ - **err** `null` when successful, `Error` otherwise.
720
+ - Returns: `Promise`
721
+ - Resolves with: `true`
734
722
 
735
- #### client.screencap(serial[, callback])
723
+ #### device.screencap()
736
724
 
737
725
  Takes a screenshot in PNG format using the built-in `screencap` utility. This is analogous to `adb shell screencap -p`. Sadly, the utility is not available on most Android `<=2.3` devices, but a silent fallback to the `client.framebuffer()` command in PNG mode is attempted, so you should have its dependencies installed just in case.
738
726
 
@@ -740,42 +728,84 @@ Generating the PNG on the device naturally requires considerably more processing
740
728
 
741
729
  For convenience purposes, if the screencap command fails (e.g. because it doesn't exist on older Androids), we fall back to `client.framebuffer(serial, 'png')`, which is slower and has additional installation requirements.
742
730
 
743
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
744
- * **callback(err, screencap)** Optional. Use this or the returned `Promise`.
745
- - **err** `null` when successful, `Error` otherwise.
746
- - **screencap** The PNG stream.
747
- * Returns: `Promise`
748
- * Resolves with: `screencap` (see callback)
731
+ - **callback(err, screencap)** Optional. Use this or the returned `Promise`.
732
+ - **err** `null` when successful, `Error` otherwise.
733
+ - **screencap** The PNG stream.
734
+ - Returns: `Promise`
735
+ - Resolves with: `screencap` (see callback)
749
736
 
750
- #### client.shell(serial, command[, callback])
737
+ #### device.shell(command)
751
738
 
752
739
  Runs a shell command on the device. Note that you'll be limited to the permissions of the `shell` user, which ADB uses.
753
740
 
754
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
755
- * **command** The shell command to execute. When `String`, the command is run as-is. When `Array`, the elements will be rudimentarily escaped (for convenience, not security) and joined to form a command.
756
- * **callback(err, output)** Optional. Use this or the returned `Promise`.
757
- - **err** `null` when successful, `Error` otherwise.
758
- - **output** A Buffer containing all the output. Call `output.toString('utf-8')` to get a readable String from it.
759
- * Returns: `Promise`
760
- * Resolves with: `output` (see callback)
741
+ - **command** The shell command to execute. When `String`, the command is run as-is. When `Array`, the elements will be rudimentarily escaped (for convenience, not security) and joined to form a command.
742
+ - **callback(err, conn)** Optional. Use this or the returned `Promise`.
743
+ - **err** `null` when successful, `Error` otherwise.
744
+ - **conn** A readable stream (`Socket` actually) containing the progressive `stdout` of the command. Use with `adb.util.readAll` to get a readable String from it.
745
+ - Returns: `Promise`
746
+ - Resolves with: `conn` (see callback)
761
747
 
762
748
  ##### Example
763
749
 
764
- ```js
765
- var Promise = require('bluebird')
766
- var adb = require('adbkit')
767
- var client = adb.createClient()
750
+ * Read the output of an instantaneous command
751
+ ```typescript
752
+ import Bluebird from 'bluebird';
753
+ import Adb from '@devicefarmer/adbkit';
754
+
755
+ const client = Adb.createClient();
756
+
757
+ client
758
+ .listDevices()
759
+ .then(function (devices) {
760
+ return Promise.map(devices, function (device) {
761
+ const device = client.getDevice(device.id);
762
+ return (
763
+ device
764
+ .shell('echo $RANDOM')
765
+ // Use the readAll() utility to read all the content without
766
+ // having to deal with the readable stream. `output` will be a Buffer
767
+ // containing all the output.
768
+ .then(adb.util.readAll)
769
+ .then(function (output) {
770
+ console.log('[%s] %s', device.id, output.toString().trim());
771
+ })
772
+ );
773
+ });
774
+ })
775
+ .then(function () {
776
+ console.log('Done.');
777
+ })
778
+ .catch(function (err) {
779
+ console.error('Something went wrong:', err.stack);
780
+ });
781
+ ```
782
+
783
+ * Progressively read the output of a long-running command and terminate it
784
+ ```typescript
785
+ import Bluebird from 'bluebird';
786
+ import Adb from '@devicefarmer/adbkit';
768
787
 
788
+ const client = Adb.createClient();
769
789
  client.listDevices()
770
790
  .then(function(devices) {
771
- return Promise.map(devices, function(device) {
772
- return client.shell(device.id, 'echo $RANDOM')
773
- // Use the readAll() utility to read all the content without
774
- // having to deal with the events. `output` will be a Buffer
775
- // containing all the output.
776
- .then(adb.util.readAll)
777
- .then(function(output) {
778
- console.log('[%s] %s', device.id, output.toString().trim())
791
+ return Bluebird.map(devices, function(device) {
792
+ const device = client.getDevice(device.id);
793
+ return device.shell('logcat') // logcat just for illustration,
794
+ // prefer client.openLogcat in real use
795
+ .then(function(conn) {
796
+ var line = 0
797
+ conn.on('data', function(data) {
798
+ // here `ps` on the device shows the running logcat process
799
+ console.log(data.toString())
800
+ line += 1
801
+ // close the stream and the running process
802
+ // on the device will be gone, gracefully
803
+ if (line > 100) conn.end()
804
+ });
805
+ conn.on('close', function() {
806
+ // here `ps` on the device shows the logcat process is gone
807
+ console.log('100 lines read already, bye')
808
+ })
779
809
  })
780
810
  })
781
811
  })
@@ -787,177 +817,138 @@ client.listDevices()
787
817
  })
788
818
  ```
789
819
 
790
- #### client.startActivity(serial, options[, callback])
820
+
821
+ #### device.startActivity(options)
791
822
 
792
823
  Starts the configured activity on the device. Roughly analogous to `adb shell am start <options>`.
793
824
 
794
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
795
- * **options** The activity configuration. The following options are available:
796
- - **debug** Set to `true` to enable debugging.
797
- - **wait** Set to `true` to wait for the activity to launch.
798
- - **user** The user to run as. Not set by default. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
799
- - **action** The action.
800
- - **data** The data URI, if any.
801
- - **mimeType** The mime type, if any.
802
- - **category** The category. For multiple categories, pass an `Array`.
803
- - **component** The component.
804
- - **flags** Numeric flags.
805
- - **extras** Any extra data.
806
- * When an `Array`, each item must be an `Object` the following properties:
807
- - **key** The key name.
808
- - **type** The type, which can be one of `'string'`, `'null'`, `'bool'`, `'int'`, `'long'`, `'float'`, `'uri'`, `'component'`.
809
- - **value** The value. Optional and unused if type is `'null'`. If an `Array`, type is automatically set to be an array of `<type>`.
810
- * When an `Object`, each key is treated as the key name. Simple values like `null`, `String`, `Boolean` and `Number` are type-mapped automatically (`Number` maps to `'int'`) and can be used as-is. For more complex types, like arrays and URIs, set the value to be an `Object` like in the Array syntax (see above), but leave out the `key` property.
811
- * **callback(err)** Optional. Use this or the returned `Promise`.
812
- - **err** `null` when successful, `Error` otherwise.
813
- * Returns: `Promise`
814
- * Resolves with: `true`
815
-
816
- #### client.startService(serial, options[, callback])
825
+ - **options** The activity configuration. The following options are available:
826
+ - **debug** Set to `true` to enable debugging.
827
+ - **wait** Set to `true` to wait for the activity to launch.
828
+ - **user** The user to run as. Not set by default. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
829
+ - **action** The action.
830
+ - **data** The data URI, if any.
831
+ - **mimeType** The mime type, if any.
832
+ - **category** The category. For multiple categories, pass an `Array`.
833
+ - **component** The component.
834
+ - **flags** Numeric flags.
835
+ - **extras** Any extra data.
836
+ - When an `Array`, each item must be an `Object` the following properties:
837
+ - **key** The key name.
838
+ - **type** The type, which can be one of `'string'`, `'null'`, `'bool'`, `'int'`, `'long'`, `'float'`, `'uri'`, `'component'`.
839
+ - **value** The value. Optional and unused if type is `'null'`. If an `Array`, type is automatically set to be an array of `<type>`.
840
+ - When an `Object`, each key is treated as the key name. Simple values like `null`, `String`, `Boolean` and `Number` are type-mapped automatically (`Number` maps to `'int'`) and can be used as-is. For more complex types, like arrays and URIs, set the value to be an `Object` like in the Array syntax (see above), but leave out the `key` property.
841
+ - **callback(err)** Optional. Use this or the returned `Promise`.
842
+ - **err** `null` when successful, `Error` otherwise.
843
+ - Returns: `Promise`
844
+ - Resolves with: `true`
845
+
846
+ #### device.startService(options)
817
847
 
818
848
  Starts the configured service on the device. Roughly analogous to `adb shell am startservice <options>`.
819
849
 
820
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
821
- * **options** The service configuration. The following options are available:
822
- - **user** The user to run as. Defaults to `0`. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
823
- - **action** See `client.startActivity()` for details.
824
- - **data** See `client.startActivity()` for details.
825
- - **mimeType** See `client.startActivity()` for details.
826
- - **category** See `client.startActivity()` for details.
827
- - **component** See `client.startActivity()` for details.
828
- - **flags** See `client.startActivity()` for details.
829
- - **extras** See `client.startActivity()` for details.
830
- * Returns: `Promise`
831
- * Resolves with: `true`
832
-
833
- #### client.stat(serial, path[, callback])
850
+ - **options** The service configuration. The following options are available:
851
+ - **user** The user to run as. Defaults to `0`. If the option is unsupported by the device, an attempt will be made to run the same command again without the user option.
852
+ - **action** See `client.startActivity()` for details.
853
+ - **data** See `client.startActivity()` for details.
854
+ - **mimeType** See `client.startActivity()` for details.
855
+ - **category** See `client.startActivity()` for details.
856
+ - **component** See `client.startActivity()` for details.
857
+ - **flags** See `client.startActivity()` for details.
858
+ - **extras** See `client.startActivity()` for details.
859
+ - Returns: `Promise`
860
+ - Resolves with: `true`
861
+
862
+ #### device.stat(path)
834
863
 
835
864
  A convenience shortcut for `sync.stat()`, mainly for one-off use cases. The connection cannot be reused, resulting in poorer performance over multiple calls. However, the Sync client will be closed automatically for you, so that's one less thing to worry about.
836
865
 
837
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
838
- * **path** See `sync.stat()` for details.
839
- * **callback(err, stats)** Optional. Use this or the returned `Promise`. See `sync.stat()` for details.
840
- * Returns: `Promise`
841
- * Resolves with: See `sync.stat()` for details.
866
+ - **path** See `sync.stat()` for details.
867
+ - **callback(err, stats)** Optional. Use this or the returned `Promise`. See `sync.stat()` for details.
868
+ - Returns: `Promise`
869
+ - Resolves with: See `sync.stat()` for details.
842
870
 
843
- #### client.syncService(serial[, callback])
871
+ #### device.syncService()
844
872
 
845
873
  Establishes a new Sync connection that can be used to push and pull files. This method provides the most freedom and the best performance for repeated use, but can be a bit cumbersome to use. For simple use cases, consider using `client.stat()`, `client.push()` and `client.pull()`.
846
874
 
847
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
848
- * **callback(err, sync)** Optional. Use this or the returned `Promise`.
849
- - **err** `null` when successful, `Error` otherwise.
850
- - **sync** The Sync client. See below for details. Call `sync.end()` when done.
851
- * Returns: `Promise`
852
- * Resolves with: `sync` (see callback)
875
+ - **callback(err, sync)** Optional. Use this or the returned `Promise`.
876
+ - **err** `null` when successful, `Error` otherwise.
877
+ - **sync** The Sync client. See below for details. Call `sync.end()` when done.
878
+ - Returns: `Promise`
879
+ - Resolves with: `sync` (see callback)
853
880
 
854
- #### client.tcpip(serial, port[, callback])
881
+ #### device.tcpip(port)
855
882
 
856
883
  Puts the device's ADB daemon into tcp mode, allowing you to use `adb connect` or `client.connect()` to connect to it. Note that the device will still be visible to ADB as a regular USB-connected device until you unplug it. Same as `adb tcpip <port>`.
857
884
 
858
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
859
- * **port** Optional. The port the device should listen on. Defaults to `5555`.
860
- * **callback(err, port)** Optional. Use this or the returned `Promise`.
861
- - **err** `null` when successful, `Error` otherwise.
862
- - **port** The port the device started listening on.
863
- * Returns: `Promise`
864
- * Resolves with: `port` (see callback)
865
-
866
- #### client.trackDevices([callback])
867
-
868
- Gets a device tracker. Events will be emitted when devices are added, removed, or their type changes (i.e. to/from `offline`). Note that the same events will be emitted for the initially connected devices also, so that you don't need to use both `client.listDevices()` and `client.trackDevices()`.
885
+ - **port** Optional. The port the device should listen on. Defaults to `5555`.
886
+ - **callback(err, port)** Optional. Use this or the returned `Promise`.
887
+ - **err** `null` when successful, `Error` otherwise.
888
+ - **port** The port the device started listening on.
889
+ - Returns: `Promise`
890
+ - Resolves with: `port` (see callback)
869
891
 
870
- Note that as the tracker will keep a connection open, you must call `tracker.end()` if you wish to stop tracking devices.
871
892
 
872
- * **callback(err, tracker)** Optional. Use this or the returned `Promise`.
873
- - **err** `null` when successful, `Error` otherwise.
874
- - **tracker** The device tracker, which is an [`EventEmitter`][node-events]. The following events are available:
875
- * **add** **(device)** Emitted when a new device is connected, once per device. See `client.listDevices()` for details on the device object.
876
- * **remove** **(device)** Emitted when a device is unplugged, once per device. This does not include `offline` devices, those devices are connected but unavailable to ADB. See `client.listDevices()` for details on the device object.
877
- * **change** **(device)** Emitted when the `type` property of a device changes, once per device. The current value of `type` is the new value. This event usually occurs the type changes from `'device'` to `'offline'` or the other way around. See `client.listDevices()` for details on the device object and the `'offline'` type.
878
- * **changeSet** **(changes)** Emitted once for all changes reported by ADB in a single run. Multiple changes can occur when, for example, a USB hub is connected/unplugged and the device list changes quickly. If you wish to process all changes at once, use this event instead of the once-per-device ones. Keep in mind that the other events will still be emitted, though.
879
- - **changes** An object with the following properties always present:
880
- * **added** An array of added device objects, each one as in the `add` event. Empty if none.
881
- * **removed** An array of removed device objects, each one as in the `remove` event. Empty if none.
882
- * **changed** An array of changed device objects, each one as in the `change` event. Empty if none.
883
- * **end** Emitted when the underlying connection ends.
884
- * **error** **(err)** Emitted if there's an error.
885
- * Returns: `Promise`
886
- * Resolves with: `tracker` (see callback)
887
-
888
- #### client.trackJdwp(serial[, callback])
893
+ #### device.trackJdwp()
889
894
 
890
895
  Starts a JDWP tracker for the given device.
891
896
 
892
897
  Note that as the tracker will keep a connection open, you must call `tracker.end()` if you wish to stop tracking JDWP processes.
893
898
 
894
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
895
- * **callback(err, tracker)** Optional. Use this or the returned `Promise`.
896
- - **err** `null` when successful, `Error` otherwise.
897
- - **tracker** The JDWP tracker, which is an [`EventEmitter`][node-events]. The following events are available:
898
- * **add** **(pid)** Emitted when a new JDWP process becomes available, once per pid.
899
- * **remove** **(pid)** Emitted when a JDWP process becomes unavailable, once per pid.
900
- * **changeSet** **(changes, pids)** All changes in a single event.
901
- - **changes** An object with the following properties always present:
902
- * **added** An array of pids that were added. Empty if none.
903
- * **removed** An array of pids that were removed. Empty if none.
904
- - **pids** All currently active pids (including pids from previous runs).
905
- * **end** Emitted when the underlying connection ends.
906
- * **error** **(err)** Emitted if there's an error.
907
- * Returns: `Promise`
908
- * Resolves with: `tracker` (see callback)
909
-
910
- #### client.uninstall(serial, pkg[, callback])
899
+ - **callback(err, tracker)** Optional. Use this or the returned `Promise`.
900
+ - **err** `null` when successful, `Error` otherwise.
901
+ - **tracker** The JDWP tracker, which is an [`EventEmitter`][node-events]. The following events are available:
902
+ - **add** **(pid)** Emitted when a new JDWP process becomes available, once per pid.
903
+ - **remove** **(pid)** Emitted when a JDWP process becomes unavailable, once per pid.
904
+ - **changeSet** **(changes, pids)** All changes in a single event.
905
+ - **changes** An object with the following properties always present:
906
+ - **added** An array of pids that were added. Empty if none.
907
+ - **removed** An array of pids that were removed. Empty if none.
908
+ - **pids** All currently active pids (including pids from previous runs).
909
+ - **end** Emitted when the underlying connection ends.
910
+ - **error** **(err)** Emitted if there's an error.
911
+ - Returns: `Promise`
912
+ - Resolves with: `tracker` (see callback)
913
+
914
+ #### device.uninstall(pkg)
911
915
 
912
916
  Uninstalls the package from the device. This is roughly analogous to `adb uninstall <pkg>`.
913
917
 
914
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
915
- * **pkg** The package name. This is NOT the APK.
916
- * **callback(err)** Optional. Use this or the returned `Promise`.
917
- - **err** `null` when successful, `Error` otherwise.
918
- * Returns: `Promise`
919
- * Resolves with: `true`
918
+ - **pkg** The package name. This is NOT the APK.
919
+ - **callback(err)** Optional. Use this or the returned `Promise`.
920
+ - **err** `null` when successful, `Error` otherwise.
921
+ - Returns: `Promise`
922
+ - Resolves with: `true`
920
923
 
921
- #### client.usb(serial[, callback])
924
+ #### device.usb()
922
925
 
923
926
  Puts the device's ADB daemon back into USB mode. Reverses `client.tcpip()`. Same as `adb usb`.
924
927
 
925
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
926
- * **callback(err)** Optional. Use this or the returned `Promise`.
927
- - **err** `null` when successful, `Error` otherwise.
928
- * Returns: `Promise`
929
- * Resolves with: `true`
930
-
931
- #### client.version([callback])
932
-
933
- Queries the ADB server for its version. This is mainly useful for backwards-compatibility purposes.
928
+ - **callback(err)** Optional. Use this or the returned `Promise`.
929
+ - **err** `null` when successful, `Error` otherwise.
930
+ - Returns: `Promise`
931
+ - Resolves with: `true`
934
932
 
935
- * **callback(err, version)** Optional. Use this or the returned `Promise`.
936
- - **err** `null` when successful, `Error` otherwise.
937
- - **version** The version of the ADB server.
938
- * Returns: `Promise`
939
- * Resolves with: `version` (see callback)
940
933
 
941
- #### client.waitBootComplete(serial[, callback])
934
+ #### device.waitBootComplete()
942
935
 
943
936
  Waits until the device has finished booting. Note that the device must already be seen by ADB. This is roughly analogous to periodically checking `adb shell getprop sys.boot_completed`.
944
937
 
945
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
946
- * **callback(err)** Optional. Use this or the returned `Promise`.
947
- - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
948
- * Returns: `Promise`
949
- * Resolves with: `true`
938
+ - **callback(err)** Optional. Use this or the returned `Promise`.
939
+ - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
940
+ - Returns: `Promise`
941
+ - Resolves with: `true`
950
942
 
951
- #### client.waitForDevice(serial[, callback])
943
+ #### device.waitForDevice()
952
944
 
953
945
  Waits until ADB can see the device. Note that you must know the serial in advance. Other than that, works like `adb -s serial wait-for-device`. If you're planning on reacting to random devices being plugged in and out, consider using `client.trackDevices()` instead.
954
946
 
955
- * **serial** The serial number of the device. Corresponds to the device ID in `client.listDevices()`.
956
- * **callback(err, id)** Optional. Use this or the returned `Promise`.
957
- - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
958
- - **id** The device ID. Can be useful for chaining.
959
- * Returns: `Promise`
960
- * Resolves with: `id` (see callback)
947
+ - **callback(err, id)** Optional. Use this or the returned `Promise`.
948
+ - **err** `null` if the device has completed booting, `Error` otherwise (can occur if the connection dies while checking).
949
+ - **id** The device ID. Can be useful for chaining.
950
+ - Returns: `Promise`
951
+ - Resolves with: `id` (see callback)
961
952
 
962
953
  ### Sync
963
954
 
@@ -965,77 +956,77 @@ Waits until ADB can see the device. Note that you must know the serial in advanc
965
956
 
966
957
  Closes the Sync connection, allowing Node to quit (assuming nothing else is keeping it alive, of course).
967
958
 
968
- * Returns: The sync instance.
959
+ - Returns: The sync instance.
969
960
 
970
961
  #### sync.pull(path)
971
962
 
972
963
  Pulls a file from the device as a `PullTransfer` [`Stream`][node-stream].
973
964
 
974
- * **path** The path to pull from.
975
- * Returns: A `PullTransfer` instance. See below for details.
965
+ - **path** The path to pull from.
966
+ - Returns: A `PullTransfer` instance. See below for details.
976
967
 
977
968
  #### sync.push(contents, path[, mode])
978
969
 
979
970
  Attempts to identify `contents` and calls the appropriate `push*` method for it.
980
971
 
981
- * **contents** When `String`, treated as a local file path and forwarded to `sync.pushFile()`. Otherwise, treated as a [`Stream`][node-stream] and forwarded to `sync.pushStream()`.
982
- * **path** The path to push to.
983
- * **mode** Optional. The mode of the file. Defaults to `0644`.
984
- * Returns: A `PushTransfer` instance. See below for details.
972
+ - **contents** When `String`, treated as a local file path and forwarded to `sync.pushFile()`. Otherwise, treated as a [`Stream`][node-stream] and forwarded to `sync.pushStream()`.
973
+ - **path** The path to push to.
974
+ - **mode** Optional. The mode of the file. Defaults to `0644`.
975
+ - Returns: A `PushTransfer` instance. See below for details.
985
976
 
986
977
  #### sync.pushFile(file, path[, mode])
987
978
 
988
979
  Pushes a local file to the given path. Note that the path must be writable by the ADB user (usually `shell`). When in doubt, use `'/data/local/tmp'` with an appropriate filename.
989
980
 
990
- * **file** The local file path.
991
- * **path** See `sync.push()` for details.
992
- * **mode** See `sync.push()` for details.
993
- * Returns: See `sync.push()` for details.
981
+ - **file** The local file path.
982
+ - **path** See `sync.push()` for details.
983
+ - **mode** See `sync.push()` for details.
984
+ - Returns: See `sync.push()` for details.
994
985
 
995
986
  #### sync.pushStream(stream, path[, mode])
996
987
 
997
988
  Pushes a [`Stream`][node-stream] to the given path. Note that the path must be writable by the ADB user (usually `shell`). When in doubt, use `'/data/local/tmp'` with an appropriate filename.
998
989
 
999
- * **stream** The readable stream.
1000
- * **path** See `sync.push()` for details.
1001
- * **mode** See `sync.push()` for details.
1002
- * Returns: See `sync.push()` for details.
990
+ - **stream** The readable stream.
991
+ - **path** See `sync.push()` for details.
992
+ - **mode** See `sync.push()` for details.
993
+ - Returns: See `sync.push()` for details.
1003
994
 
1004
- #### sync.readdir(path[, callback])
995
+ #### sync.readdir(path)
1005
996
 
1006
997
  Retrieves a list of directory entries (e.g. files) in the given path, not including the `.` and `..` entries, just like [`fs.readdir`][node-fs]. If given a non-directory path, no entries are returned.
1007
998
 
1008
- * **path** The path.
1009
- * **callback(err, files)** Optional. Use this or the returned `Promise`.
1010
- - **err** `null` when successful, `Error` otherwise.
1011
- - **files** An `Array` of [`fs.Stats`][node-fs-stats]-compatible instances. While the `stats.is*` methods are available, only the following properties are supported (in addition to the `name` field which contains the filename):
1012
- * **name** The filename.
1013
- * **mode** The raw mode.
1014
- * **size** The file size.
1015
- * **mtime** The time of last modification as a `Date`.
1016
- * Returns: `Promise`
1017
- * Resolves with: `files` (see callback)
999
+ - **path** The path.
1000
+ - **callback(err, files)** Optional. Use this or the returned `Promise`.
1001
+ - **err** `null` when successful, `Error` otherwise.
1002
+ - **files** An `Array` of [`fs.Stats`][node-fs-stats]-compatible instances. While the `stats.is*` methods are available, only the following properties are supported (in addition to the `name` field which contains the filename):
1003
+ - **name** The filename.
1004
+ - **mode** The raw mode.
1005
+ - **size** The file size.
1006
+ - **mtime** The time of last modification as a `Date`.
1007
+ - Returns: `Promise`
1008
+ - Resolves with: `files` (see callback)
1018
1009
 
1019
- #### sync.stat(path[, callback])
1010
+ #### sync.stat(path)
1020
1011
 
1021
1012
  Retrieves information about the given path.
1022
1013
 
1023
- * **path** The path.
1024
- * **callback(err, stats)** Optional. Use this or the returned `Promise`.
1025
- - **err** `null` when successful, `Error` otherwise.
1026
- - **stats** An [`fs.Stats`][node-fs-stats] instance. While the `stats.is*` methods are available, only the following properties are supported:
1027
- * **mode** The raw mode.
1028
- * **size** The file size.
1029
- * **mtime** The time of last modification as a `Date`.
1030
- * Returns: `Promise`
1031
- * Resolves with: `stats` (see callback)
1014
+ - **path** The path.
1015
+ - **callback(err, stats)** Optional. Use this or the returned `Promise`.
1016
+ - **err** `null` when successful, `Error` otherwise.
1017
+ - **stats** An [`fs.Stats`][node-fs-stats] instance. While the `stats.is*` methods are available, only the following properties are supported:
1018
+ - **mode** The raw mode.
1019
+ - **size** The file size.
1020
+ - **mtime** The time of last modification as a `Date`.
1021
+ - Returns: `Promise`
1022
+ - Resolves with: `stats` (see callback)
1032
1023
 
1033
1024
  #### sync.tempFile(path)
1034
1025
 
1035
1026
  A simple helper method for creating appropriate temporary filenames for pushing files. This is essentially the same as taking the basename of the file and appending it to `'/data/local/tmp/'`.
1036
1027
 
1037
- * **path** The path of the file.
1038
- * Returns: An appropriate temporary file path.
1028
+ - **path** The path of the file.
1029
+ - Returns: An appropriate temporary file path.
1039
1030
 
1040
1031
  ### PushTransfer
1041
1032
 
@@ -1043,18 +1034,18 @@ A simple EventEmitter, mainly for keeping track of the progress.
1043
1034
 
1044
1035
  List of events:
1045
1036
 
1046
- * **progress** **(stats)** Emitted when a chunk has been flushed to the ADB connection.
1047
- - **stats** An object with the following stats about the transfer:
1048
- * **bytesTransferred** The number of bytes transferred so far.
1049
- * **error** **(err)** Emitted on error.
1050
- - **err** An `Error`.
1051
- * **end** Emitted when the transfer has successfully completed.
1037
+ - **progress** **(stats)** Emitted when a chunk has been flushed to the ADB connection.
1038
+ - **stats** An object with the following stats about the transfer:
1039
+ - **bytesTransferred** The number of bytes transferred so far.
1040
+ - **error** **(err)** Emitted on error.
1041
+ - **err** An `Error`.
1042
+ - **end** Emitted when the transfer has successfully completed.
1052
1043
 
1053
1044
  #### pushTransfer.cancel()
1054
1045
 
1055
1046
  Cancels the transfer by ending both the stream that is being pushed and the sync connection. This will most likely end up creating a broken file on your device. **Use at your own risk.** Also note that you must create a new sync connection if you wish to continue using the sync service.
1056
1047
 
1057
- * Returns: The pushTransfer instance.
1048
+ - Returns: The pushTransfer instance.
1058
1049
 
1059
1050
  ### PullTransfer
1060
1051
 
@@ -1062,18 +1053,18 @@ Cancels the transfer by ending both the stream that is being pushed and the sync
1062
1053
 
1063
1054
  List of events:
1064
1055
 
1065
- * **progress** **(stats)** Emitted when a new chunk is received.
1066
- - **stats** An object with the following stats about the transfer:
1067
- * **bytesTransferred** The number of bytes transferred so far.
1068
- * **error** **(err)** Emitted on error.
1069
- - **err** An `Error`.
1070
- * **end** Emitted when the transfer has successfully completed.
1056
+ - **progress** **(stats)** Emitted when a new chunk is received.
1057
+ - **stats** An object with the following stats about the transfer:
1058
+ - **bytesTransferred** The number of bytes transferred so far.
1059
+ - **error** **(err)** Emitted on error.
1060
+ - **err** An `Error`.
1061
+ - **end** Emitted when the transfer has successfully completed.
1071
1062
 
1072
1063
  #### pullTransfer.cancel()
1073
1064
 
1074
1065
  Cancels the transfer by ending the connection. Can be useful for reading endless streams of data, such as `/dev/urandom` or `/dev/zero`, perhaps for benchmarking use. Note that you must create a new sync connection if you wish to continue using the sync service.
1075
1066
 
1076
- * Returns: The pullTransfer instance.
1067
+ - Returns: The pullTransfer instance.
1077
1068
 
1078
1069
  # Incompatible changes in version 2.x
1079
1070
 
@@ -1091,11 +1082,11 @@ Test coverage was also massively improved, although we've still got ways to go.
1091
1082
 
1092
1083
  ## More information
1093
1084
 
1094
- * [Android Debug Bridge][adb-site]
1095
- - [SERVICES.TXT][adb-services] (ADB socket protocol)
1096
- * [Android ADB Protocols][adb-protocols] (a blog post explaining the protocol)
1097
- * [adb.js][adb-js] (another Node.js ADB implementation)
1098
- * [ADB Chrome extension][chrome-adb]
1085
+ - [Android Debug Bridge][adb-site]
1086
+ - [SERVICES.TXT][adb-services] (ADB socket protocol)
1087
+ - [Android ADB Protocols][adb-protocols] (a blog post explaining the protocol)
1088
+ - [adb.js][adb-js] (another Node.js ADB implementation)
1089
+ - [ADB Chrome extension][chrome-adb]
1099
1090
 
1100
1091
  ## Contributing
1101
1092
 
@@ -1107,25 +1098,24 @@ See [LICENSE](LICENSE).
1107
1098
 
1108
1099
  Copyright © The OpenSTF Project. All Rights Reserved.
1109
1100
 
1110
- [nodejs]: <http://nodejs.org/>
1111
- [coffeescript]: <http://coffeescript.org/>
1112
- [npm]: <https://npmjs.org/>
1113
- [adb-js]: <https://github.com/flier/adb.js>
1114
- [adb-site]: <http://developer.android.com/tools/help/adb.html>
1115
- [adb-services]: <https://github.com/android/platform_system_core/blob/master/adb/SERVICES.TXT>
1116
- [adb-protocols]: <http://blogs.kgsoft.co.uk/2013_03_15_prg.htm>
1117
- [file_sync_service.h]: <https://github.com/android/platform_system_core/blob/master/adb/file_sync_service.h>
1118
- [chrome-adb]: <https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage>
1119
- [node-debug]: <https://npmjs.org/package/debug>
1120
- [net-connect]: <http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener>
1121
- [node-events]: <http://nodejs.org/api/events.html>
1122
- [node-stream]: <http://nodejs.org/api/stream.html>
1123
- [node-buffer]: <http://nodejs.org/api/buffer.html>
1124
- [node-net]: <http://nodejs.org/api/net.html>
1125
- [node-fs]: <http://nodejs.org/api/fs.html>
1126
- [node-fs-stats]: <http://nodejs.org/api/fs.html#fs_class_fs_stats>
1127
- [node-gm]: <https://github.com/aheckmann/gm>
1128
- [graphicsmagick]: <http://www.graphicsmagick.org/>
1129
- [imagemagick]: <http://www.imagemagick.org/>
1130
- [adbkit-logcat]: <https://npmjs.org/package/adbkit-logcat>
1131
- [adbkit-monkey]: <https://npmjs.org/package/adbkit-monkey>
1101
+ [nodejs]: http://nodejs.org/
1102
+ [npm]: https://npmjs.org/
1103
+ [adb-js]: https://github.com/flier/adb.js
1104
+ [adb-site]: http://developer.android.com/tools/help/adb.html
1105
+ [adb-services]: https://github.com/android/platform_system_core/blob/master/adb/SERVICES.TXT
1106
+ [adb-protocols]: http://blogs.kgsoft.co.uk/2013_03_15_prg.htm
1107
+ [file_sync_service.h]: https://github.com/android/platform_system_core/blob/master/adb/file_sync_service.h
1108
+ [chrome-adb]: https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage
1109
+ [node-debug]: https://npmjs.org/package/debug
1110
+ [net-connect]: http://nodejs.org/api/net.html#net_net_connect_options_connectionlistener
1111
+ [node-events]: http://nodejs.org/api/events.html
1112
+ [node-stream]: http://nodejs.org/api/stream.html
1113
+ [node-buffer]: http://nodejs.org/api/buffer.html
1114
+ [node-net]: http://nodejs.org/api/net.html
1115
+ [node-fs]: http://nodejs.org/api/fs.html
1116
+ [node-fs-stats]: http://nodejs.org/api/fs.html#fs_class_fs_stats
1117
+ [node-gm]: https://github.com/aheckmann/gm
1118
+ [graphicsmagick]: http://www.graphicsmagick.org/
1119
+ [imagemagick]: http://www.imagemagick.org/
1120
+ [adbkit-logcat]: https://npmjs.org/package/adbkit-logcat
1121
+ [adbkit-monkey]: https://npmjs.org/package/adbkit-monkey