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

Commit 2914efc3 authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

LE: Add link property listener and phy update am: 5353080a am: 8f41d1ed

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

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8dd1d1d66f138fb58f98667c9f64cd4cd69792c3
parents e41812f6 8f41d1ed
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ class LeAclConnectionTracker : public LeConnectionManagementCallbacks {
  void OnReadRemoteVersionInformationComplete(uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
    SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, lmp_version, manufacturer_name, sub_version);
  }
  void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override {
    SAVE_OR_CALL(OnPhyUpdate, tx_phy, rx_phy);
  }

  void OnDisconnection(ErrorCode reason) override {
    SAVE_OR_CALL(OnDisconnection, reason);
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class LeConnectionManagementCallbacks {
  virtual void OnDisconnection(ErrorCode reason) = 0;
  virtual void OnReadRemoteVersionInformationComplete(
      uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
  virtual void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) = 0;
};

}  // namespace acl_manager
+22 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
        on_le_connection_update_complete(event_packet);
        break;
      case SubeventCode::PHY_UPDATE_COMPLETE:
        LOG_INFO("PHY_UPDATE_COMPLETE");
        on_le_phy_update_complete(event_packet);
        break;
      case SubeventCode::DATA_LENGTH_CHANGE:
        on_data_length_change(event_packet);
@@ -268,6 +268,27 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
        complete_view.GetConnInterval(), complete_view.GetConnLatency(), complete_view.GetSupervisionTimeout());
  }

  void on_le_phy_update_complete(LeMetaEventView view) {
    auto complete_view = LePhyUpdateCompleteView::Create(view);
    if (!complete_view.IsValid()) {
      LOG_ERROR("Received on_le_phy_update_complete with invalid packet");
      return;
    } else if (complete_view.GetStatus() != ErrorCode::SUCCESS) {
      auto status = complete_view.GetStatus();
      std::string error_code = ErrorCodeText(status);
      LOG_ERROR("Received on_le_connection_update_complete with error code %s", error_code.c_str());
      return;
    }
    auto handle = complete_view.GetConnectionHandle();
    auto callbacks = get_callbacks(handle);
    if (callbacks == nullptr) {
      LOG_WARN("Can't find connection 0x%hx", handle);
      ASSERT(!crash_on_unknown_handle_);
      return;
    }
    callbacks->OnPhyUpdate(complete_view.GetTxPhy(), complete_view.GetRxPhy());
  }

  void on_le_read_remote_version_information(
      uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
    auto callbacks = get_callbacks(handle);
+1 −0
Original line number Diff line number Diff line
@@ -657,6 +657,7 @@ class AclManagerWithLeConnectionTest : public AclManagerTest {
    MOCK_METHOD3(
        OnReadRemoteVersionInformationComplete,
        void(uint8_t version, uint16_t manufacturer_name, uint16_t sub_version));
    MOCK_METHOD2(OnPhyUpdate, void(uint8_t tx_phy, uint8_t rx_phy));
  } mock_le_connection_management_callbacks_;
};

+2 −0
Original line number Diff line number Diff line
@@ -279,6 +279,8 @@ class LeAclManagerFacadeService : public LeAclManagerFacade::Service, public LeC
      LOG_INFO(
          "tx_octets: 0x%hx, tx_time: 0x%hx, rx_octets 0x%hx, rx_time 0x%hx", tx_octets, tx_time, rx_octets, rx_time);
    }

    void OnPhyUpdate(uint8_t tx_phy, uint8_t rx_phy) override {}
    void OnDisconnection(ErrorCode reason) override {
      std::unique_ptr<BasePacketBuilder> builder =
          DisconnectionCompleteBuilder::Create(ErrorCode::SUCCESS, handle_, reason);
Loading