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

Commit 3765d138 authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz Committed by Gerrit Code Review
Browse files

Merge "IOT Device Info: Replace legacy with trunk stable flag" into main

parents ba2e6728 127e22f1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ cc_test {
        "liblog",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth_log",
        "libbt-platform-protos-lite",
@@ -108,7 +109,9 @@ cc_test {
        "libbtcore",
        "libbtdevice",
        "libchrome",
        "libflagtest",
        "libgmock",
        "server_configurable_flags",
    ],
    header_libs: ["libbluetooth_headers"],
    cflags: ["-Wno-unused-parameter"],
+31 −19
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "device/include/device_iot_config.h"

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

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

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

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");

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

bool device_iot_config_exist(const std::string& section,
                             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");

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

bool device_iot_config_get_int(const std::string& section,
                               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");

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

bool device_iot_config_set_int(const std::string& section,
                               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");

@@ -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,
                                   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");

@@ -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,
                               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");

@@ -144,7 +149,8 @@ bool device_iot_config_get_hex(const std::string& section,
bool device_iot_config_set_hex(const std::string& section,
                               const std::string& key, int value,
                               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");

@@ -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,
                                          const std::string& key, int value,
                                          int byte_num) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;

  int stored_value = 0;
  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,
                               const std::string& key, char* value,
                               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(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,
                               const std::string& key,
                               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");

@@ -219,7 +228,8 @@ bool device_iot_config_set_str(const std::string& section,
bool device_iot_config_get_bin(const std::string& section,
                               const std::string& key, uint8_t* value,
                               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(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,
                                        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");

@@ -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,
                               const std::string& key, const uint8_t* value,
                               size_t length) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return false;
  if (!com::android::bluetooth::flags::device_iot_config_logging())
    return false;

  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,
                              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");

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

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_timer != NULL, "assert failed: config_timer != NULL");
@@ -327,7 +339,7 @@ void device_iot_config_flush(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_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) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return;

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

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

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

#include "btcore/include/module.h"
#include "btif/include/btif_common.h"
#include "common/init_flags.h"
#include "device/include/device_iot_config.h"
#include "os/log.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 alarm_t* config_timer;

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

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

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

  log::assert_that(config != NULL, "assert failed: config != 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) {
  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_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) {
  if (!InitFlags::IsDeviceIotConfigLoggingEnabled()) return 0;
  if (!com::android::bluetooth::flags::device_iot_config_logging()) return 0;

  int devices = 0;

+0 −6
Original line number 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 };

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

struct config_t;
struct future_t;

+157 −73

File changed.

Preview size limit exceeded, changes collapsed.

Loading