X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=policy_manager%2Fpolicy_manager.cpp;h=f3d0d4d6589c9754a2a9bbf70e22863d1b53a08c;hb=refs%2Fchanges%2F05%2F18605%2F2;hp=a482e0cbb35ba95729a811f362d27ebe3f676fde;hpb=c1d85371b1eb693128cf9553c356ea77e609d9a3;p=apps%2Fagl-service-windowmanager.git diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp index a482e0c..f3d0d4d 100644 --- a/policy_manager/policy_manager.cpp +++ b/policy_manager/policy_manager.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * Copyright (c) 2018 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ #include #include #include "policy_manager.hpp" +#include "util.hpp" #include "hmi-debug.h" extern "C" @@ -688,19 +690,16 @@ int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t delay_ms, std::string role) { + struct sd_event_source *event_source; HMI_DEBUG("wm:pm", "event_id:0x%x delay:%d role:%s", event_id, delay_ms, role.c_str()); - // Store requested role - this->req_role_list[event_id] = role; - if (0 == delay_ms) { - int ret = sd_event_add_defer(afb_daemon_get_event_loop(), NULL, + int ret = sd_event_add_defer(afb_daemon_get_event_loop(), &event_source, &pm::transitionStateWrapper, new int(event_id)); if (0 > ret) { HMI_ERROR("wm:pm", "Faild to sd_event_add_defer: errno:%d", ret); - this->req_role_list.erase(event_id); return -1; } } @@ -708,46 +707,31 @@ int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t del { // Get current time struct timespec time_spec; - clock_gettime(CLOCK_MONOTONIC, &time_spec); + clock_gettime(CLOCK_BOOTTIME, &time_spec); // Calculate timer fired time uint64_t usec = (time_spec.tv_sec * 1000000) + (time_spec.tv_nsec / 1000) + (delay_ms * 1000); // Set timer - struct sd_event_source *event_source; int ret = sd_event_add_time(afb_daemon_get_event_loop(), &event_source, - CLOCK_MONOTONIC, usec, 1, + CLOCK_BOOTTIME, usec, 1, &pm::timerEventWrapper, new int(event_id)); if (0 > ret) { HMI_ERROR("wm:pm", "Faild to sd_event_add_time: errno:%d", ret); - this->req_role_list.erase(event_id); return -1; } - - // Store event source - this->event_source_list[event_id] = event_source; } - + // Store event source + this->event_source_list[event_id] = event_source; + // Store requested role + this->req_role_list[event_id] = role; return 0; } int PolicyManager::loadRoleDb() { - std::string file_name; - - // Get afm application installed dir - char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR"); - HMI_DEBUG("wm:pm", "afm_app_install_dir:%s", afm_app_install_dir); - - if (!afm_app_install_dir) - { - HMI_ERROR("wm:pm", "AFM_APP_INSTALL_DIR is not defined"); - } - else - { - file_name = std::string(afm_app_install_dir) + std::string("/etc/roles.db"); - } + std::string file_name(get_file_path("roles.db", "wm:pm")); // Load roles.db json_object *json_obj; @@ -837,19 +821,7 @@ int PolicyManager::loadStateDb() { HMI_DEBUG("wm:pm", "Call"); - // Get afm application installed dir - char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR"); - HMI_DEBUG("wm:pm", "afm_app_install_dir:%s", afm_app_install_dir); - - std::string file_name; - if (!afm_app_install_dir) - { - HMI_ERROR("wm:pm", "AFM_APP_INSTALL_DIR is not defined"); - } - else - { - file_name = std::string(afm_app_install_dir) + std::string("/etc/states.db"); - } + std::string file_name(get_file_path("states.db", "wm:pm")); // Load states.db json_object *json_obj;