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

Commit 127e22f1 authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz
Browse files

IOT Device Info: Replace legacy with trunk stable flag

Bug: 261319328
Bug: 290844229
Bug: 261319328
Flag: com.android.bluetooth.flags.device_iot_config_logging
Test: atest bluetooth_test_gd
Change-Id: I80b2e09529da260183da5e20f0a166e35be03173
parent 4816e9bb
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ aconfig("bluetooth_flags_c_lib") {
    "bta_dm.aconfig",
    "bta_dm.aconfig",
    "btif_dm.aconfig",
    "btif_dm.aconfig",
    "connectivity.aconfig",
    "connectivity.aconfig",
    "device_iot_config.aconfig",
    "did.aconfig",
    "did.aconfig",
    "discovery_service.aconfig",
    "discovery_service.aconfig",
    "dumpsys.aconfig",
    "dumpsys.aconfig",
+3 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,7 @@ cc_test {
        "liblog",
        "liblog",
    ],
    ],
    static_libs: [
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth-types",
        "libbluetooth_log",
        "libbluetooth_log",
        "libbt-platform-protos-lite",
        "libbt-platform-protos-lite",
@@ -108,7 +109,9 @@ cc_test {
        "libbtcore",
        "libbtcore",
        "libbtdevice",
        "libbtdevice",
        "libchrome",
        "libchrome",
        "libflagtest",
        "libgmock",
        "libgmock",
        "server_configurable_flags",
    ],
    ],
    header_libs: ["libbluetooth_headers"],
    header_libs: ["libbluetooth_headers"],
    cflags: ["-Wno-unused-parameter"],
    cflags: ["-Wno-unused-parameter"],
+31 −19
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include "device/include/device_iot_config.h"
#include "device/include/device_iot_config.h"


#include <bluetooth/log.h>
#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>
#include <ctype.h>
#include <ctype.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
@@ -29,7 +30,6 @@
#include <mutex>
#include <mutex>
#include <string>
#include <string>


#include "common/init_flags.h"
#include "device_iot_config_int.h"
#include "device_iot_config_int.h"
#include "internal_include/bt_target.h"
#include "internal_include/bt_target.h"
#include "os/log.h"
#include "os/log.h"
@@ -47,11 +47,11 @@ std::mutex config_lock; // protects operations on |config|.
std::unique_ptr<config_t> config;
std::unique_ptr<config_t> config;
alarm_t* config_timer;
alarm_t* config_timer;


using bluetooth::common::InitFlags;
using namespace bluetooth;
using namespace bluetooth;


bool device_iot_config_has_section(const std::string& section) {
bool device_iot_config_has_section(const std::string& section) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -61,7 +61,8 @@ bool device_iot_config_has_section(const std::string& section) {


bool device_iot_config_exist(const std::string& section,
bool device_iot_config_exist(const std::string& section,
                             const std::string& key) {
                             const std::string& key) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -71,7 +72,8 @@ bool device_iot_config_exist(const std::string& section,


bool device_iot_config_get_int(const std::string& section,
bool device_iot_config_get_int(const std::string& section,
                               const std::string& key, int& value) {
                               const std::string& key, int& value) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -84,7 +86,8 @@ bool device_iot_config_get_int(const std::string& section,


bool device_iot_config_set_int(const std::string& section,
bool device_iot_config_set_int(const std::string& section,
                               const std::string& key, int value) {
                               const std::string& key, int value) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -101,7 +104,8 @@ bool device_iot_config_set_int(const std::string& section,


bool device_iot_config_int_add_one(const std::string& section,
bool device_iot_config_int_add_one(const std::string& section,
                                   const std::string& key) {
                                   const std::string& key) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -121,7 +125,8 @@ bool device_iot_config_int_add_one(const std::string& section,


bool device_iot_config_get_hex(const std::string& section,
bool device_iot_config_get_hex(const std::string& section,
                               const std::string& key, int& value) {
                               const std::string& key, int& value) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -144,7 +149,8 @@ bool device_iot_config_get_hex(const std::string& section,
bool device_iot_config_set_hex(const std::string& section,
bool device_iot_config_set_hex(const std::string& section,
                               const std::string& key, int value,
                               const std::string& key, int value,
                               int byte_num) {
                               int byte_num) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -170,7 +176,8 @@ bool device_iot_config_set_hex(const std::string& section,
bool device_iot_config_set_hex_if_greater(const std::string& section,
bool device_iot_config_set_hex_if_greater(const std::string& section,
                                          const std::string& key, int value,
                                          const std::string& key, int value,
                                          int byte_num) {
                                          int byte_num) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  int stored_value = 0;
  int stored_value = 0;
  bool ret = device_iot_config_get_hex(section, key, stored_value);
  bool ret = device_iot_config_get_hex(section, key, stored_value);
@@ -182,7 +189,8 @@ bool device_iot_config_set_hex_if_greater(const std::string& section,
bool device_iot_config_get_str(const std::string& section,
bool device_iot_config_get_str(const std::string& section,
                               const std::string& key, char* value,
                               const std::string& key, char* value,
                               int* size_bytes) {
                               int* size_bytes) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(value != NULL, "assert failed: value != NULL");
  log::assert_that(value != NULL, "assert failed: value != NULL");
@@ -203,7 +211,8 @@ bool device_iot_config_get_str(const std::string& section,
bool device_iot_config_set_str(const std::string& section,
bool device_iot_config_set_str(const std::string& section,
                               const std::string& key,
                               const std::string& key,
                               const std::string& value) {
                               const std::string& value) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -219,7 +228,8 @@ bool device_iot_config_set_str(const std::string& section,
bool device_iot_config_get_bin(const std::string& section,
bool device_iot_config_get_bin(const std::string& section,
                               const std::string& key, uint8_t* value,
                               const std::string& key, uint8_t* value,
                               size_t* length) {
                               size_t* length) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(value != NULL, "assert failed: value != NULL");
  log::assert_that(value != NULL, "assert failed: value != NULL");
@@ -253,7 +263,7 @@ bool device_iot_config_get_bin(const std::string& section,


size_t device_iot_config_get_bin_length(const std::string& section,
size_t device_iot_config_get_bin_length(const std::string& section,
                                        const std::string& key) {
                                        const std::string& key) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return 0;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return 0;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -269,7 +279,8 @@ size_t device_iot_config_get_bin_length(const std::string& section,
bool device_iot_config_set_bin(const std::string& section,
bool device_iot_config_set_bin(const std::string& section,
                               const std::string& key, const uint8_t* value,
                               const std::string& key, const uint8_t* value,
                               size_t length) {
                               size_t length) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  const char* lookup = "0123456789abcdef";
  const char* lookup = "0123456789abcdef";


@@ -305,7 +316,8 @@ bool device_iot_config_set_bin(const std::string& section,


bool device_iot_config_remove(const std::string& section,
bool device_iot_config_remove(const std::string& section,
                              const std::string& key) {
                              const std::string& key) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");


@@ -314,7 +326,7 @@ bool device_iot_config_remove(const std::string& section,
}
}


void device_iot_config_flush(void) {
void device_iot_config_flush(void) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -327,7 +339,7 @@ void device_iot_config_flush(void) {
}
}


bool device_iot_config_clear(void) {
bool device_iot_config_clear(void) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return true;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return true;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -349,7 +361,7 @@ bool device_iot_config_clear(void) {
}
}


void device_debug_iot_config_dump(int fd) {
void device_debug_iot_config_dump(int fd) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return;


  dprintf(fd, "\nBluetooth Iot Config:\n");
  dprintf(fd, "\nBluetooth Iot Config:\n");


+5 −6
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@
#include "device_iot_config_int.h"
#include "device_iot_config_int.h"


#include <bluetooth/log.h>
#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include <time.h>
#include <unistd.h>
#include <unistd.h>
@@ -30,7 +31,6 @@


#include "btcore/include/module.h"
#include "btcore/include/module.h"
#include "btif/include/btif_common.h"
#include "btif/include/btif_common.h"
#include "common/init_flags.h"
#include "device/include/device_iot_config.h"
#include "device/include/device_iot_config.h"
#include "os/log.h"
#include "os/log.h"
#include "osi/include/alarm.h"
#include "osi/include/alarm.h"
@@ -48,7 +48,6 @@ extern std::mutex config_lock; // protects operations on |config|.
extern std::unique_ptr<config_t> config;
extern std::unique_ptr<config_t> config;
extern alarm_t* config_timer;
extern alarm_t* config_timer;


using bluetooth::common::InitFlags;
using namespace bluetooth;
using namespace bluetooth;


static void cleanup() {
static void cleanup() {
@@ -188,8 +187,8 @@ EXPORT_SYMBOL module_t device_iot_config_module = {
    .shut_down = device_iot_config_module_shut_down,
    .shut_down = device_iot_config_module_shut_down,
    .clean_up = device_iot_config_module_clean_up};
    .clean_up = device_iot_config_module_clean_up};


void device_iot_config_write(uint16_t event, char* /* p_param */) {
void device_iot_config_write(uint16_t event, UNUSED_ATTR char* p_param) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -228,7 +227,7 @@ bool device_iot_config_has_key_value(const std::string& section,
}
}


void device_iot_config_save_async(void) {
void device_iot_config_save_async(void) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return;


  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config != NULL, "assert failed: config != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
  log::assert_that(config_timer != NULL, "assert failed: config_timer != NULL");
@@ -239,7 +238,7 @@ void device_iot_config_save_async(void) {
}
}


int device_iot_config_get_device_num(const config_t& conf) {
int device_iot_config_get_device_num(const config_t& conf) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return 0;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return 0;


  int devices = 0;
  int devices = 0;


+0 −6
Original line number Original line Diff line number Diff line
@@ -61,12 +61,6 @@ static const uint64_t CONFIG_SETTLE_PERIOD_MS = 12000;


enum ConfigSource { NOT_LOADED, ORIGINAL, BACKUP, NEW_FILE, RESET };
enum ConfigSource { NOT_LOADED, ORIGINAL, BACKUP, NEW_FILE, RESET };


#define CHECK_LOGGING_ENABLED(return_value)                               \
  do {                                                                    \
    if (!bluetooth::common::InitFlags::IsDeviceIotConfigLoggingEnabled()) \
      return (return_value);                                              \
  } while (0)

struct config_t;
struct config_t;
struct future_t;
struct future_t;


Loading