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

Commit 296e0708 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix v2 format decoding in btsnooz.py" am: 23b3d30f

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1522626

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Icd5665ad54a2672e119f79982c67a37baa6f2259
parents ee986a19 23b3d30f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ def type_to_hci(type):
        return '\x03'
    if type == TYPE_IN_EVT:
        return '\x04'
    raise RuntimeError("type_to_hci: unknown type (0x{:02x})".format(type))


def decode_snooz(snooz):
@@ -120,16 +121,16 @@ def decode_snooz_v2(decompressed, last_timestamp_ms):
    first_timestamp_ms = last_timestamp_ms + 0x00dcddb30f2f8000
    offset = 0
    while offset < len(decompressed):
        length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHIb', decompressed, offset)
        offset += 9 + length - 1
        length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHQb', decompressed, offset)
        offset += 13 + length - 1
        first_timestamp_ms -= delta_time_ms

    # Second pass does the actual writing out to stdout.
    offset = 0
    while offset < len(decompressed):
        length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHIb', decompressed, offset)
        length, packet_length, delta_time_ms, snooz_type = struct.unpack_from('=HHQb', decompressed, offset)
        first_timestamp_ms += delta_time_ms
        offset += 9
        offset += 13
        sys.stdout.write(struct.pack('>II', packet_length, length))
        sys.stdout.write(struct.pack('>II', type_to_direction(snooz_type), 0))
        sys.stdout.write(struct.pack('>II', (first_timestamp_ms >> 32), (first_timestamp_ms & 0xFFFFFFFF)))