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

Commit 36be430f authored by Sal Savage's avatar Sal Savage Committed by Automerger Merge Worker
Browse files

Merge "Properly update config when the MAC Address changes" am: 160bbce8 am:...

Merge "Properly update config when the MAC Address changes" am: 160bbce8 am: 1f9b4066 am: 7ea05b8e

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1441627

Change-Id: I2a906d01dffd47fc510a7458df7e964027597aeb
parents 102fcacd 7ea05b8e
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -451,6 +451,25 @@ bool btif_config_set_uint64(const std::string& section, const std::string& key,
  return true;
}

/*******************************************************************************
 *
 * Function         btif_config_get_str
 *
 * Description      Get the string value associated with a particular section
 *                  and key.
 *
 *                  section : The section name (i.e "Adapter")
 *                  key : The key name (i.e "Address")
 *                  value : A pointer to a buffer where we will store the value
 *                  size_bytes : The size of the buffer we have available to
 *                               write the value into. Will be updated upon
 *                               returning to contain the number of bytes
 *                               written.
 *
 * Returns          True if a value was found, False otherwise.
 *
 ******************************************************************************/

bool btif_config_get_str(const std::string& section, const std::string& key,
                         char* value, int* size_bytes) {
  if (bluetooth::shim::is_any_gd_enabled()) {
+6 −4
Original line number Diff line number Diff line
@@ -260,10 +260,12 @@ void btif_enable_bluetooth_evt() {
  std::string bdstr = local_bd_addr.ToString();

  char val[PROPERTY_VALUE_MAX] = "";
  int val_size = 0;
  if ((btif_config_get_str("Adapter", "Address", val, &val_size) == 0) ||
      strcmp(bdstr.c_str(), val) == 0) {
    LOG_DEBUG("Storing the adapter address into the config file");
  int val_size = PROPERTY_VALUE_MAX;
  if (!btif_config_get_str("Adapter", "Address", val, &val_size) ||
      strcmp(bdstr.c_str(), val) != 0) {
    // We failed to get an address or the one in the config file does not match
    // the address given by the controller interface. Update the config cache
    LOG_DEBUG("%s: Storing '%s' into the config file", __func__, bdstr.c_str());
    btif_config_set_str("Adapter", "Address", bdstr.c_str());
    btif_config_save();