Modify key generation layer 66/215566/1
authorJusung Son <jusung07.son@samsung.com>
Thu, 10 Oct 2019 11:48:49 +0000 (20:48 +0900)
committerJusung Son <jusung07.son@samsung.com>
Thu, 10 Oct 2019 11:48:49 +0000 (20:48 +0900)
- Create a key in the base layer and the normal layer.
- When upgrading the version, all settings values of the previous version are applied to the new version.
  (Before the modification, only keys with changed values were applied to the new version.)

Change-Id: I907baae939512f36172a920e528284da9708e1a0
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
common/direct.c

index aacbaf06614b49b4179c579104c4c4cfc5bdeb21..80b2aaf8210e4175370187cbf912b6ad3037c7c9 100644 (file)
@@ -356,6 +356,7 @@ int direct_create(const struct buxton_layer *layer, const char *key,
 {
        int r;
        const struct layer *ly;
+       struct buxton_layer unset_layer;
 
        if (!layer || !key || !*key || !val) {
                bxt_err("Invalid parameter");
@@ -382,6 +383,20 @@ int direct_create(const struct buxton_layer *layer, const char *key,
        }
 
        r = set_val(ly, layer->uid, BUXTON_LAYER_BASE, key, rpriv, wpriv, val);
+       if (r != BUXTON_ERROR_NONE) {
+               bxt_err("failed to create (%s: %s) %d", ly->name, key, r);
+               return r;
+       }
+
+       if (ly->storage == STORAGE_PERSISTENT) {
+               r = set_val(ly, layer->uid, BUXTON_LAYER_NORMAL, key, rpriv, wpriv, val);
+               if (r != BUXTON_ERROR_NONE) {
+                       bxt_err("failed to create (%s: %s) %d", ly->name, key, r);
+                       unset_layer = *layer;
+                       unset_layer.type = BUXTON_LAYER_BASE;
+                       direct_unset(&unset_layer, key);
+               }
+       }
 
        return r;
 }