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

Commit 3a1faf89 authored by Zach Johnson's avatar Zach Johnson Committed by Automerger Merge Worker
Browse files

Merge "EventPacket -> Event" am: 22122eed

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic239e8effa1fc5967f043180d3a72fa43a01d9f9
parents 4bc3f473 22122eed
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -32,25 +32,25 @@ class HalCaptures(object):
        return Capture(
            lambda packet: packet.payload[0:5] == b'\x0e\x0a\x01\x09\x10', lambda packet: hci_packets.ReadBdAddrCompleteView(
                hci_packets.CommandCompleteView(
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))
                    hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))

    @staticmethod
    def ConnectionRequestCapture():
        return Capture(
            lambda packet: packet.payload[0:2] == b'\x04\x0a', lambda packet: hci_packets.ConnectionRequestView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
                hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))

    @staticmethod
    def ConnectionCompleteCapture():
        return Capture(
            lambda packet: packet.payload[0:3] == b'\x03\x0b\x00', lambda packet: hci_packets.ConnectionCompleteView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
                hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))

    @staticmethod
    def DisconnectionCompleteCapture():
        return Capture(
            lambda packet: packet.payload[0:2] == b'\x05\x04', lambda packet: hci_packets.DisconnectionCompleteView(
                hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))
                hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload)))))

    @staticmethod
    def LeConnectionCompleteCapture():
@@ -58,7 +58,7 @@ class HalCaptures(object):
            lambda packet: packet.payload[0] == 0x3e and (packet.payload[2] == 0x01 or packet.payload[2] == 0x0a),
            lambda packet: hci_packets.LeConnectionCompleteView(
                hci_packets.LeMetaEventView(
                    hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))
                    hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet.payload))))))


class HciCaptures(object):
+2 −2
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ class HciMatchers(object):

    @staticmethod
    def _extract_matching_event(packet_bytes, event_code):
        event = hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(packet_bytes)))
        event = hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(packet_bytes)))
        if event is None:
            return None
        if event_code is not None and event.GetEventCode() != event_code:
@@ -144,7 +144,7 @@ class HciMatchers(object):

    @staticmethod
    def LogEventCode():
        return lambda event: logging.info("Received event: %x" % hci_packets.EventPacketView(bt_packets.PacketViewLittleEndian(list(event.payload))).GetEventCode())
        return lambda event: logging.info("Received event: %x" % hci_packets.EventView(bt_packets.PacketViewLittleEndian(list(event.event))).GetEventCode())

    @staticmethod
    def LinkKeyRequest():
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void FuzzHciHal::sendHciCommand(HciPacket packet) {
}

void FuzzHciHal::injectHciEvent(std::vector<uint8_t> data) {
  hci::EventPacketView event = hci::EventPacketView::FromBytes(data);
  hci::EventView event = hci::EventView::FromBytes(data);
  if (!event.IsValid()) {
    return;
  }
+16 −16
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    }
  }

  void on_classic_event(EventPacketView event_packet) {
  void on_classic_event(EventView event_packet) {
    EventCode event_code = event_packet.GetEventCode();
    switch (event_code) {
      case EventCode::CONNECTION_COMPLETE:
@@ -141,7 +141,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    client_handler_ = handler;
  }

  void on_incoming_connection(EventPacketView packet) {
  void on_incoming_connection(EventView packet) {
    ConnectionRequestView request = ConnectionRequestView::Create(packet);
    ASSERT(request.IsValid());
    Address address = request.GetBdAddr();
@@ -198,7 +198,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    }
  }

  void on_connection_complete(EventPacketView packet) {
  void on_connection_complete(EventView packet) {
    ConnectionCompleteView connection_complete = ConnectionCompleteView::Create(packet);
    ASSERT(connection_complete.IsValid());
    auto status = connection_complete.GetStatus();
@@ -251,7 +251,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    }
  }

  void on_connection_packet_type_changed(EventPacketView packet) {
  void on_connection_packet_type_changed(EventView packet) {
    ConnectionPacketTypeChangedView packet_type_changed = ConnectionPacketTypeChangedView::Create(packet);
    if (!packet_type_changed.IsValid()) {
      LOG_ERROR("Received on_connection_packet_type_changed with invalid packet");
@@ -272,7 +272,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    // We don't handle this event; we didn't do this in legacy stack either.
  }

  void on_central_link_key_complete(EventPacketView packet) {
  void on_central_link_key_complete(EventView packet) {
    CentralLinkKeyCompleteView complete_view = CentralLinkKeyCompleteView::Create(packet);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_central_link_key_complete with invalid packet");
@@ -294,7 +294,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnCentralLinkKeyComplete(key_flag);
  }

  void on_authentication_complete(EventPacketView packet) {
  void on_authentication_complete(EventView packet) {
    AuthenticationCompleteView authentication_complete = AuthenticationCompleteView::Create(packet);
    if (!authentication_complete.IsValid()) {
      LOG_ERROR("Received on_authentication_complete with invalid packet");
@@ -351,7 +351,7 @@ struct classic_impl : public security::ISecurityManagerListener {
        handler_->BindOnceOn(this, &classic_impl::on_accept_connection_status, address));
  }

  void on_change_connection_link_key_complete(EventPacketView packet) {
  void on_change_connection_link_key_complete(EventView packet) {
    ChangeConnectionLinkKeyCompleteView complete_view = ChangeConnectionLinkKeyCompleteView::Create(packet);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_change_connection_link_key_complete with invalid packet");
@@ -372,7 +372,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnChangeConnectionLinkKeyComplete();
  }

  void on_read_clock_offset_complete(EventPacketView packet) {
  void on_read_clock_offset_complete(EventView packet) {
    ReadClockOffsetCompleteView complete_view = ReadClockOffsetCompleteView::Create(packet);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_read_clock_offset_complete with invalid packet");
@@ -394,7 +394,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnReadClockOffsetComplete(clock_offset);
  }

  void on_mode_change(EventPacketView packet) {
  void on_mode_change(EventView packet) {
    ModeChangeView mode_change_view = ModeChangeView::Create(packet);
    if (!mode_change_view.IsValid()) {
      LOG_ERROR("Received on_mode_change with invalid packet");
@@ -417,7 +417,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnModeChange(current_mode, interval);
  }

  void on_qos_setup_complete(EventPacketView packet) {
  void on_qos_setup_complete(EventView packet) {
    QosSetupCompleteView complete_view = QosSetupCompleteView::Create(packet);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_qos_setup_complete with invalid packet");
@@ -443,7 +443,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnQosSetupComplete(service_type, token_rate, peak_bandwidth, latency, delay_variation);
  }

  void on_role_change(EventPacketView packet) {
  void on_role_change(EventView packet) {
    RoleChangeView role_change_view = RoleChangeView::Create(packet);
    if (!role_change_view.IsValid()) {
      LOG_ERROR("Received on_role_change with invalid packet");
@@ -463,7 +463,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    }
  }

  void on_flow_specification_complete(EventPacketView packet) {
  void on_flow_specification_complete(EventView packet) {
    FlowSpecificationCompleteView complete_view = FlowSpecificationCompleteView::Create(packet);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_flow_specification_complete with invalid packet");
@@ -491,7 +491,7 @@ struct classic_impl : public security::ISecurityManagerListener {
        flow_direction, service_type, token_rate, token_bucket_size, peak_bandwidth, access_latency);
  }

  void on_flush_occurred(EventPacketView packet) {
  void on_flush_occurred(EventView packet) {
    FlushOccurredView flush_occurred_view = FlushOccurredView::Create(packet);
    if (!flush_occurred_view.IsValid()) {
      LOG_ERROR("Received on_flush_occurred with invalid packet");
@@ -518,7 +518,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnReadRemoteVersionInformationComplete(version, manufacturer_name, sub_version);
  }

  void on_read_remote_supported_features_complete(EventPacketView packet) {
  void on_read_remote_supported_features_complete(EventView packet) {
    auto view = ReadRemoteSupportedFeaturesCompleteView::Create(packet);
    ASSERT_LOG(view.IsValid(), "Read remote supported features packet invalid");
    uint16_t handle = view.GetConnectionHandle();
@@ -531,7 +531,7 @@ struct classic_impl : public security::ISecurityManagerListener {
    callbacks->OnReadRemoteExtendedFeaturesComplete(0, 1, view.GetLmpFeatures());
  }

  void on_read_remote_extended_features_complete(EventPacketView packet) {
  void on_read_remote_extended_features_complete(EventView packet) {
    auto view = ReadRemoteExtendedFeaturesCompleteView::Create(packet);
    ASSERT_LOG(view.IsValid(), "Read remote extended features packet invalid");
    uint16_t handle = view.GetConnectionHandle();
@@ -545,7 +545,7 @@ struct classic_impl : public security::ISecurityManagerListener {
        view.GetPageNumber(), view.GetMaximumPageNumber(), view.GetExtendedLmpFeatures());
  }

  void on_link_supervision_timeout_changed(EventPacketView packet) {
  void on_link_supervision_timeout_changed(EventView packet) {
    auto view = LinkSupervisionTimeoutChangedView::Create(packet);
    ASSERT_LOG(view.IsValid(), "Link supervision timeout changed packet invalid");
    LOG_INFO("UNIMPLEMENTED called");
+7 −8
Original line number Diff line number Diff line
@@ -191,8 +191,7 @@ class TestHciLayer : public HciLayer {
    return command;
  }

  void RegisterEventHandler(EventCode event_code,
                            common::ContextualCallback<void(EventPacketView)> event_handler) override {
  void RegisterEventHandler(EventCode event_code, common::ContextualCallback<void(EventView)> event_handler) override {
    registered_events_[event_code] = event_handler;
  }

@@ -209,9 +208,9 @@ class TestHciLayer : public HciLayer {
    registered_le_events_.erase(subevent_code);
  }

  void IncomingEvent(std::unique_ptr<EventPacketBuilder> event_builder) {
  void IncomingEvent(std::unique_ptr<EventBuilder> event_builder) {
    auto packet = GetPacketView(std::move(event_builder));
    EventPacketView event = EventPacketView::Create(packet);
    EventView event = EventView::Create(packet);
    ASSERT_TRUE(event.IsValid());
    EventCode event_code = event.GetEventCode();
    ASSERT_NE(registered_events_.find(event_code), registered_events_.end()) << EventCodeText(event_code);
@@ -220,7 +219,7 @@ class TestHciLayer : public HciLayer {

  void IncomingLeMetaEvent(std::unique_ptr<LeMetaEventBuilder> event_builder) {
    auto packet = GetPacketView(std::move(event_builder));
    EventPacketView event = EventPacketView::Create(packet);
    EventView event = EventView::Create(packet);
    LeMetaEventView meta_event_view = LeMetaEventView::Create(event);
    EXPECT_TRUE(meta_event_view.IsValid());
    SubeventCode subevent_code = meta_event_view.GetSubeventCode();
@@ -252,14 +251,14 @@ class TestHciLayer : public HciLayer {
    EXPECT_EQ(queue_end->TryDequeue(), nullptr);
  }

  void CommandCompleteCallback(EventPacketView event) {
  void CommandCompleteCallback(EventView event) {
    CommandCompleteView complete_view = CommandCompleteView::Create(event);
    ASSERT_TRUE(complete_view.IsValid());
    std::move(command_complete_callbacks.front()).Invoke(complete_view);
    command_complete_callbacks.pop_front();
  }

  void CommandStatusCallback(EventPacketView event) {
  void CommandStatusCallback(EventView event) {
    CommandStatusView status_view = CommandStatusView::Create(event);
    ASSERT_TRUE(status_view.IsValid());
    std::move(command_status_callbacks.front()).Invoke(status_view);
@@ -293,7 +292,7 @@ class TestHciLayer : public HciLayer {
  }

 private:
  std::map<EventCode, common::ContextualCallback<void(EventPacketView)>> registered_events_;
  std::map<EventCode, common::ContextualCallback<void(EventView)>> registered_events_;
  std::map<SubeventCode, common::ContextualCallback<void(LeMetaEventView)>> registered_le_events_;
  std::list<common::ContextualOnceCallback<void(CommandCompleteView)>> command_complete_callbacks;
  std::list<common::ContextualOnceCallback<void(CommandStatusView)>> command_status_callbacks;
Loading