OSDN Git Service

enum-ify stack/btm/btm_ble_int_types::tBTM_BLE_SEC_REQ_ACT
authorChris Manton <cmanton@google.com>
Fri, 18 Sep 2020 15:54:40 +0000 (08:54 -0700)
committerChris Manton <cmanton@google.com>
Tue, 22 Sep 2020 20:21:18 +0000 (20:21 +0000)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: acts -tc BleCocTest
Test: ble paired 2 phones
Change-Id: I05ccdb3e4b1b42810f77a4d6322606434a4b58c7

stack/btm/btm_ble_int_types.h
stack/gatt/gatt_auth.cc

index 2a26ed6..d4ff12d 100644 (file)
 
 #define BTM_BLE_GAP_FAST_ADV_TIMEOUT_MS (30 * 1000)
 
-#define BTM_BLE_SEC_REQ_ACT_NONE 0
-/* encrypt the link using current key or key refresh */
-#define BTM_BLE_SEC_REQ_ACT_ENCRYPT 1
-#define BTM_BLE_SEC_REQ_ACT_PAIR 2
-/* discard the sec request while encryption is started but not completed */
-#define BTM_BLE_SEC_REQ_ACT_DISCARD 3
-typedef uint8_t tBTM_BLE_SEC_REQ_ACT;
+typedef enum : uint8_t {
+  BTM_BLE_SEC_REQ_ACT_NONE = 0,
+  /* encrypt the link using current key or key refresh */
+  BTM_BLE_SEC_REQ_ACT_ENCRYPT = 1,
+  BTM_BLE_SEC_REQ_ACT_PAIR = 2,
+  /* discard the sec request while encryption is started but not completed */
+  BTM_BLE_SEC_REQ_ACT_DISCARD = 3,
+} tBTM_BLE_SEC_REQ_ACT;
 
 /* LE scan activity bit mask, continue with LE inquiry bits */
 /* observe is in progress */
index e932987..71f8c92 100644 (file)
@@ -272,7 +272,7 @@ tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB* p_clcb) {
   bool is_link_key_known = false;
   bool is_key_mitm = false;
   uint8_t key_type;
-  tBTM_BLE_SEC_REQ_ACT sec_act = BTM_LE_SEC_NONE;
+  tBTM_BLE_SEC_REQ_ACT sec_act = BTM_BLE_SEC_REQ_ACT_NONE;
 
   if (auth_req == GATT_AUTH_REQ_NONE) return act;