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

Commit 0aab5a57 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

SecurityRecord: naming and comments clarification am: e05c7d38

Change-Id: I4823b346dcf0db5259d401de70f3ae76aa576420
parents e8c12021 e05c7d38
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -28,30 +28,31 @@ namespace bluetooth {
namespace security {
namespace record {

enum BondState { NOT_BONDED, PAIRING, PAIRED, BONDED };
enum BondState {
  /* CreateBond was called, or remote send Pairing Request */
  PAIRING,
  /* Link key has been exchanged, but not stored */
  PAIRED,
  /* Link Keys are stored persistently */
  BONDED
};

class SecurityRecord {
 public:
  explicit SecurityRecord(hci::AddressWithType address) : pseudo_address_(address), state_(NOT_BONDED) {}
  explicit SecurityRecord(hci::AddressWithType address) : pseudo_address_(address), state_(PAIRING) {}

  /**
   * Returns true if the device is bonded to another device
   * Returns true if Link Keys are stored persistently
   */
  bool IsBonded() {
    return state_ == BONDED;
  }

  /* Link key has been exchanged, but not stored */
  bool IsPaired() {
    return state_ == PAIRED;
  }

  /**
   * Returns true if a device is currently pairing to another device
   */
  bool IsPairing() {
    return state_ == PAIRING;
  }

  void SetLinkKey(std::array<uint8_t, 16> link_key, hci::KeyType key_type) {
    link_key_ = link_key;
    key_type_ = key_type;