Determine debugger command at runtime
When server_debugger is enabled, retrieve the device SDK version to execute the correct command. PR #5466 <https://github.com/Genymobile/scrcpy/pull/5466>
This commit is contained in:
parent
24588cb637
commit
9f39a5f2d6
@ -167,9 +167,6 @@ conf.set('DEFAULT_LOCAL_PORT_RANGE_LAST', '27199')
|
|||||||
# run a server debugger and wait for a client to be attached
|
# run a server debugger and wait for a client to be attached
|
||||||
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))
|
conf.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')
|
|
||||||
|
|
||||||
# enable V4L2 support (linux only)
|
# enable V4L2 support (linux only)
|
||||||
conf.set('HAVE_V4L2', v4l2_support)
|
conf.set('HAVE_V4L2', v4l2_support)
|
||||||
|
|
||||||
|
@ -739,3 +739,21 @@ sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags) {
|
|||||||
|
|
||||||
return sc_adb_parse_device_ip(buf);
|
return sc_adb_parse_device_ip(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t
|
||||||
|
sc_adb_get_device_sdk_version(struct sc_intr *intr, const char *serial) {
|
||||||
|
char *sdk_version =
|
||||||
|
sc_adb_getprop(intr, serial, "ro.build.version.sdk", SC_ADB_SILENT);
|
||||||
|
if (!sdk_version) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long value;
|
||||||
|
bool ok = sc_str_parse_integer(sdk_version, &value);
|
||||||
|
free(sdk_version);
|
||||||
|
if (!ok || value < 0 || value > 0xFFFF) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
@ -114,4 +114,10 @@ sc_adb_getprop(struct sc_intr *intr, const char *serial, const char *prop,
|
|||||||
char *
|
char *
|
||||||
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
sc_adb_get_device_ip(struct sc_intr *intr, const char *serial, unsigned flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the device SDK version.
|
||||||
|
*/
|
||||||
|
uint16_t
|
||||||
|
sc_adb_get_device_sdk_version(struct sc_intr *intr, const char *serial);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -201,18 +201,26 @@ execute_server(struct sc_server *server,
|
|||||||
cmd[count++] = "app_process";
|
cmd[count++] = "app_process";
|
||||||
|
|
||||||
#ifdef SERVER_DEBUGGER
|
#ifdef SERVER_DEBUGGER
|
||||||
|
uint16_t sdk_version = sc_adb_get_device_sdk_version(&server->intr, serial);
|
||||||
|
if (!sdk_version) {
|
||||||
|
LOGE("Could not determine SDK version");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
# define SERVER_DEBUGGER_PORT "5005"
|
# define SERVER_DEBUGGER_PORT "5005"
|
||||||
cmd[count++] =
|
const char *dbg;
|
||||||
# ifdef SERVER_DEBUGGER_METHOD_NEW
|
if (sdk_version < 28) {
|
||||||
/* Android 9 and above */
|
// Android < 9
|
||||||
"-XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,suspend=y,"
|
dbg = "-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="
|
||||||
"server=y,address="
|
|
||||||
# else
|
|
||||||
/* Android 8 and below */
|
|
||||||
"-agentlib:jdwp=transport=dt_socket,suspend=y,server=y,address="
|
|
||||||
# endif
|
|
||||||
SERVER_DEBUGGER_PORT;
|
SERVER_DEBUGGER_PORT;
|
||||||
|
} else {
|
||||||
|
// Android >= 9
|
||||||
|
dbg = "-XjdwpProvider:internal -XjdwpOptions:transport=dt_socket,"
|
||||||
|
"suspend=y,server=y,address=" SERVER_DEBUGGER_PORT;
|
||||||
|
}
|
||||||
|
cmd[count++] = dbg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cmd[count++] = "/"; // unused
|
cmd[count++] = "/"; // unused
|
||||||
cmd[count++] = "com.genymobile.scrcpy.Server";
|
cmd[count++] = "com.genymobile.scrcpy.Server";
|
||||||
cmd[count++] = SCRCPY_VERSION;
|
cmd[count++] = SCRCPY_VERSION;
|
||||||
|
@ -461,15 +461,6 @@ meson setup x -Dserver_debugger=true
|
|||||||
meson configure x -Dserver_debugger=true
|
meson configure x -Dserver_debugger=true
|
||||||
```
|
```
|
||||||
|
|
||||||
If your device runs Android 8 or below, set the `server_debugger_method` to
|
|
||||||
`old` in addition:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
meson setup 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.
|
Then recompile.
|
||||||
|
|
||||||
When you start scrcpy, it will start a debugger on port 5005 on the device.
|
When you start scrcpy, it will start a debugger on port 5005 on the device.
|
||||||
|
@ -3,6 +3,5 @@ option('compile_server', type: 'boolean', value: true, description: 'Build the s
|
|||||||
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
option('prebuilt_server', type: 'string', description: 'Path of the prebuilt server')
|
||||||
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
option('portable', type: 'boolean', value: false, description: 'Use scrcpy-server from the same directory as the scrcpy executable')
|
||||||
option('server_debugger', type: 'boolean', value: false, description: 'Run a server debugger and wait for a client to be attached')
|
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")')
|
|
||||||
option('v4l2', type: 'boolean', value: true, description: 'Enable V4L2 feature when supported')
|
option('v4l2', type: 'boolean', value: true, description: 'Enable V4L2 feature when supported')
|
||||||
option('usb', type: 'boolean', value: true, description: 'Enable HID/OTG features when supported')
|
option('usb', type: 'boolean', value: true, description: 'Enable HID/OTG features when supported')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user