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

Commit ac4e9e00 authored by Hui Peng's avatar Hui Peng
Browse files

Add implementation of IRedactableLoggable to ConnectAddressWithType

Test: refactoring CL. Existing unit tests still pass
Bug: 174487588
Tag: #security
Change-Id: I0a4fb85ef19c4637da8f6069b05243199c5058e3
parent 21a47807
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@
#include <unordered_set>
#include <unordered_set>


#include "btif/include/btif_hh.h"
#include "btif/include/btif_hh.h"
#include "common/interfaces/ILoggable.h"
#include "device/include/controller.h"
#include "device/include/controller.h"
#include "gd/common/bidi_queue.h"
#include "gd/common/bidi_queue.h"
#include "gd/common/bind.h"
#include "gd/common/bind.h"
@@ -76,18 +77,29 @@ bt_status_t do_in_main_thread(const base::Location& from_here,


using namespace bluetooth;
using namespace bluetooth;


class ConnectAddressWithType {
class ConnectAddressWithType : public bluetooth::common::IRedactableLoggable {
 public:
 public:
  explicit ConnectAddressWithType(hci::AddressWithType address_with_type)
  explicit ConnectAddressWithType(hci::AddressWithType address_with_type)
      : address_(address_with_type.GetAddress()),
      : address_(address_with_type.GetAddress()),
        type_(address_with_type.ToFilterAcceptListAddressType()) {}
        type_(address_with_type.ToFilterAcceptListAddressType()) {}


  // TODO: remove this method
  std::string const ToString() const {
  std::string const ToString() const {
    std::stringstream ss;
    std::stringstream ss;
    ss << address_ << "[" << FilterAcceptListAddressTypeText(type_) << "]";
    ss << address_.ToString() << "[" << FilterAcceptListAddressTypeText(type_)
       << "]";
    return ss.str();
    return ss.str();
  }
  }


  std::string ToStringForLogging() const override {
    return ToString();
  }
  std::string ToRedactedStringForLogging() const override {
    std::stringstream ss;
    ss << address_.ToRedactedStringForLogging() << "["
       << FilterAcceptListAddressTypeText(type_) << "]";
    return ss.str();
  }
  bool operator==(const ConnectAddressWithType& rhs) const {
  bool operator==(const ConnectAddressWithType& rhs) const {
    return address_ == rhs.address_ && type_ == rhs.type_;
    return address_ == rhs.address_ && type_ == rhs.type_;
  }
  }