From 89a49a50dc7000e163ce45b7454c5e764cf52861 Mon Sep 17 00:00:00 2001 From: Tedd Ho-Jeong An Date: Tue, 10 Mar 2020 10:00:58 -0700 Subject: [PATCH 1/3] workflow: Add workflow files This patch adds workflow files for ci: [sync.yml] - runs every 30 mins. - sync repo with upstream repo and rebase workflow branch to tip of master. - creates PR after reading patches from patchwork.kernel.org [ci.yml] - Tests the following checks: - checkpatch - gitlint - make - make check [code_scan.yml] - Static code checker: Coverity and Clang - Coverity: Submit the result to the coverity website - Clang Code Scan: Send email with result file to the internal team To simplify the history, new change will amend to this patch without creating new patch. --- .github/workflows/ci.yml | 25 +++++++++++++++++++ .github/workflows/code_scan.yml | 26 ++++++++++++++++++++ .github/workflows/sync.yml | 43 +++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/code_scan.yml create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..a3a54d1a1b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: [pull_request] + +jobs: + ci: + runs-on: ubuntu-latest + name: CI for Pull Request + steps: + - name: Checkout the source code + uses: actions/checkout@v3 + with: + path: src/src + + - name: CI + uses: tedd-an/bzcafe@main + with: + task: ci + base_folder: src + space: user + github_token: ${{ secrets.ACTION_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + patchwork_token: ${{ secrets.PATCHWORK_TOKEN }} + patchwork_user: ${{ secrets.PATCHWORK_USER }} + diff --git a/.github/workflows/code_scan.yml b/.github/workflows/code_scan.yml new file mode 100644 index 0000000000..181d08c32d --- /dev/null +++ b/.github/workflows/code_scan.yml @@ -0,0 +1,26 @@ +name: Code Scan + +on: + schedule: + - cron: "40 7 * * FRI" + +jobs: + code-scan: + runs-on: ubuntu-latest + steps: + - name: Checkout the source + uses: actions/checkout@v2 + with: + fetch-depth: 0 + path: src + - name: Code Scan + uses: BluezTestBot/action-code-scan@main + with: + src_path: src + github_token: ${{ secrets.GITHUB_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + - uses: actions/upload-artifact@v2 + with: + name: scan_report + path: scan_report.tar.gz + diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000000..d935cca9fa --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,43 @@ +name: Sync + +on: + schedule: + - cron: "*/30 * * * *" + +jobs: + sync_repo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: master + + - name: Sync Repo + uses: tedd-an/bzcafe@main + with: + task: sync + upstream_repo: 'https://git.kernel.org/pub/scm/bluetooth/bluez.git' + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cleanup PR + uses: tedd-an/bzcafe@main + with: + task: cleanup + github_token: ${{ secrets.ACTION_TOKEN }} + + sync_patchwork: + needs: sync_repo + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Sync Patchwork + uses: tedd-an/bzcafe@main + with: + task: patchwork + space: user + github_token: ${{ secrets.ACTION_TOKEN }} + email_token: ${{ secrets.EMAIL_TOKEN }} + patchwork_token: ${{ secrets.PATCHWORK_TOKEN }} + patchwork_user: ${{ secrets.PATCHWORK_USER }} + From d437017b596cb66d239b6c15e0e709cbcc9b62f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 16 Apr 2025 17:55:01 +0200 Subject: [PATCH 2/3] device: Reset svc_resolved on device_discover_services() request This allows profiles requesting to re-retrieve the services records (SDP or GATT) to be called back once the services are completed using device_wait_for_svc_complete(). --- src/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index b82a905f99..b7c2064fe0 100644 --- a/src/device.c +++ b/src/device.c @@ -6271,10 +6271,13 @@ int device_discover_services(struct btd_device *device) { int err; - if (device->bredr) + if (device->bredr) { + device->bredr_state.svc_resolved = FALSE; err = device_browse_sdp(device, NULL); - else + } else { + device->le_state.svc_resolved = FALSE; err = device_browse_gatt(device, NULL); + } if (err == 0 && device->discov_timer) { timeout_remove(device->discov_timer); From 0daf7db2ce38fc7d15e72c2423fc968ab202a86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Danis?= Date: Wed, 16 Apr 2025 17:55:02 +0200 Subject: [PATCH 3/3] input: device: Browse SDP records if not cached For a HID paired device, if the cache file containing the SDP records is not present this will prevent the device to connect and need to remove it and pair again. Current bluetoothd traces: src/shared/mgmt.c:can_read_data() [0x0000] event 0x000b src/adapter.c:connected_callback() hci0 device EC:83:50:76:BD:67 connected eir_len 31 src/shared/mgmt.c:can_read_data() [0x0000] event 0x0006 profiles/input/server.c:connect_event_cb() Incoming connection from EC:83:50:76:BD:67 on PSM 17 profiles/input/device.c:input_device_set_channel() idev 0x5580c6a331b0 psm 17 profiles/input/server.c:confirm_event_cb() profiles/input/server.c:connect_event_cb() Incoming connection from EC:83:50:76:BD:67 on PSM 19 profiles/input/device.c:input_device_set_channel() idev 0x5580c6a331b0 psm 19 profiles/input/device.c:hidp_add_connection() Could not parse HID SDP record: No such file or directory (2) profiles/input/device.c:ctrl_watch_cb() Device EC:83:50:76:BD:67 disconnected profiles/input/device.c:intr_watch_cb() Device EC:83:50:76:BD:67 disconnected This commit tries to retrieve the SDP record from the remote HID then to add the HIDP connection. --- profiles/input/device.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/profiles/input/device.c b/profiles/input/device.c index 3627573e79..ac6cdec9e5 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -86,6 +86,7 @@ struct input_device { bool virtual_cable_unplug; uint8_t type; unsigned int idle_timer; + bool sdp_rediscover; }; static int idle_timeout = 0; @@ -1062,6 +1063,22 @@ static gboolean encrypt_notify(GIOChannel *io, GIOCondition condition, return FALSE; } +static void input_device_update_rec(struct input_device *idev); +static int hidp_add_connection(struct input_device *idev); + +static void hidp_sdp_cb(struct btd_device *dev, int err, void *user_data) +{ + struct input_device *idev = user_data; + + DBG(""); + + /* Attempt to update SDP record if it had changed */ + input_device_update_rec(idev); + + if (hidp_add_connection(idev) < 0) + btd_service_disconnect(idev->service); +} + static int hidp_add_connection(struct input_device *idev) { struct hidp_connadd_req *req; @@ -1078,6 +1095,18 @@ static int hidp_add_connection(struct input_device *idev) if (err < 0) { error("Could not parse HID SDP record: %s (%d)", strerror(-err), -err); + if (err == -ENOENT && !idev->sdp_rediscover) { + err = device_discover_services(idev->device); + if (err < 0) { + error("Could not discover services: %s (%d)", + strerror(-err), -err); + goto cleanup; + } + + idev->sdp_rediscover = TRUE; + device_wait_for_svc_complete(idev->device, + hidp_sdp_cb, idev); + } goto cleanup; }