From ad1f3fd90fef200628884d45e039ca527d6baad4 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 17 Oct 2021 16:58:31 +0200 Subject: [PATCH] Retrieve device serial for AOA The serial is necessary to find the correct Android device for AOA. If it is not explicitly provided by the user via -s, then execute "adb getserialno" to retrieve it. --- app/src/scrcpy.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/scrcpy.c b/app/src/scrcpy.c index a1109fcf..bb653c14 100644 --- a/app/src/scrcpy.c +++ b/app/src/scrcpy.c @@ -437,7 +437,23 @@ scrcpy(struct scrcpy_options *options) { if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_HID) { #ifdef HAVE_AOA_HID bool aoa_hid_ok = false; - if (!aoa_init(&s->aoa, options->serial)) { + + char *serialno = NULL; + + const char *serial = options->serial; + if (!serial) { + serialno = adb_get_serialno(); + if (!serialno) { + LOGE("Could not get device serial"); + goto aoa_hid_end; + } + serial = serialno; + LOGI("Device serial: %s", serial); + } + + bool ok = aoa_init(&s->aoa, serial); + free(serialno); + if (!ok) { goto aoa_hid_end; }