Display and control your Android device
Fix server debugger for Android >= 9
Romain Vimont902b99174df8
diff --git a/DEVELOP.md b/DEVELOP.mdindex 0258782f..4d8acc59 100644--- a/DEVELOP.md+++ b/DEVELOP.md@@ -282,6 +282,15 @@ meson x -Dserver_debugger=truemeson configure x -Dserver_debugger=true```+If your device runs Android 8 or below, set the `server_debugger_method` to+`old` in addition:++```bash+meson x -Dserver_debugger=true -Dserver_debugger_method=old+# or, if x is already configured+meson configure x -Dserver_debugger=true -Dserver_debugger_method=old+```+Then recompile.When you start scrcpy, it will start a debugger on port 5005 on the device.diff --git a/app/meson.build b/app/meson.buildindex 3df2f35c..49c4683f 100644--- a/app/meson.build+++ b/app/meson.build@@ -124,6 +124,9 @@ conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))# run a server debugger and wait for a client to be attachedconf.set('SERVER_DEBUGGER', get_option('server_debugger'))+# select the debugger method ('old' for Android < 9, 'new' for Android >= 9)+conf.set('SERVER_DEBUGGER_METHOD_NEW', get_option('server_debugger_method') == 'new')+configure_file(configuration: conf, output: 'config.h')src_dir = include_directories('src')diff --git a/app/src/server.c b/app/src/server.cindex 4b2c1866..a8d598e4 100644--- a/app/src/server.c+++ b/app/src/server.c@@ -244,7 +244,13 @@ execute_server(struct server *server, const struct server_params *params) {"app_process",#ifdef SERVER_DEBUGGER# define SERVER_DEBUGGER_PORT "5005"+# ifdef SERVER_DEBUGGER_METHOD_NEW+ /* Android 9 and above */+ "-XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,suspend=y,server=y,address="+# else+ /* Android 8 and below */"-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="+# endifSERVER_DEBUGGER_PORT,#endif"/", // unuseddiff --git a/meson_options.txt b/meson_options.txtindex 4cf4a8bf..c213e7dd 100644--- a/meson_options.txt+++ b/meson_options.txt@@ -6,3 +6,4 @@ option('prebuilt_server', type: 'string', description: 'Path of the prebuilt seroption('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')option('hidpi_support', type: 'boolean', value: true, description: 'Enable High DPI support')option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')+option('server_debugger_method', type: 'combo', choices: ['old', 'new'], value: 'new', description: 'Select the debugger method (Android < 9: "old", Android >= 9: "new")')