Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7fa28fb authored by Warren Rehman's avatar Warren Rehman
Browse files

Wait for UHID interface on boot

Poll and sleep to wait for UHID interface on boot to avoid losing
initial input event after boot.

Bug: 27442119
Change-Id: Ie2141c94624363385951c8316ad854d6ae2e82ec
parent 481d034f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -424,6 +424,15 @@ void bta_hh_co_data(UINT8 dev_handle, UINT8 *p_rpt, UINT16 len, tBTA_HH_PROTO_MO
        return;
    }

    // Wait a maximum of MAX_POLLING_ATTEMPTS x POLLING_SLEEP_DURATION in case
    // device creation is pending.
    if (p_dev->fd >= 0) {
        UINT32 polling_attempts = 0;
        while (!p_dev->ready_for_data && polling_attempts++ < BTIF_HH_MAX_POLLING_ATTEMPTS) {
            usleep(BTIF_HH_POLLING_SLEEP_DURATION_US);
        }
    }

    // Send the HID data to the kernel.
    if ((p_dev->fd >= 0) && p_dev->ready_for_data) {
        bta_hh_co_write(p_dev->fd, p_rpt, len);
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#define BTIF_HH_KEYSTATE_MASK_CAPSLOCK   0x02
#define BTIF_HH_KEYSTATE_MASK_SCROLLLOCK 0x04

#define BTIF_HH_MAX_POLLING_ATTEMPTS      10
#define BTIF_HH_POLLING_SLEEP_DURATION_US 5000

/*******************************************************************************
**  Type definitions and return values