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

Commit c92bee1a authored by Alain Vongsouvanh's avatar Alain Vongsouvanh
Browse files

DO NOT MERGE ANYWHERE Bring back support for legacy bt_config.xml

An earlier CL introducing backup support for bt_config.conf blew up
support for legacy file, making upgrading from L-based OS to M-based OS
lose its bluetooth config.

BUG=27824878

Change-Id: Ic23ef2a3559b04224278edffdc0e9380c2760638
parent b2a6f175
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -43,9 +43,11 @@
#if defined(OS_GENERIC)
static const char *CONFIG_FILE_PATH = "bt_config.conf";
static const char *CONFIG_BACKUP_PATH = "bt_config.bak";
static const char *CONFIG_LEGACY_FILE_PATH = "bt_config.xml";
#else  // !defined(OS_GENERIC)
static const char *CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf";
static const char *CONFIG_BACKUP_PATH = "/data/misc/bluedroid/bt_config.bak";
static const char *CONFIG_LEGACY_FILE_PATH = "/data/misc/bluedroid/bt_config.xml";
#endif  // defined(OS_GENERIC)
static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000;

@@ -104,15 +106,19 @@ static future_t *init(void) {
    LOG_WARN("%s unable to load config file: %s; using backup.",
              __func__, CONFIG_FILE_PATH);
    config = config_new(CONFIG_BACKUP_PATH);
  }
  if (!config) {
    LOG_WARN("%s unable to load backup; attempting to transcode legacy file.", __func__);
    config = btif_config_transcode(CONFIG_LEGACY_FILE_PATH);
  }
  if (!config) {
      LOG_ERROR("%s unable to load backup; creating empty config.", __func__);
    LOG_ERROR("%s unable to transcode legacy file; creating empty config.", __func__);
    config = config_new_empty();
  }
  if (!config) {
    LOG_ERROR("%s unable to allocate a config object.", __func__);
    goto error;
  }
    }
  }

  btif_config_devcache_cleanup();