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

Commit e64f7df8 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap Signalling manager: Handle lost info request

If the remote doesn't respond info request extended features, or sends
CommandReject, we assume the remote doesn't support ERTM or FCS.
(We should probably note which remote device in the future, as
respondong to info request is mandatory, and supporting ERTM is
mandatory for BT 4.0+)

Test: cert/run --host
Change-Id: Ia7ba11d1c1d3b9245be6f7db09847aba0d0f7b22
parent 99c567d6
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -233,22 +233,20 @@ Mtu Link::GetRemoteConnectionlessMtu() const {
  return remote_connectionless_mtu_;
}

void Link::SetRemoteSupportsErtm(bool supported) {
  remote_supports_ertm_ = supported;
}

bool Link::GetRemoteSupportsErtm() const {
  return remote_supports_ertm_;
}

void Link::SetRemoteSupportsFcs(bool supported) {
  remote_supports_fcs_ = supported;
}

bool Link::GetRemoteSupportsFcs() const {
  return remote_supports_fcs_;
}

void Link::OnRemoteExtendedFeatureReceived(bool ertm_supported, bool fcs_supported) {
  remote_supports_ertm_ = ertm_supported;
  remote_supports_fcs_ = fcs_supported;
  remote_extended_feature_received_ = true;
}

void Link::AddChannelPendingingAuthentication(PendingAuthenticateDynamicChannelConnection pending_channel) {
  pending_channel_list_.push_back(std::move(pending_channel));
}
+2 −2
Original line number Diff line number Diff line
@@ -124,10 +124,9 @@ class Link : public l2cap::internal::ILink, public hci::ConnectionManagementCall
  // Information received from signaling channel
  virtual void SetRemoteConnectionlessMtu(Mtu mtu);
  virtual Mtu GetRemoteConnectionlessMtu() const;
  virtual void SetRemoteSupportsErtm(bool supported);
  virtual bool GetRemoteSupportsErtm() const;
  virtual void SetRemoteSupportsFcs(bool supported);
  virtual bool GetRemoteSupportsFcs() const;
  virtual void OnRemoteExtendedFeatureReceived(bool ertm_supported, bool fcs_supported);

  virtual std::string ToString() {
    return GetDevice().ToString();
@@ -174,6 +173,7 @@ class Link : public l2cap::internal::ILink, public hci::ConnectionManagementCall
  os::Alarm link_idle_disconnect_alarm_{l2cap_handler_};
  ClassicSignallingManager signalling_manager_;
  Mtu remote_connectionless_mtu_ = kMinimumClassicMtu;
  bool remote_extended_feature_received_ = false;
  bool remote_supports_ertm_ = false;
  bool remote_supports_fcs_ = false;
  hci::EncryptionEnabled encryption_enabled_ = hci::EncryptionEnabled::OFF;
+11 −2
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ void ClassicSignallingManager::OnCommandReject(CommandRejectView command_reject_
    LOG_WARN("Unexpected command reject: no pending request");
    return;
  }
  if (command_just_sent_.command_code_ == CommandCode::INFORMATION_REQUEST &&
      command_just_sent_.info_type_ == InformationRequestInfoType::EXTENDED_FEATURES_SUPPORTED) {
    link_->OnRemoteExtendedFeatureReceived(false, false);
  }
  alarm_.Cancel();
  handle_send_next_command();

@@ -635,8 +639,7 @@ void ClassicSignallingManager::OnInformationResponse(SignalId signal_id, const I
        LOG_WARN("Invalid InformationResponseExtendedFeatures received");
        return;
      }
      link_->SetRemoteSupportsErtm((view.GetEnhancedRetransmissionMode()));
      link_->SetRemoteSupportsFcs(view.GetFcsOption());
      link_->OnRemoteExtendedFeatureReceived(view.GetEnhancedRetransmissionMode(), view.GetFcsOption());
      // We don't care about other parameters
      break;
    }
@@ -793,6 +796,12 @@ void ClassicSignallingManager::on_command_timeout() {
      SendDisconnectionRequest(channel->GetCid(), channel->GetRemoteCid());
      return;
    }
    case CommandCode::INFORMATION_REQUEST: {
      if (command_just_sent_.info_type_ == InformationRequestInfoType::EXTENDED_FEATURES_SUPPORTED) {
        link_->OnRemoteExtendedFeatureReceived(false, false);
      }
      break;
    }
    default:
      break;
  }