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

Commit 34889d29 authored by Hansong Zhang's avatar Hansong Zhang Committed by Automerger Merge Worker
Browse files

Simplify code in shim/l2c_api.cc am: 66298066

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

Change-Id: I08899604e126128847e76593ee101f8b1712aa93
parents 3e5b1268 66298066
Loading
Loading
Loading
Loading
+5 −8
Original line number Diff line number Diff line
@@ -43,15 +43,12 @@ using namespace bluetooth::l2cap;

uint16_t classic_cid_token_counter_ = 0x41;

struct ClassicDynamicChannelInfo {
  uint16_t psm;
};
std::unordered_map<uint16_t, ClassicDynamicChannelInfo>
std::unordered_map<uint16_t /* token */, uint16_t /* cid */>
    classic_cid_token_to_channel_map_;

uint16_t add_classic_cid_token_entry(uint16_t psm) {
  uint16_t new_token = classic_cid_token_counter_;
  classic_cid_token_to_channel_map_[new_token] = {psm};
  classic_cid_token_to_channel_map_[new_token] = psm;
  classic_cid_token_counter_++;
  if (classic_cid_token_counter_ == 0) classic_cid_token_counter_ = 0x41;
  return new_token;
@@ -593,7 +590,7 @@ uint16_t bluetooth::shim::L2CA_ConnectReq(uint16_t psm,
}

bool bluetooth::shim::L2CA_DisconnectReq(uint16_t cid) {
  auto psm = classic_cid_token_to_channel_map_[cid].psm;
  auto psm = classic_cid_token_to_channel_map_[cid];
  if (classic_dynamic_channel_helper_map_.count(psm) == 0) {
    LOG(ERROR) << __func__ << "Not registered psm: " << psm;
    return false;
@@ -607,7 +604,7 @@ uint8_t bluetooth::shim::L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) {
    LOG(ERROR) << __func__ << "Invalid cid: " << cid;
    return 0;
  }
  auto psm = classic_cid_token_to_channel_map_[cid].psm;
  auto psm = classic_cid_token_to_channel_map_[cid];
  if (classic_dynamic_channel_helper_map_.count(psm) == 0) {
    LOG(ERROR) << __func__ << "Not registered psm: " << psm;
    return 0;
@@ -856,7 +853,7 @@ bool bluetooth::shim::L2CA_RemoveFixedChnl(uint16_t cid,
 * Channel hygiene APIs
 */
bool bluetooth::shim::L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
  auto psm = classic_cid_token_to_channel_map_[lcid].psm;
  auto psm = classic_cid_token_to_channel_map_[lcid];
  if (classic_dynamic_channel_helper_map_.count(psm) == 0) {
    LOG(ERROR) << __func__ << "Not registered psm: " << psm;
    return false;