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

Commit c80ad6f1 authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by android-build-merger
Browse files

SecurityManagerImpl remove special handling for first callback...

SecurityManagerImpl remove special handling for first callback insertion/deletion am: 411205f0 am: 4ce4f6f0
am: 30593975

Change-Id: I7efe1e25db0fc13ca25920a91ba00f5fa52c8efa
parents 032eea9b 30593975
Loading
Loading
Loading
Loading
+10 −24
Original line number Diff line number Diff line
@@ -101,38 +101,24 @@ void SecurityManagerImpl::RemoveBond(std::shared_ptr<hci::ClassicDevice> device)
}

void SecurityManagerImpl::RegisterCallbackListener(ISecurityManagerListener* listener, os::Handler* handler) {
  if (listeners_.size() < 1) {
    listeners_.push_back({listener, handler});
  } else {
    bool found = false;
  for (auto it = listeners_.begin(); it != listeners_.end(); ++it) {
      found = it->first == listener;
      if (found) break;
    if (it->first == listener) {
      LOG_ALWAYS_FATAL("Listener has already been registered!");
    }
  }

    if (found) {
      LOG_ERROR("Listener has already been registered!");
    } else {
  listeners_.push_back({listener, handler});
}
  }
}

void SecurityManagerImpl::UnregisterCallbackListener(ISecurityManagerListener* listener) {
  if (listeners_.size() < 1) {
    LOG_ERROR("Listener has not been registered!");
  } else {
    bool found = false;
    auto it = listeners_.begin();
    while (it != listeners_.end()) {
      found = it->first == listener;
      if (found) break;
      ++it;
    }
    if (found) {
  for (auto it = listeners_.begin(); it != listeners_.end(); ++it) {
    if (it->first == listener) {
      listeners_.erase(it);
      return;
    }
  }

  LOG_ALWAYS_FATAL("Listener has not been registered!");
}

void SecurityManagerImpl::FireDeviceBondedCallbacks(std::shared_ptr<Device> device) {