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

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

LE L2cap security enforcement interface minor fix

Move the code for default impl.

Test: cert/run
Tag: #gd-refactor
Bug: 141555841
Change-Id: I3faf430ac04fbb825595151b9ae5ca9cad233e55
parent bf008c60
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -33,6 +33,20 @@ namespace le {

const ModuleFactory L2capLeModule::Factory = ModuleFactory([]() { return new L2capLeModule(); });

/**
 * A default implementation which cannot satisfy any security level except
 * NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK.
 */
class SecurityEnforcementRejectAllImpl : public SecurityEnforcementInterface {
 public:
  void Enforce(hci::AddressWithType remote, SecurityPolicy policy, ResultCallback result_callback) override {
    if (policy == SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK) {
      result_callback.InvokeIfNotEmpty(true);
    } else {
      result_callback.InvokeIfNotEmpty(false);
    }
  }
};
static SecurityEnforcementRejectAllImpl default_security_module_impl_;

struct L2capLeModule::impl {
+0 −14
Original line number Diff line number Diff line
@@ -40,20 +40,6 @@ class SecurityEnforcementInterface {
  virtual void Enforce(hci::AddressWithType remote, SecurityPolicy policy, ResultCallback result_callback) = 0;
};

/**
 * A default implementation which cannot satisfy any security level except
 * NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK.
 */
class SecurityEnforcementRejectAllImpl : public SecurityEnforcementInterface {
 public:
  void Enforce(hci::AddressWithType remote, SecurityPolicy policy, ResultCallback result_callback) override {
    if (policy == SecurityPolicy::NO_SECURITY_WHATSOEVER_PLAINTEXT_TRANSPORT_OK) {
      result_callback.InvokeIfNotEmpty(true);
    } else {
      result_callback.InvokeIfNotEmpty(false);
    }
  }
};
}  // namespace le
}  // namespace l2cap
}  // namespace bluetooth