Modify process of analyzing current state in ResourceManager
[apps/agl-service-windowmanager.git] / src / policy_manager / policy_manager.cpp
index fb468df..ddcb1d6 100644 (file)
@@ -194,19 +194,15 @@ int PolicyManager::initializeSdEventLoop() {
 }
 
 static void addStateToJson(
-  const char* key, int is_changed, std::string state, json_object** json_out) {
-    if ((nullptr == key) || (nullptr == json_out)) {
-        HMI_ERROR("wm:pm", "Argument is nullptr!!!");
+  const char* name, int changed, std::string state, json_object** json_out) {
+    if ((nullptr == name) || (1 < changed) || (nullptr == json_out)) {
+        HMI_ERROR("wm:pm", "Invalid argument!!!");
         return;
     }
 
-    json_object* json_obj = json_object_new_object();
-    json_object_object_add(json_obj, "is_changed", json_object_new_boolean(is_changed));
-    if (is_changed) {
-        HMI_DEBUG("wm:pm", "%s: state changed (%s)", key, state.c_str());
-        json_object_object_add(json_obj, "state", json_object_new_string(state.c_str()));
-    }
-    json_object_object_add(*json_out, key, json_obj);
+    json_object_object_add(*json_out, "name", json_object_new_string(name));
+    json_object_object_add(*json_out, "state", json_object_new_string(state.c_str()));
+    json_object_object_add(*json_out, "changed", json_object_new_boolean(changed));
 }
 
 static void addStateToJson(const char* layer_name, unsigned int changed,