OSDN Git Service

Move stack/acl/acl::tBTM_PM_STATE earlier in header
authorChris Manton <cmanton@google.com>
Sat, 19 Dec 2020 19:17:14 +0000 (11:17 -0800)
committerChris Manton <cmanton@google.com>
Sun, 20 Dec 2020 02:14:40 +0000 (18:14 -0800)
Towards readable code

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

Change-Id: I91ea973bc27328cbbe8bcc1a9e432399da07a366

stack/acl/acl.h

index 6093aa9..753332a 100644 (file)
@@ -69,6 +69,43 @@ inline std::string link_policy_text(tLINK_POLICY policy) {
   return s;
 }
 
+// Power mode states.
+// Used as both value and bitmask
+enum : uint8_t {
+  BTM_PM_ST_ACTIVE = HCI_MODE_ACTIVE,      // 0x00
+  BTM_PM_ST_HOLD = HCI_MODE_HOLD,          // 0x01
+  BTM_PM_ST_SNIFF = HCI_MODE_SNIFF,        // 0x02
+  BTM_PM_ST_PARK = HCI_MODE_PARK,          // 0x03
+  BTM_PM_ST_UNUSED,                        // 0x04
+  BTM_PM_ST_PENDING = BTM_PM_STS_PENDING,  // 0x05
+  BTM_PM_ST_INVALID = 0x7F,
+  BTM_PM_STORED_MASK = 0x80, /* set this mask if the command is stored */
+};
+typedef uint8_t tBTM_PM_STATE;
+
+inline std::string power_mode_state_text(tBTM_PM_STATE state) {
+  std::string s =
+      std::string((state & BTM_PM_STORED_MASK) ? "stored:" : "immediate:");
+  switch (state & ~BTM_PM_STORED_MASK) {
+    case BTM_PM_ST_ACTIVE:
+      return s + std::string("active");
+    case BTM_PM_ST_HOLD:
+      return s + std::string("hold");
+    case BTM_PM_ST_SNIFF:
+      return s + std::string("sniff");
+    case BTM_PM_ST_PARK:
+      return s + std::string("park");
+    case BTM_PM_ST_UNUSED:
+      return s + std::string("WARN:UNUSED");
+    case BTM_PM_ST_PENDING:
+      return s + std::string("pending");
+    case BTM_PM_ST_INVALID:
+      return s + std::string("invalid");
+    default:
+      return s + std::string("UNKNOWN");
+  }
+}
+
 /* Structure returned with Role Switch information (in tBTM_CMPL_CB callback
  * function) in response to BTM_SwitchRoleToCentral call.
  */
@@ -208,43 +245,6 @@ typedef struct {
   uint8_t sca; /* Sleep clock accuracy */
 } tACL_CONN;
 
-// Power mode states.
-// Used as both value and bitmask
-enum : uint8_t {
-  BTM_PM_ST_ACTIVE = HCI_MODE_ACTIVE,      // 0x00
-  BTM_PM_ST_HOLD = HCI_MODE_HOLD,          // 0x01
-  BTM_PM_ST_SNIFF = HCI_MODE_SNIFF,        // 0x02
-  BTM_PM_ST_PARK = HCI_MODE_PARK,          // 0x03
-  BTM_PM_ST_UNUSED,                        // 0x04
-  BTM_PM_ST_PENDING = BTM_PM_STS_PENDING,  // 0x05
-  BTM_PM_ST_INVALID = 0x7F,
-  BTM_PM_STORED_MASK = 0x80, /* set this mask if the command is stored */
-};
-typedef uint8_t tBTM_PM_STATE;
-
-inline std::string power_mode_state_text(tBTM_PM_STATE state) {
-  std::string s =
-      std::string((state & BTM_PM_STORED_MASK) ? "stored:" : "immediate:");
-  switch (state & ~BTM_PM_STORED_MASK) {
-    case BTM_PM_ST_ACTIVE:
-      return s + std::string("active");
-    case BTM_PM_ST_HOLD:
-      return s + std::string("hold");
-    case BTM_PM_ST_SNIFF:
-      return s + std::string("sniff");
-    case BTM_PM_ST_PARK:
-      return s + std::string("park");
-    case BTM_PM_ST_UNUSED:
-      return s + std::string("WARN:UNUSED");
-    case BTM_PM_ST_PENDING:
-      return s + std::string("pending");
-    case BTM_PM_ST_INVALID:
-      return s + std::string("invalid");
-    default:
-      return s + std::string("UNKNOWN");
-  }
-}
-
 /****************************************************
  **      ACL Management API
  ****************************************************/