OSDN Git Service

enum-ify stack/include/l2c_api::L2CAP_PRIORITY_
authorChris Manton <cmanton@google.com>
Tue, 6 Oct 2020 17:09:58 +0000 (10:09 -0700)
committerChris Manton <cmanton@google.com>
Wed, 7 Oct 2020 21:20:25 +0000 (21:20 +0000)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink

Change-Id: I6d0f97493f407f1a4e32bc12434ec5c3c3b8ef54

main/shim/l2c_api.cc
main/shim/l2c_api.h
stack/include/l2c_api.h
stack/l2cap/l2c_api.cc
stack/l2cap/l2c_int.h
stack/l2cap/l2c_utils.cc

index ac75e6f..2433e94 100644 (file)
@@ -163,7 +163,7 @@ bool bluetooth::shim::L2CA_SetIdleTimeoutByBdAddr(const RawAddress& bd_addr,
 }
 
 bool bluetooth::shim::L2CA_SetAclPriority(const RawAddress& bd_addr,
-                                          uint8_t priority) {
+                                          tL2CAP_PRIORITY priority) {
   LOG_INFO("UNIMPLEMENTED %s", __func__);
   return false;
 }
index bbc77ac..231d3dc 100644 (file)
@@ -265,7 +265,7 @@ uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush);
  * Returns          true if a valid channel, else false
  *
  ******************************************************************************/
-bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority);
+bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority);
 
 /*******************************************************************************
  *
index ca638b2..29c9d4e 100644 (file)
 #define L2CAP_DW_CONGESTED 2
 
 /* Values for priority parameter to L2CA_SetAclPriority */
-#define L2CAP_PRIORITY_NORMAL 0
-#define L2CAP_PRIORITY_HIGH 1
+typedef enum : uint8_t {
+  L2CAP_PRIORITY_NORMAL = 0,
+  L2CAP_PRIORITY_HIGH = 1,
+} tL2CAP_PRIORITY;
 
 /* Values for priority parameter to L2CA_SetTxPriority */
 #define L2CAP_CHNL_PRIORITY_HIGH 0
@@ -518,7 +520,8 @@ extern uint16_t L2CA_FlushChannel(uint16_t lcid, uint16_t num_to_flush);
  * Returns          true if a valid channel, else false
  *
  ******************************************************************************/
-extern bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority);
+extern bool L2CA_SetAclPriority(const RawAddress& bd_addr,
+                                tL2CAP_PRIORITY priority);
 
 /*******************************************************************************
  *
index 0d1e9b3..887e0ed 100644 (file)
@@ -783,7 +783,7 @@ uint8_t L2CA_SetTraceLevel(uint8_t new_level) {
  * Returns          true if a valid channel, else false
  *
  ******************************************************************************/
-bool L2CA_SetAclPriority(const RawAddress& bd_addr, uint8_t priority) {
+bool L2CA_SetAclPriority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority) {
   if (bluetooth::shim::is_gd_shim_enabled()) {
     return bluetooth::shim::L2CA_SetAclPriority(bd_addr, priority);
   }
index 68eb905..f44df89 100644 (file)
@@ -384,7 +384,7 @@ typedef struct t_l2c_linkcb {
 
   uint8_t peer_chnl_mask[L2CAP_FIXED_CHNL_ARRAY_SIZE];
 
-  uint8_t acl_priority;     /* L2C_PRIORITY_NORMAL or L2C_PRIORITY_HIGH */
+  tL2CAP_PRIORITY acl_priority;
 
   tL2C_CCB* p_fixed_ccbs[L2CAP_NUM_FIXED_CHNLS];
 
@@ -528,7 +528,8 @@ extern tL2C_LCB* l2cu_find_lcb_by_bd_addr(const RawAddress& p_bd_addr,
                                           tBT_TRANSPORT transport);
 extern tL2C_LCB* l2cu_find_lcb_by_handle(uint16_t handle);
 
-extern bool l2cu_set_acl_priority(const RawAddress& bd_addr, uint8_t priority,
+extern bool l2cu_set_acl_priority(const RawAddress& bd_addr,
+                                  tL2CAP_PRIORITY priority,
                                   bool reset_after_rs);
 
 extern void l2cu_enqueue_ccb(tL2C_CCB* p_ccb);
index b1614dd..ead38c1 100644 (file)
@@ -2143,7 +2143,7 @@ bool l2cu_lcb_disconnecting(void) {
  *
  ******************************************************************************/
 
-bool l2cu_set_acl_priority(const RawAddress& bd_addr, uint8_t priority,
+bool l2cu_set_acl_priority(const RawAddress& bd_addr, tL2CAP_PRIORITY priority,
                            bool reset_after_rs) {
   tL2C_LCB* p_lcb;
   uint8_t* pp;