OSDN Git Service

resolve merge conflicts of 4b1a22e to cw-e-dev
authorMarie Janssen <jamuraa@google.com>
Fri, 15 Apr 2016 18:44:09 +0000 (11:44 -0700)
committerMarie Janssen <jamuraa@google.com>
Fri, 15 Apr 2016 18:44:09 +0000 (11:44 -0700)
Change-Id: Iba2d0c5b4949e4d5d4b8810123d5229d8543991b

1  2 
btif/src/btif_config.c
osi/src/config.c

@@@ -103,24 -94,22 +103,24 @@@ static future_t *init(void) 
    pthread_mutex_init(&lock, NULL);
    config = config_new(CONFIG_FILE_PATH);
    if (!config) {
 -    LOG_WARN("%s unable to load config file; attempting to transcode legacy file.", __func__);
 -    config = btif_config_transcode(LEGACY_CONFIG_FILE_PATH);
 -    if (!config) {
 -      LOG_WARN("%s unable to transcode legacy file, starting unconfigured.", __func__);
 -      config = config_new_empty();
 -      if (!config) {
 -        LOG_ERROR("%s unable to allocate a config object.", __func__);
 -        goto error;
 -      }
 -    }
 -
 -    if (config_save(config, CONFIG_FILE_PATH))
 -      unlink(LEGACY_CONFIG_FILE_PATH);
 +    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 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();
+   btif_config_remove_unpaired(config);
  
    // TODO(sharvil): use a non-wake alarm for this once we have
    // API support for it. There's no need to wake the system to
@@@ -401,12 -389,11 +400,13 @@@ static void btif_config_write(void) 
    assert(config != NULL);
    assert(alarm_timer != NULL);
  
-   btif_config_devcache_cleanup();
    pthread_mutex_lock(&lock);
-   config_save(config, CONFIG_FILE_PATH);
 +  rename(CONFIG_FILE_PATH, CONFIG_BACKUP_PATH);
 +  sync();
+   config_t *config_paired = config_new_clone(config);
+   btif_config_remove_unpaired(config_paired);
+   config_save(config_paired, CONFIG_FILE_PATH);
+   config_free(config_paired);
    pthread_mutex_unlock(&lock);
  }
  
Simple merge