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

Commit 438c837a authored by Ajay Panicker's avatar Ajay Panicker Committed by Gerrit Code Review
Browse files

Merge "Send correct key state and ignore keys from inactive device (1/2)"

parents e6736aa0 4bf8d269
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -115,9 +115,9 @@ class MediaInterfaceWrapper : public MediaInterface {
 public:
  MediaInterfaceWrapper(MediaInterface* cb) : wrapped_(cb){};

  void SendKeyEvent(uint8_t key, uint8_t status) override {
  void SendKeyEvent(uint8_t key, KeyState state) override {
    do_in_jni_thread(base::Bind(&MediaInterface::SendKeyEvent,
                                base::Unretained(wrapped_), key, status));
                                base::Unretained(wrapped_), key, state));
  }

  void GetSongInfo(SongInfoCallback info_cb) override {
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ class MediaCallbacks {
// behavior in case the threading model changes on either side.
class MediaInterface {
 public:
  virtual void SendKeyEvent(uint8_t key, uint8_t status) = 0;
  virtual void SendKeyEvent(uint8_t key, KeyState state) = 0;

  using SongInfoCallback = base::Callback<void(SongInfo)>;
  virtual void GetSongInfo(SongInfoCallback info_cb) = 0;
+5 −0
Original line number Diff line number Diff line
@@ -137,6 +137,11 @@ enum class Direction : uint8_t {
  DOWN = 0x01,
};

enum class KeyState : uint8_t {
  PUSHED = 0x00,
  RELEASED = 0x01,
};

class AttributeEntry {
 public:
  AttributeEntry(const Attribute& attribute, const std::string& value)
+13 −0
Original line number Diff line number Diff line
@@ -226,5 +226,18 @@ inline std::ostream& operator<<(std::ostream& os, const Direction& dir) {
  return os << DirectionText(dir);
}

inline std::string KeyStateText(const KeyState& state) {
  switch (state) {
    CASE_RETURN_TEXT(KeyState::PUSHED);
    CASE_RETURN_TEXT(KeyState::RELEASED);
    default:
      return "Unknown KeyState: " + loghex((uint8_t)state);
  }
}

inline std::ostream& operator<<(std::ostream& os, const KeyState& dir) {
  return os << KeyStateText(dir);
}

}  // namespace avrcp
}  // namespace bluetooth
+4 −3
Original line number Diff line number Diff line
@@ -46,8 +46,9 @@ bool PassThroughPacketBuilder::Serialize(
  return true;
}

bool PassThroughPacket::GetPushed() const {
  return (*(begin() + Packet::kMinSize()) & 0b10000000) == 0;
KeyState PassThroughPacket::GetKeyState() const {
  auto it = begin() + Packet::kMinSize();
  return static_cast<KeyState>(((*it) & 0b10000000) >> 7);
}

uint8_t PassThroughPacket::GetOperationId() const {
@@ -63,7 +64,7 @@ std::string PassThroughPacket::ToString() const {
  ss << "  └ Subunit Type = " << loghex(GetSubunitType()) << std::endl;
  ss << "  └ Subunit ID = " << loghex(GetSubunitId()) << std::endl;
  ss << "  └ OpCode = " << GetOpcode() << std::endl;
  ss << "  └ Pushed = " << GetPushed() << std::endl;
  ss << "  └ Pushed = " << GetKeyState() << std::endl;
  ss << "  └ Opperation ID = " << loghex(GetOperationId()) << std::endl;

  return ss.str();
Loading