From f1f15455d62e56135cd5e0131d415bbbc2a78fb6 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Thu, 14 Jun 2018 15:07:35 +0200 Subject: Fix a bug that duplicate the roles array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Controller call the config twice due to multiple initialisation phase, the code should handle this behaviour to not doing things twice. Also removed an unused section from the config file. Change-Id: Iecf09fe494173b757c3557d838782c50153dbfb4 Signed-off-by: Loïc Collignon --- ahl-binding/ahl-binding.cpp | 2 ++ conf.d/project/etc/policy-4a-sample1.json | 30 ------------------------------ 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/ahl-binding/ahl-binding.cpp b/ahl-binding/ahl-binding.cpp index 2bf1664..37e6847 100644 --- a/ahl-binding/ahl-binding.cpp +++ b/ahl-binding/ahl-binding.cpp @@ -330,6 +330,8 @@ int ahl_binding_t::parse_roles_config(json_object* o) { assert(o != nullptr); assert(json_object_is_type(o, json_type_array)); + + if (roles_.size()) return 0; // Roles already added, ignore. size_t count = json_object_array_length(o); roles_.reserve(count); diff --git a/conf.d/project/etc/policy-4a-sample1.json b/conf.d/project/etc/policy-4a-sample1.json index 8aa7a03..a1aebcd 100644 --- a/conf.d/project/etc/policy-4a-sample1.json +++ b/conf.d/project/etc/policy-4a-sample1.json @@ -12,36 +12,6 @@ "onload": [], "controls": [], "events": [], - "ahl-4a": { - "hals": ["4a-hal-ctxnop-laptop"], - "roles": [ - { - "uid": "multimedia", - "description": "Multimedia content (e.g. tuner, media player, etc.)", - "priority": 0, - "stream": "multimedia" - }, - { - "uid": "emergency", - "description": "Safety-relevant or critical alerts/alarms", - "priority": 100, - "stream": "emergency", - "interrupts":[ - {"type": "ramp", "args": { "uid": "ramp-slow", "volume": 30} } - ] - }, - { - "uid": "navigation", - "name": "navigation", - "description": "Navigation instructions (GPS, turn directions, etc...)", - "priority": 25, - "stream": "navigation", - "interrupts":[ - {"type": "ramp", "args": { "uid": "ramp-slow", "volume": 30} } - ] - } - ] - }, "roles":[ { "uid": "multimedia", -- cgit 1.2.3-korg