OSDN Git Service

resolve merge conflicts of d266361 to mnc-dr1.5-dev
authorMarie Janssen <jamuraa@google.com>
Fri, 15 Apr 2016 20:07:04 +0000 (13:07 -0700)
committerMarie Janssen <jamuraa@google.com>
Fri, 15 Apr 2016 20:07:04 +0000 (13:07 -0700)
Change-Id: If3b37b4cd7287ccb973b508f4911f2c2bcdbcfb2

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

@@@ -44,8 -52,8 +44,8 @@@ static const char *LEGACY_CONFIG_FILE_P
  static const period_ms_t CONFIG_SETTLE_PERIOD_MS = 3000;
  
  static void timer_config_save_cb(void *data);
 -static void btif_config_write(void);
 +static void btif_config_write(UINT16 event, char *p_param);
- static void btif_config_devcache_cleanup(void);
+ static void btif_config_remove_unpaired(config_t *config);
  
  // TODO(zachoverflow): Move these two functions out, because they are too specific for this file
  // {grumpy-cat/no, monty-python/you-make-me-sad}
@@@ -95,22 -103,24 +95,22 @@@ 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: %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;
 +    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);
    }
  
-   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
@@@ -359,14 -369,10 +359,10 @@@ void btif_config_flush(void) 
    assert(alarm_timer != NULL);
  
    alarm_cancel(alarm_timer);
 -  btif_config_write();
 +  btif_config_write(0, NULL);
-   pthread_mutex_lock(&lock);
-   config_save(config, CONFIG_FILE_PATH);
-   pthread_mutex_unlock(&lock);
  }
  
 -bool btif_config_clear(void){
 +int btif_config_clear(void){
    assert(config != NULL);
    assert(alarm_timer != NULL);
  
@@@ -397,10 -400,13 +393,11 @@@ static void btif_config_write(UNUSED_AT
    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