aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-06-15 11:42:37 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-06-15 11:42:37 +0900
commit172c4fb3d449b908baff3111fd171b42935fbb4f (patch)
tree0df20ab8ef1936919b3aa4bcc71f5e89779adfd6 /src
parent5aab17cd6ef530e367559fa56fcdea3b48f60d54 (diff)
Add new addStateToJson()
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
Diffstat (limited to 'src')
-rw-r--r--src/policy_manager/policy_manager.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/policy_manager/policy_manager.cpp b/src/policy_manager/policy_manager.cpp
index b55a44d..2e4a6f9 100644
--- a/src/policy_manager/policy_manager.cpp
+++ b/src/policy_manager/policy_manager.cpp
@@ -175,6 +175,28 @@ static void addStateToJson(
json_object_object_add(*json_out, key, json_obj);
}
+static void addStateToJson(const char* layer_name, unsigned int changed,
+ pm::AreaList area_list, json_object** json_out) {
+ if ((nullptr == layer_name) || (1 < changed) || (nullptr == json_out)) {
+ HMI_ERROR("wm:pm", "Invalid argument!!!");
+ return;
+ }
+
+ json_object* json_areas = json_object_new_array();
+ json_object* json_tmp;
+ for (pm::AreaState as : area_list) {
+ json_tmp = json_object_new_object();
+ json_object_object_add(json_tmp, "name", json_object_new_string(as.name.c_str()));
+ json_object_object_add(json_tmp, "role", json_object_new_string(as.role.c_str()));
+ json_object_array_add(json_areas, json_tmp);
+ }
+
+ json_object_object_add(*json_out, "name", json_object_new_string(layer_name));
+ json_object_object_add(*json_out, "changed", json_object_new_boolean(changed));
+ json_object_object_add(*json_out, "areas", json_areas);
+}
+
+
static int checkPolicyEntry(int event, uint64_t delay_ms, const char* role);
static int checkPolicy(sd_event_source *source, void *data) {
HMI_DEBUG("wm:pm", "Call");
@@ -516,12 +538,16 @@ static int checkPolicy(sd_event_source *source, void *data) {
// {
// "homescreen": {
- // "is_changed": <bool>,
- // "state": <const char*>
+ // "changed": <bool>,
+ // "areas": [
+ // {
+ // "name":<const char*>,
+ // "role":<const char*>
+ // }.
+ // ...
+ // ]
// }
// },
- // ]
- // }
json_tmp = json_object_new_object();
addStateToJson("homescreen",
crr_state.layer[stm::gStmLayerNoHomescreen].is_changed,