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

Commit 427c75f2 authored by Chris Manton's avatar Chris Manton
Browse files

Enum-ify bta/dm/bta_dm_int::tBTA_DM_CONN_STATE

Towards readable code

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

Change-Id: I9f67a9c775a5183a705c822b71810cd880f1faee
parent 8402044a
Loading
Loading
Loading
Loading
+23 −4
Original line number Diff line number Diff line
@@ -32,6 +32,12 @@
#include "bta/sys/bta_sys.h"
#include "main/shim/dumpsys.h"

#ifndef CASE_RETURN_TEXT
#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code
#endif

/*****************************************************************************
 *  Constants and data types
 ****************************************************************************/
@@ -158,10 +164,21 @@ typedef union {

#define BTA_DM_NUM_PEER_DEVICE 7

#define BTA_DM_NOT_CONNECTED 0
#define BTA_DM_CONNECTED 1
#define BTA_DM_UNPAIRING 2
typedef uint8_t tBTA_DM_CONN_STATE;
typedef enum : uint8_t {
  BTA_DM_NOT_CONNECTED = 0,
  BTA_DM_CONNECTED = 1,
  BTA_DM_UNPAIRING = 2,
} tBTA_DM_CONN_STATE;

inline std::string bta_conn_state_text(tBTA_DM_CONN_STATE state) {
  switch (state) {
    CASE_RETURN_TEXT(BTA_DM_NOT_CONNECTED);
    CASE_RETURN_TEXT(BTA_DM_CONNECTED);
    CASE_RETURN_TEXT(BTA_DM_UNPAIRING);
    default:
      return std::string("UNKNOWN");
  }
}

typedef enum : uint8_t {
  BTA_DM_DI_NONE = 0x00,      /* nothing special */
@@ -528,4 +545,6 @@ void bta_dm_search_set_state(uint8_t state);

void bta_dm_eir_update_uuid(uint16_t uuid16, bool adding);
void bta_dm_eir_update_cust_uuid(const tBTA_CUSTOM_UUID &curr, bool adding);

#undef CASE_RETURN_TEXT
#endif /* BTA_DM_INT_H */