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

Commit 7732014a authored by Chris Manton's avatar Chris Manton
Browse files

Add stack/include/btm_api_types::is_legal_power_mode

Towards readable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I001c2476f23acb57fbb57f20e6212e9eb3f0ef9c
parent cb2e8c46
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,17 @@ enum : uint8_t {
  BTM_PM_MD_FORCE = 0x10 /* OR this to force ACL link to a certain mode */
};
typedef uint8_t tBTM_PM_MODE;
inline bool is_legal_power_mode(tBTM_PM_MODE mode) {
  switch (mode & ~BTM_PM_MD_FORCE) {
    case BTM_PM_MD_ACTIVE:
    case BTM_PM_MD_HOLD:
    case BTM_PM_MD_SNIFF:
    case BTM_PM_MD_PARK:
      return true;
    default:
      return false;
  }
}

inline std::string power_mode_text(tBTM_PM_MODE mode) {
  std::string s = base::StringPrintf((mode & BTM_PM_MD_FORCE) ? "" : "forced:");