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

Commit d99b1ee5 authored by Ajay Panicker's avatar Ajay Panicker Committed by Android Git Automerger
Browse files

am ec102083: Implement Bluetooth settings factory reset (3/5)

* commit 'ec102083':
  Implement Bluetooth settings factory reset (3/5)
parents ce6fa8eb ec102083
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ const char *btif_config_section_name(const btif_config_section_iter_t *section);

void btif_config_save(void);
void btif_config_flush(void);
int btif_config_clear(void);

// TODO(zachoverflow): Eww...we need to move these out. These are peer specific, not config general.
bool btif_get_address_type(const BD_ADDR bd_addr, int *p_addr_type);
+8 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
#include "osi/include/allocation_tracker.h"
#include "osi/include/log.h"
#include "stack_manager.h"
#include "btif_config.h"

/************************************************************************************
**  Constants & Macros
@@ -416,6 +417,11 @@ static int set_os_callouts(bt_os_callouts_t *callouts) {
    return BT_STATUS_SUCCESS;
}

static int config_clear(void) {
    LOG_INFO("%s", __func__);
    return btif_config_clear();
}

static const bt_interface_t bluetoothInterface = {
    sizeof(bluetoothInterface),
    init,
@@ -449,7 +455,8 @@ static const bt_interface_t bluetoothInterface = {
    config_hci_snoop_log,
    set_os_callouts,
    read_energy_info,
    dump
    dump,
    config_clear
};

const bt_interface_t* bluetooth__get_bluetooth_interface ()
+20 −0
Original line number Diff line number Diff line
@@ -360,6 +360,26 @@ void btif_config_flush(void) {
  pthread_mutex_unlock(&lock);
}

int btif_config_clear(void){
  assert(config != NULL);
  assert(alarm_timer != NULL);

  alarm_cancel(alarm_timer);

  pthread_mutex_lock(&lock);
  config_free(config);

  config = config_new_empty();
  if (config == NULL) {
    pthread_mutex_unlock(&lock);
    return false;
  }

  int ret = config_save(config, CONFIG_FILE_PATH);
  pthread_mutex_unlock(&lock);
  return ret;
}

static void timer_config_save(UNUSED_ATTR void *data) {
  assert(config != NULL);
  assert(alarm_timer != NULL);