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

Commit beba6e3b authored by Archie Pusaka's avatar Archie Pusaka
Browse files

Floss: Hcidoc: Remove pending disconnection on reconnection

When host issues disconnection command with reason powering off, the
controller might or might not send a corresponding disconnection event.
In this instance, we process the disconnection when processing the
command rather than the event, and we also store this information in
pending_disconnect_due_to_host_power_off to avoid double report in case
the controller sends the disconnection event.

If the device is later reconnected and disconnected normally, the
variable pending_disconnect_due_to_host_power_off is potentially
already populated from the previous example, and it blocks us from
reporting any disconnection at all.

This CL cleans the pending disconnection variable on device connection.

Bug: 325574179
Test: m -j
Test: Using report 91536846559, verify all disconnection is reported
      for the device with OUI F7:32:6C.
Tag: #floss
Flag: EXEMPT, Floss only changes
Change-Id: I8f647ea4ab1787e125f96bc11d34a06992cfefb3
parent 29ff541d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -350,6 +350,7 @@ impl OddDisconnectionsRule {
        if let Some(_) = self.connection_attempt.remove(&address) {
            if status == ErrorCode::Success {
                self.active_handles.insert(handle, (packet.ts, address));
                self.pending_disconnect_due_to_host_power_off.remove(&handle);
            } else {
                self.reportable.push((
                    packet.ts,
@@ -449,6 +450,7 @@ impl OddDisconnectionsRule {
        if let Some(_) = self.sco_connection_attempt.remove(&address) {
            if status == ErrorCode::Success {
                self.active_handles.insert(handle, (packet.ts, address));
                self.pending_disconnect_due_to_host_power_off.remove(&handle);
            } else {
                self.reportable.push((
                    packet.ts,
@@ -486,6 +488,7 @@ impl OddDisconnectionsRule {
        if let Some(_) = self.le_connection_attempt.remove(&addr_to_remove) {
            if status == ErrorCode::Success {
                self.active_handles.insert(handle, (packet.ts, address));
                self.pending_disconnect_due_to_host_power_off.remove(&handle);
            } else {
                let message = if use_accept_list {
                    format!("LeConnectionComplete error {:?} for accept list", status)
+1 −0
Original line number Diff line number Diff line
@@ -552,6 +552,7 @@ impl InformationalRule {
        let device = self.get_or_allocate_device(address);
        device.report_connection_start(handle, ts);
        self.handles.insert(handle, *address);
        self.pending_disconnect_due_to_host_power_off.remove(&handle);
    }

    fn report_sco_connection_start(