adbcentral 1.0.0__tar.gz

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 (348) hide show
  1. adbcentral-1.0.0/ARCHITECTURE.md +1111 -0
  2. adbcentral-1.0.0/CHANGELOG.md +70 -0
  3. adbcentral-1.0.0/CLI.md +1614 -0
  4. adbcentral-1.0.0/EMBEDDING.md +517 -0
  5. adbcentral-1.0.0/LICENSE +674 -0
  6. adbcentral-1.0.0/MANIFEST.in +30 -0
  7. adbcentral-1.0.0/PKG-INFO +1167 -0
  8. adbcentral-1.0.0/README.md +1119 -0
  9. adbcentral-1.0.0/adbcentral/README.md +719 -0
  10. adbcentral-1.0.0/adbcentral/__init__.py +178 -0
  11. adbcentral-1.0.0/adbcentral/__main__.py +6 -0
  12. adbcentral-1.0.0/adbcentral/adbproc.py +443 -0
  13. adbcentral-1.0.0/adbcentral/assets/icon-light.ico +0 -0
  14. adbcentral-1.0.0/adbcentral/assets/icon-light.png +0 -0
  15. adbcentral-1.0.0/adbcentral/assets/icon.ico +0 -0
  16. adbcentral-1.0.0/adbcentral/assets/icon.png +0 -0
  17. adbcentral-1.0.0/adbcentral/audio.py +976 -0
  18. adbcentral-1.0.0/adbcentral/bin/adbcentral-gui.exe +4 -0
  19. adbcentral-1.0.0/adbcentral/cli.py +3652 -0
  20. adbcentral-1.0.0/adbcentral/config.py +397 -0
  21. adbcentral-1.0.0/adbcentral/core.py +6761 -0
  22. adbcentral-1.0.0/adbcentral/devices.py +1544 -0
  23. adbcentral-1.0.0/adbcentral/embed.py +386 -0
  24. adbcentral-1.0.0/adbcentral/embed_qt.py +223 -0
  25. adbcentral-1.0.0/adbcentral/exceptions.py +146 -0
  26. adbcentral-1.0.0/adbcentral/gui/__init__.py +22 -0
  27. adbcentral-1.0.0/adbcentral/gui/__main__.py +7 -0
  28. adbcentral-1.0.0/adbcentral/gui/adb_path.py +90 -0
  29. adbcentral-1.0.0/adbcentral/gui/app.py +643 -0
  30. adbcentral-1.0.0/adbcentral/gui/apps_panel.py +476 -0
  31. adbcentral-1.0.0/adbcentral/gui/connect_dialog.py +750 -0
  32. adbcentral-1.0.0/adbcentral/gui/console.py +4060 -0
  33. adbcentral-1.0.0/adbcentral/gui/control_api.py +752 -0
  34. adbcentral-1.0.0/adbcentral/gui/controls_panel.py +884 -0
  35. adbcentral-1.0.0/adbcentral/gui/deploy_dialog.py +404 -0
  36. adbcentral-1.0.0/adbcentral/gui/device_access.py +154 -0
  37. adbcentral-1.0.0/adbcentral/gui/device_commands.py +145 -0
  38. adbcentral-1.0.0/adbcentral/gui/device_tab.py +7387 -0
  39. adbcentral-1.0.0/adbcentral/gui/display_controls.py +147 -0
  40. adbcentral-1.0.0/adbcentral/gui/display_wall.py +612 -0
  41. adbcentral-1.0.0/adbcentral/gui/embedding.py +452 -0
  42. adbcentral-1.0.0/adbcentral/gui/file_browser.py +4302 -0
  43. adbcentral-1.0.0/adbcentral/gui/file_icons.py +295 -0
  44. adbcentral-1.0.0/adbcentral/gui/file_open.py +283 -0
  45. adbcentral-1.0.0/adbcentral/gui/fileutil.py +1009 -0
  46. adbcentral-1.0.0/adbcentral/gui/flowlayout.py +189 -0
  47. adbcentral-1.0.0/adbcentral/gui/icons.py +617 -0
  48. adbcentral-1.0.0/adbcentral/gui/local_terminal.py +1363 -0
  49. adbcentral-1.0.0/adbcentral/gui/log_panel.py +277 -0
  50. adbcentral-1.0.0/adbcentral/gui/logcat_view.py +2326 -0
  51. adbcentral-1.0.0/adbcentral/gui/main_window.py +4624 -0
  52. adbcentral-1.0.0/adbcentral/gui/mirror_panel.py +6137 -0
  53. adbcentral-1.0.0/adbcentral/gui/page_bar.py +266 -0
  54. adbcentral-1.0.0/adbcentral/gui/phone_panel.py +1864 -0
  55. adbcentral-1.0.0/adbcentral/gui/qtutil.py +532 -0
  56. adbcentral-1.0.0/adbcentral/gui/report_dialog.py +279 -0
  57. adbcentral-1.0.0/adbcentral/gui/screen_view.py +274 -0
  58. adbcentral-1.0.0/adbcentral/gui/screencap_view.py +1304 -0
  59. adbcentral-1.0.0/adbcentral/gui/scrollback.py +703 -0
  60. adbcentral-1.0.0/adbcentral/gui/session_dialog.py +281 -0
  61. adbcentral-1.0.0/adbcentral/gui/sessions.py +432 -0
  62. adbcentral-1.0.0/adbcentral/gui/settings.py +581 -0
  63. adbcentral-1.0.0/adbcentral/gui/settings_dialog.py +552 -0
  64. adbcentral-1.0.0/adbcentral/gui/shell_colors.py +265 -0
  65. adbcentral-1.0.0/adbcentral/gui/shell_icons.py +422 -0
  66. adbcentral-1.0.0/adbcentral/gui/status_bar.py +294 -0
  67. adbcentral-1.0.0/adbcentral/gui/taskbar.py +152 -0
  68. adbcentral-1.0.0/adbcentral/gui/terminal.py +126 -0
  69. adbcentral-1.0.0/adbcentral/gui/theme.py +1429 -0
  70. adbcentral-1.0.0/adbcentral/gui/tools_window.py +409 -0
  71. adbcentral-1.0.0/adbcentral/gui/transfer_log.py +624 -0
  72. adbcentral-1.0.0/adbcentral/gui/transfer_panel.py +667 -0
  73. adbcentral-1.0.0/adbcentral/gui/vtscreen.py +1112 -0
  74. adbcentral-1.0.0/adbcentral/gui/welcome.py +282 -0
  75. adbcentral-1.0.0/adbcentral/launcher.py +780 -0
  76. adbcentral-1.0.0/adbcentral/licenses/GPL-3.0.txt +674 -0
  77. adbcentral-1.0.0/adbcentral/licenses/LGPL-3.0.txt +165 -0
  78. adbcentral-1.0.0/adbcentral/licenses/THIRD-PARTY-NOTICES.md +59 -0
  79. adbcentral-1.0.0/adbcentral/netdoctor.py +391 -0
  80. adbcentral-1.0.0/adbcentral/netfetch.py +340 -0
  81. adbcentral-1.0.0/adbcentral/proctree.py +346 -0
  82. adbcentral-1.0.0/adbcentral/py.typed +0 -0
  83. adbcentral-1.0.0/adbcentral/remote_deploy.py +472 -0
  84. adbcentral-1.0.0/adbcentral/remotefs.py +712 -0
  85. adbcentral-1.0.0/adbcentral/results.py +274 -0
  86. adbcentral-1.0.0/adbcentral/scrcpy.py +901 -0
  87. adbcentral-1.0.0/adbcentral/tools.py +1588 -0
  88. adbcentral-1.0.0/adbcentral/toolsdl.py +2304 -0
  89. adbcentral-1.0.0/adbcentral/touch.py +257 -0
  90. adbcentral-1.0.0/adbcentral/update.py +617 -0
  91. adbcentral-1.0.0/adbcentral/winshell.py +527 -0
  92. adbcentral-1.0.0/adbcentral-gui.spec +123 -0
  93. adbcentral-1.0.0/adbcentral.egg-info/PKG-INFO +1167 -0
  94. adbcentral-1.0.0/adbcentral.egg-info/SOURCES.txt +346 -0
  95. adbcentral-1.0.0/adbcentral.egg-info/dependency_links.txt +1 -0
  96. adbcentral-1.0.0/adbcentral.egg-info/entry_points.txt +7 -0
  97. adbcentral-1.0.0/adbcentral.egg-info/requires.txt +19 -0
  98. adbcentral-1.0.0/adbcentral.egg-info/top_level.txt +1 -0
  99. adbcentral-1.0.0/examples/embed_in_qt.py +88 -0
  100. adbcentral-1.0.0/examples/examples.py +59 -0
  101. adbcentral-1.0.0/pyproject.toml +78 -0
  102. adbcentral-1.0.0/requirements.txt +14 -0
  103. adbcentral-1.0.0/ruff.toml +20 -0
  104. adbcentral-1.0.0/scripts/build_exe.py +50 -0
  105. adbcentral-1.0.0/scripts/gui_entry.py +87 -0
  106. adbcentral-1.0.0/scripts/make_icon.py +120 -0
  107. adbcentral-1.0.0/scripts/release.py +285 -0
  108. adbcentral-1.0.0/scripts/release_notes.py +99 -0
  109. adbcentral-1.0.0/scripts/run_tests.py +47 -0
  110. adbcentral-1.0.0/setup.cfg +4 -0
  111. adbcentral-1.0.0/tests/conftest.py +515 -0
  112. adbcentral-1.0.0/tests/fakeadb.py +256 -0
  113. adbcentral-1.0.0/tests/fakescrcpy.py +197 -0
  114. adbcentral-1.0.0/tests/test_adb_clients.py +415 -0
  115. adbcentral-1.0.0/tests/test_adb_download_runs_here.py +212 -0
  116. adbcentral-1.0.0/tests/test_adb_exec.py +187 -0
  117. adbcentral-1.0.0/tests/test_adb_host_service.py +127 -0
  118. adbcentral-1.0.0/tests/test_adb_processes.py +1169 -0
  119. adbcentral-1.0.0/tests/test_adb_resolution.py +81 -0
  120. adbcentral-1.0.0/tests/test_adb_restart_hold.py +347 -0
  121. adbcentral-1.0.0/tests/test_adb_server_address.py +73 -0
  122. adbcentral-1.0.0/tests/test_adb_server_exit.py +263 -0
  123. adbcentral-1.0.0/tests/test_adb_server_lifecycle.py +600 -0
  124. adbcentral-1.0.0/tests/test_adb_status_recovery.py +415 -0
  125. adbcentral-1.0.0/tests/test_android_shell_fallback.py +194 -0
  126. adbcentral-1.0.0/tests/test_android_shell_input.py +182 -0
  127. adbcentral-1.0.0/tests/test_android_shell_interrupt.py +129 -0
  128. adbcentral-1.0.0/tests/test_android_shell_lifecycle.py +209 -0
  129. adbcentral-1.0.0/tests/test_android_shell_pty.py +567 -0
  130. adbcentral-1.0.0/tests/test_android_shell_setting.py +60 -0
  131. adbcentral-1.0.0/tests/test_android_shell_stop.py +227 -0
  132. adbcentral-1.0.0/tests/test_android_tab_completion.py +235 -0
  133. adbcentral-1.0.0/tests/test_apps_filter.py +57 -0
  134. adbcentral-1.0.0/tests/test_apps_install.py +123 -0
  135. adbcentral-1.0.0/tests/test_attached_adb_errors.py +48 -0
  136. adbcentral-1.0.0/tests/test_bugreport_path.py +64 -0
  137. adbcentral-1.0.0/tests/test_bundled_exe.py +263 -0
  138. adbcentral-1.0.0/tests/test_call_state.py +95 -0
  139. adbcentral-1.0.0/tests/test_child_shutdown.py +124 -0
  140. adbcentral-1.0.0/tests/test_cli_arguments.py +282 -0
  141. adbcentral-1.0.0/tests/test_cli_commands.py +691 -0
  142. adbcentral-1.0.0/tests/test_cli_docs.py +43 -0
  143. adbcentral-1.0.0/tests/test_cli_doctor.py +85 -0
  144. adbcentral-1.0.0/tests/test_cli_json_output.py +96 -0
  145. adbcentral-1.0.0/tests/test_cli_process.py +83 -0
  146. adbcentral-1.0.0/tests/test_cli_streaming.py +163 -0
  147. adbcentral-1.0.0/tests/test_cli_timed_out_json.py +86 -0
  148. adbcentral-1.0.0/tests/test_closing_screens.py +667 -0
  149. adbcentral-1.0.0/tests/test_connect_authorization.py +275 -0
  150. adbcentral-1.0.0/tests/test_connect_dialog_live.py +149 -0
  151. adbcentral-1.0.0/tests/test_connect_dialog_share.py +489 -0
  152. adbcentral-1.0.0/tests/test_connect_failure_message.py +108 -0
  153. adbcentral-1.0.0/tests/test_connect_path.py +253 -0
  154. adbcentral-1.0.0/tests/test_connect_recent_hosts.py +53 -0
  155. adbcentral-1.0.0/tests/test_connection_ownership.py +71 -0
  156. adbcentral-1.0.0/tests/test_console_drain.py +193 -0
  157. adbcentral-1.0.0/tests/test_console_echo.py +288 -0
  158. adbcentral-1.0.0/tests/test_console_edit_region.py +768 -0
  159. adbcentral-1.0.0/tests/test_console_escapes.py +227 -0
  160. adbcentral-1.0.0/tests/test_console_housekeeping.py +82 -0
  161. adbcentral-1.0.0/tests/test_console_lock.py +68 -0
  162. adbcentral-1.0.0/tests/test_console_notices.py +501 -0
  163. adbcentral-1.0.0/tests/test_console_reader.py +185 -0
  164. adbcentral-1.0.0/tests/test_control_api.py +653 -0
  165. adbcentral-1.0.0/tests/test_deploy_budget.py +85 -0
  166. adbcentral-1.0.0/tests/test_deploy_dialog_hosts.py +170 -0
  167. adbcentral-1.0.0/tests/test_deploy_dialog_log.py +40 -0
  168. adbcentral-1.0.0/tests/test_deploy_missing_adb.py +257 -0
  169. adbcentral-1.0.0/tests/test_device_command_results.py +105 -0
  170. adbcentral-1.0.0/tests/test_device_control.py +992 -0
  171. adbcentral-1.0.0/tests/test_device_control_commands.py +242 -0
  172. adbcentral-1.0.0/tests/test_device_file_commands.py +290 -0
  173. adbcentral-1.0.0/tests/test_device_keyboard.py +500 -0
  174. adbcentral-1.0.0/tests/test_device_kind.py +76 -0
  175. adbcentral-1.0.0/tests/test_device_list_failures.py +106 -0
  176. adbcentral-1.0.0/tests/test_device_probe_cleanup.py +77 -0
  177. adbcentral-1.0.0/tests/test_device_probe_retry.py +190 -0
  178. adbcentral-1.0.0/tests/test_device_tracker_protocol.py +92 -0
  179. adbcentral-1.0.0/tests/test_display_retries.py +330 -0
  180. adbcentral-1.0.0/tests/test_display_tile_teardown.py +305 -0
  181. adbcentral-1.0.0/tests/test_display_tiles.py +206 -0
  182. adbcentral-1.0.0/tests/test_displays.py +1289 -0
  183. adbcentral-1.0.0/tests/test_displays_start_stopped.py +389 -0
  184. adbcentral-1.0.0/tests/test_dll_directory_during_spawn.py +54 -0
  185. adbcentral-1.0.0/tests/test_drop_is_copy.py +69 -0
  186. adbcentral-1.0.0/tests/test_embedding_minimum.py +271 -0
  187. adbcentral-1.0.0/tests/test_embedding_process.py +244 -0
  188. adbcentral-1.0.0/tests/test_engine_cli_features.py +688 -0
  189. adbcentral-1.0.0/tests/test_engine_hardening.py +220 -0
  190. adbcentral-1.0.0/tests/test_engine_review.py +1835 -0
  191. adbcentral-1.0.0/tests/test_exit_disconnect.py +109 -0
  192. adbcentral-1.0.0/tests/test_exit_status_after_resize.py +103 -0
  193. adbcentral-1.0.0/tests/test_file_browser_fixes.py +683 -0
  194. adbcentral-1.0.0/tests/test_file_browser_selection.py +461 -0
  195. adbcentral-1.0.0/tests/test_file_icons.py +289 -0
  196. adbcentral-1.0.0/tests/test_file_transfers.py +395 -0
  197. adbcentral-1.0.0/tests/test_files_cancel_leftover.py +92 -0
  198. adbcentral-1.0.0/tests/test_files_device_operations.py +1103 -0
  199. adbcentral-1.0.0/tests/test_files_done_mark.py +92 -0
  200. adbcentral-1.0.0/tests/test_files_large_folders.py +188 -0
  201. adbcentral-1.0.0/tests/test_files_layout.py +136 -0
  202. adbcentral-1.0.0/tests/test_files_local_operations.py +528 -0
  203. adbcentral-1.0.0/tests/test_files_open.py +543 -0
  204. adbcentral-1.0.0/tests/test_files_tabs.py +266 -0
  205. adbcentral-1.0.0/tests/test_files_unaddressable_names.py +351 -0
  206. adbcentral-1.0.0/tests/test_gui.py +982 -0
  207. adbcentral-1.0.0/tests/test_gui_core_review.py +1014 -0
  208. adbcentral-1.0.0/tests/test_gui_icons.py +186 -0
  209. adbcentral-1.0.0/tests/test_gui_panels_review.py +1594 -0
  210. adbcentral-1.0.0/tests/test_gui_shell.py +261 -0
  211. adbcentral-1.0.0/tests/test_gui_tools_and_serials.py +333 -0
  212. adbcentral-1.0.0/tests/test_history_limit.py +281 -0
  213. adbcentral-1.0.0/tests/test_history_owner_sweep.py +95 -0
  214. adbcentral-1.0.0/tests/test_hung_scrcpy_window.py +358 -0
  215. adbcentral-1.0.0/tests/test_kept_window_connection.py +89 -0
  216. adbcentral-1.0.0/tests/test_keys_name_display_zero.py +321 -0
  217. adbcentral-1.0.0/tests/test_licences.py +108 -0
  218. adbcentral-1.0.0/tests/test_local_adb_shell.py +280 -0
  219. adbcentral-1.0.0/tests/test_local_adb_target.py +39 -0
  220. adbcentral-1.0.0/tests/test_local_completion.py +101 -0
  221. adbcentral-1.0.0/tests/test_local_ctrl_c.py +646 -0
  222. adbcentral-1.0.0/tests/test_local_pipelines.py +262 -0
  223. adbcentral-1.0.0/tests/test_local_prompt.py +244 -0
  224. adbcentral-1.0.0/tests/test_local_prompt_mark.py +97 -0
  225. adbcentral-1.0.0/tests/test_local_remote_server.py +121 -0
  226. adbcentral-1.0.0/tests/test_local_session.py +534 -0
  227. adbcentral-1.0.0/tests/test_local_shell_rewrites.py +64 -0
  228. adbcentral-1.0.0/tests/test_local_shell_stop.py +197 -0
  229. adbcentral-1.0.0/tests/test_local_stop.py +277 -0
  230. adbcentral-1.0.0/tests/test_local_terminal.py +468 -0
  231. adbcentral-1.0.0/tests/test_log_levels.py +120 -0
  232. adbcentral-1.0.0/tests/test_log_record.py +134 -0
  233. adbcentral-1.0.0/tests/test_logcat_cli.py +142 -0
  234. adbcentral-1.0.0/tests/test_logcat_engine.py +268 -0
  235. adbcentral-1.0.0/tests/test_logcat_filter_guard.py +177 -0
  236. adbcentral-1.0.0/tests/test_logcat_old_devices.py +83 -0
  237. adbcentral-1.0.0/tests/test_logcat_panel.py +719 -0
  238. adbcentral-1.0.0/tests/test_logcat_resume.py +163 -0
  239. adbcentral-1.0.0/tests/test_logcat_without_tail_option.py +150 -0
  240. adbcentral-1.0.0/tests/test_long_command_limits.py +127 -0
  241. adbcentral-1.0.0/tests/test_main_window_actions.py +1216 -0
  242. adbcentral-1.0.0/tests/test_mirror_route.py +71 -0
  243. adbcentral-1.0.0/tests/test_mirror_screen.py +1221 -0
  244. adbcentral-1.0.0/tests/test_mount_and_update_notice.py +234 -0
  245. adbcentral-1.0.0/tests/test_moved_adb_port.py +80 -0
  246. adbcentral-1.0.0/tests/test_new_look.py +446 -0
  247. adbcentral-1.0.0/tests/test_newest_copy_and_network.py +513 -0
  248. adbcentral-1.0.0/tests/test_offline.py +180 -0
  249. adbcentral-1.0.0/tests/test_package_commands.py +201 -0
  250. adbcentral-1.0.0/tests/test_packaging.py +151 -0
  251. adbcentral-1.0.0/tests/test_phone_adb_gate.py +247 -0
  252. adbcentral-1.0.0/tests/test_phone_automotive.py +798 -0
  253. adbcentral-1.0.0/tests/test_phone_call_state_recovery.py +243 -0
  254. adbcentral-1.0.0/tests/test_phone_end_call.py +112 -0
  255. adbcentral-1.0.0/tests/test_phone_panel.py +496 -0
  256. adbcentral-1.0.0/tests/test_phone_recipient.py +82 -0
  257. adbcentral-1.0.0/tests/test_phone_support.py +117 -0
  258. adbcentral-1.0.0/tests/test_phone_support_recheck.py +140 -0
  259. adbcentral-1.0.0/tests/test_powershell_execution_policy.py +127 -0
  260. adbcentral-1.0.0/tests/test_powershell_width_follows_view.py +149 -0
  261. adbcentral-1.0.0/tests/test_proctree.py +101 -0
  262. adbcentral-1.0.0/tests/test_pulled_file_names.py +337 -0
  263. adbcentral-1.0.0/tests/test_pyside6_port.py +74 -0
  264. adbcentral-1.0.0/tests/test_quick_identity.py +64 -0
  265. adbcentral-1.0.0/tests/test_quick_open.py +274 -0
  266. adbcentral-1.0.0/tests/test_recorder_close.py +176 -0
  267. adbcentral-1.0.0/tests/test_recording_displays.py +111 -0
  268. adbcentral-1.0.0/tests/test_release_script.py +103 -0
  269. adbcentral-1.0.0/tests/test_remote_server_endpoints.py +109 -0
  270. adbcentral-1.0.0/tests/test_rename_fallback.py +272 -0
  271. adbcentral-1.0.0/tests/test_rename_onto_folder_link.py +96 -0
  272. adbcentral-1.0.0/tests/test_report_summary.py +88 -0
  273. adbcentral-1.0.0/tests/test_review_fixes.py +237 -0
  274. adbcentral-1.0.0/tests/test_root_and_forwarding.py +119 -0
  275. adbcentral-1.0.0/tests/test_save_write_over.py +186 -0
  276. adbcentral-1.0.0/tests/test_saved_target_ports.py +41 -0
  277. adbcentral-1.0.0/tests/test_scrcpy_cleanup.py +220 -0
  278. adbcentral-1.0.0/tests/test_scrcpy_like_by_hand.py +400 -0
  279. adbcentral-1.0.0/tests/test_scrcpy_list_displays.py +99 -0
  280. adbcentral-1.0.0/tests/test_scrcpy_renderer_fallback.py +181 -0
  281. adbcentral-1.0.0/tests/test_scrcpy_start_and_audio.py +446 -0
  282. adbcentral-1.0.0/tests/test_scrcpy_stop_all.py +60 -0
  283. adbcentral-1.0.0/tests/test_screen_flood.py +216 -0
  284. adbcentral-1.0.0/tests/test_screen_quality_and_pages.py +529 -0
  285. adbcentral-1.0.0/tests/test_screen_recording.py +554 -0
  286. adbcentral-1.0.0/tests/test_screen_start_and_zoom.py +448 -0
  287. adbcentral-1.0.0/tests/test_screencap_view.py +782 -0
  288. adbcentral-1.0.0/tests/test_self_update.py +339 -0
  289. adbcentral-1.0.0/tests/test_self_update_from_the_window.py +120 -0
  290. adbcentral-1.0.0/tests/test_session_dialog.py +86 -0
  291. adbcentral-1.0.0/tests/test_sessions_transient_read.py +80 -0
  292. adbcentral-1.0.0/tests/test_settings_migration.py +75 -0
  293. adbcentral-1.0.0/tests/test_settings_reads.py +81 -0
  294. adbcentral-1.0.0/tests/test_settings_transient_read.py +101 -0
  295. adbcentral-1.0.0/tests/test_share_from_the_window.py +264 -0
  296. adbcentral-1.0.0/tests/test_shared_server.py +419 -0
  297. adbcentral-1.0.0/tests/test_shell_colors.py +256 -0
  298. adbcentral-1.0.0/tests/test_shell_exit_cleanup.py +138 -0
  299. adbcentral-1.0.0/tests/test_shell_session_read.py +75 -0
  300. adbcentral-1.0.0/tests/test_shortcuts.py +341 -0
  301. adbcentral-1.0.0/tests/test_shutdown.py +149 -0
  302. adbcentral-1.0.0/tests/test_smooth_window.py +463 -0
  303. adbcentral-1.0.0/tests/test_spawned_adb_errors.py +70 -0
  304. adbcentral-1.0.0/tests/test_stale_adb_setting.py +89 -0
  305. adbcentral-1.0.0/tests/test_stale_adbcentral_adb.py +141 -0
  306. adbcentral-1.0.0/tests/test_startup_task_files.py +162 -0
  307. adbcentral-1.0.0/tests/test_status_bar.py +168 -0
  308. adbcentral-1.0.0/tests/test_store_integrity.py +233 -0
  309. adbcentral-1.0.0/tests/test_suite_isolation.py +50 -0
  310. adbcentral-1.0.0/tests/test_tab_close_connections.py +317 -0
  311. adbcentral-1.0.0/tests/test_tap_burst.py +521 -0
  312. adbcentral-1.0.0/tests/test_taskbar.py +176 -0
  313. adbcentral-1.0.0/tests/test_terminal_colors.py +755 -0
  314. adbcentral-1.0.0/tests/test_terminal_completion_gate.py +141 -0
  315. adbcentral-1.0.0/tests/test_terminal_interrupt.py +398 -0
  316. adbcentral-1.0.0/tests/test_terminal_keys.py +114 -0
  317. adbcentral-1.0.0/tests/test_terminal_long_lines.py +265 -0
  318. adbcentral-1.0.0/tests/test_terminal_paste.py +758 -0
  319. adbcentral-1.0.0/tests/test_terminal_screen.py +773 -0
  320. adbcentral-1.0.0/tests/test_terminal_send_key_menu.py +106 -0
  321. adbcentral-1.0.0/tests/test_terminal_session.py +150 -0
  322. adbcentral-1.0.0/tests/test_terminal_size.py +100 -0
  323. adbcentral-1.0.0/tests/test_text_and_sizes.py +45 -0
  324. adbcentral-1.0.0/tests/test_theme_images.py +70 -0
  325. adbcentral-1.0.0/tests/test_themes.py +1250 -0
  326. adbcentral-1.0.0/tests/test_this_pc_adb_server.py +57 -0
  327. adbcentral-1.0.0/tests/test_toasts_and_targets.py +1551 -0
  328. adbcentral-1.0.0/tests/test_tool_discovery.py +184 -0
  329. adbcentral-1.0.0/tests/test_tools_ensured_per_tool.py +50 -0
  330. adbcentral-1.0.0/tests/test_tools_install.py +325 -0
  331. adbcentral-1.0.0/tests/test_tools_newest_and_updates.py +323 -0
  332. adbcentral-1.0.0/tests/test_toolsdl.py +91 -0
  333. adbcentral-1.0.0/tests/test_transfer_log.py +493 -0
  334. adbcentral-1.0.0/tests/test_transfer_outcome.py +175 -0
  335. adbcentral-1.0.0/tests/test_transfer_panel.py +425 -0
  336. adbcentral-1.0.0/tests/test_transfer_progress.py +483 -0
  337. adbcentral-1.0.0/tests/test_transfer_replan.py +96 -0
  338. adbcentral-1.0.0/tests/test_typed_ahead_lines.py +210 -0
  339. adbcentral-1.0.0/tests/test_uncaught_errors.py +223 -0
  340. adbcentral-1.0.0/tests/test_unit.py +1677 -0
  341. adbcentral-1.0.0/tests/test_upgrade_shortcuts.py +210 -0
  342. adbcentral-1.0.0/tests/test_vt_screen.py +819 -0
  343. adbcentral-1.0.0/tests/test_windows_identity.py +801 -0
  344. adbcentral-1.0.0/tests/test_winget_mode_and_doctor.py +327 -0
  345. adbcentral-1.0.0/tests/test_winget_tools.py +491 -0
  346. adbcentral-1.0.0/tests/test_winrm_session.py +64 -0
  347. adbcentral-1.0.0/tests/test_wireless_debugging_serials.py +66 -0
  348. adbcentral-1.0.0/tests/test_write_access.py +421 -0
@@ -0,0 +1,1111 @@
1
+ # ADB Central — Architecture
2
+
3
+ This is a tour of how the codebase fits together: the layers, who calls whom, and
4
+ the few design decisions worth knowing before you change anything.
5
+
6
+ ## The one rule
7
+
8
+ There is **one engine** (`adbcentral.core.ADBHandler`) and **three thin
9
+ front-ends** on top of it — the Python API *is* the engine, the CLI parses
10
+ arguments and calls it, and the GUI calls it from background threads. No device
11
+ logic lives in the CLI or the GUI. If you add a capability, you add it to the
12
+ engine; the CLI and GUI just expose it.
13
+
14
+ ```
15
+ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐
16
+ │ Python API │ │ CLI │ │ GUI │
17
+ │ (import it) │ │ (argparse) │ │ (PySide6) │
18
+ └───────┬───────┘ └───────┬───────┘ └───────┬───────┘
19
+ └───────────────────┼───────────────────┘
20
+ ▼
21
+ ┌─────────────────────────────┐
22
+ │ adbcentral.core.ADBHandler │ the engine
23
+ └─────────────┬───────────────┘
24
+ ▼
25
+ adb / scrcpy (installed on first run)
26
+ ▼
27
+ device (USB · TCP/IP · remote adb server)
28
+ ```
29
+
30
+ ## Package layout
31
+
32
+ ```
33
+ adbcentral/
34
+ ├── __init__.py public API surface (__all__) + __version__
35
+ ├── __main__.py enables `python -m adbcentral`
36
+ ├── core.py ADBHandler — the engine. Every device operation.
37
+ ├── adbproc.py how an adb client is started (a kill-on-close job on Windows), waited for
38
+ │ (cancel, time limit) and read (UTF-8, else the OEM code page)
39
+ ├── config.py ADBConfig, ScrcpyOptions (dataclasses)
40
+ ├── results.py CommandResult/TransferResult/StreamResult/OperationResult, strip_ansi
41
+ ├── exceptions.py ADBError hierarchy
42
+ ├── devices.py enumerate devices; share/serve helpers (shared server, firewall, startup task)
43
+ ├── scrcpy.py launch scrcpy; remote-tunnel + host resolution; software-render env;
44
+ │ did it really start (wait_started) and scrcpy's own words when not (scrcpy_failure)
45
+ ├── audio.py a device's playback audio through scrcpy, no window: WAV/Opus, live levels + PCM
46
+ ├── tools.py locate adb/scrcpy by absolute path (the newest of winget's and ~/.adbcentral/tools,
47
+ │ PATH's folders, an SDK); releases read from the executables (tool_version);
48
+ │ Windows' own programs by full path; the adb server's one starter and stopper; diagnose()
49
+ ├── toolsdl.py download/upgrade adb + scrcpy into ~/.adbcentral/tools, where a build exists and runs;
50
+ │ the once-a-day automatic update (auto_update) that never stops the adb server
51
+ ├── update.py self-update: is a newer release out, can pip install it here, pip-upgrade, relaunch
52
+ ├── proctree.py end a process tree without taking down an adb server; the one way a child is stopped
53
+ ├── touch.py the pure parts of rapid tap bursts (see below)
54
+ ├── remote_deploy.py deploy 'serve' to remote Windows hosts over WinRM (pywinrm/NTLM)
55
+ ├── remotefs.py device-file shell helpers (ls parsing, mv/cp/rm/probe) shared by the engine and the Files tab
56
+ ├── cli.py argparse front-end; console-script entry points
57
+ ├── embed.py start ADB Central inside another program's window and drive its control API (stdlib only)
58
+ ├── embed_qt.py ADBCentralWidget: that, as a widget for PyQt5, PySide6, PyQt6 or PySide2
59
+ ├── launcher.py Windows: the GUI as ADBCentral.exe, a branded copy of this Python (see below)
60
+ ├── winshell.py Windows: taskbar mode, window app ID + pin command, .lnk shortcuts (ctypes COM)
61
+ ├── assets/ icon.ico / icon.png (dark), icon-light.ico / icon-light.png
62
+ └── gui/ the PySide6 (Qt 6) application (see below)
63
+ ```
64
+
65
+ ## The engine — `core.ADBHandler`
66
+
67
+ A handler is bound to one target via `ADBConfig` (a USB serial, a `host:port`
68
+ network device, or a device on a **remote adb server**). Construction is cheap;
69
+ `connect()` does the handshake.
70
+
71
+ Two things shape every method:
72
+
73
+ - **`_run` / `_run_global`** build the right `adb` command line. `_base()` injects
74
+ `-s <serial>` and, for a remote server, `-H <host> -P <port>` — so the *same*
75
+ code drives a local or remote device with no special-casing upstream.
76
+ - **safe mode.** Methods take `safe=None|True|False`. In raw mode they return a
77
+ result dataclass and raise on failure (good for scripts). In **safe mode**
78
+ (`ADBHandler(cfg, safe=True)`, what the GUI uses) they wrap everything in
79
+ `_guard()` and return an `OperationResult` instead of throwing, so a misbehaving
80
+ device can't crash the UI. A `log_callback` receives the real `adb` command line,
81
+ its duration/exit code, and full error text.
82
+
83
+ Logging levels matter: the raw `$ adb …` command trace is emitted at **DEBUG**,
84
+ and meaningful events at INFO/WARNING/ERROR, so the GUI log can hide the noise by
85
+ default and reveal it on demand.
86
+
87
+ Helpers worth knowing: `ShellSession` (a persistent interactive shell with
88
+ `send`/`read`; `read()` returns what has arrived and never waits, on any
89
+ platform, so a script may poll an idle shell), `iter_lines`/`stream` (live
90
+ logcat), `capture_png` and `screen_record` (multi-strategy capture that survives
91
+ RDP), and `mirror` (scrcpy).
92
+
93
+ A few rules hold across the methods:
94
+
95
+ - **Starting adb.** A one-shot command runs through `_exec`; a child that is
96
+ read while it runs (a push or pull, `iter_lines` and what is built on it,
97
+ `open_shell`, `popen`, the screencap stream, the recorder) starts through
98
+ `_spawn`. Both turn an adb that cannot be started (locked, quarantined, being
99
+ replaced) into an `ADBError`, so no caller ever sees a bare `OSError`. A
100
+ `cancel` event (`_exec`, `shell(cancel=…)`) lets another thread call a
101
+ command off: adb is killed at once and the call fails with
102
+ `ADBConnectionError`.
103
+ - **Time limits.** `command_timeout` (60 s) is meant for quick commands. A
104
+ command that runs as long as its data takes keeps a limit of its own, which
105
+ `_work_timeout` only ever raises: an install (five minutes, ten for split
106
+ APKs, plus the time the files take at 128 KB/s), a device copy (ten minutes)
107
+ and a delete (five) get the longer of that and `command_timeout`, and no
108
+ limit at all when `command_timeout` is None (the CLI's `--timeout 0`). For
109
+ a push or pull see `transfer_timeout` below.
110
+ - **The device's own answer decides.** An install or uninstall worked when adb
111
+ ended well *and* the package manager said `Success` on a line of its own
112
+ (`_pm_answer`; a staged install says `Success.` and more on that line): the
113
+ word anywhere else is not its answer (adb names the APK in its error, and
114
+ an APK can be called `SuccessFactors.apk`). `uninstall(keep_data=True)` asks
115
+ the device's package manager itself (`cmd package uninstall -k`, and
116
+ `pm uninstall -k` where that gives no verdict), because `adb uninstall`
117
+ refuses `-k`. A command that changes device files (`make_dir`, `touch`,
118
+ `copy`, `move`, `remove`, `chmod`, all through `_file_command`) goes out as
119
+ `{ command; } && echo ADBCENTRAL_DONE` (`remotefs._marked`) and worked only
120
+ when adb ended well and that mark is the last line of its output
121
+ (`_marked_done`): a device before Android 7 gives adb no exit status, so
122
+ there a refused change ends 0 like one that was made.
123
+ `remotefs._list_remote_dir` asks once more, with a mark, about a folder that
124
+ listed nothing while the device said something: a folder it would not list
125
+ is an error, never an empty folder. `call_state()` reads every SIM's
126
+ `mCallState` (a call on any of them counts, then a ring); `"unknown"` means
127
+ the device answered without a call state, and a device that could not be
128
+ asked is an `ADBCommandError`, since nothing was learnt about it.
129
+ - **Whose app.** `pm` and `content` mean user 0 unless told otherwise, and on
130
+ Android Automotive that is the headless system user while the driver is a
131
+ secondary one. `_content_user()` asks for the foreground user
132
+ (`am get-current-user`, cached), and `_package_user()` names it for
133
+ `pm clear`, `pm grant` and `pm revoke` when that user has the package; a
134
+ phone, whose foreground user is 0, keeps the plain command.
135
+ - **Whose connection.** `owns_connection` is true when this handler's own
136
+ `adb connect` made the network connection (adb answered "connected to", not
137
+ "already connected to"), and stays true when the same target is connected
138
+ again (a tab's reconnect loop after a reboot), until `disconnect()`. Only
139
+ such a connection is this app's to drop (see The device tab).
140
+ - `parse_display_info` leaves out the virtual display scrcpy mirrors through
141
+ (named `scrcpy`, not physical), which Android lists while a screen runs.
142
+
143
+ ## adb / scrcpy management
144
+
145
+ ADB Central never assumes the tools are installed. `tools.py` finds them, first hit
146
+ wins: an explicit path, `ADBCENTRAL_ADB` / `ADBCENTRAL_SCRCPY`, the GUI's path
147
+ setting, ADB Central's own copy (what winget installed or `~/.adbcentral/tools`,
148
+ whichever is the newer release: `managed_copy` reads it from the executables
149
+ with `tool_version`, cached per file), a copy placed in the package, `PATH`, and
150
+ the common SDK and install folders. The last three are used only while
151
+ ADB Central has no copy of its own, and their first use is logged as a warning
152
+ (`_log_fallback`): a copy it does not keep up to date is never used silently.
153
+ `locate` says which copy runs and why, `all_copies` lists every copy found. An explicit path or an environment variable
154
+ that names no executable is an error, never a reason to fall through (a
155
+ different adb would restart the server the chosen one started); a stale path in
156
+ Settings is a preference, and is skipped with a warning.
157
+
158
+ Auto-detection looks at absolute locations only, never in the current folder,
159
+ and `find_adb` / `find_scrcpy` always answer with an absolute path.
160
+ `shutil.which` starts with the working folder on Windows (and takes an empty or
161
+ relative `PATH` entry for it anywhere), so with it an `adb.bat` lying in a
162
+ downloaded project would be started as adb. `tools._on_path` asks each
163
+ absolute folder of `PATH` for the file by its full path instead; a location
164
+ built on an unset variable is skipped (`_first_file`), and the Unix folders
165
+ are left out on Windows, where `/usr/bin` names a folder of whichever drive
166
+ is current.
167
+ `_on_path` is the lookup for everything ADB Central itself starts by name: adb,
168
+ scrcpy and the editor of `adbcentral edit`. Windows' own
169
+ programs (netsh, schtasks, PowerShell, rundll32) are started with
170
+ `executable=tools.windows_program(name)`, their full path in System32, for the
171
+ same reason: named bare, a program of that name in the current folder runs in
172
+ their place.
173
+
174
+ ADB Central ships neither tool. On Windows `toolsdl.py` installs them through winget
175
+ on the first run (`Google.PlatformTools`, `Genymobile.scrcpy`). winget's change
176
+ to `PATH` reaches only programs started after it, so
177
+ `tools._winget_candidates` looks in winget's package folders instead.
178
+ Where there is no winget, where it fails, and on the other systems, `toolsdl.py`
179
+ downloads the publishers' archives into `~/.adbcentral/tools`, which is why a
180
+ fresh install just works.
181
+
182
+ Updates (6.6.0) always go to `~/.adbcentral/tools`, from the publishers:
183
+ `update_tool` compares the copy that runs with Google's manifest or scrcpy's
184
+ latest GitHub release, downloads and verifies the newer archive, and swaps it in
185
+ while the adb server and any scrcpy keep running (`_swap_live_or_stopped`:
186
+ Windows lets the folder of a running program be renamed, so the old copy runs
187
+ on from `*.old` and every new start uses the new one; the server picks it up at
188
+ its next start). The newer copy then wins over winget's by its release, and over
189
+ a Settings path's copy unless that one is pinned ("Use exactly this copy",
190
+ `adb_path_pinned` / `scrcpy_path_pinned`): `tools._choose` takes the newest
191
+ release of the Settings copy and ADB Central's own, `tools._resolve` keeps the
192
+ choice for a few seconds and looks again when one of those files changes. The
193
+ GUI's device tabs keep no scrcpy path: every screen start asks `find_scrcpy`.
194
+ The publishers' pages are read by `netfetch.py`: Python's client, then on
195
+ Windows the Windows network settings (PowerShell's .NET client with the system
196
+ proxy, PAC and this account's sign-in); scrcpy's newest release from GitHub's
197
+ API, else github.com's release page. Why a page could not be read is kept
198
+ (`toolsdl.latest_error`) and said in the update's result. `update_tool` asks
199
+ the official source and, where the copy that runs is winget's or that source
200
+ did not answer, winget (`winget_show`); `_routes` orders the ways to try,
201
+ winget first when it has the newest, and a way that fails hands over to the
202
+ next. The answer says where the update came from (`via`), each source's newest
203
+ (`latest_by_source`) and why one could not say (`source_errors`).
204
+ `netdoctor.py` is `adbcentral tools doctor`: every step towards Google and
205
+ GitHub, each a function the tests replace. Only an
206
+ update allowed to (`stop_if_in_use`), and only when Windows refuses the swap,
207
+ stops the server first. `auto_update` runs it once a day (`.update-check.json`
208
+ in the tools folder; an hour later after a failed check), from the window at
209
+ start and hourly (also embedded) and from the CLI's `scrcpy` / `audio`; the
210
+ `.update.lock` file keeps two processes from swapping the same folder. A path
211
+ set on purpose (an environment variable, or a pinned Settings path) is never
212
+ updated by itself. `tools_report` is what
213
+ `adbcentral tools status` and Settings > Tools show. Each
214
+ is downloaded only where a build exists for the machine
215
+ (`adb_download_supported()`: Windows, macOS and Linux on x86-64, Google's one
216
+ Linux build; `scrcpy_download_supported()`: Windows). `ensure_tools` only ever
217
+ fetches a tool that is missing: replacing adb means stopping the running
218
+ server, so upgrades go through `upgrade_tools`. A downloaded adb must answer
219
+ `adb version` from its staging folder (`_require_runnable`) before the server
220
+ is stopped or anything is replaced, so a build that cannot run here (musl,
221
+ NixOS) never takes the place of a working system adb. After a swap the tools
222
+ cache is cleared, so the copy just installed is the one found and reported.
223
+
224
+ `update.py` handles upgrading ADB Central *itself* from GitHub Releases and relaunching. It
225
+ keeps two questions apart: whether a newer release exists (`check`,
226
+ `check_cached`, asked from any copy) and whether pip can install it here
227
+ (`can_self_update`; `self_update_blocker` says why not: the standalone exe, a
228
+ source checkout). The GUI tells a copy pip cannot update about a newer release
229
+ too, with the blocker's text as the way to get it.
230
+
231
+ ## scrcpy & remote tunnels
232
+
233
+ `scrcpy.py` is the fiddly bit. Over a **remote** adb server, scrcpy's video tunnel
234
+ has to be pinned: it sets `--tunnel-host` and keeps the port inside a bounded
235
+ range (`--port=27184:27199`, the range the firewall rules open, so that
236
+ concurrent tabs do not race for one port),
237
+ forces adb-forward, can switch to **software rendering** for stubborn IVI GPUs,
238
+ and pins scrcpy to ADB Central's own `adb` via the `ADB` env var. `resolve_host()`
239
+ strips stray `:port` suffixes; the adb v37 quirk where
240
+ `ANDROID_ADB_SERVER_ADDRESS` wants a **bare** host (it wraps it itself; an IPv6
241
+ literal keeps its brackets, as with `-H`) is handled here. `launch_scrcpy`
242
+ decides once whether a "remote" server is really this PC (the same rule the
243
+ device list uses) and the session says so (`ScrcpySession.tunnel_host`).
244
+ `list_displays` (scrcpy's own display list) captures scrcpy's output in a temp
245
+ file, not in pipes: scrcpy's adb clients inherit its output, and on Windows a
246
+ pipe is read until the last of them lets go of it, which can hold the call
247
+ long past its timeout. At the timeout scrcpy's whole process tree is ended
248
+ (`proctree.stop_process(grace=0, tree=True)`).
249
+
250
+ ## Sharing devices: serve & deploy
251
+
252
+ - **`devices.start_shared_server()`** runs `adb -a … server start` detached, so a
253
+ machine can share the devices attached to it. A server that has not answered
254
+ within its 10 s is stopped before the failure is reported: left running, it
255
+ would bind every interface a moment later, with the share reported as failed
256
+ and its port not recorded. `open_firewall()` opens 5037 and scrcpy's tunnel
257
+ ports (27184–27199) for Domain and Private networks only (the server has no
258
+ password), and `stop_shared_server()` closes them again.
259
+ `~/.adbcentral/sharing.json` records the ports this account shared (a tools
260
+ update stops and restarts those servers once) and, in SYSTEM's profile, this
261
+ user's adb keys, which the startup task's server (below) passes to adb as
262
+ `ADB_VENDOR_KEYS`.
263
+ - **`install_serve_task()`** registers a SYSTEM startup Scheduled Task so the
264
+ share survives logoff/reboot (more robust than a login-folder launcher); it
265
+ stops whatever answers on the port first, so only the task's own server can
266
+ pass its readiness check. What the task runs, it runs as SYSTEM at every
267
+ start, so none of it may be a file that an account without administrator
268
+ rights can change (`_others_can_change` reads the owner and the access list
269
+ of the file and of every folder above it). An adb that is (the one in
270
+ `~/.adbcentral/tools` always) is pinned as a copy under
271
+ `%ProgramFiles%\ADB Central\adb` (`_protected_adb`; installing the task again
272
+ brings the copy up to date), and the install is refused when that folder
273
+ would not be protected either. The interpreter and the package cannot be
274
+ copied: the task is installed with a warning that names them.
275
+ `uninstall_serve_task()` returns False when there is no task and raises when
276
+ the task is there and could not be removed. Deleting it takes administrator
277
+ rights, and schtasks answers for a task this user may not look at as for one
278
+ that does not exist, so `_serve_task_registered` also looks for the
279
+ scheduler's own file of that name. Stop sharing and
280
+ `serve --uninstall-startup` then say that the task shares the devices again
281
+ at the next start, instead of that nothing was installed.
282
+ - **`remote_deploy.deploy_serve()`** does the above on *remote* Windows hosts
283
+ **from your machine**, over WinRM. It uses **pywinrm with NTLM transport** —
284
+ explicit `DOMAIN\user` credentials over plain WinRM, no Kerberos/TrustedHosts
285
+ setup needed — then runs `adbcentral serve --startup-task` on each host. `serve`
286
+ itself never downloads adb (its startup task runs as SYSTEM, where a download
287
+ would be a second adb), so the script first asks the host's ADB Central whether
288
+ it finds one and runs `adbcentral fetch-tools --adb-only` when it finds none,
289
+ except where downloads are turned off or an adb path set on purpose is wrong,
290
+ which `serve` then explains. What `serve` warns about on the host comes back
291
+ as `WARNING:` / `INFO:` lines and reaches the deploy log whole (`_NOTE_MAX`).
292
+ The GUI wraps this in a dialog with a pre-flight Test; the CLI exposes it as
293
+ `adbcentral deploy-serve`.
294
+ - **In the GUI** a share ends on a warning, not on "can now connect", when the
295
+ firewall's answer says other machines may be kept out
296
+ (`connect_dialog.firewall_warning`: no rule added, a port left out, a Public
297
+ network). A login auto-start that could not be set up is a warning too,
298
+ never a failed share: the server is shared by then. The Connect dialog's
299
+ share runs through `MainWindow.run_share_task(…, log=True)`, which logs what
300
+ the share reports even after that dialog has closed.
301
+
302
+ ## The GUI (`adbcentral/gui/`)
303
+
304
+ PySide6 (Qt 6), one engine call per user action, all blocking work on `QThread`s
305
+ so the UI never freezes. A Python thread never holds the last reference to a
306
+ QObject (Python would destroy it on that thread): workers share plain state, and
307
+ the window's thread collects their results (see `shell_icons.py`).
308
+
309
+ ```
310
+ app.py QApplication bootstrap, theme, excepthook, app-user-model-id
311
+ embedding.py --embed-into / --api-port / --hide: living inside a host window, its size and DPI
312
+ control_api.py the control API: HTTP + JSON on 127.0.0.1 with a token, events, device commands
313
+ taskbar.py the taskbar icon for Windows' light/dark mode, live; what a pin starts
314
+ main_window.py menu bar, the tab row (Sessions, device tabs, New ▾, Quick connect,
315
+ the work area; `ribbon` is its commands' part name), the session
316
+ tree (`sidebar`: docked, or floating over a device tab), log dock,
317
+ View › Layout (Standard / Compact), upgrade/self-update, shortcuts,
318
+ share/deploy actions
319
+ welcome.py the start page: Connect, Save a target, Discover, Pair, and links
320
+ status_bar.py the coloured status bar: state, messages by kind, ADB/devices/version chips
321
+ device_tab.py per-device tab; connects in the background; hosts the sub-panels;
322
+ the terminal's framed intro; Screen / Screenshot / Reboot at the top right
323
+ page_bar.py the device's pages down the left edge (Standard: names under the
324
+ icons, Compact: icons only), Split and More at its foot
325
+ console.py AnsiConsole — the interactive shell terminal
326
+ vtscreen.py the VT100/xterm screen for full-screen programs (no Qt)
327
+ screen_view.py paints that screen over the console's scrollback
328
+ shell_colors.py what the console colours: words that say what happened, prompts, logcat lines (no Qt)
329
+ terminal.py reader thread that pumps shell bytes into the console
330
+ local_terminal.py PowerShell / CMD sessions over pipes: environment, input, Ctrl+C, output transcoding
331
+ logcat_view.py live logcat with filtering + complete-save
332
+ file_browser.py device filesystem tree + push/pull; one per Files tab
333
+ file_open.py opening files in their apps; device copies whose saves go back
334
+ transfer_log.py transfer history model + size measuring (no Qt)
335
+ transfer_panel.py the Transfers panel: summary, table, retry, report
336
+ file_icons.py native file-type icons, with the glyphs as fallback
337
+ shell_icons.py Windows' file icons, fetched on a thread of their own
338
+ apps_panel.py package list / install / uninstall / start / stop
339
+ controls_panel.py the responsive grid of device controls
340
+ phone_panel.py dialer / calls / SMS
341
+ mirror_panel.py scrcpy launch (window / embedded, scrcpy's own defaults) + recording
342
+ tools_window.py the adb & scrcpy window: copies in use, releases, updates (toolsdl)
343
+ screencap_view.py the ADB screencap renderer, for builds where scrcpy does not run
344
+ display_wall.py every display side by side (IVI Displays); display_controls.py is a tile's key row
345
+ device_commands.py ordered device commands off the UI thread; which display a key names
346
+ device_access.py the write-access dialog (adb root / disable-verity / remount)
347
+ connect_dialog.py / session_dialog.py / settings_dialog.py / deploy_dialog.py
348
+ scrollback.py disk-archived scrollback so saves are complete under a flood
349
+ log_panel.py leveled, filterable log dock
350
+ theme.py dark/light stylesheets, emoji→QIcon, themed accents
351
+ sessions.py / settings.py persisted saved targets + app settings (~/.adbcentral)
352
+ ```
353
+
354
+ These patterns recur and are worth preserving:
355
+
356
+ - **Decoupled ingestion.** The shell and logcat never process incoming bytes on
357
+ the receiving path. They enqueue + archive (both O(1)) and a timer renders a
358
+ *bounded* slice per tick. That's what keeps the UI responsive under a million
359
+ lines of output, and why a Save is always complete even if the on-screen buffer
360
+ was trimmed (see `scrollback.py`). The one bound on that: each history file
361
+ keeps to `Scrollback.HISTORY_LIMIT_MB` (1 GB; `history_limit_mb` in
362
+ settings.json, 0 for none) and to less while the disk is nearly full, in two
363
+ parts, the older one dropped once the newer is full, and a save says what
364
+ went. Logcat archives on its reader thread, before
365
+ any cap, and applies its Filter there too, so the caps only ever drop matching
366
+ lines; a new Filter searches the whole archive. What the reader hands to the
367
+ page stays bounded and cheap while nothing drains it (a hidden page, a
368
+ minimised window): its backlog holds `_LINES_MAX` lines, an emptied batch
369
+ leaves the list, and its count of dropped lines moves to the batch after it
370
+ unless a filter change or Clear has made it stale (`_Capture.live_from`, the
371
+ one mark of that moment, which the reader and the panel both read). The
372
+ terminal's own text (Stop
373
+ and reconnect notices, a submitted line, a screen clear) goes through the same
374
+ queue when output is waiting, so it lands where it happened in the stream.
375
+ A line typed while a command runs is drawn at once (it may be that command's
376
+ answer); if the shell reads it as a command after all, that copy goes when
377
+ the shell echoes it after its prompt. A line typed before a shell's first
378
+ prompt is left to that echo.
379
+ - **Every adb client goes through `adbproc`.** `ADBHandler._exec` (one-shot
380
+ commands), `_spawn` (streams, transfers, shells), `pair`, `run_attached`,
381
+ `list_devices`, `adb version`, the `start-server` launcher and `kill-server`
382
+ start their client with `adbproc.popen`: on Windows it is started
383
+ suspended, put into the process's kill-on-close job, and resumed
384
+ (`NtResumeProcess` on the handle Popen holds; a thread snapshot costs a
385
+ tenth of a second), so it ends with the host, a crashed one too. The job
386
+ lets what a client starts leave it silently: the adb server is shared and
387
+ never ended with a client. The server started directly (`adb -a nodaemon
388
+ server`, for sharing) is never a client and never in the job. `adbproc.run`
389
+ is the one wait: *cancel* (an Event or a callable) and the time limit are
390
+ looked at every `adbproc.POLL_S`, and either ends only the client, with exit
391
+ code 124 (`ADBTimeoutError` / `ADBCancelledError`, `timed_out` /
392
+ `cancelled` on the result). Tests fake adb at this seam (`conftest.FakeAdb`
393
+ patches `adbproc.run`), or run a real fake adb process (`tests/fakeadb.py`).
394
+ - **Nothing slow on the window's thread.** What could take it for long goes
395
+ elsewhere or is bounded. A logcat repaint spends at most
396
+ `LogcatPanel._PAINT_BUDGET_S`, at the line cost it measures as it paints,
397
+ and the newest lines that fit go on screen; terminals drawing at once share
398
+ `AnsiConsole._SHARED_BUDGET` of each tick (`AnsiConsole._drawing`); both
399
+ draw a batch as one edit of the document. Windows' file icons come from
400
+ `shell_icons.ShellIcons`, whose worker asks the shell and makes a QImage (a
401
+ QPixmap may not be made off the window's thread); a Files row asks when
402
+ its name cell is drawn (`_NameDelegate`, `_ICON_LATER_ROLE`), so a folder
403
+ of thousands asks for a screenful. Moving a widget to another parent
404
+ applies the stylesheet again to all of its children, so a layout that
405
+ changes (Device Control's columns) moves layout items, never widgets, and
406
+ pages are built inside their final parent: `_build_control_view(place=…)`
407
+ puts the empty Device Control among the pages before the screen and the
408
+ controls are built in its cards, and `_LazyPage` hands itself to the
409
+ page's factory. No program starts on the window's thread either: the
410
+ Android terminal's `adb shell` opens on a thread (`_OpeningShell` stands
411
+ in for the ShellSession meanwhile: running, nothing to read, input waits
412
+ for it), and `LocalShellSession` starts PowerShell or CMD on one
413
+ (`wait_started`, `start_error`; its writer and closers wait for it).
414
+ - **The edit region.** In `AnsiConsole` the synthetic prompt (Android shell over a
415
+ pipe) and the line being typed are always the last characters of the document,
416
+ and output is inserted above them. Typing while a command streams therefore never
417
+ mixes with its output, and editing the line never touches it. The region's
418
+ lengths (`_prompt_len`, `_line_len`) are document positions, which Qt counts
419
+ in UTF-16 units (an emoji takes two); `_line` and `_cpos` are characters, and
420
+ `_doc_len`, `_char_index` and `_doc_spans` convert (word and prompt colours
421
+ are found in characters and painted in positions). What an input method is
422
+ composing is drawn by the console itself in the edit line at the caret,
423
+ underlined (`_preedit`): Qt's own drawing would put it wherever the caret
424
+ was left in the scrollback. It counts in `_line_len` but is no part of
425
+ `_line`, so Enter never runs it. A plain left press on a selection collapses it,
426
+ so Qt never arms a drag: the view is editable, and a drag would move the
427
+ text out of the document behind the edit region's back.
428
+ - **Reliable stop.** The Android shell runs on a device terminal, so Stop sends a
429
+ real Ctrl+C (`\x03`): the command stops (`ping` prints its summary) and the
430
+ shell stays. If within 3 s neither the device prompt nor anything but the
431
+ terminal's own `^C` comes back (the command ignores Ctrl+C), or Stop is
432
+ pressed again before the prompt, the hard path runs: it tears down the shell
433
+ (which ends its own device-side process group, never anything device-wide),
434
+ discards stale in-flight data via a current-reader guard, and reopens in the
435
+ same folder. A program that answers the Ctrl+C with a prompt of its own
436
+ (`sqlite3`, a shell with another prompt) is never reopened under the user.
437
+ Restart shell takes the hard path at once, and over plain pipes (no PTY,
438
+ where `Ctrl+C` can't signal the device) Stop always does.
439
+ The PowerShell / CMD terminals start a typed interactive `adb shell` with
440
+ `-t -t` (a device PTY), so there Stop sends a real Ctrl+C to the device and
441
+ keeps the adb shell; a second Stop before the device prompt returns (or no
442
+ answer within 3 s) reopens the local shell, re-enters the same adb shell and
443
+ `cd`s back. That adb-shell mode ends only when PowerShell's or CMD's own
444
+ prompt shows, never on a typed `exit`, which may leave only a shell inside
445
+ it (`su`, `sh`, `run-as`): until then Stop, Tab and typed text keep going to
446
+ the device. For a local command, Stop raises a real Ctrl+C in the shell's
447
+ hidden console (`LocalShellSession.send_ctrl_c`: ADB Central attaches to that
448
+ console for the call, ignoring the event itself, or a helper process does
449
+ when ADB Central has a console of its own; shells are started with Ctrl+C
450
+ handling on). As in a console window `ping` prints its summary, a REPL its
451
+ KeyboardInterrupt, and the shell abandons the rest of the line, script or
452
+ batch file (cmd's "Terminate batch job" question is answered yes); an adb
453
+ server a typed `adb` forked has no console and is not touched. A command
454
+ that ignores it without a word for 1.5 s, or a second Stop, has its
455
+ processes ended (`LocalShellSession.kill_command`: never the shell, its
456
+ `conhost.exe` or an adb server, see `proctree`); a shell whose prompt is
457
+ still not back 1.5 s later (a loop inside PowerShell itself), or a third
458
+ Stop, is replaced. What counts as the command's answer is any output since
459
+ the moment the Ctrl+C was raised. The report of `send_ctrl_c` names that
460
+ moment (`CtrlC.at`, taken just before the event) because the report follows
461
+ the event a moment later, and a REPL has printed its KeyboardInterrupt and
462
+ prompt by then; a command that answered runs on, and only another Stop ends
463
+ it. Stop never types an answer for the user: a shell that runs no program
464
+ and waits for a line itself (`pause`, `set /p`, `Read-Host`, a `-Confirm`
465
+ question, the rest of a `>>` block) notices Ctrl+C only after reading one,
466
+ and Enter would confirm, run the block or let the script go on, so it is
467
+ replaced instead, when its prompt is still not back 3 s after the Ctrl+C. It
468
+ gets as long as a command that ignores Ctrl+C because the prompt of a shell
469
+ that did stop can take a while (a prompt function that asks git, a .NET call
470
+ that has to return first). Only a shell already at its prompt (a background
471
+ job was stopped) is sent an empty line, for a new prompt. Stop, the button
472
+ and Ctrl+C alike, drops the lines of a paste that have not run yet, in all
473
+ three terminals.
474
+ - **Local shells over pipes.** cmd and PowerShell run without a console, so
475
+ `local_terminal` stands in for one: `PYTHONUNBUFFERED`, LF-only input written
476
+ by a thread of its own, a `Read-Host` that shows its prompt, and an invisible
477
+ OSC mark (`PROMPT_MARK_RE`) at the end of every prompt (a `prompt` /
478
+ `set prompt=` typed in cmd, or a one-line `function prompt` in PowerShell,
479
+ gets it again). The widget uses that mark (or a default prompt) to tell a
480
+ command from input for a running program: conveniences (`ls`,
481
+ `adb shell -t -t`, streaming `find`/Select-String for a plain `| findstr`,
482
+ PowerShell's buffer width once the view was resized) apply only to commands.
483
+ cmd's `ls` becomes `dir` only when the session's PATH has no `ls` of its own
484
+ (Git for Windows, MSYS2, busybox). `local_terminal.find_command` looks that
485
+ up, and the grep that `gnu_grep` asks for its version, once per session and
486
+ off the UI thread, in the absolute folders of the session's PATH with its
487
+ PATHEXT, never in the current folder (that is ADB Central's own working folder,
488
+ not the shell's, and a `grep.bat` lying there would be run).
489
+ PowerShell keeps the PC's execution policy (its startup script goes in with
490
+ `-Command`). ConPTY, which would give
491
+ findstr, `timeout` and progress output a real console, is not used.
492
+ Over pipes cmd and most console tools write the console code page, while
493
+ PowerShell, git and Python write UTF-8, so `OutputTranscoder` keeps each
494
+ line that is valid UTF-8 and decodes any other with the code page. A read
495
+ may end anywhere in a line: a character it cuts off is held for its rest
496
+ (the start of a UTF-8 sequence when the line is UTF-8 up to there, else
497
+ what the code page's incremental decoder cannot decode yet: the lead byte
498
+ of a double-byte character), for `HOLD_GRACE_S` at most, and the rest of a
499
+ code-page line that was cut inside a character or by a full read is decoded
500
+ with the code page too, whatever it looks like by itself.
501
+ cmd's `cls` writes nothing but a form feed to a pipe, so cmd's
502
+ terminal alone turns on `AnsiConsole.set_form_feed_clears()`; everywhere
503
+ else, and while a device terminal has the output, a form feed is a line
504
+ feed, as on a terminal.
505
+ - **The Android shell's terminal.** `_AndroidShellWidget` opens
506
+ `open_shell(tty=True)` (`adb shell -t -t`) unless the `android_shell_pty`
507
+ setting is off: the device prints its own prompt and echo, and its programs
508
+ write line by line. A hidden first line turns mksh's line editor off (adb
509
+ gives the terminal no size, so it scrolled long lines sideways), sets
510
+ `stty cols/rows` from the view and prints an OSC 7718 mark; output is held
511
+ back until that mark (3 s at most), so neither the line nor the device's first
512
+ prompt shows. The device prompt on the output tail (`[N|]host:/path $`, also
513
+ from a nested `su`/`sh`) is what "ready" means: the console's at-prompt
514
+ state (never "no" while a command runs, since the terminal echoes typed lines
515
+ then too), paste pacing, a settled Ctrl+C and the folder for Tab. Input is
516
+ one LF per line, never a trailing bare CR (adb.exe holds it) and never 0x1A
517
+ (end of input to adb.exe), written by a thread of its own (`_ShellInput`), and
518
+ a line typed before the first prompt waits for it (whatever follows the
519
+ hidden line's mark, also a PS1 that looks like no prompt here). Such lines
520
+ queue (`_early_lines`) and go out one per prompt; a line typed while some
521
+ still wait goes behind them (sent at once it would run ahead of them), the
522
+ console stays in typing-ahead mode until the queue is empty, and Stop clears
523
+ it. Once the
524
+ view is wider or narrower, the next command typed at the prompt carries
525
+ `stty cols/rows` in front (its echo hidden); nothing is typed into a
526
+ running program. The size is
527
+ `AnsiConsole.cell_size`: whole character cells, margins and the scroll bar
528
+ left out whether it shows yet or not. The hidden first line's mark carries
529
+ the terminal's name (`tty`); it leaves `ls` and `grep` as they are, so they
530
+ do not colour their output (see the colour rules below). The reader
531
+ folds adb.exe's CR CR LF into CR LF,
532
+ carrying CRs across reads. A terminal shell that ends or reports an adb error
533
+ before its first prompt (an adb without `-t`, a build without terminals)
534
+ falls back to pipes, where the console draws the prompt; that is undone when
535
+ a plain shell fails at once too (the device was the problem). A device
536
+ without shell_v2 gives a terminal even over pipes: its prompt before any
537
+ command gives that away, and it is set up like one.
538
+ - **Colour, Ctrl+C and full-screen programs.** The console draws output as
539
+ lines (horizontal cursor moves included). A line of the view is at most
540
+ `_LINE_MAX` (4,096) characters: Qt lays a line out whole for every insert
541
+ into it and paints it whole, so output that never ends its line (minified
542
+ JSON, base64) continues on the next line of the view (`_out_cut`), as a
543
+ terminal wraps at its width. A cut line's block is marked (`_CUT`), Copy
544
+ joins such lines again (`_selected_text`), and the saved history is
545
+ untouched. Whole lines that need no format of their own are gathered and go
546
+ in with what follows them as ONE insert (an insert per line makes a flood of
547
+ short lines many times as slow), and a slice of the queue is cut at
548
+ `_SLICE_LINES` lines as well as at `_SUB` characters. Moves and overwrites
549
+ along a line work in document positions and never split a character
550
+ (`_char_edge`). A tab moves to the next multiple of 8 columns, counting only
551
+ the text since the tab before it. Colour it adds is kept for what
552
+ matters; output with colours of its own keeps them. An owner that
553
+ recognises its shell's prompt calls `mark_prompt()` after feeding the
554
+ output, and the console colours that prompt (`shell_colors.prompt_spans`)
555
+ unless it has colours of its own, in one quiet colour
556
+ (`theme.TERM_PROMPT_COLORS`, which the prompts the console styles itself
557
+ use too), red only for a failed command's status and root's `#`. A local
558
+ shell's own prompt (PowerShell's, cmd's) is styled as it arrives in the
559
+ stream (`_style_local_prompts_stream`), but only where the read ends with
560
+ it or the terminal's OSC mark (or the first byte of that mark) follows it,
561
+ and never on a device terminal: an output line that merely starts like a
562
+ prompt has text after it. A line
563
+ that was plain text from start to end and is a logcat line
564
+ (`shell_colors.LogcatLines`) takes its priority's colour when it is a
565
+ warning, error or fatal one (`COLOURED_LEVELS`), even when it came in
566
+ several reads; the rest stay plain. In any other plain line, bar a prompt
567
+ and the command after it, only the words `shell_colors.meaning_spans` finds
568
+ are coloured (`theme.TERM_MEANING_COLORS`): errors, denials and blocks red,
569
+ warnings amber, successes green. They are words of their own (not part of
570
+ a path, a file name, an identifier or a `key=`), matched through a letter
571
+ tree (`_trie`); `may_mean` rules most lines out before that, and a line's
572
+ text and its words' formats go in as one edit, laid out once, so floods
573
+ stay fast. The undrawn backlog is capped at about a
574
+ second of drawing (`_backlog_cap`, from the measured rate). That rate
575
+ (`_render_rate`) is taken from every tick that ran out of time with output
576
+ still waiting, however little it drew (short lines are slow to draw, and
577
+ slow drawing must be measured too), or that drew 32 KB; once everything is
578
+ drawn, a rate below the first guess goes back to it. Ctrl+C on a
579
+ device terminal calls `interrupt_output()`: the backlog goes, and so does
580
+ what arrives before the terminal's own `^C` echo (held, released after a
581
+ second or with the prompt if no echo comes); Stop in PowerShell/CMD drops
582
+ the backlog too. A device terminal's owner calls `set_screen_input(fn)`:
583
+ then output that needs a screen (the alternate screen, a scroll region,
584
+ a cursor position on another line, moves up or down, lines inserted or
585
+ deleted; home + ED 2 stays a plain clear) hands the rest of the stream to a
586
+ `vtscreen.Screen` seeded with the view's last lines, painted by
587
+ `ScreenView`, and every key goes to the program through *fn* (LF for Enter
588
+ and Ctrl+M, never 0x1A), also the keys the window has shortcuts for; its
589
+ cursor and status questions are answered there too. The screen's backlog
590
+ is capped the same way, keeping the newest output (the program redraws),
591
+ never past a switch of screens; Ctrl+C there drops it and still goes to
592
+ the program. The screen goes when the program leaves the alternate screen
593
+ (the view comes back as it was), at the next `mark_prompt()` on the main
594
+ screen (its rows down to the cursor, and a few thousand that scrolled off,
595
+ replace the lines it took over; untouched rows keep their formats), or at
596
+ `end_screen()` when its terminal is gone (the adb shell in PowerShell/CMD
597
+ ended). While it shows, our own notices wait until it goes. The Android
598
+ shell resizes the device terminal of a running program with
599
+ `ADBHandler.resize_terminal` (`stty -F` in a one-shot shell); an adb shell
600
+ in PowerShell/CMD has no terminal name, so its programs keep the size they
601
+ started with (`top` asks the screen for it). An escape sequence that a read
602
+ cut off waits for the next read, in the console's saved history as on a
603
+ program's screen. It is looked for only in the last 4,096 characters and
604
+ only after the last string terminator there, and what follows the last ST
605
+ of a read is tokenized without the DCS/SOS/PM/APC string form
606
+ (`vtscreen._TOKEN_AFTER_ST`), since no string can end there: a read full of
607
+ unfinished string starts costs no more than its length.
608
+
609
+ ### Rapid tap bursts
610
+
611
+ `touch.py` holds the pure parts: parsing ``getevent -pl``, choosing the
612
+ touchscreen, scaling a display point into the panel's own units and building the
613
+ device-side loop. `ADBHandler.tap_burst` runs that loop in ONE ``adb shell`` so
614
+ no tap waits for the PC, prefers ``sendevent`` (the device's own tool, so the
615
+ events are packed for its kernel) when the shell may write to the input node,
616
+ and falls back to ``input tap`` otherwise — as it always does for a burst aimed
617
+ at another display, since an input node belongs to one screen, and on a display
618
+ turned against its panel (the panel reports in its own orientation; an explicit
619
+ ``events`` burst turns the point back by the rotation ``dumpsys input`` reports).
620
+ The loop stops at the first refused tap, and prints its progress so the caller
621
+ can follow it; a burst is ended only when that progress stops coming.
622
+
623
+ ### Push, pull and screen recording
624
+
625
+ adb prints its ``[ NN%]`` progress only to a terminal, never into the pipe
626
+ ADB Central reads. `ADBHandler._transfer` therefore measures the copy itself
627
+ (`_TransferWatch`, from the first second on): what a pull has written on this PC,
628
+ what the device holds for a push. A Windows folder lists each file with the
629
+ size it had when it was last closed (0 bytes for one adb still writes), so
630
+ there the watch asks every file that is listed differently from its snapshot
631
+ for its own size. Measuring never takes more than a fifth of the time, and
632
+ with a stall limit set the longest pause between two looks is a quarter of
633
+ it. `transfer_timeout` is that stall limit, not a deadline, and a pull that is
634
+ ended early removes the one file it created. `pulled()`, the files that are
635
+ new or changed against the snapshot taken before adb started, is also what a
636
+ pull's result counts: what it copied, not what its folder held before. A copy
637
+ that failed reports adb's own `error:` lines (the first five), which come
638
+ before its "1 file pushed" summary.
639
+
640
+ Android takes file names that Windows does not: with a `:` in the name NTFS
641
+ writes into a hidden stream of another, empty file and reports no error, a
642
+ trailing dot or space is dropped, and `nul` is a device. On Windows the engine
643
+ therefore picks the name a pulled file is stored under itself (`_pull_target`).
644
+ A name taken from the device is made one Windows can store
645
+ (`_windows_file_name`). A destination that was typed is read as Windows reads
646
+ it (`_typed_target`: its trailing dots and spaces go, so the path as typed
647
+ goes on naming the copy), and only the characters Windows forbids are
648
+ replaced. adb is given that path, a WARNING says so where a name was
649
+ replaced, and whatever looks at the copy afterwards (the transfer's result, a
650
+ recording's `_save_clip`, `edit_file`) uses the name it was stored under.
651
+
652
+ `replace_file` (the save path of `edit_file` and of the Files tab's editor and
653
+ Open) pushes the new content under a temporary name and writes it over the
654
+ file on the device (`cat` into it), so the file keeps its owner, mode and
655
+ SELinux label; the write counts only when the device's last line is its mark
656
+ (`remotefs.WRITTEN_MARK`: a device before Android 7 gives no exit status).
657
+ Writing over a file empties it first, so the device is asked before whether
658
+ its file system has room, and without it the save is refused with the file
659
+ as it was. If the write is cut short all the same (the file's
660
+ size-and-time stamp changed, or the device no longer answers), the pushed
661
+ copy stays beside the file and the error names it; the next save of that file
662
+ that works removes it.
663
+
664
+ A recording aimed at a folder (one that exists, or a path ending in a
665
+ separator) is given a file of its own there, named after the time
666
+ (`_recording_file`): into a folder adb would pull the clip under its device
667
+ name, which is not the path that is checked and returned afterwards. The
668
+ name is taken at once, as an empty file that holds it until the clip is
669
+ recorded (or the program exits), so two recordings started in the same second
670
+ each get a file. On Windows the path is read as Windows reads it before the
671
+ folder is looked up, as a pull's target is: the engine decides which folder
672
+ `clips ` names, whatever the file system would answer for the name as typed.
673
+ `bugreport` likewise returns the file that was saved: its path with `.zip`
674
+ added as adb adds it, or in a folder the file adb names.
675
+ `screen_record_continuous` records the next part while the last one is pulled,
676
+ so the pulls leave no gap. The recorder and transfer children run in a session
677
+ of their own on Linux and macOS, so a Ctrl+C in the terminal reaches Python
678
+ alone and the CLI can still stop the recording cleanly; children still running
679
+ when the interpreter exits are ended then, with their clean-up. Every child the
680
+ engine, scrcpy and the GUI's streams start is stopped through
681
+ `proctree.stop_process`.
682
+
683
+ ### Shutdown
684
+
685
+ The window goes first. `MainWindow.closeEvent` detaches and parks its workers
686
+ (`_release_workers`), closes every tab's session and then calls
687
+ `mirror_panel.finish_recordings(window)`: while the window, the device
688
+ connections and the adb server are still there, a modal dialog names the
689
+ recordings that are still being stopped and saved and waits for their workers,
690
+ each within its own limits (scrcpy's close timeout, the engine's stall limit
691
+ for a pull). Stopping the server under the pull of a device recording would
692
+ lose the recording, and a scrcpy still writing its MP4 index would get the
693
+ exit's few seconds instead of its own. Only the dialog's button, **Close
694
+ without saving**, gives
695
+ up the wait (Esc and a close request do not); a recording that turned out not
696
+ to be saved is reported before the app goes. A "Run a command on ALL devices"
697
+ that is still running is called off as the workers are released
698
+ (`_BroadcastThread.stop()` sets the cancel event that each per-device
699
+ `shell(cancel=…)` carries, and the engine kills that adb at once): each
700
+ command may run for a minute, and the process does not exit before the last
701
+ of them has ended.
702
+
703
+ A closed tab, like a display tile taken off its wall, is destroyed through
704
+ `mirror_panel.delete_when_released`: it is only hidden until no screen panel
705
+ in it reports `still_closing()` (see Screens and recordings).
706
+ Destroying a panel destroys the scrcpy window embedded in it, which waits for
707
+ as long as a hung scrcpy does not answer, and a panel whose recording is still
708
+ being saved is the one that reports the result.
709
+
710
+ `gui/app.py::_stop_started_tools` runs when the app exits. It first waits
711
+ (3 s at most, `local_terminal.join_closers`) for the PowerShell / CMD terminals
712
+ the closing tabs ended: their process-tree kills run on daemon threads, which
713
+ died with the app before the kill landed and left the shell and its commands
714
+ running. A shell that had ended by itself (`exit`) may have left commands
715
+ running on its hidden console (`start /b ping -t`); closing its terminal ends
716
+ those too (`proctree.kill_tree(pid, include_root=False)`, on Windows, where
717
+ the open process handle keeps the PID the shell's own). Then `scrcpy.stop_all()`
718
+ closes any mirror this process started (every `ScrcpySession` registers
719
+ itself), all at once within one time budget,
720
+ and `ADBHandler.stop_server` stops the adb server if this process started it
721
+ (`tools.owned_adb_server`) and this PC is not sharing its devices. Turning
722
+ `stop_adb_on_exit` off leaves both running: the main window then releases
723
+ separate scrcpy windows (`MirrorPanel.keep_window_open`) before its tabs close.
724
+ The server steps run inside `tools.server_lock_patience`: another thread can
725
+ hold the server lock across a blocking adb call (a restart, a share, a closing
726
+ tab's disconnect), and past a few seconds the exit leaves the server running
727
+ rather than keep a closed app alive; other threads still wait for the lock.
728
+
729
+ ### The adb server: one starter, one stopper
730
+
731
+ `tools.ensure_adb_server` is the only way ADB Central starts the local server. It
732
+ keeps the `adb start-server` launcher it spawned per port, and every caller that
733
+ finds the port dead while that launcher runs waits on it instead of spawning
734
+ another, each with its own timeout, outside the lock. The GUI pre-warm
735
+ (`gui/adb_path.prewarm_adb_server`, once per process), `MainWindow`'s startup
736
+ check, device tabs (`ADBHandler._connect`), restarts and the device list all
737
+ share it. A server that answers once a launcher ran is recorded as started here,
738
+ until that launcher ends without adb's "daemon started successfully": it found
739
+ a server there after all. A launcher keeps what its credit took the place of
740
+ (`_Launch.replaced`), and the record then goes back to that: a server this
741
+ process had started before, which was only slow to answer when the second
742
+ launcher ran, stays ADB Central's to stop (as far as the launcher before it said
743
+ so: that one is asked next), and any other is another program's, started in
744
+ the same moment, and is left alone.
745
+ `tools.kill_adb_server` is the only stopper (restart, "Stop sharing", tools
746
+ upgrades, exit): it waits until the port is released and forgets the record.
747
+ The default port follows `ANDROID_ADB_SERVER_PORT` (`tools.local_adb_port`), as
748
+ adb's own commands do, so the socket probes, the tracker and the start agree.
749
+ After startup the GUI compares the server's `host:version` protocol (and
750
+ `host:server-status` executable) with its own adb and warns about a server that
751
+ another adb would keep restarting.
752
+
753
+ Whatever stops the server holds the device tabs on it first
754
+ (`DeviceTab.prepare_for_adb_restart`, see The device tab): a restart, a share
755
+ or its undoing, a tools download or upgrade, a self-update. A plain adb
756
+ command that finds no server starts one itself, which ADB Central would not have
757
+ recorded (and, during a tools update, from the folder being replaced). **Check
758
+ for updates** therefore checks adb and scrcpy first, on a worker
759
+ (`_tools_check_worker`), and leaves the tabs alone: an answer of "up to date"
760
+ must not cost every tab its shell. The tabs are held only when the upgrade
761
+ that follows replaces a tool, and that upgrade reuses the check. The check
762
+ counts as a tool task until its answer is in, so a download asked for
763
+ meanwhile is turned away like any second tool task.
764
+
765
+ On a first launch without adb, where adb is downloaded by itself (auto-fetch
766
+ on, and a build exists for the machine), the window skips the startup check
767
+ that could only fail and waits in the state "waiting for the download of adb"
768
+ (`_adb_awaits_download`). The server starts once the download is in; a
769
+ download that fails, or never starts, still ends in the startup check, which
770
+ says what is wrong.
771
+
772
+ The device list (`devices.list_devices`) asks a running server over its
773
+ socket, which takes no adb. When it has to start the server and there is no
774
+ adb to start it with, `ADBNotFoundError` goes out: a missing adb is never an
775
+ empty device list. With `strict=True` (the GUI and the CLI) a server that
776
+ cannot start is a `ConnectionError` with the launcher's own words
777
+ (`last_adb_server_error()`).
778
+
779
+ ### Write access to protected files
780
+
781
+ `ADBHandler.access_status()` reports root, `ro.debuggable`, the build type, the
782
+ dm-verity mode and the bootloader state from one shell call. `make_writable()`
783
+ runs `adb root`, optionally `adb disable-verity`, then `adb remount`, and
784
+ handles the reboots those need (after a reboot adbd is not root, so root runs
785
+ again). The GUI shows `gui/device_access.WriteAccessDialog` when a change is
786
+ refused (`is_permission_problem`), runs the choice through `DeviceTab`, and
787
+ holds every terminal meanwhile: the Android shell pauses and reconnects, and
788
+ PowerShell/CMD reopen the `adb shell` they were in, in the same device folder.
789
+ While held, the tab's shell-lost and reconnect paths leave the terminals alone
790
+ (`_release_terminals` brings them back, resumes a Logcat capture, lists a built
791
+ Files page's folder again and loads a built Phone page again), and a
792
+ Terminal opened for the first time meanwhile opens after the release.
793
+
794
+ ### The device tab
795
+
796
+ `DeviceTab` connects on a worker and asks the device everything a new tab
797
+ needs in ONE `adb shell` (`_DeviceProbe`: prompt, build properties, feature
798
+ list, `wm size`, displays). The tab opens on the identity sections; the rest
799
+ follows from the same process. A probe that brought no profile, or one without
800
+ the feature list, runs once more a moment later (`PROBE_RETRY_MS`): a device
801
+ that is still starting answers adbd but lists no features, and classifies as a
802
+ phone whatever it is. A profile without features is kept meanwhile and applied
803
+ when the repeat brings none, since a head unit says "automotive" in its build
804
+ characteristics either way.
805
+
806
+ A network device that a tab's own `adb connect` connected is disconnected
807
+ again when the last tab on it closes (`_Connections`, the engine's
808
+ `owns_connection`). A connect that failed lets go of its handler through
809
+ `_release_connection` too: `adb connect` may have made the connection before
810
+ the connect failed (a device that never authorised this PC), a retry is then
811
+ answered "already connected" and owns nothing, so the first handler remains
812
+ the one to drop it with.
813
+
814
+ **The ADB-restart hold.** `prepare_for_adb_restart()` suspends everything in
815
+ the tab that runs adb by itself: the shells, a Logcat capture, a running wait
816
+ for the device (`_ReconnectThread.cancel()`: no adb command starts after it,
817
+ and nothing is reported) and a built Phone page. A wait asked for during the
818
+ hold is deferred. `finish_adb_restart(True)` starts the one recovery, for at
819
+ least the time an ended wait still had; `finish_adb_restart(False)` offers
820
+ Reconnect and releases the Phone page without loading it.
821
+
822
+ **The Phone page** has `suspend_for_device_loss()` /
823
+ `resume_after_reconnect(reload=True)`, named as on the Logcat page. While
824
+ held, its timers, a show, Refresh and the continuations of running jobs ask
825
+ nothing; a Refresh or a first show during the hold runs when it ends. A
826
+ reconnect and the end of an adbd restart load a built page again (a hidden
827
+ one when it is next shown). The call-state poll calls the engine in raw mode,
828
+ so a poll that fails is not logged as an error each time, and only a real
829
+ answer stops it: a device without a call state, a missing telephony service
830
+ or a permission denial show "No telephony", while a query that adb or the
831
+ device did not answer shows "Checking…" and is asked again. A support check
832
+ that failed, or that the device answered with nothing known, is not kept as
833
+ the answer either: Refresh, the next show and a reconnect ask again. End asks
834
+ the call state once more while the device is known to be idle, and sends the
835
+ End-call key only for a ringing or active call: with no call Android takes
836
+ that key for its power button.
837
+
838
+ **Which display a key names** is decided in one place,
839
+ `device_commands.input_display(display_id, displays, sdk)`. Android sends a
840
+ key without a display to whichever display has the focus, so on a device with
841
+ several displays, display 0 is named like any other where `input` takes a
842
+ display (API level 29 or later, and known); a device with one display, an
843
+ older Android or an unknown version keeps the plain command. Every key route
844
+ asks it: a tile's key row (`DisplayControls`), a screen's own keyboard route
845
+ and Device Control's provider (`MirrorPanel.key_display_id()`; `_KeyBatcher`
846
+ sends what its owner names) and the screencap view
847
+ (`ScreencapView.key_display_id()`). `DeviceTab._note_sdk` forwards the API
848
+ level to the screen panel and the display wall, and
849
+ `DisplayWall._sync_key_displays` tells each tile how many displays there are.
850
+ Taps keep the plain command for display 0: a tap without a display goes
851
+ there.
852
+
853
+ ### Files
854
+
855
+ **Names that are never acted on.** A table's `unsafe_names` are left alone: on
856
+ the device side, names the listing could not identify exactly; on the PC side
857
+ (Windows), names that end in a dot or a space (`_inexact_local_name`), which
858
+ WSL, Git Bash and NTFS-3G make. Windows drops those characters from a path,
859
+ so a path to `photos.` reaches `photos`. Every row action refuses such a row
860
+ with a message (Delete, Rename, Edit, Open, entering the folder, Push, Copy,
861
+ a drag, a drop onto such a folder), and a path of that kind dropped from
862
+ outside is neither pushed nor copied.
863
+
864
+ **Device changes are judged by a mark.** A device before Android 7 gives adb
865
+ no exit status: `adb shell` exits 0 whatever the command did. The commands
866
+ the tab sends itself (New folder, New file, Paste, Rename) therefore go out
867
+ with the same mark as the engine's file commands (see The engine; the tab
868
+ keeps its own `_marked` / `_marked_done`) and count as done only when that
869
+ mark is the last line of the output. Delete is the engine's
870
+ (`ADBHandler.remove`, which refuses `/` and checks every path first); the tab
871
+ looks afterwards whether the items are gone (`_check_removed`), and its retry
872
+ after a refusal leaves out what the first try did remove, because the engine
873
+ deletes nothing while one of its paths is missing.
874
+
875
+ Storage that ignores case (/sdcard) answers for one item under both spellings
876
+ of its name. A rename to the same name in other letters therefore goes
877
+ through a temporary name in two steps (`remotefs._rename_cmd`), and the
878
+ engine's `move` and `copy` ask the device whether the folder found at the
879
+ destination is the source itself (`_in_other_letters`): `move` then renames
880
+ it instead of moving it into itself, and `copy` refuses.
881
+
882
+ **Rows and dialogs.** Events keep running while a dialog is open, and a
883
+ write-access retry may open another folder meanwhile. Device Delete and
884
+ Rename therefore take the folder together with the names before their
885
+ dialog, build their paths from it, and are dropped with a line in the log
886
+ when the pane shows another folder afterwards (`_remote_pane_left`).
887
+
888
+ **Saving.** The built-in editor notes a device file's `(size, modified)`
889
+ before the pull and after each save, as files opened in their apps do
890
+ (`_device_stamp`), compares it before saving and asks before it replaces a
891
+ file that something else changed. A PC file is saved through a temporary
892
+ file beside it, which then takes its place: on Windows with `ReplaceFileW`
893
+ (`_put_in_place`), which hands the old file's other data streams (the mark of
894
+ a downloaded file), its own permissions and its creation time to the new
895
+ one. A drive that cannot swap gets the plain rename, and a file that is in
896
+ use is written in place.
897
+
898
+ **Local copies** compare source and destination by where they really are
899
+ (`os.path.realpath`: junctions, links, `subst` and mapped drives resolved),
900
+ so a folder is never copied into itself through another name for it, and the
901
+ `copytree` hook (`_loop_guard`) leaves out, and reports, a link that leads
902
+ back into the folder being copied or to the folder the copy goes into.
903
+ `transfer_log.measure_remote` writes each path once (in a shell variable)
904
+ and cuts its commands at 100 paths or 24,000 characters, counted as a
905
+ Windows command line holds them: Windows starts no command line longer than
906
+ 32,767 characters, and past that no size is measured at all.
907
+
908
+ ### Screens and recordings
909
+
910
+ `MirrorPanel` shows one display: scrcpy embedded or in its own window, or ADB
911
+ screencap frames (`ScreencapView`). Starting is a replace operation: one
912
+ requested start waits while a launch is cancelled or the previous session
913
+ closes. `_screen_wanted()` says whether a screen shows or is on its way (not
914
+ after Stop) and `_screen_display()` for which display. A display picked
915
+ meanwhile is therefore the one that starts, the picker stays with the display
916
+ that is or will be on screen, and a change of renderer leaves a start that
917
+ waits alone (it picks its renderer when it begins) and brings no screen back
918
+ after Stop.
919
+
920
+ The screen's scrcpy gets scrcpy's own defaults: `start()` adds only the
921
+ display picked (`--display-id`, never for display 0), a camera, a recording,
922
+ what the user ticked (Settings: stay awake, screen off; Options: software
923
+ rendering, UHID keyboard), the window flags embedding needs and the audio
924
+ (`_apply_audio_options`: a head unit's `AUTOMOTIVE_AUDIO_ARGS`, nothing for any
925
+ other device, `--no-audio` when off or for a view with no sound of its own). A
926
+ change of the audio, or a device found to be a head unit after its screen
927
+ started, starts a running screen again in place (`_restart_for_audio`). A
928
+ failed start is tried once more with the same command (`_RETRIES`); a device
929
+ that refuses audio gets its screen without it.
930
+
931
+ A recording runs in one of two modes: `integrated` (scrcpy's own `--record`:
932
+ `_start_integrated_record` starts the screen again, the same way, recording,
933
+ and Stop recording closes it with WM_CLOSE so that the MP4 is finished and
934
+ starts it again without `--record`: one scrcpy, one encoder on the device) and
935
+ `device` (`screenrecord` on the device, pulled afterwards: with the ADB
936
+ screencap renderer, where no scrcpy runs). While scrcpy itself records or is
937
+ about to, `start()` refuses every other start: the start that carries the
938
+ recording may still be waiting, and another would take its place.
939
+ `_begin_record` notes the size and time of a file already at the chosen path
940
+ (`_rec_overwrites`), and `_recording_written()` takes a file for the recording
941
+ only once it holds data and is not that old file unchanged; it decides what is
942
+ reported as saved.
943
+
944
+ `still_closing()` is true while a panel is still needed after
945
+ `close_panel()`: a session starting or closing, the scrcpy of an integrated
946
+ recording, the workers that stop and save a recording, a recorder still
947
+ launching. `delete_when_released(widget, released=None)` (a closed tab; a
948
+ tile the display wall removes) hides the widget and deletes it once no panel
949
+ in it says so, looking again on every `screen_stopped` and on a 250 ms poll.
950
+ `finish_recordings(window)` is the exit's wait (see Shutdown). A separate
951
+ scrcpy window that does not answer is restored with `ShowWindowAsync`, never
952
+ waited for.
953
+
954
+
955
+ ### Logcat, the log panel and the settings files
956
+
957
+ Python's matcher never releases the GIL, so a Filter or Highlight pattern
958
+ that backtracks catastrophically freezes the window whichever thread runs it.
959
+ `logcat_view.compile_filter` therefore matches as plain text whatever it
960
+ cannot trust, and says why: text that is no valid regular expression, nested
961
+ repeats, a repeat whose alternatives can match the same text (`_Overlaps`),
962
+ and a pattern that is too slow in a trial (`_too_slow`). The trial searches
963
+ three probe lines at growing lengths up to 512 characters, each within 10 ms,
964
+ and tries one start inside a run of one character at growing lengths up to
965
+ 4,096, each within 4 ms: for ten common characters and for every character
966
+ the pattern names (64 at most), as the end of a line and with more after the
967
+ run. Repeats that can share such a run (`\s*\s*x`, `/+\s*/+x`) search an
968
+ ordinary line in no time, and a line with a few thousand of that character
969
+ for minutes.
970
+
971
+ The log panel keeps its record per level (`log_panel._Record`: the newest
972
+ 20,000 lines of each), and its view holds no more than 20,000 lines, so
973
+ whatever "Show" is set to, a line on screen is in the record that Save and a
974
+ change of "Show" work from. In one list for all levels the hidden adb trace,
975
+ far more frequent than anything else, would push out errors that are still on
976
+ screen.
977
+
978
+ `settings.json` and `sessions.json` (and a targets file to import) are read
979
+ as `utf-8-sig`: a file edited by hand may start with a byte order mark
980
+ (PowerShell 5.1's `-Encoding UTF8`, an editor's "UTF-8 with BOM"), and read
981
+ as plain UTF-8 such a file does not parse, which leaves the defaults in its
982
+ place.
983
+
984
+ ## ADB Central on Windows: its name, its taskbar icon, its pins
985
+
986
+ Windows names a process after its program file, and the GUI ran in
987
+ `pythonw.exe`: Task Manager listed "Python" with Python's icon, and a taskbar
988
+ pin of the window started a bare `pythonw`. Three parts fix that.
989
+
990
+ - **ADBCentral.exe** (`launcher.py`). `adbcentral-gui`, `adbcentral gui` and
991
+ `python main.py` start the GUI through `launcher.relaunch()`, which runs it in
992
+ `~/.adbcentral/launcher/<environment>/bin/ADBCentral.exe`: a copy of this Python's
993
+ `pythonw.exe` whose icon and version resources (Task Manager's name is the
994
+ `FileDescription`) are replaced with `UpdateResourceW`, beside copies of the
995
+ Python DLLs and a `pyvenv.cfg` pointing at the Python home — the layout of a
996
+ virtualenv made with copies. `ADBCentral.exe -m adbcentral_launch` runs a
997
+ generated module of the copy's own site folder, which puts the originating
998
+ `sys.path` back (a source checkout first, as `python main.py` has it), runs
999
+ the `.pth` files of its site folders (editable installs) and sets
1000
+ `sys.executable` back to the real interpreter: pip, the update checks and
1001
+ every helper process run the real Python, exactly as before. The copy is
1002
+ rebuilt when Python, ADB Central or the icon change and checked once by starting
1003
+ it (`--probe`); a copy that fails is not retried until something changes, and
1004
+ any failure runs the GUI in-process as before. The launching process waits
1005
+ 1.5 s (a GUI that ends at once runs in-process instead) and ends; inside a job
1006
+ that allows no breakaway (an IDE) it stays with the GUI. `ADBCENTRAL_NO_LAUNCHER=1`
1007
+ turns it off; the test suite sets it. The one-file exe is ADB Central already.
1008
+ `state.json` beside the copy records what it was built of (`built`: the stamp
1009
+ of Python's files, ADB Central's version and the icon, and a hash of the
1010
+ generated files), whether its check passed (`ok`) and what it was made for
1011
+ (`prefix`, the environment, and `root`, the folder holding ADB Central).
1012
+ `_forget_orphans` removes the copies whose Python,
1013
+ environment or ADB Central folder is gone (a deleted venv, a removed checkout);
1014
+ a folder on a drive that is not connected says nothing, and a copy without
1015
+ that record is judged by what its generated script names.
1016
+ A shortcut or a pin starts ADBCentral.exe itself, with nothing before it to
1017
+ look at the copy. So unless `relaunch()` started it (which says so with
1018
+ `ADBCENTRAL_LAUNCHER_CHECKED`), `run_branded` checks the copy first
1019
+ (`_stale`): the launcher turned off, a failed check, a stamp that differs
1020
+ from this Python's and ADB Central's (a `pip install -U` or a Python update
1021
+ since), or no PySide6. A stale copy hands the start over (`_hand_over`): it
1022
+ runs `adbcentral.cli.launch_gui` in the real interpreter and ends, so the GUI
1023
+ comes up in a copy built anew, in plain Python when the launcher is turned
1024
+ off, or as the wheel's executable when PySide6 is missing. If the hand-over
1025
+ cannot start, the GUI runs in the copy after all.
1026
+ - **The window's identity** (`winshell.set_window_identity`, from
1027
+ `gui/taskbar.py`). The main window carries the app ID and what a pin shows
1028
+ and runs: `RelaunchCommand` (what the shortcuts start, see below), the name
1029
+ and the icon. Windows keeps 255 characters of each, so the command
1030
+ is a module name rather than a script path, with an 8.3 fallback.
1031
+ - **The icon follows the taskbar's mode.** `scripts/make_icon.py` draws the
1032
+ dark and a light variant; `winshell.icon_file()` keeps lasting copies in
1033
+ `~/.adbcentral/icons` (shortcuts must not point into a pip-upgraded package or
1034
+ the one-file exe's temp folder). A native event filter catches
1035
+ `WM_SETTINGCHANGE` "ImmersiveColorSet"; after a short pause the window icon
1036
+ follows `SystemUsesLightTheme`, and the icons of ADB Central's pins, Start-menu
1037
+ and Desktop shortcuts follow in a worker thread (their `.lnk` files, through
1038
+ `IShellLinkW`, which keeps their app ID). Shortcuts are written through COM
1039
+ with the app ID (so a pin made of one groups with the running window), and an
1040
+ out-of-date one is rewritten once, never on every launch. The shell is only
1041
+ touched on the real `windows` platform, never from the tests' offscreen
1042
+ windows.
1043
+
1044
+ What a shortcut or a pin starts is decided in `cli._resolve_gui_target`: the
1045
+ one-file exe itself (or the `adbcentral-gui` that started it, below); with
1046
+ PySide6, this environment's ADBCentral.exe; otherwise the `adbcentral-gui`
1047
+ launcher beside the interpreter, else `pythonw -m adbcentral gui`. ADBCentral.exe
1048
+ runs the GUI of this Python, so without PySide6 it would open nothing. Where
1049
+ nothing starts the GUI at all (no PySide6 and no bundled exe) no shortcut is
1050
+ written (`_no_gui`). The PowerShell fallback that writes a shortcut where COM
1051
+ fails holds no value in its script: name, target, arguments, folder and icon
1052
+ travel in `ADBCENTRAL_LNK_*` environment variables, because a path with an
1053
+ apostrophe or a typographic quote would end a quoted string in the script.
1054
+
1055
+ Without PySide6 on Windows, `adbcentral-gui` runs the executable bundled in the
1056
+ wheel from a copy in `~/.adbcentral/gui` (`cli._staged_exe`): a running exe is
1057
+ locked, so running the packaged one in place would block
1058
+ `pip install --upgrade`, and the folder is the user's own, where no other
1059
+ account can leave a file under the copy's name. The name carries version and
1060
+ size; a copy is run again only while it equals the packaged exe byte for
1061
+ byte, a new one is written under a temporary name and renamed, and the copies
1062
+ of other builds are deleted. `launch_gui` tells that exe what started it
1063
+ (`ADBCENTRAL_GUI_STARTED_BY`), so its shortcuts, their upkeep and its pin's
1064
+ `RelaunchCommand` name `adbcentral-gui` and not the copy, which the next
1065
+ upgrade replaces. A shortcut or a pin that starts a copy of the wheel's exe
1066
+ all the same is pointed at what starts ADB Central, at every start and on a
1067
+ mode change (`winshell.revive_shortcuts`, through `retarget_shortcut`, which
1068
+ keeps its app ID and icon). `cli._revive_shortcuts` adds the Desktop and
1069
+ Start-menu shortcuts to the pins whether or not shortcut upkeep is on, and
1070
+ creates none. `winshell.pinned_shortcuts()` covers `User Pinned\TaskBar` and
1071
+ `User Pinned\ImplicitAppShortcuts\*`, where Windows keeps the pin of a window
1072
+ whose app ID no Start-menu shortcut has.
1073
+
1074
+ ## Packaging
1075
+
1076
+ - `pyproject.toml` — package metadata, the console-script/gui-script entry
1077
+ points, optional extras (`gui`, `winrm`, `all`), and package assets.
1078
+ - `adbcentral-gui.spec` + `scripts/build_exe.py` — PyInstaller build of the
1079
+ versioned GUI executable (`dist/ADBCentral-<version>-win64.exe`). `collect_all`
1080
+ pulls the entire pywinrm/NTLM stack so WinRM works in the frozen exe.
1081
+ `scripts/gui_entry.py` is the frozen entry point (with a startup self-test hook).
1082
+ - `scripts/release.py` — copy that exe into `adbcentral/bin/adbcentral-gui.exe`
1083
+ (package data, git-ignored), build wheel+sdist, check the wheel contains the
1084
+ exe. Pushing a `v*` tag publishes the same files on the GitHub Release, the
1085
+ one place ADB Central is released. `adbcentral-gui` starts the bundled exe when PySide6 is
1086
+ not installed, from a copy in `~/.adbcentral/gui` (see above).
1087
+
1088
+ ## Where things live at runtime
1089
+
1090
+ ```
1091
+ ~/.adbcentral/
1092
+ ├── tools/ downloaded adb + scrcpy (verified against the publisher's checksum)
1093
+ ├── settings.json theme, fonts, defaults (+ .lock, cross-process writes)
1094
+ ├── sessions.json saved targets (+ .lock; re-read and merged before each write)
1095
+ ├── sharing.json ports shared with `serve`, the startup task's port and adb keys
1096
+ ├── logs/ temp scrollback archives (cleaned on close; 1 GB each at most;
1097
+ │ named after their process, which holds a lock there while
1098
+ │ it runs, so a start's clean-up spares another's)
1099
+ ├── launcher/ Windows: one ADBCentral.exe per Python environment (launcher.py)
1100
+ ├── gui/ Windows: the copy of the wheel's exe that adbcentral-gui runs without PySide6
1101
+ ├── icons/ the dark and light icons that shortcuts and pins point at
1102
+ └── crash.log uncaught GUI errors
1103
+ ```
1104
+
1105
+ All of these resolve through `config.user_dir()` / `user_path()`, which re-read
1106
+ `HOME`/`USERPROFILE` on every call.
1107
+
1108
+ One folder is outside it on purpose, on Windows under `%ProgramFiles%\ADB Central\`,
1109
+ where only administrators can write: `adb\`, the copy of adb that the SYSTEM
1110
+ startup task runs (`devices._protected_adb`). It runs as SYSTEM, so it is never
1111
+ taken from a folder another account could have filled first.