From 000e5f8983984d65cc7599908541801ec2babed2 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Fri, 3 Aug 2018 09:25:19 +0900 Subject: [PATCH 01/16] Fix mistake Currently, the code is not usable currently. Change-Id: I2de1c0f04df411f085faacc1ab71203ba9b5e0b1 Signed-off-by: Kazumasa Mitsunari --- src/wm_client.cpp | 2 +- src/wm_client.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wm_client.cpp b/src/wm_client.cpp index a9ed547..09e2e00 100644 --- a/src/wm_client.cpp +++ b/src/wm_client.cpp @@ -174,7 +174,7 @@ bool WMClient::removeRole(const string &role) return ret; } -#ifndef GTEST_ENABLED +#if GTEST_ENABLED bool WMClient::subscribe(afb_req req, const string &evname) { if(evname != kKeyError){ diff --git a/src/wm_client.hpp b/src/wm_client.hpp index 0d6faeb..259d504 100644 --- a/src/wm_client.hpp +++ b/src/wm_client.hpp @@ -53,7 +53,7 @@ class WMClient bool removeSurfaceIfExist(unsigned surface); bool removeRole(const std::string& role); -#ifndef GTEST_ENABLED +#if GTEST_ENABLED bool subscribe(afb_req req, const std::string &event_name); void emitError(WM_CLIENT_ERROR_EVENT ev); #endif -- 2.16.6 From 38255dcda8e7e9462ed3b16ebe39c638bc9b349f Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Thu, 9 Aug 2018 18:53:06 +0900 Subject: [PATCH 02/16] Fix multiple erase of surface information When application is killed and the surface is destroyed, the surface informations is erased twice. Therefore remove the one eracing process. Change-Id: I707febf5b5003058bcf847f635c16fb0d68e01d0 Signed-off-by: Yuta Doi --- src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b5659e2..261df8b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -203,8 +203,6 @@ static void cbRemoveClientCtxt(void *data) } g_afb_instance->wmgr.id_alloc.remove_id(sid); g_afb_instance->wmgr.layers.remove_surface(sid); - g_afb_instance->wmgr.controller->sprops.erase(sid); - g_afb_instance->wmgr.controller->surfaces.erase(sid); HMI_DEBUG("wm", "delete surfaceID %d", sid); } g_afb_instance->wmgr.removeClient(ctxt->name); -- 2.16.6 From c1d85371b1eb693128cf9553c356ea77e609d9a3 Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Mon, 9 Jul 2018 17:23:31 +0900 Subject: [PATCH 03/16] Readd Policy Manager as plugin This patch reverts commit c6f9a9b8468b3746a3dec7ee2a0b7d84ec9fb44a and update it. Policy Manager decides next layout by inputed event and current state based on the policy table. And Policy Manager is plugin for Window Manager. Therefore the OEMs can replace it. This patch provides Policy Manager I/F as reference implementation and does not have policy table. Therefore Policy Manager updates each layers to draw the applications in requested area in accordance with just like activate/deactivate request. [APIs of Policy Manager class] - int initialize(void) Initialize Policy Manger. in: none out: 0(success), -1(error) - void registerCallback(CallbackTable callback_table) Register callback functions. in: the pointers of callback handlers out: none "CallbackTable" type is as follows: typedef struct { Handler onStateTransitioned; Handler onError; } CallbackTable; "Handler" type is as follows: using Handler = std::function; - int setInputEventData(json_object *json_in) Set input event data for the policy table. in: input event data as json_object out: 0(success), -1(error) - int executeStateTransition(void) Execute state transition by using set input event data. in: none out: 0(success), -1(error) - void undoState(void) Undo state only once per once state transition. in: none out: none [Callbacks of Policy Manager class] - void onStateTransitioned(json_object *json_out) When state transition succeeds, this callback is called. The argument json_out has the state after transition. - void onError(json_object *json_out) When state transition fails, this callback is called. The argument json_out has the error information like message, inputed event datas and etc.. Bug-AGL: SPEC-1537 Change-Id: Ib8c71f2e544cb90b6763d07fad56dc1c453e9a97 Signed-off-by: Yuta Doi --- CMakeLists.txt | 4 + layers.json.split | 56 -- policy_manager/CMakeLists.txt | 88 +++ policy_manager/db/roles.db | 40 + policy_manager/db/states.db | 174 ++++ policy_manager/policy_manager.cpp | 1356 ++++++++++++++++++++++++++++++++ policy_manager/policy_manager.hpp | 149 ++++ policy_manager/stm/stm.c | 118 +++ policy_manager/stm/stm.h | 175 +++++ policy_manager/stm/stub/CMakeLists.txt | 44 ++ policy_manager/stm/stub/stm_inner.c | 151 ++++ policy_manager/stm/stub/stm_inner.h | 27 + src/CMakeLists.txt | 13 +- src/json_helper.cpp | 12 + src/json_helper.hpp | 1 + src/main.cpp | 30 +- src/pm_wrapper.cpp | 261 ++++++ src/pm_wrapper.hpp | 75 ++ src/window_manager.cpp | 528 ++++--------- src/window_manager.hpp | 10 +- 20 files changed, 2846 insertions(+), 466 deletions(-) delete mode 100644 layers.json.split create mode 100644 policy_manager/CMakeLists.txt create mode 100644 policy_manager/db/roles.db create mode 100644 policy_manager/db/states.db create mode 100644 policy_manager/policy_manager.cpp create mode 100644 policy_manager/policy_manager.hpp create mode 100644 policy_manager/stm/stm.c create mode 100644 policy_manager/stm/stm.h create mode 100644 policy_manager/stm/stub/CMakeLists.txt create mode 100644 policy_manager/stm/stub/stm_inner.c create mode 100644 policy_manager/stm/stub/stm_inner.h create mode 100644 src/pm_wrapper.cpp create mode 100644 src/pm_wrapper.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ed6d6d..e1cb0db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,4 +79,8 @@ set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. ' set(LINK_LIBCXX OFF CACHE BOOL "Link against LLVMs libc++") +# Add PolicyManager as plugin +set(PLUGIN_PM policy_manager) +add_subdirectory(${PLUGIN_PM}) + add_subdirectory(src) diff --git a/layers.json.split b/layers.json.split deleted file mode 100644 index 641e2f4..0000000 --- a/layers.json.split +++ /dev/null @@ -1,56 +0,0 @@ -{ - "comment": "Surface ID to Layer ID mapping", - - "main_surface": { - "surface_role": "HomeScreen", - "comment": "This surface should never be made invisible (The HomeScreen)" - }, - - "mappings": [ - { - "role": "BackGroundLayer", - "name": "BackGroundLayer", - "layer_id": 999, - "comment": "Single BackGround layer map for the map, radio, music and video" - }, - { - "role": "homescreen", - "name": "FarHomeScreen", - "layer_id": 1000, - "comment": "FarHomeScreen is the part of HomeScreen. The z order of this layer is lower than NearHomeScreen" - }, - { - "role": "music|video|browser|radio|phone|map|hvac|settings|dashboard|poi|mixer|sdl|launcher|fallback", - "name": "Apps", - "layer_id": 1001, - "comment": "Range of IDs that will always be placed on layer 1001", - - "split_layouts": [ - { - "name": "map", - "main_match": "map", - "sub_match": "hvac|music", - "priority": 1000 - } - ] - }, - { - "role": "software_keyboard", - "name": "NearHomeScreen", - "layer_id": 1002, - "comment": "NearHomeScreen is the part of HomeScreen. The z order of this layer is upper than FarHomeScreen" - }, - { - "role": "restriction", - "name": "Restriction", - "layer_id": 1003, - "comment": "This layer is for restriction notification. This is used by restriction role" - }, - { - "role": "^on_screen.*", - "name": "OnScreen", - "layer_id": 9999, - "comment": "Range of IDs that will always be placed on the OnScreen layer, that gets a very high 'dummy' id of 9999" - } - ] -} diff --git a/policy_manager/CMakeLists.txt b/policy_manager/CMakeLists.txt new file mode 100644 index 0000000..23aec19 --- /dev/null +++ b/policy_manager/CMakeLists.txt @@ -0,0 +1,88 @@ +# +# Copyright (c) 2017 TOYOTA MOTOR CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include(FindPkgConfig) +pkg_check_modules(AFB REQUIRED afb-daemon) +pkg_check_modules(SD REQUIRED libsystemd>=222) + +# Set name of STM +set(STM_DIR stub) + +# Add STM directory +add_subdirectory(stm/${STM_DIR}) + +set(TARGETS_PM ${PLUGIN_PM}) + +add_library(${TARGETS_PM} + SHARED + policy_manager.cpp + stm/stm.c +) + +target_include_directories(${TARGETS_PM} + PRIVATE + ${AFB_INCLUDE_DIRS} + ${SD_INCLUDE_DIRS} + ../include + ../src + ./ + ./stm + ./stm/${STM_DIR} +) + +target_link_libraries(${TARGETS_PM} + PRIVATE + ${AFB_LIBRARIES} + ${SD_LIBRARIES} + pmstm +) + +target_compile_definitions(${TARGETS_PM} + PRIVATE + _GNU_SOURCE +) + +target_compile_options(${TARGETS_PM} + PRIVATE + -Wall -Wextra -Wno-unused-parameter -Wno-comment) + +set_target_properties(${TARGETS_PM} + PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + + C_EXTENSIONS OFF + C_STANDARD 99 + C_STANDARD_REQUIRED ON + + LINK_FLAGS "-Wl,-rpath,'$ORIGIN'" +) + +if (LINK_LIBCXX) + set_target_properties(${TARGETS_PM} + PROPERTIES + LINK_FLAGS "-lc++ -Wl,-rpath,'$ORIGIN'" + ) +endif() + +add_custom_command(TARGET ${TARGETS_PM} POST_BUILD + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib + COMMAND cp -f ${PROJECT_BINARY_DIR}/${PLUGIN_PM}/lib${PLUGIN_PM}.so ${PROJECT_BINARY_DIR}/package/root/lib + COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/etc + COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/states.db ${PROJECT_BINARY_DIR}/package/root/etc + COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/roles.db ${PROJECT_BINARY_DIR}/package/root/etc +) diff --git a/policy_manager/db/roles.db b/policy_manager/db/roles.db new file mode 100644 index 0000000..5d31aea --- /dev/null +++ b/policy_manager/db/roles.db @@ -0,0 +1,40 @@ +{ + "roles":[ + { + "category": "homescreen", + "role": "homescreen", + "area": "fullscreen", + "layer": "homescreen", + }, + { + "category": "debug", + "role": "launcher | map | poi | browser | sdl | mixer | radio | hvac | debug | phone | video | music | settings | dashboard | fallback", + "area": "normal.full | split.main | split.sub | fullscreen", + "layer": "apps", + }, + { + "category": "software_keyboard", + "role": "software_keyboard", + "area": "software_keyboard", + "layer": "near_homescreen", + }, + { + "category": "restriction", + "role": "restriction", + "area": "restriction.normal | restriction.split.main | restriction.split.sub", + "layer": "restriction", + }, + { + "category": "pop_up", + "role": "on_screen | on_screen_phone", + "area": "on_screen", + "layer": "on_screen", + }, + { + "category": "system_alert", + "role": "system_alert", + "area": "on_screen", + "layer": "on_screen", + } + ] +} diff --git a/policy_manager/db/states.db b/policy_manager/db/states.db new file mode 100644 index 0000000..371be3b --- /dev/null +++ b/policy_manager/db/states.db @@ -0,0 +1,174 @@ +{ + "states": [ + { + "name": "homescreen", + "areas": [ + { + "name": "fullscreen", + "category": "homescreen" + } + ] + }, + { + "name": "map.normal", + "areas": [ + { + "name": "normal.full", + "category": "map" + } + ] + }, + { + "name": "map.split", + "areas": [ + { + "name": "split.main", + "category": "map" + }, + { + "name": "split.sub", + "category": "splitable" + } + ] + }, + { + "name": "map.fullscreen", + "areas": [ + { + "name": "fullscreen", + "category": "map" + } + ] + }, + { + "name": "splitable.normal", + "areas": [ + { + "name": "normal.full", + "category": "splitable" + } + ] + }, + { + "name": "splitable.split", + "areas": [ + { + "name": "split.main", + "category": "splitable" + }, + { + "name": "split.sub", + "category": "splitable" + } + ] + }, + { + "name": "general.normal", + "areas": [ + { + "name": "normal.full", + "category": "general" + } + ] + }, + { + "name": "system.normal", + "areas": [ + { + "name": "normal.full", + "category": "system" + } + ] + }, + { + "name": "software_keyboard", + "areas": [ + { + "name": "software_keyboard", + "category": "software_keyboard" + } + ] + }, + { + "name": "restriction.normal", + "areas": [ + { + "name": "restriction.normal", + "category": "restriction" + } + ] + }, + { + "name": "restriction.split.main", + "areas": [ + { + "name": "restriction.split.main", + "category": "restriction" + } + ] + }, + { + "name": "restriction.split.sub", + "areas": [ + { + "name": "restriction.split.sub", + "category": "restriction" + } + ] + }, + { + "name": "pop_up", + "areas": [ + { + "name": "on_screen", + "category": "pop_up" + } + ] + }, + { + "name": "system_alert", + "areas": [ + { + "name": "on_screen", + "category": "system_alert" + } + ] + }, + { + "name": "debug.normal", + "areas": [ + { + "name": "normal.full", + "category": "debug" + } + ] + }, + { + "name": "debug.split.main", + "areas": [ + { + "name": "split.main", + "category": "debug" + } + ] + }, + { + "name": "debug.split.sub", + "areas": [ + { + "name": "split.sub", + "category": "debug" + } + ] + }, + { + "name": "debug.fullscreen", + "areas": [ + { + "name": "fullscreen", + "category": "debug" + } + ] + } + ] +} diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp new file mode 100644 index 0000000..a482e0c --- /dev/null +++ b/policy_manager/policy_manager.cpp @@ -0,0 +1,1356 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "policy_manager.hpp" +#include "hmi-debug.h" + +extern "C" +{ +#define AFB_BINDING_VERSION 2 +#include +#include +#include "stm.h" +} + +namespace pm +{ +static const int kInvisibleRoleHistoryNum = 5; + +static PolicyManager *g_context; + +static int transitionStateWrapper(sd_event_source *source, void *data) +{ + int ret = g_context->transitionState(source, data); + return ret; +} + +static int timerEventWrapper(sd_event_source *source, uint64_t usec, void *data) +{ + int ret = g_context->timerEvent(source, usec, data); + return ret; +} + +} // namespace pm + +PolicyManager::PolicyManager() + : eventname2no(), + categoryname2no(), + areaname2no(), + role2category(), + category2role(), + category2areas() +{} + +int PolicyManager::initialize() +{ + int ret = 0; + + // Create convert map + for (int i = StmEvtNoMin; i <= StmEvtNoMax; i++) + { + HMI_DEBUG("wm:pm", "event name:%s no:%d", kStmEventName[i], i); + this->eventname2no[kStmEventName[i]] = i; + } + + for (int i = StmCtgNoMin; i <= StmCtgNoMax; i++) + { + HMI_DEBUG("wm:pm", "category name:%s no:%d", kStmCategoryName[i], i); + this->categoryname2no[kStmCategoryName[i]] = i; + } + + for (int i = StmAreaNoMin; i <= StmAreaNoMax; i++) + { + HMI_DEBUG("wm:pm", "area name:%s no:%d", kStmAreaName[i], i); + this->areaname2no[kStmAreaName[i]] = i; + } + + // Load roles.db + ret = this->loadRoleDb(); + if (0 > ret) + { + HMI_ERROR("wm:pm", "Load roles.db Error!!"); + return ret; + } + + // Load states.db + ret = this->loadStateDb(); + if (0 > ret) + { + HMI_ERROR("wm:pm", "Load states.db Error!!"); + return ret; + } + + // Initialize state which is managed by PolicyManager + this->initializeState(); + + // Initialize StateTransitioner + stmInitialize(); + + // Store instance + pm::g_context = this; + + return ret; +} + +void PolicyManager::registerCallback(CallbackTable callback) +{ + this->callback.onStateTransitioned = callback.onStateTransitioned; + this->callback.onError = callback.onError; +} + +int PolicyManager::setInputEventData(json_object *json_in) +{ + // Check arguments + if (nullptr == json_in) + { + HMI_ERROR("wm:pm", "Argument is NULL!!"); + return -1; + } + + // Get event from json_object + const char *event = this->getStringFromJson(json_in, "event"); + int event_no = StmEvtNoNone; + if (nullptr != event) + { + // Convert name to number + auto itr = this->eventname2no.find(event); + if (this->eventname2no.end() != itr) + { + event_no = this->eventname2no[event]; + HMI_DEBUG("wm:pm", "event(%s:%d)", event, event_no); + } + else + { + HMI_ERROR("wm:pm", "Invalid event name!!"); + return -1; + } + } + else + { + HMI_ERROR("wm:pm", "Event is not set!!"); + return -1; + } + + // Get role from json_object + const char *role = this->getStringFromJson(json_in, "role"); + std::string category = ""; + int category_no = StmCtgNoNone; + if (nullptr != role) + { + HMI_DEBUG("wm:pm", "role(%s)", role); + + // Convert role to category + auto itr = this->role2category.find(role); + if (this->role2category.end() != itr) + { + category = this->role2category[role]; + } + else + { + itr = this->role2category.find("fallback"); + if (this->role2category.end() != itr) + { + HMI_DEBUG("wm:pm", "Role:%s is not registered in roles.db, fallback as normal app", role); + category = this->role2category["fallback"]; + } + } + + if ("" != category) + { + // Convert name to number + category_no = categoryname2no[category]; + HMI_DEBUG("wm:pm", "category(%s:%d)", category.c_str(), category_no); + } + } + if (StmCtgNoNone == category_no) + { + role = ""; + } + + // Get area from json_object + const char *area = this->getStringFromJson(json_in, "area"); + int area_no = StmAreaNoNone; + if ((nullptr != area) && (StmCtgNoNone != category_no)) + { + for (const auto &x : this->category2areas[category]) + { + if (x == std::string(area)) + { + area_no = this->areaname2no[area]; + break; + } + } + if (StmAreaNoNone == area_no) + { + area = this->category2areas[category].front().c_str(); + area_no = this->areaname2no[area]; + } + HMI_DEBUG("wm:pm", "area(%s:%d)", area, area_no); + } + + // Set event info to the queue + EventInfo event_info; + int event_id = STM_CREATE_EVENT_ID(event_no, category_no, area_no); + event_info.event = event_id; + event_info.role = std::string(role); + event_info.delay = 0; + this->event_info_queue.push(event_info); + + return 0; +} + +int PolicyManager::executeStateTransition() +{ + int ret; + EventInfo event_info; + + // Get event info from queue and delete + event_info = this->event_info_queue.front(); + this->event_info_queue.pop(); + + // Set event info to check policy + ret = this->setStateTransitionProcessToSystemd(event_info.event, + event_info.delay, + event_info.role); + return ret; +} + +void PolicyManager::undoState() +{ + HMI_DEBUG("wm:pm", "Undo State !!!"); + + // Undo state of STM + stmUndoState(); + + HMI_DEBUG("wm:pm", ">>>>>>>>>> BEFORE UNDO"); + this->dumpLayerState(this->crr_layers); + + this->crr_layers = this->prv_layers; + + HMI_DEBUG("wm:pm", ">>>>>>>>>> AFTER UNDO"); + this->dumpLayerState(this->crr_layers); +} + +void PolicyManager::initializeState() +{ + this->initializeLayerState(); +} + +void PolicyManager::initializeLayerState() +{ + AreaState init_area; + LayoutState init_layout; + init_area.name = kStmAreaName[StmAreaNoNone]; + init_area.category = kStmCategoryName[StmCtgNoNone]; + init_area.role = ""; + init_layout.name = kStmLayoutName[StmLayoutNoNone]; + init_layout.area_list.push_back(init_area); + + for (int i = StmLayerNoMin; i <= StmLayerNoMax; i++) + { + const char *layer_name = kStmLayerName[i]; + this->crr_layers[layer_name].name = layer_name; + this->crr_layers[layer_name].layout_state = init_layout; + this->crr_layers[layer_name].changed = false; + } + + this->prv_layers = this->crr_layers; +} + +void PolicyManager::addStateToJson(const char *name, bool changed, + std::string state, json_object **json_out) +{ + if ((nullptr == name) || (nullptr == json_out)) + { + HMI_ERROR("wm:pm", "Invalid argument!!!"); + return; + } + + 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)); +} + +void PolicyManager::addStateToJson(const char *layer_name, bool changed, + AreaList area_list, json_object **json_out) +{ + if ((nullptr == layer_name) || (nullptr == json_out)) + { + HMI_ERROR("wm:pm", "Invalid argument!!!"); + return; + } + + json_object *json_areas = json_object_new_array(); + json_object *json_tmp; + for (const auto &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); +} + +void PolicyManager::updateState(int event_id, StmState crr_state) +{ + this->updateLayer(event_id, crr_state); +} + +void PolicyManager::updateLayer(int event_id, StmState crr_state) +{ + for (int layer_no = StmLayerNoMin; + layer_no <= StmLayerNoMax; layer_no++) + { + HMI_DEBUG("wm:pm", ">>> LAYER:%s CHANGED:%d LAYOUT:%s", + kStmLayerName[layer_no], crr_state.layer[layer_no].changed, + kStmLayoutName[crr_state.layer[layer_no].state]); + } + + // Store previous layers + this->prv_layers = this->crr_layers; + + // Update layers + for (int layer_no = StmLayerNoMin; + layer_no <= StmLayerNoMax; layer_no++) + { + const char *layer_name = kStmLayerName[layer_no]; + + // This layer is changed? + int changed = crr_state.layer[layer_no].changed; + if (changed) + { + HMI_DEBUG("wm:pm", ">>>>>>>>>> Update layout of layer:%s", layer_name); + + // Get current layout name of this layer + int crr_layout_state_no = crr_state.layer[layer_no].state; + std::string crr_layout_name = std::string(kStmLayoutName[crr_layout_state_no]); + + LayoutState crr_layout_state; + this->updateLayout(event_id, layer_no, + crr_layout_name, crr_layout_state); + + // Update current layout of this layer + this->crr_layers[layer_name].layout_state = crr_layout_state; + } + // Update changed flag + this->crr_layers[layer_name].changed = (changed) ? true : false; + } + + // Erase role for the event_id from list + this->req_role_list.erase(event_id); + + HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (BEFORE)"); + this->dumpLayerState(this->prv_layers); + + HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (AFTER)"); + this->dumpLayerState(this->crr_layers); + + this->dumpInvisibleRoleHistory(); +} + +int PolicyManager::updateLayout(int event_id, int layer_no, + std::string crr_layout_name, LayoutState &crr_layout_state) +{ + int changed; + + int event_no = STM_GET_EVENT_FROM_ID(event_id); + int category_no = STM_GET_CATEGORY_FROM_ID(event_id); + int area_no = STM_GET_AREA_FROM_ID(event_id); + + std::string req_evt = kStmEventName[event_no]; + std::string req_ctg = kStmCategoryName[category_no]; + std::string req_area = kStmAreaName[area_no]; + std::string req_role = this->req_role_list[event_id]; + + const char *layer_name = kStmLayerName[layer_no]; + + // Get previous layout name of this layer + LayoutState prv_layout_state = this->prv_layers[layer_name].layout_state; + std::string prv_layout_name = prv_layout_state.name; + + if ((prv_layout_name == crr_layout_name) && + (kStmLayoutName[StmLayoutNoNone] == crr_layout_name)) + { + // If previous and current layout are none + // Copy previous layout state for current + crr_layout_state = prv_layout_state; + changed = 0; + } + else + { + crr_layout_state = prv_layout_state; + changed = 1; + + HMI_DEBUG("wm:pm", "-- layout name previous:%s current:%s", + prv_layout_name.c_str(), crr_layout_name.c_str()); + if (prv_layout_name == crr_layout_name) + { + HMI_DEBUG("wm:pm", "---- Previous layout is same with current"); + } + else + { + // If previous layout is NOT same with current, + // current areas is set with default value + HMI_DEBUG("wm:pm", "---- Previous layout is NOT same with current"); + crr_layout_state.name = this->default_layouts[crr_layout_name].name; + crr_layout_state.category_num = this->default_layouts[crr_layout_name].category_num; + crr_layout_state.area_list = this->default_layouts[crr_layout_name].area_list; + } + + // Create candidate list + std::map cand_list; + // for (int ctg_no = StmCtgNoMin; + // ctg_no <= StmCtgNoMax; ctg_no++) + // { + for (const auto &ctg : this->layer2categories[layer_name]) + { + // if (ctg_no == StmCtgNoNone) + // { + // continue; + // } + + // const char *ctg = kStmCategoryName[ctg_no]; + HMI_DEBUG("wm:pm", "-- Create candidate list for ctg:%s", ctg.c_str()); + + AreaList tmp_cand_list; + int candidate_num = 0; + int blank_num = crr_layout_state.category_num[ctg]; + + // If requested event is "activate" + // and there are requested category and area, + // update area with requested role in current layout. + bool request_for_this_layer = false; + std::string used_role = ""; + if ((ctg == req_ctg) && ("activate" == req_evt)) + { + HMI_DEBUG("wm:pm", "---- Requested event is activate"); + for (AreaState &as : crr_layout_state.area_list) + { + if (as.category == req_ctg) + { + request_for_this_layer = true; + + if (as.name == req_area) + { + as.role = req_role; + used_role = req_role; + blank_num--; + HMI_DEBUG("wm:pm", "------ Update current layout: area:%s category:%s role:%s", + as.name.c_str(), as.category.c_str(), as.role.c_str()); + break; + } + } + } + } + + // Create candidate list for category from the previous displayed categories + for (AreaState area_state : prv_layout_state.area_list) + { + if ((ctg == area_state.category) && + (used_role != area_state.role)) + { + // If there is the category + // which is same with new category and not used for updating yet, + // push it to list + HMI_DEBUG("wm:pm", "---- Push previous(category:%s role:%s) to candidate list", + area_state.category.c_str(), area_state.role.c_str()); + tmp_cand_list.push_back(area_state); + candidate_num++; + } + } + + // If NOT updated by requested area: + // there is not requested area in new layout, + // so push requested role to candidate list + if (request_for_this_layer && ("" == used_role)) + { + HMI_DEBUG("wm:pm", "---- Push request(area:%s category:%s role:%s) to candidate list", + req_area.c_str(), req_ctg.c_str(), req_role.c_str()); + AreaState area_state; + area_state.name = req_area; + area_state.category = req_ctg; + area_state.role = req_role; + tmp_cand_list.push_back(area_state); + candidate_num++; + } + + HMI_DEBUG("wm:pm", "---- blank_num:%d candidate_num:%d", blank_num, candidate_num); + + // Compare number of candidate/blank, + // And remove role in order of the oldest as necessary + if (candidate_num < blank_num) + { + // Refer history stack + // and add to the top of tmp_cand_list in order to the newest + while (candidate_num != blank_num) + { + AreaState area_state; + area_state.name = kStmAreaName[StmAreaNoNone]; + area_state.category = ctg; + area_state.role = this->popInvisibleRoleHistory(ctg); + if ("" == area_state.role) + { + HMI_ERROR("wm:pm", "There is no role in history stack!!"); + } + tmp_cand_list.push_back(area_state); + HMI_DEBUG("wm:pm", "------ Add role:%s to candidate list", + area_state.role.c_str()); + candidate_num++; + } + } + else if (candidate_num > blank_num) + { + // Remove the oldest role from candidate list + while (candidate_num != blank_num) + { + std::string removed_role = tmp_cand_list.begin()->role; + HMI_DEBUG("wm:pm", "------ Remove the oldest role:%s from candidate list", + removed_role.c_str()); + tmp_cand_list.erase(tmp_cand_list.begin()); + candidate_num--; + + // Push removed data to history stack + this->pushInvisibleRoleHistory(ctg, removed_role); + + // Remove from current layout + for (AreaState &as : crr_layout_state.area_list) + { + if (as.role == removed_role) + { + as.role = ""; + } + } + } + } + else + { // (candidate_num == blank_num) + // nop + } + + cand_list[ctg] = tmp_cand_list; + } + + // Update areas + HMI_DEBUG("wm:pm", "-- Update areas by using candidate list"); + for (AreaState &as : crr_layout_state.area_list) + { + HMI_DEBUG("wm:pm", "---- Check area:%s category:%s role:%s", + as.name.c_str(), as.category.c_str(), as.role.c_str()); + if ("" == as.role) + { + HMI_DEBUG("wm:pm", "------ Update this area with role:%s", + cand_list[as.category].begin()->role.c_str()); + as.role = cand_list[as.category].begin()->role; + cand_list[as.category].erase(cand_list[as.category].begin()); + } + } + } + return changed; +} + +void PolicyManager::createOutputInformation(StmState crr_state, json_object **json_out) +{ + json_object *json_tmp; + + // Create layout information + // + // "layers": [ + // { + // "homescreen": { + // "changed": , + // "areas": [ + // { + // "name":, + // "role": + // }. + // ... + // ] + // } + // }, + // ... + json_object *json_layer = json_object_new_array(); + const char *layer_name; + for (int layer_no = StmLayerNoMin; + layer_no <= StmLayerNoMax; layer_no++) + { + layer_name = kStmLayerName[layer_no]; + json_tmp = json_object_new_object(); + this->addStateToJson(layer_name, + this->crr_layers[layer_name].changed, + this->crr_layers[layer_name].layout_state.area_list, + &json_tmp); + json_object_array_add(json_layer, json_tmp); + } + json_object_object_add(*json_out, "layers", json_layer); +} + +int PolicyManager::transitionState(sd_event_source *source, void *data) +{ + HMI_DEBUG("wm:pm", ">>>>>>>>>> START STATE TRANSITION"); + + int event_id = *((int *)data); + + int event_no, category_no, area_no; + event_no = STM_GET_EVENT_FROM_ID(event_id); + category_no = STM_GET_CATEGORY_FROM_ID(event_id); + area_no = STM_GET_AREA_FROM_ID(event_id); + HMI_DEBUG("wm:pm", ">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s", + kStmEventName[event_no], + kStmCategoryName[category_no], + kStmAreaName[area_no]); + + // Transition state + StmState crr_state; + int ret = stmTransitionState(event_id, &crr_state); + if (0 > ret) + { + HMI_ERROR("wm:pm", "Failed transition state"); + if (nullptr != this->callback.onError) + { + json_object *json_out = json_object_new_object(); + json_object_object_add(json_out, "message", + json_object_new_string("Failed to transition state")); + json_object_object_add(json_out, "event", + json_object_new_string(kStmEventName[event_no])); + json_object_object_add(json_out, "role", + json_object_new_string(this->req_role_list[event_id].c_str())); + json_object_object_add(json_out, "area", + json_object_new_string(kStmAreaName[area_no])); + this->callback.onError(json_out); + json_object_put(json_out); + } + return -1; + } + + // Update state which is managed by PolicyManager + this->updateState(event_id, crr_state); + + // Create output information for ResourceManager + json_object *json_out = json_object_new_object(); + this->createOutputInformation(crr_state, &json_out); + + // Notify changed state + if (nullptr != this->callback.onStateTransitioned) + { + this->callback.onStateTransitioned(json_out); + } + + // Release json_object + json_object_put(json_out); + + // Release data + delete (int *)data; + + // Destroy sd_event_source object + sd_event_source_unref(source); + + // Remove event source from list + if (this->event_source_list.find(event_id) != this->event_source_list.end()) + { + this->event_source_list.erase(event_id); + } + + HMI_DEBUG("wm:pm", ">>>>>>>>>> FINISH STATE TRANSITION"); + return 0; +} + +int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data) +{ + HMI_DEBUG("wm:pm", "Call"); + + int ret = this->transitionState(source, data); + return ret; +} + +int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t delay_ms, std::string role) +{ + 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, + &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; + } + } + else + { + // Get current time + struct timespec time_spec; + clock_gettime(CLOCK_MONOTONIC, &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, + &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; + } + + 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"); + } + + // Load roles.db + json_object *json_obj; + int ret = this->inputJsonFilie(file_name.c_str(), &json_obj); + if (0 > ret) + { + HMI_ERROR("wm:pm", "Could not open roles.db, so use default role information"); + json_obj = json_tokener_parse(kDefaultRoleDb); + } + HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj)); + + json_object *json_roles; + if (!json_object_object_get_ex(json_obj, "roles", &json_roles)) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + + int len = json_object_array_length(json_roles); + HMI_DEBUG("wm:pm", "json_cfg len:%d", len); + HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_roles)); + + json_object *json_tmp; + const char *category; + const char *roles; + const char *areas; + const char *layer; + for (int i = 0; i < len; i++) + { + json_tmp = json_object_array_get_idx(json_roles, i); + + category = this->getStringFromJson(json_tmp, "category"); + roles = this->getStringFromJson(json_tmp, "role"); + areas = this->getStringFromJson(json_tmp, "area"); + layer = this->getStringFromJson(json_tmp, "layer"); + + if ((nullptr == category) || (nullptr == roles) || + (nullptr == areas) || (nullptr == layer)) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + + // Parse roles by '|' + std::vector vct_roles; + vct_roles = this->parseString(std::string(roles), '|'); + + // Parse areas by '|' + Areas vct_areas; + vct_areas = this->parseString(std::string(areas), '|'); + + // Set role, category, areas + for (auto itr = vct_roles.begin(); itr != vct_roles.end(); ++itr) + { + this->role2category[*itr] = std::string(category); + } + this->category2role[category] = std::string(roles); + this->category2areas[category] = vct_areas; + this->layer2categories[layer].push_back(category); + } + + // Check + HMI_DEBUG("wm:pm", "Check role2category"); + for (const auto &x : this->role2category) + { + HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str()); + } + + HMI_DEBUG("wm:pm", "Check category2role"); + for (const auto &x : this->category2role) + { + HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str()); + } + + HMI_DEBUG("wm:pm", "Check category2areas"); + for (const auto &x : this->category2areas) + { + for (const auto &y : x.second) + { + HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), y.c_str()); + } + } + return 0; +} + +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"); + } + + // Load states.db + json_object *json_obj; + int ret = this->inputJsonFilie(file_name.c_str(), &json_obj); + if (0 > ret) + { + HMI_DEBUG("wm:pm", "Could not open states.db, so use default layout information"); + json_obj = json_tokener_parse(kDefaultStateDb); + } + HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj)); + + // Perse states + HMI_DEBUG("wm:pm", "Perse states"); + json_object *json_cfg; + if (!json_object_object_get_ex(json_obj, "states", &json_cfg)) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + + int len = json_object_array_length(json_cfg); + HMI_DEBUG("wm:pm", "json_cfg len:%d", len); + HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_cfg)); + + const char *layout; + const char *role; + const char *category; + for (int i = 0; i < len; i++) + { + json_object *json_tmp = json_object_array_get_idx(json_cfg, i); + + layout = this->getStringFromJson(json_tmp, "name"); + if (nullptr == layout) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + HMI_DEBUG("wm:pm", "> layout:%s", layout); + + json_object *json_area_array; + if (!json_object_object_get_ex(json_tmp, "areas", &json_area_array)) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + + int len_area = json_object_array_length(json_area_array); + HMI_DEBUG("wm:pm", "json_area_array len:%d", len_area); + HMI_DEBUG("wm:pm", "json_area_array dump:%s", json_object_get_string(json_area_array)); + + LayoutState layout_state; + AreaState area_state; + std::map category_num; + for (int ctg_no = StmCtgNoMin; + ctg_no <= StmCtgNoMax; ctg_no++) + { + const char *ctg_name = kStmCategoryName[ctg_no]; + category_num[ctg_name] = 0; + } + + for (int j = 0; j < len_area; j++) + { + json_object *json_area = json_object_array_get_idx(json_area_array, j); + + // Get area name + const char *area = this->getStringFromJson(json_area, "name"); + if (nullptr == area) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + area_state.name = std::string(area); + HMI_DEBUG("wm:pm", ">> area:%s", area); + + // Get app attribute of the area + category = this->getStringFromJson(json_area, "category"); + if (nullptr == category) + { + HMI_ERROR("wm:pm", "Parse Error!!"); + return -1; + } + area_state.category = std::string(category); + category_num[category]++; + HMI_DEBUG("wm:pm", ">>> category:%s", category); + + role = this->getStringFromJson(json_area, "role"); + if (nullptr != role) + { + // Role is NOT essential here + area_state.role = std::string(role); + } + else + { + area_state.role = std::string(""); + } + HMI_DEBUG("wm:pm", ">>> role:%s", role); + + layout_state.area_list.push_back(area_state); + } + + layout_state.name = layout; + layout_state.category_num = category_num; + this->default_layouts[layout] = layout_state; + } + + // initialize for none layout + LayoutState none_layout_state; + memset(&none_layout_state, 0, sizeof(none_layout_state)); + none_layout_state.name = "none"; + this->default_layouts["none"] = none_layout_state; + + // Check + for (auto itr_layout = this->default_layouts.begin(); + itr_layout != this->default_layouts.end(); ++itr_layout) + { + HMI_DEBUG("wm:pm", ">>> layout:%s", itr_layout->first.c_str()); + + for (auto itr_area = itr_layout->second.area_list.begin(); + itr_area != itr_layout->second.area_list.end(); ++itr_area) + { + HMI_DEBUG("wm:pm", ">>> >>> area :%s", itr_area->name.c_str()); + HMI_DEBUG("wm:pm", ">>> >>> category:%s", itr_area->category.c_str()); + HMI_DEBUG("wm:pm", ">>> >>> role :%s", itr_area->role.c_str()); + } + } + + // Release json_object + json_object_put(json_obj); + + return 0; +} + +void PolicyManager::pushInvisibleRoleHistory(std::string category, std::string role) +{ + auto i = std::remove_if(this->invisible_role_history[category].begin(), + this->invisible_role_history[category].end(), + [role](std::string x) { return (role == x); }); + + if (this->invisible_role_history[category].end() != i) + { + this->invisible_role_history[category].erase(i); + } + + this->invisible_role_history[category].push_back(role); + + if (pm::kInvisibleRoleHistoryNum < invisible_role_history[category].size()) + { + this->invisible_role_history[category].erase( + this->invisible_role_history[category].begin()); + } +} + +std::string PolicyManager::popInvisibleRoleHistory(std::string category) +{ + std::string role; + if (invisible_role_history[category].empty()) + { + role = ""; + } + else + { + role = this->invisible_role_history[category].back(); + this->invisible_role_history[category].pop_back(); + } + return role; +} + +const char *PolicyManager::getStringFromJson(json_object *obj, const char *key) +{ + json_object *tmp; + if (!json_object_object_get_ex(obj, key, &tmp)) + { + HMI_DEBUG("wm:pm", "Not found key \"%s\"", key); + return nullptr; + } + + return json_object_get_string(tmp); +} + +int PolicyManager::inputJsonFilie(const char *file, json_object **obj) +{ + const int input_size = 128; + int ret = -1; + + HMI_DEBUG("wm:pm", "Input file: %s", file); + + // Open json file + FILE *fp = fopen(file, "rb"); + if (nullptr == fp) + { + HMI_ERROR("wm:pm", "Could not open file"); + return ret; + } + + // Parse file data + struct json_tokener *tokener = json_tokener_new(); + enum json_tokener_error json_error; + char buffer[input_size]; + int block_cnt = 1; + while (1) + { + size_t len = fread(buffer, sizeof(char), input_size, fp); + *obj = json_tokener_parse_ex(tokener, buffer, len); + if (nullptr != *obj) + { + HMI_DEBUG("wm:pm", "File input is success"); + ret = 0; + break; + } + + json_error = json_tokener_get_error(tokener); + if ((json_tokener_continue != json_error) || (input_size > len)) + { + HMI_ERROR("wm:pm", "Failed to parse file (byte:%d err:%s)", + (input_size * block_cnt), json_tokener_error_desc(json_error)); + HMI_ERROR("wm:pm", "\n%s", buffer); + *obj = nullptr; + break; + } + block_cnt++; + } + + // Close json file + fclose(fp); + + // Free json_tokener + json_tokener_free(tokener); + + return ret; +} + +void PolicyManager::dumpLayerState(std::unordered_map &layers) +{ + HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------"); + HMI_DEBUG("wm:pm", "|%-15s|%s|%-20s|%-20s|%-20s|%-20s|", + "LAYER", "C", "LAYOUT", "AREA", "CATEGORY", "ROLE"); + for (const auto &itr : layers) + { + LayerState ls = itr.second; + const char* layer = ls.name.c_str(); + const char* changed = (ls.changed) ? "T" : "f"; + const char* layout = ls.layout_state.name.c_str(); + bool first = true; + for (const auto &as : ls.layout_state.area_list) + { + if (first) + { + first = false; + HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", + layer, changed, layout, + as.name.c_str(), as.category.c_str(), as.role.c_str()); + } + else + HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", + "", "", "", as.name.c_str(), as.category.c_str(), as.role.c_str()); + } + } + HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------"); +} + +void PolicyManager::dumpInvisibleRoleHistory() +{ + HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP INVISIBLE ROLE HISTORY ( category [older > newer] )"); + for (int ctg_no = StmCtgNoMin; ctg_no <= StmCtgNoMax; ctg_no++) + { + if (ctg_no == StmCtgNoNone) + continue; + + std::string category = std::string(kStmCategoryName[ctg_no]); + + std::string str = category + " [ "; + for (const auto &i : this->invisible_role_history[category]) + str += (i + " > "); + + str += "]"; + HMI_DEBUG("wm:pm", "%s", str.c_str()); + } +} + +std::vector PolicyManager::parseString(std::string str, char delimiter) +{ + // Parse string by delimiter + std::vector vct; + std::stringstream ss{str}; + std::string buf; + while (std::getline(ss, buf, delimiter)) + { + if (!buf.empty()) + { + // Delete space and push back to vector + vct.push_back(this->deleteSpace(buf)); + } + } + return vct; +} + +std::string PolicyManager::deleteSpace(std::string str) +{ + std::string ret = str; + size_t pos; + while ((pos = ret.find_first_of(" ")) != std::string::npos) + { + ret.erase(pos, 1); + } + return ret; +} + +const char *PolicyManager::kDefaultRoleDb = "{ \ + \"roles\":[ \ + { \ + \"category\": \"homescreen\", \ + \"role\": \"homescreen\", \ + \"area\": \"fullscreen\", \ + }, \ + { \ + \"category\": \"map\", \ + \"role\": \"map\", \ + \"area\": \"normal.full | split.main\", \ + }, \ + { \ + \"category\": \"general\", \ + \"role\": \"launcher | poi | browser | sdl | mixer | radio | hvac | debug | phone | video | music\", \ + \"area\": \"normal.full\", \ + }, \ + { \ + \"category\": \"system\", \ + \"role\": \"settings | dashboard\", \ + \"area\": \"normal.full\", \ + }, \ + { \ + \"category\": \"software_keyboard\", \ + \"role\": \"software_keyboard\", \ + \"area\": \"software_keyboard\", \ + }, \ + { \ + \"category\": \"restriction\", \ + \"role\": \"restriction\", \ + \"area\": \"restriction.normal | restriction.split.main | restriction.split.sub\", \ + }, \ + { \ + \"category\": \"pop_up\", \ + \"role\": \"pop_up\", \ + \"area\": \"on_screen\", \ + }, \ + { \ + \"category\": \"system_alert\", \ + \"role\": \"system_alert\", \ + \"area\": \"on_screen\", \ + } \ + ] \ +}"; + +const char *PolicyManager::kDefaultStateDb = "{ \ + \"states\": [ \ + { \ + \"name\": \"homescreen\", \ + \"layer\": \"far_homescreen\", \ + \"areas\": [ \ + { \ + \"name\": \"fullscreen\", \ + \"category\": \"homescreen\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"map.normal\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"normal.full\", \ + \"category\": \"map\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"map.split\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"split.main\", \ + \"category\": \"map\" \ + }, \ + { \ + \"name\": \"split.sub\", \ + \"category\": \"splitable\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"map.fullscreen\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"fullscreen\", \ + \"category\": \"map\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"splitable.normal\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"normal.full\", \ + \"category\": \"splitable\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"splitable.split\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"split.main\", \ + \"category\": \"splitable\" \ + }, \ + { \ + \"name\": \"split.sub\", \ + \"category\": \"splitable\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"general.normal\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"normal.full\", \ + \"category\": \"general\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"system.normal\", \ + \"layer\": \"apps\", \ + \"areas\": [ \ + { \ + \"name\": \"normal.full\", \ + \"category\": \"system\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"software_keyboard\", \ + \"layer\": \"near_homescreen\", \ + \"areas\": [ \ + { \ + \"name\": \"software_keyboard\", \ + \"category\": \"software_keyboard\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"restriction.normal\", \ + \"layer\": \"restriction\", \ + \"areas\": [ \ + { \ + \"name\": \"restriction.normal\", \ + \"category\": \"restriction\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"restriction.split.main\", \ + \"layer\": \"restriction\", \ + \"areas\": [ \ + { \ + \"name\": \"restriction.split.main\", \ + \"category\": \"restriction\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"restriction.split.sub\", \ + \"layer\": \"restriction\", \ + \"areas\": [ \ + { \ + \"name\": \"restriction.split.sub\", \ + \"category\": \"restriction\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"pop_up\", \ + \"layer\": \"on_screen\", \ + \"areas\": [ \ + { \ + \"name\": \"on_screen\", \ + \"category\": \"pop_up\" \ + } \ + ] \ + }, \ + { \ + \"name\": \"system_alert\", \ + \"layer\": \"on_screen\", \ + \"areas\": [ \ + { \ + \"name\": \"on_screen\", \ + \"category\": \"system_alert\" \ + } \ + ] \ + } \ + ] \ +}"; diff --git a/policy_manager/policy_manager.hpp b/policy_manager/policy_manager.hpp new file mode 100644 index 0000000..798b706 --- /dev/null +++ b/policy_manager/policy_manager.hpp @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_POLICY_MANAGER_HPP +#define TMCAGLWM_POLICY_MANAGER_HPP + +#include +#include +#include +#include + +struct json_object; +struct sd_event; +struct sd_event_source; +struct StmState; + +class PolicyManager +{ + public: + explicit PolicyManager(); + ~PolicyManager() = default; + + using Handler = std::function; + + typedef struct + { + Handler onStateTransitioned; + Handler onError; + } CallbackTable; + + int initialize(); + void registerCallback(CallbackTable callback_table); + int setInputEventData(json_object *json_in); + int executeStateTransition(); + void undoState(); + + // Do not use these functions + int transitionState(sd_event_source *source, void *data); + int timerEvent(sd_event_source *source, uint64_t usec, void *data); + + private: + // Disable copy and move + PolicyManager(PolicyManager const &) = delete; + PolicyManager &operator=(PolicyManager const &) = delete; + PolicyManager(PolicyManager &&) = delete; + PolicyManager &operator=(PolicyManager &&) = delete; + + typedef struct EventInfo + { + int event; + std::string role; + uint64_t delay; + } EventInfo; + + typedef struct AreaState + { + std::string name; + std::string category; + std::string role; + } AreaState; + + typedef std::vector AreaList; + typedef struct LayoutState + { + std::string name; + std::map category_num; + AreaList area_list; + } LayoutState; + + typedef struct LayerState + { + std::string name; + LayoutState layout_state; + bool changed; + } LayerState; + + typedef std::vector Areas; + typedef std::vector Categories; + typedef std::vector Roles; + + // Convert map + std::unordered_map eventname2no; + std::unordered_map categoryname2no; + std::unordered_map areaname2no; + + std::unordered_map role2category; + std::unordered_map category2role; + std::unordered_map category2areas; + std::unordered_map layer2categories; + + std::queue event_info_queue; + std::map event_source_list; + std::map req_role_list; + + CallbackTable callback; + + std::unordered_map prv_layers; + std::unordered_map crr_layers; + + std::unordered_map default_layouts; + + std::map invisible_role_history; + + void initializeState(); + void initializeLayerState(); + void updateState(int event_id, StmState crr_state); + void updateLayer(int event_id, StmState crr_state); + int updateLayout(int event_id, int layer_no, + std::string crr_layout_name, LayoutState &crr_layout_state); + void createOutputInformation(StmState crr_state, json_object **json_out); + int setStateTransitionProcessToSystemd(int event, uint64_t delay_ms, std::string role); + + void pushInvisibleRoleHistory(std::string category, std::string role); + std::string popInvisibleRoleHistory(std::string category); + + int loadRoleDb(); + int loadStateDb(); + + void dumpLayerState(std::unordered_map &layers); + void dumpInvisibleRoleHistory(); + + void addStateToJson(const char *name, bool changed, + std::string state, json_object **json_out); + void addStateToJson(const char *layer_name, bool changed, + AreaList area_list, json_object **json_out); + const char *getStringFromJson(json_object *obj, const char *key); + int inputJsonFilie(const char *file, json_object **obj); + + std::vector parseString(std::string str, char delimiter); + std::string deleteSpace(std::string str); + + static const char *kDefaultRoleDb; + static const char *kDefaultStateDb; +}; + +#endif // TMCAGLWM_POLICY_MANAGER_HPP diff --git a/policy_manager/stm/stm.c b/policy_manager/stm/stm.c new file mode 100644 index 0000000..c63a599 --- /dev/null +++ b/policy_manager/stm/stm.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "stm.h" +#include "stm_inner.h" + +const char* kStmEventName[] = { + "none", + "activate", + "deactivate", + "restriction_mode_off", + "restriction_mode_1_on", + "restriction_mode_2_on", + "undo", +}; + +const char* kStmCategoryName[] = { + "none", + "homescreen", + "map", + "general", + "splitable", + "pop_up", + "system_alert", + "restriction", + "system", + "software_keyboard", + "debug", +}; + +const char* kStmAreaName[] = { + "none", + "fullscreen", + "normal.full", + "split.main", + "split.sub", + "on_screen", + "restriction.normal", + "restriction.split.main", + "restriction.split.sub", + "software_keyboard", +}; + +const char* kStmLayoutName[] = { + "none", + "pop_up", + "system_alert", + "map.normal", + "map.split", + "map.fullscreen", + "splitable.normal", + "splitable.split", + "general.normal", + "homescreen", + "restriction.normal", + "restriction.split.main", + "restriction.split.sub", + "system.normal", + "software_keyboard", + "debug.normal", + "debug.split.main", + "debug.split.sub", + "debug.fullscreen", +}; + +const char* kStmLayerName[] = { + "homescreen", + "apps", + "near_homescreen", + "restriction", + "on_screen", +}; + +const char* kStmModeName[] = { + "trans_gear", + "parking_brake", + "accel_pedal", + "running", + "lamp", + "lightstatus_brake", + "restriction_mode", +}; + +const char* kStmRestrictionModeStateName[] = { + "off", + "1on", + "2on", +}; + +const char** kStmModeStateNameList[] = { + kStmRestrictionModeStateName, +}; + +void stmInitialize() { + stmInitializeInner(); +} + +int stmTransitionState(int event, StmState* state) { + return stmTransitionStateInner(event, state); +} + +void stmUndoState() { + stmUndoStateInner(); +} diff --git a/policy_manager/stm/stm.h b/policy_manager/stm/stm.h new file mode 100644 index 0000000..deebf9c --- /dev/null +++ b/policy_manager/stm/stm.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_STM_HPP +#define TMCAGLWM_STM_HPP + +#define STM_TRUE 1 +#define STM_FALSE 0 + +#define STM_CREATE_EVENT_ID(evt, ctg, area) \ + ((evt) | ((ctg) << 8) | ((area) << 16)) + +#define STM_GET_EVENT_FROM_ID(id) \ + ((id) & 0xFF) + +#define STM_GET_CATEGORY_FROM_ID(id) \ + (((id) >> 8) & 0xFF) + +#define STM_GET_AREA_FROM_ID(id) \ + (((id) >> 16) & 0xFF) + +// Event number +enum StmEvtNo { + StmEvtNoNone = 0, + StmEvtNoActivate, + StmEvtNoDeactivate, + StmEvtNoRestrictionModeOff, + StmEvtNoRestrictionMode1On, + StmEvtNoRestrictionMode2On, + StmEvtNoUndo, + + StmEvtNoNum, + + StmEvtNoMin = StmEvtNoNone, + StmEvtNoMax = StmEvtNoNum - 1, +}; + +// Category number +enum StmCtgNo { + StmCtgNoNone = 0, + StmCtgNoHomescreen, + StmCtgNoMap, + StmCtgNoGeneral, + StmCtgNoSplitable, + StmCtgNoPopUp, + StmCtgNoSystemAlert, + StmCtgNoRestriction, + StmCtgNoSystem, + StmCtgNoSoftwareKeyboard, + StmCtgNoDebug, + + StmCtgNoNum, + + StmCtgNoMin = StmCtgNoNone, + StmCtgNoMax = StmCtgNoNum - 1, +}; + +// Area number +enum StmAreaNo { + StmAreaNoNone = 0, + StmAreaNoFullscreen, + StmAreaNoNormal, + StmAreaNoSplitMain, + StmAreaNoSplitSub, + StmAreaNoOnScreen, + StmAreaNoRestrictionNormal, + StmAreaNoRestrictionSplitMain, + StmAreaNoRestrictionSplitSub, + StmAreaNoSoftwareKyeboard, + + StmAreaNoNum, + + StmAreaNoMin = StmAreaNoNone, + StmAreaNoMax = StmAreaNoNum - 1, +}; + +// Layer number +enum StmLayerNo { + StmLayerNoHomescreen = 0, + StmLayerNoApps, + StmLayerNoNearHomescreen, + StmLayerNoRestriction, + StmLayerNoOnScreen, + + StmLayerNoNum, + + StmLayerNoMin = StmLayerNoHomescreen, + StmLayerNoMax = StmLayerNoNum - 1, +}; + +// Layout kind number +enum StmLayoutNo { + StmLayoutNoNone = 0, + StmLayoutNoPopUp, + StmLayoutNoSysAlt, + StmLayoutNoMapNml, + StmLayoutNoMapSpl, + StmLayoutNoMapFll, + StmLayoutNoSplNml, + StmLayoutNoSplSpl, + StmLayoutNoGenNml, + StmLayoutNoHms, + StmLayoutNoRstNml, + StmLayoutNoRstSplMain, + StmLayoutNoRstSplSub, + StmLayoutNoSysNml, + StmLayoutNoSftKbd, + StmLayoutNoDbgNml, + StmLayoutNoDbgSplMain, + StmLayoutNoDbgSplSub, + StmLayoutNoDbgFll, + + StmLayoutNoNum, + + StmLayoutNoMin = StmLayoutNoNone, + StmLayoutNoMax = StmLayoutNoNum - 1, +}; + +// Mode kind number +enum StmModeNo { + StmModeNoRestrictionMode = 0, + + StmModeNoNum, + + StmModeNoMin = StmModeNoRestrictionMode, + StmModeNoMax = StmModeNoNum - 1, +}; + +// Enum for mode state +enum StmRestrictionModeSttNo { + StmRestrictionModeSttNoOff = 0, + StmRestrictionModeSttNo1On, + StmRestrictionModeSttNo2On, +}; + +// String for state +extern const char* kStmEventName[]; +extern const char* kStmCategoryName[]; +extern const char* kStmAreaName[]; +extern const char* kStmLayoutName[]; +extern const char* kStmLayerName[]; +extern const char* kStmModeName[]; +extern const char** kStmModeStateNameList[]; + +// Struct for state +typedef struct StmBaseState { + int changed; + int state; +} StmBaseState; + +typedef struct StmState { + StmBaseState mode[StmModeNoNum]; + StmBaseState layer[StmLayerNoNum]; +} StmState; + +// API +void stmInitialize(); +int stmTransitionState(int event_no, StmState* state); +void stmUndoState(); + + +#endif // TMCAGLWM_STM_HPP diff --git a/policy_manager/stm/stub/CMakeLists.txt b/policy_manager/stm/stub/CMakeLists.txt new file mode 100644 index 0000000..81f0e00 --- /dev/null +++ b/policy_manager/stm/stub/CMakeLists.txt @@ -0,0 +1,44 @@ +# +# Copyright (c) 2017 TOYOTA MOTOR CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(TARGETS_STM pmstm) + +add_library(${TARGETS_STM} + STATIC + ./stm_inner.c +) + +target_include_directories(${TARGETS_STM} + PRIVATE + ../ + ./ +) + +target_compile_definitions(${TARGETS_STM} + PRIVATE + _GNU_SOURCE +) + +target_compile_options(${TARGETS_STM} + PRIVATE + -Wall -Wextra -Wno-unused-parameter -Wno-comment) + +set_target_properties(${TARGETS_STM} + PROPERTIES + C_EXTENSIONS OFF + C_STANDARD 99 + C_STANDARD_REQUIRED ON +) diff --git a/policy_manager/stm/stub/stm_inner.c b/policy_manager/stm/stub/stm_inner.c new file mode 100644 index 0000000..bd1b319 --- /dev/null +++ b/policy_manager/stm/stub/stm_inner.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "stm.h" +#include "stm_inner.h" + +static StmState g_stm_crr_state; +static StmState g_stm_prv_state; + +void stmInitializeInner() { + // Initialize previous state + memset(&g_stm_prv_state, 0, sizeof(g_stm_prv_state)); + + // Initialize current state + g_stm_crr_state = g_stm_prv_state; +} + +int stmTransitionStateInner(int event, StmState* state) { + int event_no, category_no, area_no; + + event_no = STM_GET_EVENT_FROM_ID(event); + category_no = STM_GET_CATEGORY_FROM_ID(event); + area_no = STM_GET_AREA_FROM_ID(event); + + // Backup previous state + g_stm_prv_state = g_stm_crr_state; + + // ------------------------------------------------------- + // There is no policy table by default. + // Therefore update each layers + // to draw the applications in requested area + // in accordance with inputed activate/deactivate events. + // ------------------------------------------------------- + if (StmEvtNoActivate == event_no) + { + if (StmCtgNoHomescreen == category_no) + { + g_stm_crr_state.layer[StmLayerNoHomescreen].state = StmLayoutNoHms; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_TRUE; + + // For AGL JIRA SPEC-1407 + // Apps layer is invisibled only when Homescreen app is started already + if (StmLayoutNoHms == g_stm_prv_state.layer[StmLayerNoHomescreen].state) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + } + } + else if (StmCtgNoDebug == category_no) + { + if (StmAreaNoNormal == area_no) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoDbgNml; + } + else if (StmAreaNoSplitMain == area_no) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoDbgSplMain; + } + else if (StmAreaNoSplitSub == area_no) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoDbgSplSub; + } + else if (StmAreaNoFullscreen == area_no) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoDbgFll; + } + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + } + else if (StmCtgNoSoftwareKeyboard == category_no) + { + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoSftKbd; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE; + } + else if (StmCtgNoPopUp == category_no) + { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoPopUp; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; + } + else if (StmCtgNoSystemAlert == category_no) + { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoSysAlt; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; + } + } + else if (StmEvtNoDeactivate == event_no) + { + if (StmCtgNoHomescreen == category_no) + { + g_stm_crr_state.layer[StmLayerNoHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_TRUE; + } + else if (StmCtgNoDebug == category_no) + { + if ((StmLayoutNoDbgNml == g_stm_prv_state.layer[StmLayerNoApps].state) || + (StmLayoutNoDbgSplMain == g_stm_prv_state.layer[StmLayerNoApps].state) || + (StmLayoutNoDbgSplSub == g_stm_prv_state.layer[StmLayerNoApps].state) || + (StmLayoutNoDbgFll == g_stm_prv_state.layer[StmLayerNoApps].state)) + { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + } + } + else if (StmCtgNoSoftwareKeyboard == category_no) + { + if (StmLayoutNoSftKbd == g_stm_prv_state.layer[StmLayerNoNearHomescreen].state ) + { + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE; + } + } + else if (StmCtgNoPopUp == category_no) + { + if (StmLayoutNoPopUp == g_stm_prv_state.layer[StmLayerNoOnScreen].state ) + { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; + } + } + else if (StmCtgNoSystemAlert == category_no) + { + if (StmLayoutNoSysAlt == g_stm_prv_state.layer[StmLayerNoOnScreen].state ) + { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; + } + } + } + + // Copy current state for return + memcpy(state, &g_stm_crr_state, sizeof(g_stm_crr_state)); + + return 0; +} + +void stmUndoStateInner() { + g_stm_crr_state = g_stm_prv_state; +} diff --git a/policy_manager/stm/stub/stm_inner.h b/policy_manager/stm/stub/stm_inner.h new file mode 100644 index 0000000..7079447 --- /dev/null +++ b/policy_manager/stm/stub/stm_inner.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_STM_INNER_HPP +#define TMCAGLWM_STM_INNER_HPP + +struct StmState; + +// API +void stmInitializeInner(); +int stmTransitionStateInner(int event_no, StmState* state); +void stmUndoStateInner(); + +#endif // TMCAGLWM_STM_INNER_HPP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42b81b7..3c8da4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,20 +37,23 @@ add_library(${TARGETS_WM} MODULE wm_client.cpp wm_error.cpp applist.cpp - request.cpp) + request.cpp + pm_wrapper.cpp) target_include_directories(${TARGETS_WM} PRIVATE ${AFB_INCLUDE_DIRS} ${SD_INCLUDE_DIRS} ../include - ../src) + ../src + ../${PLUGIN_PM}) target_link_libraries(${TARGETS_WM} PRIVATE ${AFB_LIBRARIES} ${WLC_LIBRARIES} - ${SD_LIBRARIES}) + ${SD_LIBRARIES} + ${PLUGIN_PM}) target_compile_definitions(${TARGETS_WM} PRIVATE @@ -82,12 +85,12 @@ set_target_properties(${TARGETS_WM} C_STANDARD 99 C_STANDARD_REQUIRED ON - LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map") + LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -Wl,-rpath,'$ORIGIN'") if (LINK_LIBCXX) set_target_properties(${TARGETS_WM} PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -lc++") + LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../export.map -lc++ -Wl,-rpath,'$ORIGIN'") endif() if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "") diff --git a/src/json_helper.cpp b/src/json_helper.cpp index c2f4173..b97f21d 100644 --- a/src/json_helper.cpp +++ b/src/json_helper.cpp @@ -136,6 +136,18 @@ int getIntFromJson(json_object *obj, const char *key) return json_object_get_int(tmp); } +json_bool getBoolFromJson(json_object *obj, const char *key) +{ + json_object *tmp; + if (!json_object_object_get_ex(obj, key, &tmp)) + { + HMI_DEBUG("wm:jh", "Not found key \"%s\"", key); + return FALSE; + } + + return json_object_get_boolean(tmp); +} + int inputJsonFilie(const char* file, json_object** obj) { const int input_size = 128; diff --git a/src/json_helper.hpp b/src/json_helper.hpp index 2f6b817..5333130 100644 --- a/src/json_helper.hpp +++ b/src/json_helper.hpp @@ -30,6 +30,7 @@ json_object *to_json(std::vector const &v); namespace jh { const char* getStringFromJson(json_object* obj, const char* key); int getIntFromJson(json_object *obj, const char *key); +json_bool getBoolFromJson(json_object *obj, const char *key); int inputJsonFilie(const char* file, json_object** obj); } // namespace jh diff --git a/src/main.cpp b/src/main.cpp index 261df8b..0447f86 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -184,27 +184,19 @@ static void cbRemoveClientCtxt(void *data) return; } HMI_DEBUG("wm", "remove app %s", ctxt->name.c_str()); - // Lookup surfaceID and remove it because App is dead. - auto pSid = g_afb_instance->wmgr.id_alloc.lookup(ctxt->role.c_str()); - if (pSid) - { - auto sid = *pSid; - auto o_state = *g_afb_instance->wmgr.layers.get_layout_state(sid); - if (o_state != nullptr) - { - if (o_state->main == sid) - { - o_state->main = -1; - } - else if (o_state->sub == sid) + + // Policy Manager does not know this app was killed, + // so notify it by deactivate request. + g_afb_instance->wmgr.api_deactivate_surface( + ctxt->name.c_str(), ctxt->role.c_str(), + [](const char *errmsg) { + if (errmsg != nullptr) { - o_state->sub = -1; + HMI_ERROR("wm", errmsg); + return; } - } - g_afb_instance->wmgr.id_alloc.remove_id(sid); - g_afb_instance->wmgr.layers.remove_surface(sid); - HMI_DEBUG("wm", "delete surfaceID %d", sid); - } + }); + g_afb_instance->wmgr.removeClient(ctxt->name); delete ctxt; } diff --git a/src/pm_wrapper.cpp b/src/pm_wrapper.cpp new file mode 100644 index 0000000..1454bf9 --- /dev/null +++ b/src/pm_wrapper.cpp @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "pm_wrapper.hpp" +#include "json_helper.hpp" +#include "hmi-debug.h" + +namespace wm +{ + +static PMWrapper *g_context; + +namespace +{ + +static void onStateTransitioned(json_object *json_out) +{ + g_context->updateStates(json_out); +} + +static void onError(json_object *json_out) +{ + HMI_DEBUG("wm", "error message from PolicyManager:%s", + json_object_get_string(json_out)); + + g_context->processError(); +} + +} // namespace + +PMWrapper::PMWrapper() {} + +int PMWrapper::initialize() +{ + int ret = 0; + + ret = this->pm.initialize(); + if (0 > ret) + { + HMI_ERROR("wm:pmw", "Faild to initialize PolicyManager"); + } + + g_context = this; + + return ret; +} + +void PMWrapper::registerCallback(StateTransitionHandler on_state_transitioned, + ErrorHandler on_error) +{ + this->on_state_transitioned = on_state_transitioned; + this->on_error = on_error; + + PolicyManager::CallbackTable my_callback; + my_callback.onStateTransitioned = onStateTransitioned; + my_callback.onError = onError; + this->pm.registerCallback(my_callback); +} + +int PMWrapper::setInputEventData(Task task, std::string role, std::string area) +{ + const char* event; + if (Task::TASK_ALLOCATE == task) + { + event = "activate"; + } + else if (Task::TASK_RELEASE == task) + { + event = "deactivate"; + } + else + { + event = ""; + } + + json_object *json_in = json_object_new_object(); + json_object_object_add(json_in, "event", json_object_new_string(event)); + json_object_object_add(json_in, "role", json_object_new_string(role.c_str())); + json_object_object_add(json_in, "area", json_object_new_string(area.c_str())); + + int ret; + ret = this->pm.setInputEventData(json_in); + if (0 > ret) + { + HMI_ERROR("wm:pmw", "Faild to set input event data to PolicyManager"); + } + json_object_put(json_in); + + return ret; +} + +int PMWrapper::executeStateTransition() +{ + int ret; + ret = this->pm.executeStateTransition(); + if (0 > ret) + { + HMI_ERROR("wm:pmw", "Failed to execute state transition for PolicyManager"); + } + + return ret; +} + +void PMWrapper::undoState() +{ + this->pm.undoState(); + + this->crrlayer2rolestate = this->prvlayer2rolestate; +} + +void PMWrapper::updateStates(json_object *json_out) +{ + std::vector actions; + + HMI_DEBUG("wm", "json_out dump:%s", json_object_get_string(json_out)); + + this->createLayoutChangeAction(json_out, actions); + + this->on_state_transitioned(actions); +} + +void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector &actions) +{ + // Get displayed roles from previous layout + json_object *json_layers; + if (!json_object_object_get_ex(json_out, "layers", &json_layers)) + { + HMI_DEBUG("wm", "Not found key \"layers\""); + return; + } + + int len = json_object_array_length(json_layers); + HMI_DEBUG("wm", "json_layers len:%d", len); + + for (int i = 0; i < len; i++) + { + json_object *json_tmp = json_object_array_get_idx(json_layers, i); + + std::string layer_name = jh::getStringFromJson(json_tmp, "name"); + json_bool changed = jh::getBoolFromJson(json_tmp, "changed"); + HMI_DEBUG("wm", "layer:%s changed:%d", layer_name.c_str(), changed); + + if (changed) + { + json_object *json_areas; + if (!json_object_object_get_ex(json_tmp, "areas", &json_areas)) + { + HMI_DEBUG("wm", "Not found key \"areas\""); + return; + } + + int len = json_object_array_length(json_areas); + HMI_DEBUG("wm", "json_layers len:%d", len); + + // Store previous role state in this layer + this->prvlayer2rolestate[layer_name] = this->crrlayer2rolestate[layer_name]; + + RoleState crr_roles; + RoleState prv_roles = this->prvlayer2rolestate[layer_name]; + for (int j = 0; j < len; j++) + { + json_object *json_tmp2 = json_object_array_get_idx(json_areas, j); + + std::string area_name = jh::getStringFromJson(json_tmp2, "name"); + std::string role_name = jh::getStringFromJson(json_tmp2, "role"); + + crr_roles[role_name] = area_name; + + auto i_prv = prv_roles.find(role_name); + HMI_DEBUG("wm", "current role:%s area:%s", + role_name.c_str(), area_name.c_str()); + + // If current role does not exist in previous + if (prv_roles.end() == i_prv) + { + HMI_DEBUG("wm", "current role does not exist in previous"); + + // Set activate action + bool end_draw_finished = false; + WMAction act + { + "", + role_name, + area_name, + TaskVisible::VISIBLE, + end_draw_finished + }; + actions.push_back(act); + } + else + { + HMI_DEBUG("wm", "previous role:%s area:%s", + i_prv->first.c_str(), i_prv->second.c_str()); + + // If current role exists in previous and area is different with previous + if (area_name != i_prv->second) + { + HMI_DEBUG("wm", "current role exists in previous and area is different with previous"); + + // Set activate action + bool end_draw_finished = false; + WMAction act + { + "", + role_name, + area_name, + TaskVisible::VISIBLE, + end_draw_finished + }; + actions.push_back(act); + } + + // Remove role which exist in current list from previous list + prv_roles.erase(i_prv); + } + } + + // Deactivate roles which remains in previous list + // because these are not displayed in current layout + for (auto i_prv : prv_roles) + { + HMI_DEBUG("wm", "Deactivate role:%s", i_prv.first.c_str()); + + // Set deactivate action + bool end_draw_finished = true; + WMAction act + { + "", + i_prv.first, + "", + TaskVisible::INVISIBLE, + end_draw_finished + }; + actions.push_back(act); + } + + // Update previous role list + this->crrlayer2rolestate[layer_name] = crr_roles; + } + } +} + +void PMWrapper::processError() +{ + this->on_error(); +} + +} // namespace wm diff --git a/src/pm_wrapper.hpp b/src/pm_wrapper.hpp new file mode 100644 index 0000000..31ec002 --- /dev/null +++ b/src/pm_wrapper.hpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_PM_WRAPPER_HPP +#define TMCAGLWM_PM_WRAPPER_HPP + +#include +#include +#include +#include +#include "policy_manager.hpp" +#include "request.hpp" + +struct json_object; +struct sd_event; +struct sd_event_source; +struct StmState; + +namespace wm +{ + +class PMWrapper +{ + public: + explicit PMWrapper(); + ~PMWrapper() = default; + + using StateTransitionHandler = std::function)>; + using ErrorHandler = std::function; + + int initialize(); + void registerCallback(StateTransitionHandler on_state_transitioned, + ErrorHandler on_error); + int setInputEventData(Task task, std::string role, std::string area); + int executeStateTransition(); + void undoState(); + + // Do not use these functions + void updateStates(json_object *json_out); + void processError(); + + private: + // Disable copy and move + PMWrapper(PMWrapper const &) = delete; + PMWrapper &operator=(PMWrapper const &) = delete; + PMWrapper(PMWrapper &&) = delete; + PMWrapper &operator=(PMWrapper &&) = delete; + + typedef std::map RoleState; + + PolicyManager pm; + StateTransitionHandler on_state_transitioned; + ErrorHandler on_error; + std::map prvlayer2rolestate; + std::map crrlayer2rolestate; + + void createLayoutChangeAction(json_object *json_out, std::vector &actions); +}; + +} // namespace wm + +#endif // TMCAGLWM_PM_WRAPPER_HPP diff --git a/src/window_manager.cpp b/src/window_manager.cpp index aa42d82..24b6f30 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -55,6 +55,7 @@ const char kKeyIds[] = "ids"; static sd_event_source *g_timer_ev_src = nullptr; static AppList g_app_list; +static WindowManager *g_context; namespace { @@ -99,6 +100,15 @@ static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata return 0; } +static void onStateTransitioned(std::vector actions) +{ + g_context->startTransitionWrapper(actions); +} + +static void onError() +{ + g_context->processError(WMError::LAYOUT_CHANGE_FAIL); +} } // namespace /** @@ -163,6 +173,15 @@ int WindowManager::init() // Load old_role.db this->loadOldRoleDb(); + // Store my context for calling callback from PolicyManager + g_context = this; + + // Initialize PMWrapper + this->pmw.initialize(); + + // Register callback to PolicyManager + this->pmw.registerCallback(onStateTransitioned, onError); + // Make afb event for (int i = Event_Val_Min; i <= Event_Val_Max; i++) { @@ -444,6 +463,9 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) if(ret != WMError::SUCCESS) { //this->emit_error(); + + // Undo state of PolicyManager + this->pmw.undoState(); } this->emitScreenUpdated(current_req); HMI_SEQ_INFO(current_req, "Finish request status: %s", errorDescription(ret)); @@ -506,18 +528,6 @@ result WindowManager::api_get_area_info(char const *drawing_name) return Err("Surface is not on any layer!"); } - auto o_state = *this->layers.get_layout_state(*surface_id); - if (o_state == nullptr) - { - return Err("Could not find layer for surface"); - } - - struct LayoutState &state = *o_state; - if ((state.main != *surface_id) && (state.sub != *surface_id)) - { - return Err("Surface is inactive"); - } - // Set area rectangle compositor::rect area_info = this->area_info[*surface_id]; json_object *object = json_object_new_object(); @@ -592,7 +602,9 @@ void WindowManager::surface_created(uint32_t surface_id) void WindowManager::surface_removed(uint32_t surface_id) { - HMI_DEBUG("wm", "surface_id is %u", surface_id); + HMI_DEBUG("wm", "Delete surface_id %u", surface_id); + this->id_alloc.remove_id(surface_id); + this->layers.remove_surface(surface_id); g_app_list.removeSurface(surface_id); } @@ -620,6 +632,94 @@ void WindowManager::timerHandler() this->processNextRequest(); } +void WindowManager::startTransitionWrapper(std::vector &actions) +{ + WMError ret; + unsigned req_num = g_app_list.currentRequestNumber(); + + if (actions.empty()) + { + if (g_app_list.haveRequest()) + { + HMI_SEQ_DEBUG(req_num, "There is no WMAction for this request"); + goto proc_remove_request; + } + else + { + HMI_SEQ_DEBUG(req_num, "There is no request"); + return; + } + } + + for (auto &act : actions) + { + if ("" != act.role) + { + bool found; + auto const &surface_id = this->lookup_id(act.role.c_str()); + std::string appid = g_app_list.getAppID(*surface_id, act.role, &found); + if (!found) + { + if (TaskVisible::INVISIBLE == act.visible) + { + // App is killed, so do not set this action + continue; + } + else + { + HMI_SEQ_ERROR(req_num, "appid which is visible is not found"); + ret = WMError::FAIL; + goto error; + } + } + act.appid = appid; + } + + ret = g_app_list.setAction(req_num, act); + if (ret != WMError::SUCCESS) + { + HMI_SEQ_ERROR(req_num, "Setting action is failed"); + goto error; + } + } + + HMI_SEQ_DEBUG(req_num, "Start transition."); + ret = this->startTransition(req_num); + if (ret != WMError::SUCCESS) + { + if (ret == WMError::NO_LAYOUT_CHANGE) + { + goto proc_remove_request; + } + else + { + HMI_SEQ_ERROR(req_num, "Transition state is failed"); + goto error; + } + } + + return; + +error: + //this->emit_error() + HMI_SEQ_ERROR(req_num, errorDescription(ret)); + this->pmw.undoState(); + +proc_remove_request: + g_app_list.removeRequest(req_num); + this->processNextRequest(); +} + +void WindowManager::processError(WMError error) +{ + unsigned req_num = g_app_list.currentRequestNumber(); + + //this->emit_error() + HMI_SEQ_ERROR(req_num, errorDescription(error)); + g_app_list.removeRequest(req_num); + this->processNextRequest(); +} + /* ******* Private Functions ******* */ @@ -936,12 +1036,6 @@ WMError WindowManager::doTransition(unsigned req_num) { HMI_SEQ_DEBUG(req_num, "check policy"); WMError ret = this->checkPolicy(req_num); - if (ret != WMError::SUCCESS) - { - return ret; - } - HMI_SEQ_DEBUG(req_num, "Start transition."); - ret = this->startTransition(req_num); return ret; } @@ -952,7 +1046,6 @@ WMError WindowManager::checkPolicy(unsigned req_num) */ // get current trigger bool found = false; - bool split = false; WMError ret = WMError::LAYOUT_CHANGE_FAIL; auto trigger = g_app_list.getRequest(req_num, &found); if (!found) @@ -962,89 +1055,33 @@ WMError WindowManager::checkPolicy(unsigned req_num) } std::string req_area = trigger.area; - // >>>> Compatible with current window manager until policy manager coming if (trigger.task == Task::TASK_ALLOCATE) { - HMI_SEQ_DEBUG(req_num, "Check split or not"); const char *msg = this->check_surface_exist(trigger.role.c_str()); if (msg) { HMI_SEQ_ERROR(req_num, msg); - ret = WMError::LAYOUT_CHANGE_FAIL; return ret; } - - auto const &surface_id = this->lookup_id(trigger.role.c_str()); - auto o_state = *this->layers.get_layout_state(*surface_id); - struct LayoutState &state = *o_state; - - unsigned curernt_sid = state.main; - split = this->can_split(state, *surface_id); - - if (split) - { - HMI_SEQ_DEBUG(req_num, "Split happens"); - // Get current visible role - std::string add_role = this->lookup_name(state.main).value(); - // Set next area - std::string add_area = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaMain); - // Change request area - req_area = std::string(kNameLayoutSplit) + "." + std::string(kNameAreaSub); - HMI_SEQ_NOTICE(req_num, "Change request area from %s to %s, because split happens", - trigger.area.c_str(), req_area.c_str()); - // set another action - std::string add_name = g_app_list.getAppID(curernt_sid, add_role, &found); - if (!found) - { - HMI_SEQ_ERROR(req_num, "Couldn't widhdraw with surfaceID : %d", curernt_sid); - ret = WMError::NOT_REGISTERED; - return ret; - } - HMI_SEQ_INFO(req_num, "Additional split app %s, role: %s, area: %s", - add_name.c_str(), add_role.c_str(), add_area.c_str()); - // Set split action - bool end_draw_finished = false; - WMAction split_action{ - add_name, - add_role, - add_area, - TaskVisible::VISIBLE, - end_draw_finished}; - WMError ret = g_app_list.setAction(req_num, split_action); - if (ret != WMError::SUCCESS) - { - HMI_SEQ_ERROR(req_num, "Failed to set action"); - return ret; - } - g_app_list.reqDump(); - } - } - else - { - HMI_SEQ_DEBUG(req_num, "split doesn't happen"); } - // Set invisible task(Remove if policy manager finish) - ret = this->setInvisibleTask(trigger.role, split); - if(ret != WMError::SUCCESS) + // Input event data to PolicyManager + if (0 > this->pmw.setInputEventData(trigger.task, trigger.role, trigger.area)) { - HMI_SEQ_ERROR(req_num, "Failed to set invisible task: %s", errorDescription(ret)); + HMI_SEQ_ERROR(req_num, "Failed to set input event data to PolicyManager"); return ret; } - /* get new status from Policy Manager */ - HMI_SEQ_NOTICE(req_num, "ATM, Policy manager does't exist, then set WMAction as is"); - if(trigger.role == "homescreen") + // Execute state transition of PolicyManager + if (0 > this->pmw.executeStateTransition()) { - // TODO : Remove when Policy Manager completed - HMI_SEQ_NOTICE(req_num, "Hack. This process will be removed. Change HomeScreen code!!"); - req_area = "fullscreen"; + HMI_SEQ_ERROR(req_num, "Failed to execute state transition of PolicyManager"); + return ret; } - TaskVisible task_visible = - (trigger.task == Task::TASK_ALLOCATE) ? TaskVisible::VISIBLE : TaskVisible::INVISIBLE; - ret = g_app_list.setAction(req_num, trigger.appid, trigger.role, req_area, task_visible); + ret = WMError::SUCCESS; + g_app_list.reqDump(); return ret; @@ -1066,7 +1103,7 @@ WMError WindowManager::startTransition(unsigned req_num) for (const auto &action : actions) { - if (action.visible != TaskVisible::INVISIBLE) + if (action.visible == TaskVisible::VISIBLE) { sync_draw_happen = true; @@ -1097,163 +1134,11 @@ WMError WindowManager::startTransition(unsigned req_num) this->deactivate(client->surfaceID(x.role)); } } - ret = NO_LAYOUT_CHANGE; + ret = WMError::NO_LAYOUT_CHANGE; } return ret; } -WMError WindowManager::setInvisibleTask(const std::string &role, bool split) -{ - unsigned req_num = g_app_list.currentRequestNumber(); - HMI_SEQ_DEBUG(req_num, "set current visible app to invisible task"); - bool found = false; - auto trigger = g_app_list.getRequest(req_num, &found); - // I don't check found == true here because this is checked in caller. - if(trigger.role == "homescreen") - { - HMI_SEQ_INFO(req_num, "In case of 'homescreen' visible, don't change app to invisible"); - return WMError::SUCCESS; - } - - // This task is copied from original actiavete surface - const char *drawing_name = this->rolenew2old[role].c_str(); - auto const &surface_id = this->lookup_id(role.c_str()); - auto layer_id = this->layers.get_layer_id(*surface_id); - auto o_state = *this->layers.get_layout_state(*surface_id); - struct LayoutState &state = *o_state; - std::string add_name, add_role; - std::string add_area = ""; - int surface; - TaskVisible task_visible = TaskVisible::INVISIBLE; - bool end_draw_finished = true; - - for (auto const &l : this->layers.mapping) - { - if (l.second.layer_id <= *layer_id) - { - continue; - } - HMI_DEBUG("wm", "debug: main %d , sub : %d", l.second.state.main, l.second.state.sub); - if (l.second.state.main != -1) - { - //this->deactivate(l.second.state.main); - surface = l.second.state.main; - add_role = *this->id_alloc.lookup(surface); - add_name = g_app_list.getAppID(surface, add_role, &found); - if(!found){ - return WMError::NOT_REGISTERED; - } - HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str()); - WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished}; - g_app_list.setAction(req_num, act); - l.second.state.main = -1; - } - - if (l.second.state.sub != -1) - { - //this->deactivate(l.second.state.sub); - surface = l.second.state.sub; - add_role = *this->id_alloc.lookup(surface); - add_name = g_app_list.getAppID(surface, add_role, &found); - if (!found) - { - return WMError::NOT_REGISTERED; - } - HMI_SEQ_INFO(req_num, "Invisible %s", add_name.c_str()); - WMAction act{add_name, add_role, add_area, task_visible, end_draw_finished}; - g_app_list.setAction(req_num, act); - l.second.state.sub = -1; - } - } - - // change current state here, but this is hack - auto layer = this->layers.get_layer(*layer_id); - - if (state.main == -1) - { - HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal); - } - else - { - if (0 != strcmp(drawing_name, "HomeScreen")) - { - if (split) - { - if (state.sub != *surface_id) - { - if (state.sub != -1) - { - //this->deactivate(state.sub); - WMAction deact_sub; - deact_sub.role = - std::move(*this->id_alloc.lookup(state.sub)); - deact_sub.area = add_area; - deact_sub.appid = g_app_list.getAppID(state.sub, deact_sub.role, &found); - if (!found) - { - HMI_SEQ_ERROR(req_num, "App doesn't exist for role : %s", - deact_sub.role.c_str()); - return WMError::NOT_REGISTERED; - } - deact_sub.visible = task_visible; - deact_sub.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req_num, "Set invisible task for %s", deact_sub.appid.c_str()); - g_app_list.setAction(req_num, deact_sub); - } - } - //state = LayoutState{state.main, *surface_id}; - } - else - { - HMI_DEBUG("wm", "Layout: %s", kNameLayoutNormal); - - //this->surface_set_layout(*surface_id); - if (state.main != *surface_id) - { - // this->deactivate(state.main); - WMAction deact_main; - deact_main.role = std::move(*this->id_alloc.lookup(state.main)); - ; - deact_main.area = add_area; - deact_main.appid = g_app_list.getAppID(state.main, deact_main.role, &found); - if (!found) - { - HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist"); - return WMError::NOT_REGISTERED; - } - deact_main.visible = task_visible; - deact_main.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); - g_app_list.setAction(req_num, deact_main); - } - if (state.sub != -1) - { - if (state.sub != *surface_id) - { - //this->deactivate(state.sub); - WMAction deact_sub; - deact_sub.role = std::move(*this->id_alloc.lookup(state.sub)); - ; - deact_sub.area = add_area; - deact_sub.appid = g_app_list.getAppID(state.sub, deact_sub.role, &found); - if (!found) - { - HMI_SEQ_DEBUG(req_num, "sub surface ddoesn't exist"); - return WMError::NOT_REGISTERED; - } - deact_sub.visible = task_visible; - deact_sub.end_draw_finished = end_draw_finished; - HMI_SEQ_DEBUG(req_num, "sub surface doesn't exist"); - g_app_list.setAction(req_num, deact_sub); - } - } - //state = LayoutState{*surface_id}; - } - } - } - return WMError::SUCCESS; -} - WMError WindowManager::doEndDraw(unsigned req_num) { // get actions @@ -1271,37 +1156,37 @@ WMError WindowManager::doEndDraw(unsigned req_num) // layout change and make it visible for (const auto &act : actions) { - // layout change - if(!g_app_list.contains(act.appid)){ - ret = WMError::NOT_REGISTERED; - } - ret = this->layoutChange(act); - if(ret != WMError::SUCCESS) - { - HMI_SEQ_WARNING(req_num, - "Failed to manipulate surfaces while state change : %s", errorDescription(ret)); - return ret; - } - ret = this->visibilityChange(act); - if (ret != WMError::SUCCESS) + if(act.visible != TaskVisible::NO_CHANGE) { - HMI_SEQ_WARNING(req_num, - "Failed to manipulate surfaces while state change : %s", errorDescription(ret)); - return ret; + // layout change + if(!g_app_list.contains(act.appid)){ + ret = WMError::NOT_REGISTERED; + } + ret = this->layoutChange(act); + if(ret != WMError::SUCCESS) + { + HMI_SEQ_WARNING(req_num, + "Failed to manipulate surfaces while state change : %s", errorDescription(ret)); + return ret; + } + ret = this->visibilityChange(act); + if (ret != WMError::SUCCESS) + { + HMI_SEQ_WARNING(req_num, + "Failed to manipulate surfaces while state change : %s", errorDescription(ret)); + return ret; + } + HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str()); + //this->lm_enddraw(act.role.c_str()); } - HMI_SEQ_DEBUG(req_num, "visible %s", act.role.c_str()); - //this->lm_enddraw(act.role.c_str()); } this->layout_commit(); - // Change current state - this->changeCurrentState(req_num); - HMI_SEQ_INFO(req_num, "emit flushDraw"); for(const auto &act_flush : actions) { - if(act_flush.visible != TaskVisible::INVISIBLE) + if(act_flush.visible == TaskVisible::VISIBLE) { // TODO: application requests by old role, // so convert role new to old for emitting event @@ -1367,74 +1252,6 @@ WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area) return WMError::SUCCESS; } -WMError WindowManager::changeCurrentState(unsigned req_num) -{ - HMI_SEQ_DEBUG(req_num, "Change current layout state"); - bool trigger_found = false, action_found = false; - auto trigger = g_app_list.getRequest(req_num, &trigger_found); - auto actions = g_app_list.getActions(req_num, &action_found); - if (!trigger_found || !action_found) - { - HMI_SEQ_ERROR(req_num, "Action not found"); - return WMError::LAYOUT_CHANGE_FAIL; - } - - // Layout state reset - struct LayoutState reset_state{-1, -1}; - HMI_SEQ_DEBUG(req_num,"Reset layout state"); - for (const auto &action : actions) - { - if(!g_app_list.contains(action.appid)){ - return WMError::NOT_REGISTERED; - } - auto client = g_app_list.lookUpClient(action.appid); - auto pCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role)); - if(pCurState == nullptr) - { - HMI_SEQ_ERROR(req_num, "Counldn't find current status"); - continue; - } - pCurState->main = reset_state.main; - pCurState->sub = reset_state.sub; - } - - HMI_SEQ_DEBUG(req_num, "Change state"); - for (const auto &action : actions) - { - auto client = g_app_list.lookUpClient(action.appid); - auto pLayerCurState = *this->layers.get_layout_state((int)client->surfaceID(action.role)); - if (pLayerCurState == nullptr) - { - HMI_SEQ_ERROR(req_num, "Counldn't find current status"); - continue; - } - int surface = -1; - - if (action.visible != TaskVisible::INVISIBLE) - { - surface = (int)client->surfaceID(action.role); - HMI_SEQ_INFO(req_num, "Change %s surface : %d, state visible area : %s", - action.role.c_str(), surface, action.area.c_str()); - // visible == true -> layout changes - if(action.area == "normal.full" || action.area == "split.main") - { - pLayerCurState->main = surface; - } - else if (action.area == "split.sub") - { - pLayerCurState->sub = surface; - } - else - { - // normalfull - pLayerCurState->main = surface; - } - } - } - - return WMError::SUCCESS; -} - void WindowManager::emitScreenUpdated(unsigned req_num) { // Get visible apps @@ -1641,63 +1458,10 @@ const char *WindowManager::check_surface_exist(const char *drawing_name) return "Surface is not on any layer!"; } - auto o_state = *this->layers.get_layout_state(*surface_id); - - if (o_state == nullptr) - { - return "Could not find layer for surface"; - } - HMI_DEBUG("wm", "surface %d is detected", *surface_id); return nullptr; } -bool WindowManager::can_split(struct LayoutState const &state, int new_id) -{ - if (state.main != -1 && state.main != new_id) - { - auto new_id_layer = this->layers.get_layer_id(new_id).value(); - auto current_id_layer = this->layers.get_layer_id(state.main).value(); - - // surfaces are on separate layers, don't bother. - if (new_id_layer != current_id_layer) - { - return false; - } - - std::string const &new_id_str = this->lookup_name(new_id).value(); - std::string const &cur_id_str = this->lookup_name(state.main).value(); - - auto const &layer = this->layers.get_layer(new_id_layer); - - HMI_DEBUG("wm", "layer info name: %s", layer->name.c_str()); - - if (layer->layouts.empty()) - { - return false; - } - - for (auto i = layer->layouts.cbegin(); i != layer->layouts.cend(); i++) - { - HMI_DEBUG("wm", "%d main_match '%s'", new_id_layer, i->main_match.c_str()); - auto rem = std::regex(i->main_match); - if (std::regex_match(cur_id_str, rem)) - { - // build the second one only if the first already matched - HMI_DEBUG("wm", "%d sub_match '%s'", new_id_layer, i->sub_match.c_str()); - auto res = std::regex(i->sub_match); - if (std::regex_match(new_id_str, res)) - { - HMI_DEBUG("wm", "layout matched!"); - return true; - } - } - } - } - - return false; -} - const char* WindowManager::kDefaultOldRoleDb = "{ \ \"old_roles\": [ \ { \ diff --git a/src/window_manager.hpp b/src/window_manager.hpp index 2358c5a..6cbd355 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -25,6 +25,7 @@ #include "layers.hpp" #include "layout.hpp" #include "wayland_ivi_wm.hpp" +#include "pm_wrapper.hpp" #include "hmi-debug.h" #include "request.hpp" #include "wm_error.hpp" @@ -227,8 +228,11 @@ class WindowManager void removeClient(const std::string &appid); void exceptionProcessForTransition(); const char* convertRoleOldToNew(char const *role); + // Do not use this function void timerHandler(); + void startTransitionWrapper(std::vector &actions); + void processError(WMError error); private: bool pop_pending_events(); @@ -255,13 +259,11 @@ class WindowManager WMError doTransition(unsigned sequence_number); WMError checkPolicy(unsigned req_num); WMError startTransition(unsigned req_num); - WMError setInvisibleTask(const std::string &role, bool split); WMError doEndDraw(unsigned req_num); WMError layoutChange(const WMAction &action); WMError visibilityChange(const WMAction &action); WMError setSurfaceSize(unsigned surface, const std::string& area); - WMError changeCurrentState(unsigned req_num); void emitScreenUpdated(unsigned req_num); void setTimer(); @@ -272,13 +274,13 @@ class WindowManager const char *check_surface_exist(const char *role); - bool can_split(struct LayoutState const &state, int new_id); - private: std::unordered_map area2size; std::unordered_map roleold2new; std::unordered_map rolenew2old; + PMWrapper pmw; + static const char* kDefaultOldRoleDb; }; -- 2.16.6 From 1859dd4135f5d019f16a1333df318ecd1211afb9 Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Wed, 11 Jul 2018 16:21:37 +0900 Subject: [PATCH 04/16] Readd policy table generated by ZIPC for EXAMPLE This patch reverts commit e4222ca8da3b02afca5625fa2cef6832aa8ce90e and update it. To Policy Manager, add the source code of policy table which is generated by ZIPC for EXAMPLE. If use this example, please comment out line 22 and uncomment line 23 in policy_manager/CMakeLists.txt as follows: #set(STM_DIR stub) set(STM_DIR zipc) If try to show split layout, please set bool value "ON" to TRY_SPLIT_LAYOUT at line 28 in policy_manager/CMakeLists.txt as follows: set(TRY_SPLIT_LAYOUT OFF CACHE BOOL "Enable to show split layout") The generated source codes by ZIPC are "Common" and "StateTransitionor" in policy_manager/stm/zipc/. Bug-AGL: SPEC-1537 Change-Id: I1f91cf728eab79c229c5b4b12b9e1bdd338f64aa Signed-off-by: Yuta Doi --- policy_manager/CMakeLists.txt | 17 +- policy_manager/db/roles.db.zipc | 52 + policy_manager/db/roles.db.zipc.split | 60 + policy_manager/stm/zipc/CMakeLists.txt | 73 + policy_manager/stm/zipc/Common/Event.h | 6 + policy_manager/stm/zipc/Common/MisraCType.h | 16 + policy_manager/stm/zipc/Common/ZCommonInclude.h | 16 + .../StateTransitionor/AppsLayer/ZAPL_AppsLayer.c | 2006 ++++++++++++++++++++ .../StateTransitionor/AppsLayer/ZAPL_AppsLayer.h | 123 ++ .../StateTransitionor/AppsLayer/ZAPL_Apps_func.c | 128 ++ .../StateTransitionor/AppsLayer/ZAPL_Apps_func.h | 22 + .../HomeScreenLayer/ZHSL_HomeScreen.c | 152 ++ .../HomeScreenLayer/ZHSL_HomeScreen.h | 39 + .../HomeScreenLayer/ZHSL_HomeScreen_func.c | 45 + .../HomeScreenLayer/ZHSL_HomeScreen_func.h | 14 + .../NearHomeScreen/ZNHL_NearHomeScreen_func.c | 65 + .../NearHomeScreen/ZNHL_NearHomeScreen_func.h | 16 + .../NearHomeScreen/ZNHL_NearHomescreen.c | 242 +++ .../NearHomeScreen/ZNHL_NearHomescreen.h | 53 + .../OnScreenlayer/ZOSL_OnScreen_func.c | 72 + .../OnScreenlayer/ZOSL_OnScreen_func.h | 17 + .../StateTransitionor/OnScreenlayer/ZOSL_OslMain.c | 764 ++++++++ .../StateTransitionor/OnScreenlayer/ZOSL_OslMain.h | 82 + .../RestrictionLayer/ZREL_RelMain.c | 976 ++++++++++ .../RestrictionLayer/ZREL_RelMain.h | 94 + .../RestrictionLayer/ZREL_Restriction_func.c | 81 + .../RestrictionLayer/ZREL_Restriction_func.h | 18 + .../RestrictionMode/ZREM_RestrictionMode.c | 168 ++ .../RestrictionMode/ZREM_RestrictionMode.h | 46 + .../RestrictionMode/ZREM_RestrictionMode_func.c | 53 + .../RestrictionMode/ZREM_RestrictionMode_func.h | 15 + .../StateTransitionor/ZST_StateTransitionor_def.h | 15 + .../StateTransitionor/ZST_StateTransitionor_func.c | 102 + .../StateTransitionor/ZST_StateTransitionor_func.h | 13 + .../StateTransitionor/ZST_StateTransitionor_var.c | 56 + .../StateTransitionor/ZST_StateTransitionor_var.h | 20 + .../stm/zipc/StateTransitionor/ZST_include.h | 29 + policy_manager/stm/zipc/stm_inner.h | 22 + 38 files changed, 5787 insertions(+), 1 deletion(-) create mode 100644 policy_manager/db/roles.db.zipc create mode 100644 policy_manager/db/roles.db.zipc.split create mode 100644 policy_manager/stm/zipc/CMakeLists.txt create mode 100644 policy_manager/stm/zipc/Common/Event.h create mode 100644 policy_manager/stm/zipc/Common/MisraCType.h create mode 100644 policy_manager/stm/zipc/Common/ZCommonInclude.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h create mode 100644 policy_manager/stm/zipc/StateTransitionor/ZST_include.h create mode 100644 policy_manager/stm/zipc/stm_inner.h diff --git a/policy_manager/CMakeLists.txt b/policy_manager/CMakeLists.txt index 23aec19..584d311 100644 --- a/policy_manager/CMakeLists.txt +++ b/policy_manager/CMakeLists.txt @@ -20,6 +20,21 @@ pkg_check_modules(SD REQUIRED libsystemd>=222) # Set name of STM set(STM_DIR stub) +#set(STM_DIR zipc) + +# Select roles.db +if(zipc MATCHES ${STM_DIR}) + # if trying to show split layout, change from OFF to ON + set(TRY_SPLIT_LAYOUT OFF CACHE BOOL "Enable to show split layout") + + if(${TRY_SPLIT_LAYOUT}) + set(ROLES_DB_NAME roles.db.zipc.split) + else() + set(ROLES_DB_NAME roles.db.zipc) + endif() +else() + set(ROLES_DB_NAME roles.db) +endif() # Add STM directory add_subdirectory(stm/${STM_DIR}) @@ -84,5 +99,5 @@ add_custom_command(TARGET ${TARGETS_PM} POST_BUILD COMMAND cp -f ${PROJECT_BINARY_DIR}/${PLUGIN_PM}/lib${PLUGIN_PM}.so ${PROJECT_BINARY_DIR}/package/root/lib COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/etc COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/states.db ${PROJECT_BINARY_DIR}/package/root/etc - COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/roles.db ${PROJECT_BINARY_DIR}/package/root/etc + COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/db/${ROLES_DB_NAME} ${PROJECT_BINARY_DIR}/package/root/etc/roles.db ) diff --git a/policy_manager/db/roles.db.zipc b/policy_manager/db/roles.db.zipc new file mode 100644 index 0000000..facb1d8 --- /dev/null +++ b/policy_manager/db/roles.db.zipc @@ -0,0 +1,52 @@ +{ + "roles":[ + { + "category": "homescreen", + "role": "homescreen", + "area": "fullscreen", + "layer": "homescreen", + }, + { + "category": "map", + "role": "map", + "area": "normal.full | split.main", + "layer": "apps", + }, + { + "category": "general", + "role": "launcher | poi | browser | sdl | mixer | radio | hvac | debug | phone | video | music | fallback", + "area": "normal.full", + "layer": "apps", + }, + { + "category": "system", + "role": "settings | dashboard", + "area": "normal.full", + "layer": "apps", + }, + { + "category": "software_keyboard", + "role": "software_keyboard", + "area": "software_keyboard", + "layer": "near_homescreen", + }, + { + "category": "restriction", + "role": "restriction", + "area": "restriction.normal | restriction.split.main | restriction.split.sub", + "layer": "restriction", + }, + { + "category": "pop_up", + "role": "on_screen | on_screen_phone", + "area": "on_screen", + "layer": "on_screen", + }, + { + "category": "system_alert", + "role": "system_alert", + "area": "on_screen", + "layer": "on_screen", + } + ] +} diff --git a/policy_manager/db/roles.db.zipc.split b/policy_manager/db/roles.db.zipc.split new file mode 100644 index 0000000..73c80cf --- /dev/null +++ b/policy_manager/db/roles.db.zipc.split @@ -0,0 +1,60 @@ +{ + "roles":[ + { + "category": "homescreen", + "role": "homescreen", + "area": "fullscreen", + "layer": "homescreen", + }, + { + "category": "map", + "role": "map", + "area": "normal.full | split.main", + "layer": "apps", + }, + { + "category": "general", + "role": "launcher | poi | browser | sdl | mixer | radio | hvac | debug | phone | fallback", + "area": "normal.full", + "description": "For split test, video and music are moved to category:splitable", + "layer": "apps", + }, + { + "category": "system", + "role": "settings | dashboard", + "area": "normal.full", + "layer": "apps", + }, + { + "category": "splitable", + "role": "video | music", + "area": "normal.full | split.main | split.sub", + "description": "For split test, video and music are included here", + "layer": "apps", + }, + { + "category": "software_keyboard", + "role": "software_keyboard", + "area": "software_keyboard", + "layer": "near_homescreen", + }, + { + "category": "restriction", + "role": "restriction", + "area": "restriction.normal | restriction.split.main | restriction.split.sub", + "layer": "restriction", + }, + { + "category": "pop_up", + "role": "on_screen | on_screen_phone", + "area": "on_screen", + "layer": "on_screen", + }, + { + "category": "system_alert", + "role": "system_alert", + "area": "on_screen", + "layer": "on_screen", + } + ] +} diff --git a/policy_manager/stm/zipc/CMakeLists.txt b/policy_manager/stm/zipc/CMakeLists.txt new file mode 100644 index 0000000..de286a7 --- /dev/null +++ b/policy_manager/stm/zipc/CMakeLists.txt @@ -0,0 +1,73 @@ +# +# Copyright (c) 2017 TOYOTA MOTOR CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +set(TARGETS_STM pmstm) + +set(ST_DIR StateTransitionor) +set(ST_DIR_CMN Common) +set(ST_DIR_AL ${ST_DIR}/AppsLayer) +set(ST_DIR_HS ${ST_DIR}/HomeScreenLayer) +set(ST_DIR_NHS ${ST_DIR}/NearHomeScreen) +set(ST_DIR_OS ${ST_DIR}/OnScreenlayer) +set(ST_DIR_RL ${ST_DIR}/RestrictionLayer) +set(ST_DIR_RM ${ST_DIR}/RestrictionMode) + +add_library(${TARGETS_STM} + STATIC + ${ST_DIR}/ZST_StateTransitionor_func.c + ${ST_DIR}/ZST_StateTransitionor_var.c + ${ST_DIR_AL}/ZAPL_AppsLayer.c + ${ST_DIR_AL}/ZAPL_Apps_func.c + ${ST_DIR_HS}/ZHSL_HomeScreen.c + ${ST_DIR_HS}/ZHSL_HomeScreen_func.c + ${ST_DIR_NHS}/ZNHL_NearHomescreen.c + ${ST_DIR_NHS}/ZNHL_NearHomeScreen_func.c + ${ST_DIR_OS}/ZOSL_OslMain.c + ${ST_DIR_OS}/ZOSL_OnScreen_func.c + ${ST_DIR_RL}/ZREL_RelMain.c + ${ST_DIR_RL}/ZREL_Restriction_func.c + ${ST_DIR_RM}/ZREM_RestrictionMode.c + ${ST_DIR_RM}/ZREM_RestrictionMode_func.c +) + +target_include_directories(${TARGETS_STM} + PRIVATE + ./ + ./${ST_DIR} + ./${ST_DIR_AL} + ./${ST_DIR_HS} + ./${ST_DIR_NHS} + ./${ST_DIR_OS} + ./${ST_DIR_RL} + ./${ST_DIR_RM} + ./${ST_DIR_CMN} +) + +target_compile_definitions(${TARGETS_STM} + PRIVATE + _GNU_SOURCE +) + +target_compile_options(${TARGETS_STM} + PRIVATE + -Wall -Wextra -Wno-unused-parameter -Wno-comment) + +set_target_properties(${TARGETS_STM} + PROPERTIES + C_EXTENSIONS OFF + C_STANDARD 99 + C_STANDARD_REQUIRED ON +) diff --git a/policy_manager/stm/zipc/Common/Event.h b/policy_manager/stm/zipc/Common/Event.h new file mode 100644 index 0000000..3601b08 --- /dev/null +++ b/policy_manager/stm/zipc/Common/Event.h @@ -0,0 +1,6 @@ +#ifndef ZHEADER_EVENT_H +#define ZHEADER_EVENT_H + +#define ZEVENT_NULL ( 0U ) + +#endif diff --git a/policy_manager/stm/zipc/Common/MisraCType.h b/policy_manager/stm/zipc/Common/MisraCType.h new file mode 100644 index 0000000..5a535fb --- /dev/null +++ b/policy_manager/stm/zipc/Common/MisraCType.h @@ -0,0 +1,16 @@ +#ifndef ZHEADER_MISRACTYPE_H +#define ZHEADER_MISRACTYPE_H + +typedef char char_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long int64_t; +typedef unsigned long uint64_t; +typedef float float32_t; +typedef double float64_t; + +#endif diff --git a/policy_manager/stm/zipc/Common/ZCommonInclude.h b/policy_manager/stm/zipc/Common/ZCommonInclude.h new file mode 100644 index 0000000..6b9b84b --- /dev/null +++ b/policy_manager/stm/zipc/Common/ZCommonInclude.h @@ -0,0 +1,16 @@ +#ifndef ZHEADER_ZCOMMONINCLUDE_H +#define ZHEADER_ZCOMMONINCLUDE_H + +#define ZFALSE ( 0U ) +#define ZTRUE ( 1U ) + +#define ZNULL ( 0x00 ) + +#define ZEVENT_NONHIT ( -1 ) + +#define ZRET_NORMAL ( 0U ) +#define ZRET_ERROR ( 1U ) +#define ZRET_NONACTIVE ( 2U ) +typedef unsigned char ZeRetType; + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c new file mode 100644 index 0000000..b6891e8 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c @@ -0,0 +1,2006 @@ +/************************************************************/ +/* ZAPL_AppsLayer.c */ +/* AppsLayer State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZAPL_AppsLayerState[ZAPL_APPSLAYERSTATENOMAX]; + +static void ZAPL_AppsLayers0StateEntry( void ); +static void ZAPL_AppsLayers1StateEntry( void ); +static void ZAPL_AppsLayers0e1( void ); +static void ZAPL_AppsLayers1e0( void ); +static void ZAPL_RestrictionModeOffs0e0( void ); +static void ZAPL_RestrictionModeOffs0e2( void ); +static void ZAPL_RestrictionModeOffs0e3( void ); +static void ZAPL_RestrictionModeOffs0e6( void ); +static void ZAPL_RestrictionModeOffs0e7( void ); +static void ZAPL_RestrictionModeOffs0e13( void ); +static void ZAPL_RestrictionModeOffs0e15( void ); +static void ZAPL_RestrictionModeOffs0e18( void ); +static void ZAPL_RestrictionModeOffs1e0( void ); +static void ZAPL_RestrictionModeOffs1e8( void ); +static void ZAPL_RestrictionModeOffs2e3( void ); +static void ZAPL_RestrictionModeOffs3e2( void ); +static void ZAPL_RestrictionModeOffs4e3( void ); +static void ZAPL_RestrictionModeOffs5e3( void ); +static void ZAPL_RestrictionModeOffs6e6( void ); +static void ZAPL_RestrictionModeOffs7e7( void ); +static void ZAPL_RestrictionModeOns0e1( void ); +static void ZAPL_RestrictionModeOns0e2( void ); +static void ZAPL_RestrictionModeOns1e0( void ); +static void ZAPL_RestrictionModeOns1e3( void ); +static void ZAPL_AppsLayers0Event( void ); +static void ZAPL_RestrictionModeOffs0Event( void ); +static void ZAPL_RestrictionModeOffs1Event( void ); +static void ZAPL_RestrictionModeOffs2Event( void ); +static void ZAPL_RestrictionModeOffs3Event( void ); +static void ZAPL_RestrictionModeOffs4Event( void ); +static void ZAPL_RestrictionModeOffs5Event( void ); +static void ZAPL_RestrictionModeOffs6Event( void ); +static void ZAPL_RestrictionModeOffs7Event( void ); +static void ZAPL_AppsLayers1Event( void ); +static void ZAPL_RestrictionModeOns0Event( void ); +static void ZAPL_RestrictionModeOns1Event( void ); + +/****************************************/ +/* State start activity function */ +/* STM : AppsLayer */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZAPL_AppsLayers0StateEntry( void ) +{ + switch( ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] ) + { + case ZAPL_RESTRICTIONMODEOFFS0: + stm_apl_start_activity_none(); + break; + case ZAPL_RESTRICTIONMODEOFFS1: + stm_apl_start_activity_map(); + break; + case ZAPL_RESTRICTIONMODEOFFS2: + stm_apl_start_activity_map_split(); + break; + case ZAPL_RESTRICTIONMODEOFFS3: + stm_apl_start_activity_map_fullscreen(); + break; + case ZAPL_RESTRICTIONMODEOFFS4: + stm_apl_start_activity_splitable_normal(); + break; + case ZAPL_RESTRICTIONMODEOFFS5: + stm_apl_start_activity_splitable_split(); + break; + case ZAPL_RESTRICTIONMODEOFFS6: + stm_apl_start_activity_general(); + break; + case ZAPL_RESTRICTIONMODEOFFS7: + stm_apl_start_activity_system(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* State start activity function */ +/* STM : AppsLayer */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZAPL_AppsLayers1StateEntry( void ) +{ + switch( ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] ) + { + case ZAPL_RESTRICTIONMODEONS0: + stm_apl_start_activity_map(); + break; + case ZAPL_RESTRICTIONMODEONS1: + stm_apl_start_activity_map_fullscreen(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Action function */ +/* STM : AppsLayer */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : stt_prv_layer_apps_not_sys_nml( No 1 ) */ +/****************************************/ +static void ZAPL_AppsLayers0e1( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYER] = ( uint8_t )ZAPL_APPSLAYERS1; + ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] = ( uint8_t )ZAPL_RESTRICTIONMODEONS0; + ZAPL_AppsLayers1StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : AppsLayer */ +/* State : restriction_mode_2_on( No 1 ) */ +/* Event : stt_restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZAPL_AppsLayers1e0( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYER] = ( uint8_t )ZAPL_APPSLAYERS0; + ZAPL_AppsLayers0StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : ara_normal( No 0 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e0( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS1; + stm_apl_start_activity_map(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : ara_fullscreen( No 2 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e2( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS3; + stm_apl_start_activity_map_fullscreen(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : ara_normal( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e3( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS4; + stm_apl_start_activity_splitable_normal(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : ara_normal( No 6 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e6( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS6; + stm_apl_start_activity_general(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : ara_normal( No 7 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e7( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS7; + stm_apl_start_activity_system(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_apps_none( No 13 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e13( void ) +{ + stm_apl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_apps_map_spl( No 15 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e15( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS2; + stm_apl_start_activity_map_split(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_apps_spl_spl( No 18 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0e18( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS5; + stm_apl_start_activity_splitable_split(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : map( No 1 ) */ +/* Event : ara_normal( No 0 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs1e0( void ) +{ + stm_apl_start_activity_map(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : map( No 1 ) */ +/* Event : ara_fullscreen( No 8 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs1e8( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS0; + stm_apl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : map_split( No 2 ) */ +/* Event : ara_normal( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs2e3( void ) +{ + stm_apl_start_activity_map_split(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : map_fullscreen( No 3 ) */ +/* Event : ara_fullscreen( No 2 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs3e2( void ) +{ + stm_apl_start_activity_map_fullscreen(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : splitable_normal( No 4 ) */ +/* Event : ara_normal( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs4e3( void ) +{ + stm_apl_start_activity_splitable_normal(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : splitable_split( No 5 ) */ +/* Event : ara_normal( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs5e3( void ) +{ + stm_apl_start_activity_splitable_split(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : general( No 6 ) */ +/* Event : ara_normal( No 6 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs6e6( void ) +{ + stm_apl_start_activity_general(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOff */ +/* State : system( No 7 ) */ +/* Event : ara_normal( No 7 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs7e7( void ) +{ + stm_apl_start_activity_system(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOn */ +/* State : map( No 0 ) */ +/* Event : ara_fullscreen( No 1 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns0e1( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] = ( uint8_t )ZAPL_RESTRICTIONMODEONS1; + stm_apl_start_activity_map_fullscreen(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOn */ +/* State : map( No 0 ) */ +/* Event : stt_prv_layer_apps_map_nml( No 2 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns0e2( void ) +{ + stm_apl_start_activity_map(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOn */ +/* State : map_fullscreen( No 1 ) */ +/* Event : ara_normal( No 0 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns1e0( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] = ( uint8_t )ZAPL_RESTRICTIONMODEONS0; + stm_apl_start_activity_map(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionModeOn */ +/* State : map_fullscreen( No 1 ) */ +/* Event : stt_prv_layer_apps_map_fll( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns1e3( void ) +{ + stm_apl_start_activity_map_fullscreen(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : AppsLayer */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZAPL_AppsLayers0Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + stm_apl_event_restriction_mode_2_on(); + /*stt_map_is_activated*/ + if( g_stm_map_is_activated == STM_TRUE ) + { + /*stt_prv_layer_apps_not_sys_nml*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state != StmLayoutNoSysNml ) + { + ZAPL_AppsLayers0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs0Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs0e13(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : map( No 1 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs1Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs1e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*ara_split_sub*/ + else if( g_stm_area == StmAreaNoSplitSub ) + { + ZAPL_RestrictionModeOffs0e15(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs1e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : map_split( No 2 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs2Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs2e3(); + } + /*ara_split_sub*/ + else if( g_stm_area == StmAreaNoSplitSub ) + { + ZAPL_RestrictionModeOffs2e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + ZAPL_RestrictionModeOffs0e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs2e3(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : map_fullscreen( No 3 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs3Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs3e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e15(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs3e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : splitable_normal( No 4 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs4Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*ara_split_main*/ + else if( g_stm_area == StmAreaNoSplitMain ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs4e3(); + } + /*ara_split_main*/ + else if( g_stm_area == StmAreaNoSplitMain ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*ara_split_sub*/ + else if( g_stm_area == StmAreaNoSplitSub ) + { + ZAPL_RestrictionModeOffs0e18(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_splitable*/ + if( g_stm_category == StmCtgNoSplitable ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs4e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : splitable_split( No 5 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs5Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*ara_split_main*/ + else if( g_stm_area == StmAreaNoSplitMain ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs5e3(); + } + /*ara_split_main*/ + else if( g_stm_area == StmAreaNoSplitMain ) + { + ZAPL_RestrictionModeOffs5e3(); + } + /*ara_split_sub*/ + else if( g_stm_area == StmAreaNoSplitSub ) + { + ZAPL_RestrictionModeOffs5e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_splitable*/ + if( g_stm_category == StmCtgNoSplitable ) + { + ZAPL_RestrictionModeOffs0e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs5e3(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : general( No 6 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs6Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs6e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_general*/ + if( g_stm_category == StmCtgNoGeneral ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs6e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs0e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOff */ +/* State : system( No 7 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOffs7Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*ara_fullscreen*/ + else if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_splitable*/ + else if( g_stm_category == StmCtgNoSplitable ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_general*/ + else if( g_stm_category == StmCtgNoGeneral ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs0e6(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_system*/ + else if( g_stm_category == StmCtgNoSystem ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOffs7e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_system*/ + if( g_stm_category == StmCtgNoSystem ) + { + ZAPL_RestrictionModeOffs1e8(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_none*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoNone ) + { + ZAPL_RestrictionModeOffs1e8(); + } + /*stt_prv_layer_apps_map_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOffs0e0(); + } + /*stt_prv_layer_apps_map_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZAPL_RestrictionModeOffs0e15(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOffs0e2(); + } + /*stt_prv_layer_apps_spl_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZAPL_RestrictionModeOffs0e3(); + } + /*stt_prv_layer_apps_spl_spl*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZAPL_RestrictionModeOffs0e18(); + } + /*stt_prv_layer_apps_gen_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZAPL_RestrictionModeOffs0e6(); + } + /*stt_prv_layer_apps_sys_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSysNml ) + { + ZAPL_RestrictionModeOffs7e7(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : AppsLayer */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZAPL_AppsLayers1Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + stm_apl_event_restriction_mode_off(); + ZAPL_AppsLayers1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOn */ +/* State : map( No 0 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns0Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZAPL_RestrictionModeOns0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_map_nml*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOns0e2(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOns0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionModeOn */ +/* State : map_fullscreen( No 1 ) */ +/****************************************/ +static void ZAPL_RestrictionModeOns1Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_map*/ + if( g_stm_category == StmCtgNoMap ) + { + /*ara_normal*/ + if( g_stm_area == StmAreaNoNormal ) + { + ZAPL_RestrictionModeOns1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_apps_map_nml*/ + if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapNml ) + { + ZAPL_RestrictionModeOns1e0(); + } + /*stt_prv_layer_apps_map_fll*/ + else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMapFll ) + { + ZAPL_RestrictionModeOns1e3(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event call function */ +/* STM : AppsLayer */ +/****************************************/ +void stm_apl_event_call( void ) +{ + stm_apl_start_stm(); + switch( ZAPL_AppsLayerState[ZAPL_APPSLAYER] ) + { + case ZAPL_APPSLAYERS0: + switch( ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] ) + { + case ZAPL_RESTRICTIONMODEOFFS0: + ZAPL_RestrictionModeOffs0Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS1: + ZAPL_RestrictionModeOffs1Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS2: + ZAPL_RestrictionModeOffs2Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS3: + ZAPL_RestrictionModeOffs3Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS4: + ZAPL_RestrictionModeOffs4Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS5: + ZAPL_RestrictionModeOffs5Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS6: + ZAPL_RestrictionModeOffs6Event(); + break; + case ZAPL_RESTRICTIONMODEOFFS7: + ZAPL_RestrictionModeOffs7Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZAPL_AppsLayers0Event(); + break; + case ZAPL_APPSLAYERS1: + switch( ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] ) + { + case ZAPL_RESTRICTIONMODEONS0: + ZAPL_RestrictionModeOns0Event(); + break; + case ZAPL_RESTRICTIONMODEONS1: + ZAPL_RestrictionModeOns1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZAPL_AppsLayers1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : AppsLayer */ +/****************************************/ +void stm_apl_initialize( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYER] = ( uint8_t )ZAPL_APPSLAYERS0; + ZAPL_AppsLayerState[ZAPL_APPSLAYERS0F] = ( uint8_t )ZAPL_RESTRICTIONMODEOFFS0; + ZAPL_AppsLayerState[ZAPL_APPSLAYERS1F] = ( uint8_t )ZAPL_RESTRICTIONMODEONS0; + ZAPL_AppsLayers0StateEntry(); +} + +/****************************************/ +/* Terminate function */ +/* STM : AppsLayer */ +/****************************************/ +void ZAPL_AppsLayerTerminate( void ) +{ + ZAPL_AppsLayerState[ZAPL_APPSLAYER] = ( uint8_t )ZAPL_APPSLAYERTERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h new file mode 100644 index 0000000..4cbbc10 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h @@ -0,0 +1,123 @@ +/************************************************************/ +/* ZAPL_AppsLayer.h */ +/* AppsLayer State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZAPL_APPSLAYER_H +#define ZHEADER_ZAPL_APPSLAYER_H + +/*State management variable access define*/ +#define ZAPL_APPSLAYER ( 0U ) +#define ZAPL_APPSLAYERS0F ( 1U ) +#define ZAPL_APPSLAYERS1F ( 2U ) +#define ZAPL_APPSLAYERS0 ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFS0 ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFS1 ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFS2 ( 2U ) +#define ZAPL_RESTRICTIONMODEOFFS3 ( 3U ) +#define ZAPL_RESTRICTIONMODEOFFS4 ( 4U ) +#define ZAPL_RESTRICTIONMODEOFFS5 ( 5U ) +#define ZAPL_RESTRICTIONMODEOFFS6 ( 6U ) +#define ZAPL_RESTRICTIONMODEOFFS7 ( 7U ) +#define ZAPL_APPSLAYERS1 ( 1U ) +#define ZAPL_RESTRICTIONMODEONS0 ( 0U ) +#define ZAPL_RESTRICTIONMODEONS1 ( 1U ) +#define ZAPL_APPSLAYERSTATENOMAX ( 3U ) + +/*End state define*/ +#define ZAPL_APPSLAYEREND ( 8U ) +/*Terminate state define*/ +#define ZAPL_APPSLAYERTERMINATE ( ZAPL_APPSLAYEREND + 1U ) + +/*State no define*/ +#define ZAPL_APPSLAYERS0STATENO ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFS0STATENO ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFS1STATENO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFS2STATENO ( 2U ) +#define ZAPL_RESTRICTIONMODEOFFS3STATENO ( 3U ) +#define ZAPL_RESTRICTIONMODEOFFS4STATENO ( 4U ) +#define ZAPL_RESTRICTIONMODEOFFS5STATENO ( 5U ) +#define ZAPL_RESTRICTIONMODEOFFS6STATENO ( 6U ) +#define ZAPL_RESTRICTIONMODEOFFS7STATENO ( 7U ) +#define ZAPL_APPSLAYERS1STATENO ( 1U ) +#define ZAPL_RESTRICTIONMODEONS0STATENO ( 0U ) +#define ZAPL_RESTRICTIONMODEONS1STATENO ( 1U ) + +/*State serial no define*/ +#define ZAPL_APPSLAYERS0STATESERIALNO ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFS0STATESERIALNO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFS1STATESERIALNO ( 2U ) +#define ZAPL_RESTRICTIONMODEOFFS2STATESERIALNO ( 3U ) +#define ZAPL_RESTRICTIONMODEOFFS3STATESERIALNO ( 4U ) +#define ZAPL_RESTRICTIONMODEOFFS4STATESERIALNO ( 5U ) +#define ZAPL_RESTRICTIONMODEOFFS5STATESERIALNO ( 6U ) +#define ZAPL_RESTRICTIONMODEOFFS6STATESERIALNO ( 7U ) +#define ZAPL_RESTRICTIONMODEOFFS7STATESERIALNO ( 8U ) +#define ZAPL_APPSLAYERS1STATESERIALNO ( 9U ) +#define ZAPL_RESTRICTIONMODEONS0STATESERIALNO ( 10U ) +#define ZAPL_RESTRICTIONMODEONS1STATESERIALNO ( 11U ) + +/*Event no define*/ +#define ZAPL_APPSLAYERE0EVENTNO ( 0U ) +#define ZAPL_APPSLAYERE1EVENTNO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFE0EVENTNO ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFE1EVENTNO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFE2EVENTNO ( 2U ) +#define ZAPL_RESTRICTIONMODEOFFE3EVENTNO ( 3U ) +#define ZAPL_RESTRICTIONMODEOFFE4EVENTNO ( 4U ) +#define ZAPL_RESTRICTIONMODEOFFE5EVENTNO ( 5U ) +#define ZAPL_RESTRICTIONMODEOFFE6EVENTNO ( 6U ) +#define ZAPL_RESTRICTIONMODEOFFE7EVENTNO ( 7U ) +#define ZAPL_RESTRICTIONMODEOFFE8EVENTNO ( 8U ) +#define ZAPL_RESTRICTIONMODEOFFE9EVENTNO ( 9U ) +#define ZAPL_RESTRICTIONMODEOFFE10EVENTNO ( 10U ) +#define ZAPL_RESTRICTIONMODEOFFE11EVENTNO ( 11U ) +#define ZAPL_RESTRICTIONMODEOFFE12EVENTNO ( 12U ) +#define ZAPL_RESTRICTIONMODEOFFE13EVENTNO ( 13U ) +#define ZAPL_RESTRICTIONMODEOFFE14EVENTNO ( 14U ) +#define ZAPL_RESTRICTIONMODEOFFE15EVENTNO ( 15U ) +#define ZAPL_RESTRICTIONMODEOFFE16EVENTNO ( 16U ) +#define ZAPL_RESTRICTIONMODEOFFE17EVENTNO ( 17U ) +#define ZAPL_RESTRICTIONMODEOFFE18EVENTNO ( 18U ) +#define ZAPL_RESTRICTIONMODEOFFE19EVENTNO ( 19U ) +#define ZAPL_RESTRICTIONMODEOFFE20EVENTNO ( 20U ) +#define ZAPL_RESTRICTIONMODEONE0EVENTNO ( 0U ) +#define ZAPL_RESTRICTIONMODEONE1EVENTNO ( 1U ) +#define ZAPL_RESTRICTIONMODEONE2EVENTNO ( 2U ) +#define ZAPL_RESTRICTIONMODEONE3EVENTNO ( 3U ) + +/*Event serial no define*/ +#define ZAPL_APPSLAYERE0EVENTSERIALNO ( 0U ) +#define ZAPL_APPSLAYERE1EVENTSERIALNO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFE0EVENTNO ( 0U ) +#define ZAPL_RESTRICTIONMODEOFFE1EVENTNO ( 1U ) +#define ZAPL_RESTRICTIONMODEOFFE2EVENTNO ( 2U ) +#define ZAPL_RESTRICTIONMODEOFFE3EVENTNO ( 3U ) +#define ZAPL_RESTRICTIONMODEOFFE4EVENTNO ( 4U ) +#define ZAPL_RESTRICTIONMODEOFFE5EVENTNO ( 5U ) +#define ZAPL_RESTRICTIONMODEOFFE6EVENTNO ( 6U ) +#define ZAPL_RESTRICTIONMODEOFFE7EVENTNO ( 7U ) +#define ZAPL_RESTRICTIONMODEOFFE8EVENTNO ( 8U ) +#define ZAPL_RESTRICTIONMODEOFFE9EVENTNO ( 9U ) +#define ZAPL_RESTRICTIONMODEOFFE10EVENTNO ( 10U ) +#define ZAPL_RESTRICTIONMODEOFFE11EVENTNO ( 11U ) +#define ZAPL_RESTRICTIONMODEOFFE12EVENTNO ( 12U ) +#define ZAPL_RESTRICTIONMODEOFFE13EVENTNO ( 13U ) +#define ZAPL_RESTRICTIONMODEOFFE14EVENTNO ( 14U ) +#define ZAPL_RESTRICTIONMODEOFFE15EVENTNO ( 15U ) +#define ZAPL_RESTRICTIONMODEOFFE16EVENTNO ( 16U ) +#define ZAPL_RESTRICTIONMODEOFFE17EVENTNO ( 17U ) +#define ZAPL_RESTRICTIONMODEOFFE18EVENTNO ( 18U ) +#define ZAPL_RESTRICTIONMODEOFFE19EVENTNO ( 19U ) +#define ZAPL_RESTRICTIONMODEOFFE20EVENTNO ( 20U ) +#define ZAPL_RESTRICTIONMODEONE0EVENTNO ( 0U ) +#define ZAPL_RESTRICTIONMODEONE1EVENTNO ( 1U ) +#define ZAPL_RESTRICTIONMODEONE2EVENTNO ( 2U ) +#define ZAPL_RESTRICTIONMODEONE3EVENTNO ( 3U ) + +/*Extern function*/ +extern void stm_apl_event_call( void ); +extern void stm_apl_initialize( void ); +extern void ZAPL_AppsLayerTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c new file mode 100644 index 0000000..b42df05 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c @@ -0,0 +1,128 @@ +/************************************************************/ +/* ZAPL_Apps_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_apl_start_activity_none + */ +void stm_apl_start_activity_none() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_start_activity_map + */ +void stm_apl_start_activity_map() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMapNml; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + + if ((g_stm_event == StmEvtNoActivate) + && (g_stm_category == StmCtgNoMap)) { + g_stm_map_is_activated = STM_TRUE; + } +} + +/* + * @name stm_apl_start_activity_map_split + */ +void stm_apl_start_activity_map_split() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMapSpl; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + + if ((g_stm_event == StmEvtNoActivate) + && (g_stm_category == StmCtgNoMap)) { + g_stm_map_is_activated = STM_TRUE; + } +} + +/* + * @name stm_apl_start_activity_map_fullscreen + */ +void stm_apl_start_activity_map_fullscreen() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMapFll; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; + + if ((g_stm_event == StmEvtNoActivate) + && (g_stm_category == StmCtgNoMap)) { + g_stm_map_is_activated = STM_TRUE; + } +} + +/* + * @name stm_apl_start_activity_splitable_normal + */ +void stm_apl_start_activity_splitable_normal() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoSplNml; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_start_activity_splitable_split + */ +void stm_apl_start_activity_splitable_split() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoSplSpl; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_start_activity_general + */ +void stm_apl_start_activity_general() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoGenNml; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_start_activity_system + */ +void stm_apl_start_activity_system() { + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoSysNml; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_event_restriction_mode_off + */ +void stm_apl_event_restriction_mode_off() { + g_stm_crr_state.layer[StmLayerNoApps].state = g_prv_apps_state_rest_mode_1; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE; +} + +/* + * @name stm_apl_event_restriction_mode_2_on + */ +void stm_apl_event_restriction_mode_2_on() { + g_prv_apps_state_rest_mode_1 = g_stm_prv_state.layer[StmLayerNoApps].state; +} + +/* + * @name stm_apl_initialize_variable + */ +void stm_apl_initialize_variable() { + g_stm_prv_state.layer[StmLayerNoApps].state = StmLayoutNoNone; + g_stm_prv_state.layer[StmLayerNoApps].changed = STM_FALSE; + + g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_FALSE; +} + +/* + * @name stm_apl_start_stm + */ +void stm_apl_start_stm() { + if (g_stm_event == StmEvtNoUndo) { + // nop + } + else { + g_stm_prv_state.layer[StmLayerNoApps].state = g_stm_crr_state.layer[StmLayerNoApps].state; + } + g_stm_crr_state.layer[StmLayerNoApps].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h new file mode 100644 index 0000000..6f741b5 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h @@ -0,0 +1,22 @@ +/************************************************************/ +/* ZAPL_Apps_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZAPL_APPS_FUNC_H +#define ZHEADER_ZAPL_APPS_FUNC_H + +extern void stm_apl_start_activity_none(); +extern void stm_apl_start_activity_map(); +extern void stm_apl_start_activity_map_split(); +extern void stm_apl_start_activity_map_fullscreen(); +extern void stm_apl_start_activity_splitable_normal(); +extern void stm_apl_start_activity_splitable_split(); +extern void stm_apl_start_activity_general(); +extern void stm_apl_start_activity_system(); +extern void stm_apl_event_restriction_mode_off(); +extern void stm_apl_event_restriction_mode_2_on(); +extern void stm_apl_initialize_variable(); +extern void stm_apl_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c new file mode 100644 index 0000000..a4cd474 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c @@ -0,0 +1,152 @@ +/************************************************************/ +/* ZHSL_HomeScreen.c */ +/* HomeScreen State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZHSL_HomeScreenState[ZHSL_HOMESCREENSTATENOMAX]; + +static void ZHSL_HomeScreens0e0( void ); +static void ZHSL_HomeScreens1e0( void ); +static void ZHSL_HomeScreens0Event( void ); +static void ZHSL_HomeScreens1Event( void ); + +/****************************************/ +/* Action function */ +/* STM : HomeScreen */ +/* State : none( No 0 ) */ +/* Event : ara_fullscreen( No 0 ) */ +/****************************************/ +static void ZHSL_HomeScreens0e0( void ) +{ + ZHSL_HomeScreenState[ZHSL_HOMESCREEN] = ( uint8_t )ZHSL_HOMESCREENS1; + stm_hsl_start_activity_homescreen(); +} + +/****************************************/ +/* Action function */ +/* STM : HomeScreen */ +/* State : homescreen( No 1 ) */ +/* Event : ara_fullscreen( No 0 ) */ +/****************************************/ +static void ZHSL_HomeScreens1e0( void ) +{ + stm_hsl_start_activity_homescreen(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : HomeScreen */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZHSL_HomeScreens0Event( void ) +{ + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_homescreen*/ + if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZHSL_HomeScreens0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : HomeScreen */ +/* State : homescreen( No 1 ) */ +/****************************************/ +static void ZHSL_HomeScreens1Event( void ) +{ + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_homescreen*/ + if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZHSL_HomeScreens1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event call function */ +/* STM : HomeScreen */ +/****************************************/ +void stm_hsl_event_call( void ) +{ + stm_hsl_start_stm(); + switch( ZHSL_HomeScreenState[ZHSL_HOMESCREEN] ) + { + case ZHSL_HOMESCREENS0: + ZHSL_HomeScreens0Event(); + break; + case ZHSL_HOMESCREENS1: + ZHSL_HomeScreens1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : HomeScreen */ +/****************************************/ +void stm_hsl_initialize( void ) +{ + ZHSL_HomeScreenState[ZHSL_HOMESCREEN] = ( uint8_t )ZHSL_HOMESCREENS0; + stm_hsl_start_activity_none(); +} + +/****************************************/ +/* Terminate function */ +/* STM : HomeScreen */ +/****************************************/ +void ZHSL_HomeScreenTerminate( void ) +{ + ZHSL_HomeScreenState[ZHSL_HOMESCREEN] = ( uint8_t )ZHSL_HOMESCREENTERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h new file mode 100644 index 0000000..ffa8552 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h @@ -0,0 +1,39 @@ +/************************************************************/ +/* ZHSL_HomeScreen.h */ +/* HomeScreen State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZHSL_HOMESCREEN_H +#define ZHEADER_ZHSL_HOMESCREEN_H + +/*State management variable access define*/ +#define ZHSL_HOMESCREEN ( 0U ) +#define ZHSL_HOMESCREENS0 ( 0U ) +#define ZHSL_HOMESCREENS1 ( 1U ) +#define ZHSL_HOMESCREENSTATENOMAX ( 1U ) + +/*End state define*/ +#define ZHSL_HOMESCREENEND ( 2U ) +/*Terminate state define*/ +#define ZHSL_HOMESCREENTERMINATE ( ZHSL_HOMESCREENEND + 1U ) + +/*State no define*/ +#define ZHSL_HOMESCREENS0STATENO ( 0U ) +#define ZHSL_HOMESCREENS1STATENO ( 1U ) + +/*State serial no define*/ +#define ZHSL_HOMESCREENS0STATESERIALNO ( 0U ) +#define ZHSL_HOMESCREENS1STATESERIALNO ( 1U ) + +/*Event no define*/ +#define ZHSL_HOMESCREENE0EVENTNO ( 0U ) + +/*Event serial no define*/ +#define ZHSL_HOMESCREENE0EVENTSERIALNO ( 0U ) + +/*Extern function*/ +extern void stm_hsl_event_call( void ); +extern void stm_hsl_initialize( void ); +extern void ZHSL_HomeScreenTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c new file mode 100644 index 0000000..4d50ab0 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c @@ -0,0 +1,45 @@ +/************************************************************/ +/* ZHSL_HomeScreen_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_hsl_start_activity_none + */ +void stm_hsl_start_activity_none() { + g_stm_crr_state.layer[StmLayerNoHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_TRUE; +} + +/* + * @name stm_hsl_start_activity_homescreen + */ +void stm_hsl_start_activity_homescreen() { + g_stm_crr_state.layer[StmLayerNoHomescreen].state = StmLayoutNoHms; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_TRUE; +} + +/* + * @name stm_hsl_initialize_variable + */ +void stm_hsl_initialize_variable() { + g_stm_prv_state.layer[StmLayerNoHomescreen].state = StmLayoutNoNone; + g_stm_prv_state.layer[StmLayerNoHomescreen].changed = STM_FALSE; + + g_stm_crr_state.layer[StmLayerNoHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_FALSE; +} + +/* + * @name stm_hsl_start_stm + */ +void stm_hsl_start_stm() { + g_stm_prv_state.layer[StmLayerNoHomescreen].state = g_stm_crr_state.layer[StmLayerNoHomescreen].state; + g_stm_crr_state.layer[StmLayerNoHomescreen].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h new file mode 100644 index 0000000..d5f4ab9 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h @@ -0,0 +1,14 @@ +/************************************************************/ +/* ZHSL_HomeScreen_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZHSL_HOMESCREEN_FUNC_H +#define ZHEADER_ZHSL_HOMESCREEN_FUNC_H + +extern void stm_hsl_start_activity_none(); +extern void stm_hsl_start_activity_homescreen(); +extern void stm_hsl_initialize_variable(); +extern void stm_hsl_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c new file mode 100644 index 0000000..c8ba22f --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c @@ -0,0 +1,65 @@ +/************************************************************/ +/* ZNHL_NearHomeScreen_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_nhl_start_activity_none + */ +void stm_nhl_start_activity_none() { + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE; +} + +/* + * @name stm_nhl_start_activity_software_keyboard + */ +void stm_nhl_start_activity_software_keyboard() { + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoSftKbd; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE; +} + +/* + * @name stm_nhl_event_restriction_mode_off + */ +void stm_nhl_event_restriction_mode_off() { + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = g_prv_near_homescreen_state_rest_mode_1; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE; +} + +/* + * @name stm_nhl_event_restriction_mode_2_on + */ +void stm_nhl_event_restriction_mode_on() { + g_prv_near_homescreen_state_rest_mode_1 = g_stm_prv_state.layer[StmLayerNoNearHomescreen].state; +} + +/* + * @name stm_nhl_initialize_variable + */ +void stm_nhl_initialize_variable() { + g_stm_prv_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoNone; + g_stm_prv_state.layer[StmLayerNoNearHomescreen].changed = STM_FALSE; + + g_stm_crr_state.layer[StmLayerNoNearHomescreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_FALSE; +} + +/* + * @name stm_nhl_start_stm + */ +void stm_nhl_start_stm() { + if (g_stm_event == StmEvtNoUndo) { + // nop + } + else { + g_stm_prv_state.layer[StmLayerNoNearHomescreen].state = g_stm_crr_state.layer[StmLayerNoNearHomescreen].state; + } + g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h new file mode 100644 index 0000000..d2b13f7 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h @@ -0,0 +1,16 @@ +/************************************************************/ +/* ZNHL_NearHomeScreen_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZNHL_NEARHOMESCREEN_FUNC_H +#define ZHEADER_ZNHL_NEARHOMESCREEN_FUNC_H + +extern void stm_nhl_start_activity_none(); +extern void stm_nhl_start_activity_software_keyboard(); +extern void stm_nhl_event_restriction_mode_off(); +extern void stm_nhl_event_restriction_mode_on(); +extern void stm_nhl_initialize_variable(); +extern void stm_nhl_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c new file mode 100644 index 0000000..cc3bbc7 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c @@ -0,0 +1,242 @@ +/************************************************************/ +/* ZNHL_NearHomescreen.c */ +/* NearHomescreen State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREENSTATENOMAX]; + +static void ZNHL_NearHomescreens0e0( void ); +static void ZNHL_NearHomescreens0e3( void ); +static void ZNHL_NearHomescreens1e0( void ); +static void ZNHL_NearHomescreens1e2( void ); +static void ZNHL_NearHomescreens0Event( void ); +static void ZNHL_NearHomescreens1Event( void ); + +/****************************************/ +/* Action function */ +/* STM : NearHomescreen */ +/* State : none( No 0 ) */ +/* Event : ara_software_keyboard( No 0 ) */ +/****************************************/ +static void ZNHL_NearHomescreens0e0( void ) +{ + ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] = ( uint8_t )ZNHL_NEARHOMESCREENS1; + stm_nhl_start_activity_software_keyboard(); +} + +/****************************************/ +/* Action function */ +/* STM : NearHomescreen */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_near_homescreen_none( No 3 ) */ +/****************************************/ +static void ZNHL_NearHomescreens0e3( void ) +{ + stm_nhl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : NearHomescreen */ +/* State : software_keyboard( No 1 ) */ +/* Event : ara_software_keyboard( No 0 ) */ +/****************************************/ +static void ZNHL_NearHomescreens1e0( void ) +{ + stm_nhl_start_activity_software_keyboard(); +} + +/****************************************/ +/* Action function */ +/* STM : NearHomescreen */ +/* State : software_keyboard( No 1 ) */ +/* Event : ctg_software_keyboard( No 2 ) */ +/****************************************/ +static void ZNHL_NearHomescreens1e2( void ) +{ + ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] = ( uint8_t )ZNHL_NEARHOMESCREENS0; + stm_nhl_start_activity_none(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : NearHomescreen */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZNHL_NearHomescreens0Event( void ) +{ + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_software_keyboard*/ + if( g_stm_category == StmCtgNoSoftwareKeyboard ) + { + /*ara_software_keyboard*/ + if( g_stm_area == StmAreaNoSoftwareKyeboard ) + { + ZNHL_NearHomescreens0e0(); + } + else + { + ZNHL_NearHomescreens0e0(); + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_near_homescreen_none*/ + if( g_stm_prv_state.layer[StmLayerNoNearHomescreen].state == StmLayoutNoNone ) + { + ZNHL_NearHomescreens0e3(); + } + /*stt_prv_layer_near_homescreen_sft_kbd*/ + else if( g_stm_prv_state.layer[StmLayerNoNearHomescreen].state == StmLayoutNoSftKbd ) + { + ZNHL_NearHomescreens0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : NearHomescreen */ +/* State : software_keyboard( No 1 ) */ +/****************************************/ +static void ZNHL_NearHomescreens1Event( void ) +{ + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_software_keyboard*/ + if( g_stm_category == StmCtgNoSoftwareKeyboard ) + { + /*ara_software_keyboard*/ + if( g_stm_area == StmAreaNoSoftwareKyeboard ) + { + ZNHL_NearHomescreens1e0(); + } + else + { + ZNHL_NearHomescreens1e0(); + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_software_keyboard*/ + if( g_stm_category == StmCtgNoSoftwareKeyboard ) + { + ZNHL_NearHomescreens1e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_near_homescreen_none*/ + if( g_stm_prv_state.layer[StmLayerNoNearHomescreen].state == StmLayoutNoNone ) + { + ZNHL_NearHomescreens1e2(); + } + /*stt_prv_layer_near_homescreen_sft_kbd*/ + else if( g_stm_prv_state.layer[StmLayerNoNearHomescreen].state == StmLayoutNoSftKbd ) + { + ZNHL_NearHomescreens1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*stt_restriction_mode_1_on*/ + else if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo1On ) + { + ZNHL_NearHomescreens1e2(); + } + /*stt_crr_layer_apps_changed*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].changed == STM_TRUE ) + { + ZNHL_NearHomescreens1e2(); + } + /*stt_crr_layer_hs_changed*/ + else if( g_stm_crr_state.layer[StmLayerNoHomescreen].changed == STM_TRUE ) + { + ZNHL_NearHomescreens1e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event call function */ +/* STM : NearHomescreen */ +/****************************************/ +void stm_nhl_event_call( void ) +{ + stm_nhl_start_stm(); + switch( ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] ) + { + case ZNHL_NEARHOMESCREENS0: + ZNHL_NearHomescreens0Event(); + break; + case ZNHL_NEARHOMESCREENS1: + ZNHL_NearHomescreens1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : NearHomescreen */ +/****************************************/ +void stm_nhl_initialize( void ) +{ + ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] = ( uint8_t )ZNHL_NEARHOMESCREENS0; + stm_nhl_start_activity_none(); +} + +/****************************************/ +/* Terminate function */ +/* STM : NearHomescreen */ +/****************************************/ +void ZNHL_NearHomescreenTerminate( void ) +{ + ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] = ( uint8_t )ZNHL_NEARHOMESCREENTERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h new file mode 100644 index 0000000..f23775e --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h @@ -0,0 +1,53 @@ +/************************************************************/ +/* ZNHL_NearHomescreen.h */ +/* NearHomescreen State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZNHL_NEARHOMESCREEN_H +#define ZHEADER_ZNHL_NEARHOMESCREEN_H + +/*State management variable access define*/ +#define ZNHL_NEARHOMESCREEN ( 0U ) +#define ZNHL_NEARHOMESCREENS0 ( 0U ) +#define ZNHL_NEARHOMESCREENS1 ( 1U ) +#define ZNHL_NEARHOMESCREENSTATENOMAX ( 1U ) + +/*End state define*/ +#define ZNHL_NEARHOMESCREENEND ( 2U ) +/*Terminate state define*/ +#define ZNHL_NEARHOMESCREENTERMINATE ( ZNHL_NEARHOMESCREENEND + 1U ) + +/*State no define*/ +#define ZNHL_NEARHOMESCREENS0STATENO ( 0U ) +#define ZNHL_NEARHOMESCREENS1STATENO ( 1U ) + +/*State serial no define*/ +#define ZNHL_NEARHOMESCREENS0STATESERIALNO ( 0U ) +#define ZNHL_NEARHOMESCREENS1STATESERIALNO ( 1U ) + +/*Event no define*/ +#define ZNHL_NEARHOMESCREENE0EVENTNO ( 0U ) +#define ZNHL_NEARHOMESCREENE1EVENTNO ( 1U ) +#define ZNHL_NEARHOMESCREENE2EVENTNO ( 2U ) +#define ZNHL_NEARHOMESCREENE3EVENTNO ( 3U ) +#define ZNHL_NEARHOMESCREENE4EVENTNO ( 4U ) +#define ZNHL_NEARHOMESCREENE5EVENTNO ( 5U ) +#define ZNHL_NEARHOMESCREENE6EVENTNO ( 6U ) +#define ZNHL_NEARHOMESCREENE7EVENTNO ( 7U ) + +/*Event serial no define*/ +#define ZNHL_NEARHOMESCREENE0EVENTSERIALNO ( 0U ) +#define ZNHL_NEARHOMESCREENE1EVENTSERIALNO ( 1U ) +#define ZNHL_NEARHOMESCREENE2EVENTSERIALNO ( 2U ) +#define ZNHL_NEARHOMESCREENE3EVENTSERIALNO ( 3U ) +#define ZNHL_NEARHOMESCREENE4EVENTSERIALNO ( 4U ) +#define ZNHL_NEARHOMESCREENE5EVENTSERIALNO ( 5U ) +#define ZNHL_NEARHOMESCREENE6EVENTSERIALNO ( 6U ) +#define ZNHL_NEARHOMESCREENE7EVENTSERIALNO ( 7U ) + +/*Extern function*/ +extern void stm_nhl_event_call( void ); +extern void stm_nhl_initialize( void ); +extern void ZNHL_NearHomescreenTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c new file mode 100644 index 0000000..90a6f6f --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c @@ -0,0 +1,72 @@ +/************************************************************/ +/* ZOSL_OnScreen_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_osl_start_activity_none + */ +void stm_osl_start_activity_none() { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; +} + +/* + * @name stm_osl_start_activity_pop_up + */ +void stm_osl_start_activity_pop_up() { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoPopUp; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; +} + +/* + * @name stm_osl_start_activity_system_alert + */ +void stm_osl_start_activity_system_alert() { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoSysAlt; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; +} + +/* + * @name stm_osl_event_restriction_mode_off + */ +void stm_osl_event_restriction_mode_off() { + g_stm_crr_state.layer[StmLayerNoOnScreen].state = g_prv_on_screen_state_rest_mode_1; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE; +} + +/* + * @name stm_osl_event_restriction_mode_2_on + */ +void stm_osl_event_restriction_mode_2_on() { + g_prv_on_screen_state_rest_mode_1 = g_stm_prv_state.layer[StmLayerNoOnScreen].state; +} +/* + * @name stm_osl_initialize_variable + */ +void stm_osl_initialize_variable() { + g_stm_prv_state.layer[StmLayerNoOnScreen].state = StmLayoutNoNone; + g_stm_prv_state.layer[StmLayerNoOnScreen].changed = STM_FALSE; + + g_stm_crr_state.layer[StmLayerNoOnScreen].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_FALSE; +} + +/* + * @name stm_osl_start_stm + */ +void stm_osl_start_stm() { + if (g_stm_event == StmEvtNoUndo) { + // nop + } + else { + g_stm_prv_state.layer[StmLayerNoOnScreen].state = g_stm_crr_state.layer[StmLayerNoOnScreen].state; + } + g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h new file mode 100644 index 0000000..e85accb --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h @@ -0,0 +1,17 @@ +/************************************************************/ +/* ZOSL_OnScreen_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZOSL_ONSCREEN_FUNC_H +#define ZHEADER_ZOSL_ONSCREEN_FUNC_H + +extern void stm_osl_start_activity_none(); +extern void stm_osl_start_activity_pop_up(); +extern void stm_osl_start_activity_system_alert(); +extern void stm_osl_event_restriction_mode_off(); +extern void stm_osl_event_restriction_mode_2_on(); +extern void stm_osl_initialize_variable(); +extern void stm_osl_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c new file mode 100644 index 0000000..53a50e1 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c @@ -0,0 +1,764 @@ +/************************************************************/ +/* ZOSL_OslMain.c */ +/* OslMain State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZOSL_OslMainState[ZOSL_OSLMAINSTATENOMAX]; + +static void ZOSL_OslMains0StateEntry( void ); +static void ZOSL_OslMains1StateEntry( void ); +static void ZOSL_OslMains0e1( void ); +static void ZOSL_OslMains0e2( void ); +static void ZOSL_OslMains1e0( void ); +static void ZOSL_OslRestOffs0e0( void ); +static void ZOSL_OslRestOffs0e1( void ); +static void ZOSL_OslRestOffs0e4( void ); +static void ZOSL_OslRestOffs1e0( void ); +static void ZOSL_OslRestOffs1e2( void ); +static void ZOSL_OslRestOffs2e1( void ); +static void ZOSL_OslRestOns0e0( void ); +static void ZOSL_OslRestOns0e2( void ); +static void ZOSL_OslRestOns1e0( void ); +static void ZOSL_OslRestOns1e1( void ); +static void ZOSL_OslMains0Event( void ); +static void ZOSL_OslRestOffs0Event( void ); +static void ZOSL_OslRestOffs1Event( void ); +static void ZOSL_OslRestOffs2Event( void ); +static void ZOSL_OslMains1Event( void ); +static void ZOSL_OslRestOns0Event( void ); +static void ZOSL_OslRestOns1Event( void ); + +/****************************************/ +/* State start activity function */ +/* STM : OslMain */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZOSL_OslMains0StateEntry( void ) +{ + switch( ZOSL_OslMainState[ZOSL_OSLMAINS0F] ) + { + case ZOSL_OSLRESTOFFS0: + stm_osl_start_activity_none(); + break; + case ZOSL_OSLRESTOFFS1: + stm_osl_start_activity_pop_up(); + break; + case ZOSL_OSLRESTOFFS2: + stm_osl_start_activity_system_alert(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* State start activity function */ +/* STM : OslMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZOSL_OslMains1StateEntry( void ) +{ + switch( ZOSL_OslMainState[ZOSL_OSLMAINS1F] ) + { + case ZOSL_OSLRESTONS0: + stm_osl_start_activity_none(); + break; + case ZOSL_OSLRESTONS1: + stm_osl_start_activity_system_alert(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Action function */ +/* STM : OslMain */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : stt_crr_layer_on_screen_pop( No 1 ) */ +/****************************************/ +static void ZOSL_OslMains0e1( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAIN] = ( uint8_t )ZOSL_OSLMAINS1; + ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS0; + ZOSL_OslMains1StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : OslMain */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : stt_crr_layer_on_screen_sys( No 2 ) */ +/****************************************/ +static void ZOSL_OslMains0e2( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAIN] = ( uint8_t )ZOSL_OSLMAINS1; + ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS1; + ZOSL_OslMains1StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : OslMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/* Event : stt_restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZOSL_OslMains1e0( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAIN] = ( uint8_t )ZOSL_OSLMAINS0; + ZOSL_OslMains0StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : none( No 0 ) */ +/* Event : ara_onscreen( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOffs0e0( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAINS0F] = ( uint8_t )ZOSL_OSLRESTOFFS1; + stm_osl_start_activity_pop_up(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : none( No 0 ) */ +/* Event : ara_onscreen( No 1 ) */ +/****************************************/ +static void ZOSL_OslRestOffs0e1( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAINS0F] = ( uint8_t )ZOSL_OSLRESTOFFS2; + stm_osl_start_activity_system_alert(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_on_screen_none( No 4 ) */ +/****************************************/ +static void ZOSL_OslRestOffs0e4( void ) +{ + stm_osl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : popup( No 1 ) */ +/* Event : ara_onscreen( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOffs1e0( void ) +{ + stm_osl_start_activity_pop_up(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : popup( No 1 ) */ +/* Event : ctg_popup( No 2 ) */ +/****************************************/ +static void ZOSL_OslRestOffs1e2( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAINS0F] = ( uint8_t )ZOSL_OSLRESTOFFS0; + stm_osl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOff */ +/* State : system_alert( No 2 ) */ +/* Event : ara_onscreen( No 1 ) */ +/****************************************/ +static void ZOSL_OslRestOffs2e1( void ) +{ + stm_osl_start_activity_system_alert(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOn */ +/* State : none( No 0 ) */ +/* Event : ara_onscreen( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOns0e0( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS1; + stm_osl_start_activity_system_alert(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOn */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_on_screen_none( No 2 ) */ +/****************************************/ +static void ZOSL_OslRestOns0e2( void ) +{ + stm_osl_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOn */ +/* State : system_alert( No 1 ) */ +/* Event : ara_onscreen( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOns1e0( void ) +{ + stm_osl_start_activity_system_alert(); +} + +/****************************************/ +/* Action function */ +/* STM : OslRestOn */ +/* State : system_alert( No 1 ) */ +/* Event : ctg_systemalert( No 1 ) */ +/****************************************/ +static void ZOSL_OslRestOns1e1( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS0; + stm_osl_start_activity_none(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslMain */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZOSL_OslMains0Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + stm_rel_event_restriction_mode_2_on(); + /*stt_crr_layer_on_screen_pop*/ + if( g_stm_crr_state.layer[StmLayerNoOnScreen].state == StmLayoutNoPopUp ) + { + ZOSL_OslMains0e1(); + } + /*stt_crr_layer_on_screen_sys*/ + else if( g_stm_crr_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslMains0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslRestOff */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOffs0Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_popup*/ + if( g_stm_category == StmCtgNoPopUp ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_systemalert*/ + else if( g_stm_category == StmCtgNoSystemAlert ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_on_screen_none*/ + if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoNone ) + { + ZOSL_OslRestOffs0e4(); + } + /*stt_prv_layer_on_screen_pop_up*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoPopUp ) + { + ZOSL_OslRestOffs0e0(); + } + /*stt_prv_layer_on_screen_sys_alt*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslRestOff */ +/* State : popup( No 1 ) */ +/****************************************/ +static void ZOSL_OslRestOffs1Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_popup*/ + if( g_stm_category == StmCtgNoPopUp ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOffs1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_systemalert*/ + else if( g_stm_category == StmCtgNoSystemAlert ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_popup*/ + if( g_stm_category == StmCtgNoPopUp ) + { + ZOSL_OslRestOffs1e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_on_screen_none*/ + if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoNone ) + { + ZOSL_OslRestOffs1e2(); + } + /*stt_prv_layer_on_screen_pop_up*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoPopUp ) + { + ZOSL_OslRestOffs1e0(); + } + /*stt_prv_layer_on_screen_sys_alt*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslRestOff */ +/* State : system_alert( No 2 ) */ +/****************************************/ +static void ZOSL_OslRestOffs2Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_systemalert*/ + if( g_stm_category == StmCtgNoSystemAlert ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOffs2e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_systemalert*/ + if( g_stm_category == StmCtgNoSystemAlert ) + { + ZOSL_OslRestOffs1e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_on_screen_none*/ + if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoNone ) + { + ZOSL_OslRestOffs1e2(); + } + /*stt_prv_layer_on_screen_pop_up*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoPopUp ) + { + ZOSL_OslRestOffs0e0(); + } + /*stt_prv_layer_on_screen_sys_alt*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslRestOffs2e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZOSL_OslMains1Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + stm_rel_event_restriction_mode_off(); + ZOSL_OslMains1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslRestOn */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZOSL_OslRestOns0Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_systemalert*/ + if( g_stm_category == StmCtgNoSystemAlert ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOns0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_on_screen_none*/ + if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoNone ) + { + ZOSL_OslRestOns0e2(); + } + /*stt_prv_layer_on_screen_sys_alt*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslRestOns0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : OslRestOn */ +/* State : system_alert( No 1 ) */ +/****************************************/ +static void ZOSL_OslRestOns1Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + /*evt_activate*/ + if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_systemalert*/ + if( g_stm_category == StmCtgNoSystemAlert ) + { + /*ara_onscreen*/ + if( g_stm_area == StmAreaNoOnScreen ) + { + ZOSL_OslRestOns1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_systemalert*/ + if( g_stm_category == StmCtgNoSystemAlert ) + { + ZOSL_OslRestOns1e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_on_screen_none*/ + if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoNone ) + { + ZOSL_OslRestOns1e1(); + } + /*stt_prv_layer_on_screen_sys_alt*/ + else if( g_stm_prv_state.layer[StmLayerNoOnScreen].state == StmLayoutNoSysAlt ) + { + ZOSL_OslRestOns1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event call function */ +/* STM : OslMain */ +/****************************************/ +void stm_osl_event_call( void ) +{ + stm_osl_start_stm(); + switch( ZOSL_OslMainState[ZOSL_OSLMAIN] ) + { + case ZOSL_OSLMAINS0: + switch( ZOSL_OslMainState[ZOSL_OSLMAINS0F] ) + { + case ZOSL_OSLRESTOFFS0: + ZOSL_OslRestOffs0Event(); + break; + case ZOSL_OSLRESTOFFS1: + ZOSL_OslRestOffs1Event(); + break; + case ZOSL_OSLRESTOFFS2: + ZOSL_OslRestOffs2Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZOSL_OslMains0Event(); + break; + case ZOSL_OSLMAINS1: + switch( ZOSL_OslMainState[ZOSL_OSLMAINS1F] ) + { + case ZOSL_OSLRESTONS0: + ZOSL_OslRestOns0Event(); + break; + case ZOSL_OSLRESTONS1: + ZOSL_OslRestOns1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZOSL_OslMains1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : OslMain */ +/****************************************/ +void stm_osl_initialize( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAIN] = ( uint8_t )ZOSL_OSLMAINS0; + ZOSL_OslMainState[ZOSL_OSLMAINS0F] = ( uint8_t )ZOSL_OSLRESTOFFS0; + ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS0; + ZOSL_OslMains0StateEntry(); +} + +/****************************************/ +/* Terminate function */ +/* STM : OslMain */ +/****************************************/ +void ZOSL_OslMainTerminate( void ) +{ + ZOSL_OslMainState[ZOSL_OSLMAIN] = ( uint8_t )ZOSL_OSLMAINTERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h new file mode 100644 index 0000000..ee45304 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h @@ -0,0 +1,82 @@ +/************************************************************/ +/* ZOSL_OslMain.h */ +/* OslMain State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZOSL_OSLMAIN_H +#define ZHEADER_ZOSL_OSLMAIN_H + +/*State management variable access define*/ +#define ZOSL_OSLMAIN ( 0U ) +#define ZOSL_OSLMAINS0F ( 1U ) +#define ZOSL_OSLMAINS1F ( 2U ) +#define ZOSL_OSLMAINS0 ( 0U ) +#define ZOSL_OSLRESTOFFS0 ( 0U ) +#define ZOSL_OSLRESTOFFS1 ( 1U ) +#define ZOSL_OSLRESTOFFS2 ( 2U ) +#define ZOSL_OSLMAINS1 ( 1U ) +#define ZOSL_OSLRESTONS0 ( 0U ) +#define ZOSL_OSLRESTONS1 ( 1U ) +#define ZOSL_OSLMAINSTATENOMAX ( 3U ) + +/*End state define*/ +#define ZOSL_OSLMAINEND ( 3U ) +/*Terminate state define*/ +#define ZOSL_OSLMAINTERMINATE ( ZOSL_OSLMAINEND + 1U ) + +/*State no define*/ +#define ZOSL_OSLMAINS0STATENO ( 0U ) +#define ZOSL_OSLRESTOFFS0STATENO ( 0U ) +#define ZOSL_OSLRESTOFFS1STATENO ( 1U ) +#define ZOSL_OSLRESTOFFS2STATENO ( 2U ) +#define ZOSL_OSLMAINS1STATENO ( 1U ) +#define ZOSL_OSLRESTONS0STATENO ( 0U ) +#define ZOSL_OSLRESTONS1STATENO ( 1U ) + +/*State serial no define*/ +#define ZOSL_OSLMAINS0STATESERIALNO ( 0U ) +#define ZOSL_OSLRESTOFFS0STATESERIALNO ( 1U ) +#define ZOSL_OSLRESTOFFS1STATESERIALNO ( 2U ) +#define ZOSL_OSLRESTOFFS2STATESERIALNO ( 3U ) +#define ZOSL_OSLMAINS1STATESERIALNO ( 4U ) +#define ZOSL_OSLRESTONS0STATESERIALNO ( 5U ) +#define ZOSL_OSLRESTONS1STATESERIALNO ( 6U ) + +/*Event no define*/ +#define ZOSL_OSLMAINE0EVENTNO ( 0U ) +#define ZOSL_OSLMAINE1EVENTNO ( 1U ) +#define ZOSL_OSLMAINE2EVENTNO ( 2U ) +#define ZOSL_OSLRESTOFFE0EVENTNO ( 0U ) +#define ZOSL_OSLRESTOFFE1EVENTNO ( 1U ) +#define ZOSL_OSLRESTOFFE2EVENTNO ( 2U ) +#define ZOSL_OSLRESTOFFE3EVENTNO ( 3U ) +#define ZOSL_OSLRESTOFFE4EVENTNO ( 4U ) +#define ZOSL_OSLRESTOFFE5EVENTNO ( 5U ) +#define ZOSL_OSLRESTOFFE6EVENTNO ( 6U ) +#define ZOSL_OSLRESTONE0EVENTNO ( 0U ) +#define ZOSL_OSLRESTONE1EVENTNO ( 1U ) +#define ZOSL_OSLRESTONE2EVENTNO ( 2U ) +#define ZOSL_OSLRESTONE3EVENTNO ( 3U ) + +/*Event serial no define*/ +#define ZOSL_OSLMAINE0EVENTSERIALNO ( 0U ) +#define ZOSL_OSLMAINE1EVENTSERIALNO ( 1U ) +#define ZOSL_OSLMAINE2EVENTSERIALNO ( 2U ) +#define ZOSL_OSLRESTOFFE0EVENTNO ( 0U ) +#define ZOSL_OSLRESTOFFE1EVENTNO ( 1U ) +#define ZOSL_OSLRESTOFFE2EVENTNO ( 2U ) +#define ZOSL_OSLRESTOFFE3EVENTNO ( 3U ) +#define ZOSL_OSLRESTOFFE4EVENTNO ( 4U ) +#define ZOSL_OSLRESTOFFE5EVENTNO ( 5U ) +#define ZOSL_OSLRESTOFFE6EVENTNO ( 6U ) +#define ZOSL_OSLRESTONE0EVENTNO ( 0U ) +#define ZOSL_OSLRESTONE1EVENTNO ( 1U ) +#define ZOSL_OSLRESTONE2EVENTNO ( 2U ) +#define ZOSL_OSLRESTONE3EVENTNO ( 3U ) + +/*Extern function*/ +extern void stm_osl_event_call( void ); +extern void stm_osl_initialize( void ); +extern void ZOSL_OslMainTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c new file mode 100644 index 0000000..6d07643 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c @@ -0,0 +1,976 @@ +/************************************************************/ +/* ZREL_RelMain.c */ +/* RelMain State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZREL_RelMainState[ZREL_RELMAINSTATENOMAX]; + +static void ZREL_RelMains0StateEntry( void ); +static void ZREL_RelMains1StateEntry( void ); +static void ZREL_RelMains0e1( void ); +static void ZREL_RelMains1e0( void ); +static void ZREL_RelRestOffs0e0( void ); +static void ZREL_RelRestOffs0e1( void ); +static void ZREL_RelRestOffs0e8( void ); +static void ZREL_RelRestOffs0e13( void ); +static void ZREL_RelRestOffs1e1( void ); +static void ZREL_RelRestOffs1e4( void ); +static void ZREL_RelRestOffs2e15( void ); +static void ZREL_RelRestOffs3e0( void ); +static void ZREL_RelMains0Event( void ); +static void ZREL_RelRestOffs0Event( void ); +static void ZREL_RelRestOffs1Event( void ); +static void ZREL_RelRestOffs2Event( void ); +static void ZREL_RelRestOffs3Event( void ); +static void ZREL_RelMains1Event( void ); +static void ZREL_RelRestOns0Event( void ); + +/****************************************/ +/* State start activity function */ +/* STM : RelMain */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZREL_RelMains0StateEntry( void ) +{ + switch( ZREL_RelMainState[ZREL_RELMAINS0F] ) + { + case ZREL_RELRESTOFFS0: + stm_rel_start_activity_none(); + break; + case ZREL_RELRESTOFFS1: + stm_rel_start_activity_restriction_normal(); + break; + case ZREL_RELRESTOFFS2: + stm_rel_start_activity_restriction_split_main(); + break; + case ZREL_RELRESTOFFS3: + stm_rel_start_activity_restriction_split_sub(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* State start activity function */ +/* STM : RelMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZREL_RelMains1StateEntry( void ) +{ + switch( ZREL_RelMainState[ZREL_RELMAINS1F] ) + { + case ZREL_RELRESTONS0: + stm_rel_start_activity_none(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Action function */ +/* STM : RelMain */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : stt_restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZREL_RelMains0e1( void ) +{ + ZREL_RelMainState[ZREL_RELMAIN] = ( uint8_t )ZREL_RELMAINS1; + ZREL_RelMainState[ZREL_RELMAINS1F] = ( uint8_t )ZREL_RELRESTONS0; + ZREL_RelMains1StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : RelMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/* Event : stt_restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZREL_RelMains1e0( void ) +{ + ZREL_RelMainState[ZREL_RELMAIN] = ( uint8_t )ZREL_RELMAINS0; + ZREL_RelMains0StateEntry(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : none( No 0 ) */ +/* Event : stt_crr_layer_apps_map_spl( No 0 ) */ +/****************************************/ +static void ZREL_RelRestOffs0e0( void ) +{ + ZREL_RelMainState[ZREL_RELMAINS0F] = ( uint8_t )ZREL_RELRESTOFFS3; + stm_rel_start_activity_restriction_split_sub(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : none( No 0 ) */ +/* Event : stt_crr_layer_apps_spl_nml( No 1 ) */ +/****************************************/ +static void ZREL_RelRestOffs0e1( void ) +{ + ZREL_RelMainState[ZREL_RELMAINS0F] = ( uint8_t )ZREL_RELRESTOFFS1; + stm_rel_start_activity_restriction_normal(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : none( No 0 ) */ +/* Event : ara_restriction_split_main( No 8 ) */ +/****************************************/ +static void ZREL_RelRestOffs0e8( void ) +{ + ZREL_RelMainState[ZREL_RELMAINS0F] = ( uint8_t )ZREL_RELRESTOFFS2; + stm_rel_start_activity_restriction_split_main(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : none( No 0 ) */ +/* Event : stt_prv_layer_rst_none( No 13 ) */ +/****************************************/ +static void ZREL_RelRestOffs0e13( void ) +{ + stm_rel_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : restriction_normal( No 1 ) */ +/* Event : stt_crr_layer_apps_spl_nml( No 1 ) */ +/****************************************/ +static void ZREL_RelRestOffs1e1( void ) +{ + stm_rel_start_activity_restriction_normal(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : restriction_normal( No 1 ) */ +/* Event : ELSE( No 4 ) */ +/****************************************/ +static void ZREL_RelRestOffs1e4( void ) +{ + ZREL_RelMainState[ZREL_RELMAINS0F] = ( uint8_t )ZREL_RELRESTOFFS0; + stm_rel_start_activity_none(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : restriction_split_main( No 2 ) */ +/* Event : stt_prv_layer_rst_rst_spl_main( No 15 ) */ +/****************************************/ +static void ZREL_RelRestOffs2e15( void ) +{ + stm_rel_start_activity_restriction_split_main(); +} + +/****************************************/ +/* Action function */ +/* STM : RelRestOff */ +/* State : restriction_split_sub( No 3 ) */ +/* Event : stt_crr_layer_apps_map_spl( No 0 ) */ +/****************************************/ +static void ZREL_RelRestOffs3e0( void ) +{ + stm_rel_start_activity_restriction_split_sub(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelMain */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZREL_RelMains0Event( void ) +{ + /*stt_restriction_mode_2_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo2On ) + { + stm_rel_event_restriction_mode_2_on(); + ZREL_RelMains0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelRestOff */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZREL_RelRestOffs0Event( void ) +{ + /*stt_restriction_mode_1_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo1On ) + { + /*stt_crr_layer_apps_changed*/ + if( g_stm_crr_state.layer[StmLayerNoApps].changed == STM_TRUE ) + { + /*stt_crr_layer_apps_map_spl*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + /*stt_crr_layer_apps_spl_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_spl_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_gen_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZREL_RelRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_activate*/ + else if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + /*ara_restriction_normal*/ + if( g_stm_area == StmAreaNoRestrictionNormal ) + { + /*stt_crr_layer_apps_spl_nml*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_map_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ara_restriction_split_main*/ + else if( g_stm_area == StmAreaNoRestrictionSplitMain ) + { + ZREL_RelRestOffs0e8(); + } + /*ara_restriction_split_sub*/ + else if( g_stm_area == StmAreaNoRestrictionSplitSub ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*stt_restriction_mode_off*/ + else if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*evt_undo*/ + if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_rst_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoNone ) + { + ZREL_RelRestOffs0e13(); + } + /*stt_prv_layer_rst_rst_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_prv_layer_rst_rst_spl_main*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplMain ) + { + ZREL_RelRestOffs0e8(); + } + /*stt_prv_layer_rst_rst_spl_sub*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplSub ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelRestOff */ +/* State : restriction_normal( No 1 ) */ +/****************************************/ +static void ZREL_RelRestOffs1Event( void ) +{ + /*stt_restriction_mode_1_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo1On ) + { + /*stt_crr_layer_apps_changed*/ + if( g_stm_crr_state.layer[StmLayerNoApps].changed == STM_TRUE ) + { + /*stt_crr_layer_apps_map_spl*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + /*stt_crr_layer_apps_spl_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs1e1(); + } + /*stt_crr_layer_apps_spl_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZREL_RelRestOffs1e1(); + } + /*stt_crr_layer_apps_gen_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZREL_RelRestOffs1e1(); + } + else + { + ZREL_RelRestOffs1e4(); + } + } + /*stt_crr_layer_hs_changed*/ + else if( g_stm_crr_state.layer[StmLayerNoHomescreen].changed == STM_TRUE ) + { + /*stt_crr_layer_hs_hms*/ + if( g_stm_crr_state.layer[StmLayerNoHomescreen].state == StmLayoutNoHms ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_activate*/ + else if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + /*ara_restriction_normal*/ + if( g_stm_area == StmAreaNoRestrictionNormal ) + { + /*stt_crr_layer_apps_map_spl*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ara_restriction_split_main*/ + else if( g_stm_area == StmAreaNoRestrictionSplitMain ) + { + ZREL_RelRestOffs0e8(); + } + /*ara_restriction_split_sub*/ + else if( g_stm_area == StmAreaNoRestrictionSplitSub ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*stt_restriction_mode_off*/ + else if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*stt_prv_layer_rst_not_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_rst_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*stt_prv_layer_rst_rst_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstNml ) + { + ZREL_RelRestOffs1e1(); + } + /*stt_prv_layer_rst_rst_spl_main*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplMain ) + { + ZREL_RelRestOffs0e8(); + } + /*stt_prv_layer_rst_rst_spl_sub*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplSub ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelRestOff */ +/* State : restriction_split_main( No 2 ) */ +/****************************************/ +static void ZREL_RelRestOffs2Event( void ) +{ + /*stt_restriction_mode_1_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo1On ) + { + /*stt_crr_layer_apps_changed*/ + if( g_stm_crr_state.layer[StmLayerNoApps].changed == STM_TRUE ) + { + /*stt_crr_layer_apps_map_spl*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + /*stt_crr_layer_apps_spl_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_spl_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_gen_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZREL_RelRestOffs0e1(); + } + else + { + ZREL_RelRestOffs1e4(); + } + } + /*stt_crr_layer_hs_changed*/ + else if( g_stm_crr_state.layer[StmLayerNoHomescreen].changed == STM_TRUE ) + { + /*stt_crr_layer_hs_hms*/ + if( g_stm_crr_state.layer[StmLayerNoHomescreen].state == StmLayoutNoHms ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_activate*/ + else if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + /*ara_restriction_normal*/ + if( g_stm_area == StmAreaNoRestrictionNormal ) + { + /*stt_crr_layer_apps_spl_nml*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_map_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ara_restriction_split_sub*/ + else if( g_stm_area == StmAreaNoRestrictionSplitSub ) + { + ZREL_RelRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*stt_restriction_mode_off*/ + else if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*stt_prv_layer_rst_not_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_rst_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*stt_prv_layer_rst_rst_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_prv_layer_rst_rst_spl_main*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplMain ) + { + ZREL_RelRestOffs2e15(); + } + /*stt_prv_layer_rst_rst_spl_sub*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplSub ) + { + ZREL_RelRestOffs0e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelRestOff */ +/* State : restriction_split_sub( No 3 ) */ +/****************************************/ +static void ZREL_RelRestOffs3Event( void ) +{ + /*stt_restriction_mode_1_on*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNo1On ) + { + /*stt_crr_layer_apps_changed*/ + if( g_stm_crr_state.layer[StmLayerNoApps].changed == STM_TRUE ) + { + /*stt_crr_layer_apps_map_spl*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoMapSpl ) + { + ZREL_RelRestOffs3e0(); + } + /*stt_crr_layer_apps_spl_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_spl_spl*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_crr_layer_apps_gen_nml*/ + else if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml ) + { + ZREL_RelRestOffs0e1(); + } + else + { + ZREL_RelRestOffs1e4(); + } + } + /*stt_crr_layer_hs_changed*/ + else if( g_stm_crr_state.layer[StmLayerNoHomescreen].changed == STM_TRUE ) + { + /*stt_crr_layer_hs_hms*/ + if( g_stm_crr_state.layer[StmLayerNoHomescreen].state == StmLayoutNoHms ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_activate*/ + else if( g_stm_event == StmEvtNoActivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + /*ara_restriction_normal*/ + if( g_stm_area == StmAreaNoRestrictionNormal ) + { + /*stt_crr_layer_apps_spl_nml*/ + if( g_stm_crr_state.layer[StmLayerNoApps].state == StmLayoutNoSplNml ) + { + ZREL_RelRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ara_restriction_split_main*/ + else if( g_stm_area == StmAreaNoRestrictionSplitMain ) + { + ZREL_RelRestOffs0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*ctg_homescreen*/ + else if( g_stm_category == StmCtgNoHomescreen ) + { + /*ara_fullscreen*/ + if( g_stm_area == StmAreaNoFullscreen ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*evt_deactivate*/ + else if( g_stm_event == StmEvtNoDeactivate ) + { + /*ctg_restriction*/ + if( g_stm_category == StmCtgNoRestriction ) + { + ZREL_RelRestOffs1e4(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + /*stt_restriction_mode_off*/ + else if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + /*stt_prv_layer_rst_not_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*evt_undo*/ + else if( g_stm_event == StmEvtNoUndo ) + { + /*stt_prv_layer_rst_none*/ + if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoNone ) + { + ZREL_RelRestOffs1e4(); + } + /*stt_prv_layer_rst_rst_nml*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstNml ) + { + ZREL_RelRestOffs0e1(); + } + /*stt_prv_layer_rst_rst_spl_main*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplMain ) + { + ZREL_RelRestOffs0e8(); + } + /*stt_prv_layer_rst_rst_spl_sub*/ + else if( g_stm_prv_state.layer[StmLayerNoRestriction].state == StmLayoutNoRstSplSub ) + { + ZREL_RelRestOffs3e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelMain */ +/* State : restriction_mode_2_on( No 1 ) */ +/****************************************/ +static void ZREL_RelMains1Event( void ) +{ + /*stt_restriction_mode_off*/ + if( g_stm_crr_state.mode[StmModeNoRestrictionMode].state == StmRestrictionModeSttNoOff ) + { + stm_rel_event_restriction_mode_off(); + ZREL_RelMains1e0(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RelRestOn */ +/* State : none( No 0 ) */ +/****************************************/ +static void ZREL_RelRestOns0Event( void ) +{ +} + +/****************************************/ +/* Event call function */ +/* STM : RelMain */ +/****************************************/ +void stm_rel_event_call( void ) +{ + stm_rel_start_stm(); + switch( ZREL_RelMainState[ZREL_RELMAIN] ) + { + case ZREL_RELMAINS0: + switch( ZREL_RelMainState[ZREL_RELMAINS0F] ) + { + case ZREL_RELRESTOFFS0: + ZREL_RelRestOffs0Event(); + break; + case ZREL_RELRESTOFFS1: + ZREL_RelRestOffs1Event(); + break; + case ZREL_RELRESTOFFS2: + ZREL_RelRestOffs2Event(); + break; + case ZREL_RELRESTOFFS3: + ZREL_RelRestOffs3Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZREL_RelMains0Event(); + break; + case ZREL_RELMAINS1: + switch( ZREL_RelMainState[ZREL_RELMAINS1F] ) + { + case ZREL_RELRESTONS0: + ZREL_RelRestOns0Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } + ZREL_RelMains1Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : RelMain */ +/****************************************/ +void stm_rel_initialize( void ) +{ + ZREL_RelMainState[ZREL_RELMAIN] = ( uint8_t )ZREL_RELMAINS0; + ZREL_RelMainState[ZREL_RELMAINS0F] = ( uint8_t )ZREL_RELRESTOFFS0; + ZREL_RelMainState[ZREL_RELMAINS1F] = ( uint8_t )ZREL_RELRESTONS0; + ZREL_RelMains0StateEntry(); +} + +/****************************************/ +/* Terminate function */ +/* STM : RelMain */ +/****************************************/ +void ZREL_RelMainTerminate( void ) +{ + ZREL_RelMainState[ZREL_RELMAIN] = ( uint8_t )ZREL_RELMAINTERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h new file mode 100644 index 0000000..ce82e7a --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h @@ -0,0 +1,94 @@ +/************************************************************/ +/* ZREL_RelMain.h */ +/* RelMain State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZREL_RELMAIN_H +#define ZHEADER_ZREL_RELMAIN_H + +/*State management variable access define*/ +#define ZREL_RELMAIN ( 0U ) +#define ZREL_RELMAINS0F ( 1U ) +#define ZREL_RELMAINS1F ( 2U ) +#define ZREL_RELMAINS0 ( 0U ) +#define ZREL_RELRESTOFFS0 ( 0U ) +#define ZREL_RELRESTOFFS1 ( 1U ) +#define ZREL_RELRESTOFFS2 ( 2U ) +#define ZREL_RELRESTOFFS3 ( 3U ) +#define ZREL_RELMAINS1 ( 1U ) +#define ZREL_RELRESTONS0 ( 0U ) +#define ZREL_RELMAINSTATENOMAX ( 3U ) + +/*End state define*/ +#define ZREL_RELMAINEND ( 4U ) +/*Terminate state define*/ +#define ZREL_RELMAINTERMINATE ( ZREL_RELMAINEND + 1U ) + +/*State no define*/ +#define ZREL_RELMAINS0STATENO ( 0U ) +#define ZREL_RELRESTOFFS0STATENO ( 0U ) +#define ZREL_RELRESTOFFS1STATENO ( 1U ) +#define ZREL_RELRESTOFFS2STATENO ( 2U ) +#define ZREL_RELRESTOFFS3STATENO ( 3U ) +#define ZREL_RELMAINS1STATENO ( 1U ) +#define ZREL_RELRESTONS0STATENO ( 0U ) + +/*State serial no define*/ +#define ZREL_RELMAINS0STATESERIALNO ( 0U ) +#define ZREL_RELRESTOFFS0STATESERIALNO ( 1U ) +#define ZREL_RELRESTOFFS1STATESERIALNO ( 2U ) +#define ZREL_RELRESTOFFS2STATESERIALNO ( 3U ) +#define ZREL_RELRESTOFFS3STATESERIALNO ( 4U ) +#define ZREL_RELMAINS1STATESERIALNO ( 5U ) +#define ZREL_RELRESTONS0STATESERIALNO ( 6U ) + +/*Event no define*/ +#define ZREL_RELMAINE0EVENTNO ( 0U ) +#define ZREL_RELMAINE1EVENTNO ( 1U ) +#define ZREL_RELRESTOFFE0EVENTNO ( 0U ) +#define ZREL_RELRESTOFFE1EVENTNO ( 1U ) +#define ZREL_RELRESTOFFE2EVENTNO ( 2U ) +#define ZREL_RELRESTOFFE3EVENTNO ( 3U ) +#define ZREL_RELRESTOFFE4EVENTNO ( 4U ) +#define ZREL_RELRESTOFFE5EVENTNO ( 5U ) +#define ZREL_RELRESTOFFE6EVENTNO ( 6U ) +#define ZREL_RELRESTOFFE7EVENTNO ( 7U ) +#define ZREL_RELRESTOFFE8EVENTNO ( 8U ) +#define ZREL_RELRESTOFFE9EVENTNO ( 9U ) +#define ZREL_RELRESTOFFE10EVENTNO ( 10U ) +#define ZREL_RELRESTOFFE11EVENTNO ( 11U ) +#define ZREL_RELRESTOFFE12EVENTNO ( 12U ) +#define ZREL_RELRESTOFFE13EVENTNO ( 13U ) +#define ZREL_RELRESTOFFE14EVENTNO ( 14U ) +#define ZREL_RELRESTOFFE15EVENTNO ( 15U ) +#define ZREL_RELRESTOFFE16EVENTNO ( 16U ) +#define ZREL_RELRESTONE0EVENTNO ( 0U ) + +/*Event serial no define*/ +#define ZREL_RELMAINE0EVENTSERIALNO ( 0U ) +#define ZREL_RELMAINE1EVENTSERIALNO ( 1U ) +#define ZREL_RELRESTOFFE0EVENTNO ( 0U ) +#define ZREL_RELRESTOFFE1EVENTNO ( 1U ) +#define ZREL_RELRESTOFFE2EVENTNO ( 2U ) +#define ZREL_RELRESTOFFE3EVENTNO ( 3U ) +#define ZREL_RELRESTOFFE4EVENTNO ( 4U ) +#define ZREL_RELRESTOFFE5EVENTNO ( 5U ) +#define ZREL_RELRESTOFFE6EVENTNO ( 6U ) +#define ZREL_RELRESTOFFE7EVENTNO ( 7U ) +#define ZREL_RELRESTOFFE8EVENTNO ( 8U ) +#define ZREL_RELRESTOFFE9EVENTNO ( 9U ) +#define ZREL_RELRESTOFFE10EVENTNO ( 10U ) +#define ZREL_RELRESTOFFE11EVENTNO ( 11U ) +#define ZREL_RELRESTOFFE12EVENTNO ( 12U ) +#define ZREL_RELRESTOFFE13EVENTNO ( 13U ) +#define ZREL_RELRESTOFFE14EVENTNO ( 14U ) +#define ZREL_RELRESTOFFE15EVENTNO ( 15U ) +#define ZREL_RELRESTOFFE16EVENTNO ( 16U ) +#define ZREL_RELRESTONE0EVENTNO ( 0U ) + +/*Extern function*/ +extern void stm_rel_event_call( void ); +extern void stm_rel_initialize( void ); +extern void ZREL_RelMainTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c new file mode 100644 index 0000000..5195f98 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c @@ -0,0 +1,81 @@ +/************************************************************/ +/* ZREL_Restriction_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_rel_start_activity_none + */ +void stm_rel_start_activity_none() { + g_stm_crr_state.layer[StmLayerNoRestriction].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE; +} + +/* + * @name stm_rel_start_activity_restriction_normal + */ +void stm_rel_start_activity_restriction_normal() { + g_stm_crr_state.layer[StmLayerNoRestriction].state = StmLayoutNoRstNml; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE; +} + +/* + * @name stm_rel_start_activity_restriction_split_main + */ +void stm_rel_start_activity_restriction_split_main() { + g_stm_crr_state.layer[StmLayerNoRestriction].state = StmLayoutNoRstSplMain; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE; +} + +/* + * @name stm_rel_start_activity_restriction_split_sub + */ +void stm_rel_start_activity_restriction_split_sub() { + g_stm_crr_state.layer[StmLayerNoRestriction].state = StmLayoutNoRstSplSub; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE; +} + +/* + * @name stm_rel_event_restriction_mode_off + */ +void stm_rel_event_restriction_mode_off() { + g_stm_crr_state.layer[StmLayerNoRestriction].state = g_prv_restriction_state_rest_mode_1; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE; +} + +/* + * @name stm_rel_event_restriction_mode_2_on + */ +void stm_rel_event_restriction_mode_2_on() { + g_prv_restriction_state_rest_mode_1 = g_stm_prv_state.layer[StmLayerNoRestriction].state; +} + +/* + * @name stm_rel_initialize_variable + */ +void stm_rel_initialize_variable() { + g_stm_prv_state.layer[StmLayerNoRestriction].state = StmLayoutNoNone; + g_stm_prv_state.layer[StmLayerNoRestriction].changed = STM_FALSE; + + g_stm_crr_state.layer[StmLayerNoRestriction].state = StmLayoutNoNone; + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_FALSE; +} + +/* + * @name stm_rel_start_stm + */ +void stm_rel_start_stm() { + if (g_stm_event == StmEvtNoUndo) { + // nop + } + else { + g_stm_prv_state.layer[StmLayerNoRestriction].state = g_stm_crr_state.layer[StmLayerNoRestriction].state; + } + g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h new file mode 100644 index 0000000..5cd9b7d --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h @@ -0,0 +1,18 @@ +/************************************************************/ +/* ZREL_Restriction_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZREL_RESTRICTION_FUNC_H +#define ZHEADER_ZREL_RESTRICTION_FUNC_H + +extern void stm_rel_start_activity_none(); +extern void stm_rel_start_activity_restriction_normal(); +extern void stm_rel_start_activity_restriction_split_main(); +extern void stm_rel_start_activity_restriction_split_sub(); +extern void stm_rel_event_restriction_mode_off(); +extern void stm_rel_event_restriction_mode_2_on(); +extern void stm_rel_initialize_variable(); +extern void stm_rel_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c new file mode 100644 index 0000000..7fe5700 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c @@ -0,0 +1,168 @@ +/************************************************************/ +/* ZREM_RestrictionMode.c */ +/* RestrictionMode State transition model source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/* State management variable */ +static uint8_t ZREM_RestrictionModeState[ZREM_RESTRICTIONMODESTATENOMAX]; + +static void ZREM_RestrictionModes0e1( void ); +static void ZREM_RestrictionModes0e2( void ); +static void ZREM_RestrictionModes1e0( void ); +static void ZREM_RestrictionModes0Event( void ); +static void ZREM_RestrictionModes1Event( void ); +static void ZREM_RestrictionModes2Event( void ); + +/****************************************/ +/* Action function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : evt_restriction_mode_1_on( No 1 ) */ +/****************************************/ +static void ZREM_RestrictionModes0e1( void ) +{ + ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES1; + stm_rem_start_activity_restriction_mode_1_on(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_off( No 0 ) */ +/* Event : evt_restriction_mode_2_on( No 2 ) */ +/****************************************/ +static void ZREM_RestrictionModes0e2( void ) +{ + ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES2; + stm_rem_start_activity_restriction_mode_2_on(); +} + +/****************************************/ +/* Action function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_1_on( No 1 ) */ +/* Event : evt_restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZREM_RestrictionModes1e0( void ) +{ + ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES0; + stm_rem_start_activity_restriction_mode_off(); +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_off( No 0 ) */ +/****************************************/ +static void ZREM_RestrictionModes0Event( void ) +{ + /*evt_restriction_mode_1_on*/ + if( g_stm_event == StmEvtNoRestrictionMode1On ) + { + ZREM_RestrictionModes0e1(); + } + /*evt_restriction_mode_2_on*/ + else if( g_stm_event == StmEvtNoRestrictionMode2On ) + { + ZREM_RestrictionModes0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_1_on( No 1 ) */ +/****************************************/ +static void ZREM_RestrictionModes1Event( void ) +{ + /*evt_restriction_mode_off*/ + if( g_stm_event == StmEvtNoRestrictionModeOff ) + { + ZREM_RestrictionModes1e0(); + } + /*evt_restriction_mode_2_on*/ + else if( g_stm_event == StmEvtNoRestrictionMode2On ) + { + ZREM_RestrictionModes0e2(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event appraisal function */ +/* STM : RestrictionMode */ +/* State : restriction_mode_2_on( No 2 ) */ +/****************************************/ +static void ZREM_RestrictionModes2Event( void ) +{ + /*evt_restriction_mode_off*/ + if( g_stm_event == StmEvtNoRestrictionModeOff ) + { + ZREM_RestrictionModes1e0(); + } + /*evt_restriction_mode_1_on*/ + else if( g_stm_event == StmEvtNoRestrictionMode1On ) + { + ZREM_RestrictionModes0e1(); + } + else + { + /*Else and default design have not done.*/ + /*Please confirm the STM and design else and default.*/ + } +} + +/****************************************/ +/* Event call function */ +/* STM : RestrictionMode */ +/****************************************/ +void stm_rem_event_call( void ) +{ + stm_rem_start_stm(); + switch( ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] ) + { + case ZREM_RESTRICTIONMODES0: + ZREM_RestrictionModes0Event(); + break; + case ZREM_RESTRICTIONMODES1: + ZREM_RestrictionModes1Event(); + break; + case ZREM_RESTRICTIONMODES2: + ZREM_RestrictionModes2Event(); + break; + default: + /*Not accessible to this else (default).*/ + break; + } +} + +/****************************************/ +/* Initial function */ +/* STM : RestrictionMode */ +/****************************************/ +void stm_rem_initialize( void ) +{ + ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES0; + stm_rem_start_activity_restriction_mode_off(); +} + +/****************************************/ +/* Terminate function */ +/* STM : RestrictionMode */ +/****************************************/ +void ZREM_RestrictionModeTerminate( void ) +{ + ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODETERMINATE; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h new file mode 100644 index 0000000..f2c2026 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h @@ -0,0 +1,46 @@ +/************************************************************/ +/* ZREM_RestrictionMode.h */ +/* RestrictionMode State transition model header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZREM_RESTRICTIONMODE_H +#define ZHEADER_ZREM_RESTRICTIONMODE_H + +/*State management variable access define*/ +#define ZREM_RESTRICTIONMODE ( 0U ) +#define ZREM_RESTRICTIONMODES0 ( 0U ) +#define ZREM_RESTRICTIONMODES1 ( 1U ) +#define ZREM_RESTRICTIONMODES2 ( 2U ) +#define ZREM_RESTRICTIONMODESTATENOMAX ( 1U ) + +/*End state define*/ +#define ZREM_RESTRICTIONMODEEND ( 3U ) +/*Terminate state define*/ +#define ZREM_RESTRICTIONMODETERMINATE ( ZREM_RESTRICTIONMODEEND + 1U ) + +/*State no define*/ +#define ZREM_RESTRICTIONMODES0STATENO ( 0U ) +#define ZREM_RESTRICTIONMODES1STATENO ( 1U ) +#define ZREM_RESTRICTIONMODES2STATENO ( 2U ) + +/*State serial no define*/ +#define ZREM_RESTRICTIONMODES0STATESERIALNO ( 0U ) +#define ZREM_RESTRICTIONMODES1STATESERIALNO ( 1U ) +#define ZREM_RESTRICTIONMODES2STATESERIALNO ( 2U ) + +/*Event no define*/ +#define ZREM_RESTRICTIONMODEE0EVENTNO ( 0U ) +#define ZREM_RESTRICTIONMODEE1EVENTNO ( 1U ) +#define ZREM_RESTRICTIONMODEE2EVENTNO ( 2U ) + +/*Event serial no define*/ +#define ZREM_RESTRICTIONMODEE0EVENTSERIALNO ( 0U ) +#define ZREM_RESTRICTIONMODEE1EVENTSERIALNO ( 1U ) +#define ZREM_RESTRICTIONMODEE2EVENTSERIALNO ( 2U ) + +/*Extern function*/ +extern void stm_rem_event_call( void ); +extern void stm_rem_initialize( void ); +extern void ZREM_RestrictionModeTerminate( void ); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c new file mode 100644 index 0000000..94807f8 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c @@ -0,0 +1,53 @@ +/************************************************************/ +/* ZREM_RestrictionMode_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "../ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +/* + * @name stm_rem_start_activity_restriction_mode_1_on + */ +void stm_rem_start_activity_restriction_mode_1_on() { + g_stm_crr_state.mode[StmModeNoRestrictionMode].state = StmRestrictionModeSttNo1On; + g_stm_crr_state.mode[StmModeNoRestrictionMode].changed = STM_TRUE; +} + +/* + * @name stm_rem_start_activity_restriction_mode_2_on + */ +void stm_rem_start_activity_restriction_mode_2_on() { + g_stm_crr_state.mode[StmModeNoRestrictionMode].state = StmRestrictionModeSttNo2On; + g_stm_crr_state.mode[StmModeNoRestrictionMode].changed = STM_TRUE; +} + +/* + * @name stm_rem_start_activity_restriction_mode_off + */ +void stm_rem_start_activity_restriction_mode_off() { + g_stm_crr_state.mode[StmModeNoRestrictionMode].state = StmRestrictionModeSttNoOff; + g_stm_crr_state.mode[StmModeNoRestrictionMode].changed = STM_TRUE; +} + +/* + * @name stm_rem_initialize_variable + */ +void stm_rem_initialize_variable() { + g_stm_prv_state.mode[StmModeNoRestrictionMode].state = StmRestrictionModeSttNoOff; + g_stm_prv_state.mode[StmModeNoRestrictionMode].changed = STM_FALSE; + + g_stm_crr_state.mode[StmModeNoRestrictionMode].state = StmRestrictionModeSttNoOff; + g_stm_crr_state.mode[StmModeNoRestrictionMode].changed = STM_FALSE; +} + +/* + * @name stm_rem_start_stm + */ +void stm_rem_start_stm() { + g_stm_prv_state.mode[StmModeNoRestrictionMode].state = g_stm_crr_state.mode[StmModeNoRestrictionMode].state; + g_stm_crr_state.mode[StmModeNoRestrictionMode].changed = STM_FALSE; +} diff --git a/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h new file mode 100644 index 0000000..f85ab14 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h @@ -0,0 +1,15 @@ +/************************************************************/ +/* ZREM_RestrictionMode_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZREM_RESTRICTIONMODE_FUNC_H +#define ZHEADER_ZREM_RESTRICTIONMODE_FUNC_H + +extern void stm_rem_start_activity_restriction_mode_1_on(); +extern void stm_rem_start_activity_restriction_mode_2_on(); +extern void stm_rem_start_activity_restriction_mode_off(); +extern void stm_rem_initialize_variable(); +extern void stm_rem_start_stm(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h new file mode 100644 index 0000000..0212a95 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h @@ -0,0 +1,15 @@ +/************************************************************/ +/* ZST_StateTransitionor_def.h */ +/* Define header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZST_STATETRANSITIONOR_DEF_H +#define ZHEADER_ZST_STATETRANSITIONOR_DEF_H + +/************************************************************* + Define definition +*************************************************************/ + +#include "../../../stm.h" + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c new file mode 100644 index 0000000..3903202 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c @@ -0,0 +1,102 @@ +/************************************************************/ +/* ZST_StateTransitionor_func.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "ZST_include.h" + +/************************************************************* + Function definition +*************************************************************/ + +#include + +//================================= +// API +//================================= +/** + * Initialize STM + */ +void stmInitializeInner() { + // Initialize previous state + memset(&g_stm_prv_state, 0, sizeof(g_stm_prv_state)); + + // Initialize current state + g_stm_crr_state = g_stm_prv_state; + + /* Initialize restriction mode state */ + stm_rem_initialize(); + stm_rem_initialize_variable(); + + // Initialize homecsreen layer + stm_hsl_initialize(); + stm_hsl_initialize_variable(); + + // Initialize apps layer + stm_apl_initialize(); + stm_apl_initialize_variable(); + + // Initialize near_homecsreen layer + stm_nhl_initialize(); + stm_nhl_initialize_variable(); + + /* Initialize restriction layer */ + stm_rel_initialize(); + stm_rel_initialize_variable(); + + g_stm_map_is_activated = STM_FALSE; +} + +/** + * Transition State + */ +int stmTransitionStateInner(int event_id, StmState* state) { + g_stm_event = STM_GET_EVENT_FROM_ID(event_id); + g_stm_category = STM_GET_CATEGORY_FROM_ID(event_id); + g_stm_area = STM_GET_AREA_FROM_ID(event_id); + + // restriction mode + stm_rem_event_call(); + + // homescreen layer + stm_hsl_event_call(); + + // apps layer + stm_apl_event_call(); + + // near_homecsreen layer + stm_nhl_event_call(); + + // restriction layer + stm_rel_event_call(); + + // on_screen layer + stm_osl_event_call(); + + // Copy current state for return + memcpy(state, &g_stm_crr_state, sizeof(g_stm_crr_state)); + + return 0; +} + +/** + * Undo State + */ +void stmUndoStateInner() { + g_stm_event = StmEvtNoUndo; + + // apps layer + stm_apl_event_call(); + + // near_homecsreen layer + stm_nhl_event_call(); + + // restriction layer + stm_rel_event_call(); + + // on_screen layer + stm_osl_event_call(); + + g_stm_crr_state = g_stm_prv_state; +} + diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h new file mode 100644 index 0000000..78c4636 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h @@ -0,0 +1,13 @@ +/************************************************************/ +/* ZST_StateTransitionor_func.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZST_STATETRANSITIONOR_FUNC_H +#define ZHEADER_ZST_STATETRANSITIONOR_FUNC_H + +extern void stmInitializeInner(); +extern int stmTransitionStateInner(int event_id, StmState* state); +extern void stmUndoStateInner(); + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c new file mode 100644 index 0000000..b3a2273 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c @@ -0,0 +1,56 @@ +/************************************************************/ +/* ZST_StateTransitionor_var.c */ +/* Function and variable source file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#include "ZST_include.h" + +/************************************************************* + Variable definition +*************************************************************/ + +// Current state +StmState g_stm_crr_state; + +// Previous state +StmState g_stm_prv_state; + +/** + * g_stm_event + */ +int g_stm_event; + +/** + * g_stm_category + */ +int g_stm_category; + +/** + * g_stm_area + */ +int g_stm_area; + +/** + * g_stm_map_is_activated + */ +int g_stm_map_is_activated; + +/** + * g_prv_apps_state_rest_mode_1 + */ +int g_prv_apps_state_rest_mode_1; + +/** + * g_prv_near_homescreen_state_rest_mode_1 + */ +int g_prv_near_homescreen_state_rest_mode_1; + +/** + * g_prv_restriction_state_rest_mode_1 + */ +int g_prv_restriction_state_rest_mode_1; + +/** + * g_prv_on_screen_state_rest_mode_1 + */ +int g_prv_on_screen_state_rest_mode_1; diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h new file mode 100644 index 0000000..57b52ee --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h @@ -0,0 +1,20 @@ +/************************************************************/ +/* ZST_StateTransitionor_var.h */ +/* Function and variable header file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ +#ifndef ZHEADER_ZST_STATETRANSITIONOR_VAR_H +#define ZHEADER_ZST_STATETRANSITIONOR_VAR_H + +extern StmState g_stm_crr_state; +extern StmState g_stm_prv_state; +extern int g_stm_event; +extern int g_stm_category; +extern int g_stm_area; +extern int g_stm_map_is_activated; +extern int g_prv_apps_state_rest_mode_1; +extern int g_prv_near_homescreen_state_rest_mode_1; +extern int g_prv_restriction_state_rest_mode_1; +extern int g_prv_on_screen_state_rest_mode_1; + +#endif diff --git a/policy_manager/stm/zipc/StateTransitionor/ZST_include.h b/policy_manager/stm/zipc/StateTransitionor/ZST_include.h new file mode 100644 index 0000000..e3d1572 --- /dev/null +++ b/policy_manager/stm/zipc/StateTransitionor/ZST_include.h @@ -0,0 +1,29 @@ +/************************************************************/ +/* ZST_include.h */ +/* Functional block ST include file */ +/* ZIPC Designer Version 1.2.0 */ +/************************************************************/ + +#ifndef ZHEADER_ZST_INCLUDE_H +#define ZHEADER_ZST_INCLUDE_H + +#include "../Common/ZCommonInclude.h" +#include "../Common/MisraCType.h" +#include "../Common/Event.h" +#include "ZST_StateTransitionor_def.h" +#include "ZST_StateTransitionor_func.h" +#include "ZST_StateTransitionor_var.h" +#include "AppsLayer/ZAPL_Apps_func.h" +#include "OnScreenlayer/ZOSL_OnScreen_func.h" +#include "HomeScreenLayer/ZHSL_HomeScreen_func.h" +#include "RestrictionLayer/ZREL_Restriction_func.h" +#include "RestrictionMode/ZREM_RestrictionMode_func.h" +#include "NearHomeScreen/ZNHL_NearHomeScreen_func.h" +#include "AppsLayer/ZAPL_AppsLayer.h" +#include "OnScreenlayer/ZOSL_OslMain.h" +#include "HomeScreenLayer/ZHSL_HomeScreen.h" +#include "RestrictionLayer/ZREL_RelMain.h" +#include "RestrictionMode/ZREM_RestrictionMode.h" +#include "NearHomeScreen/ZNHL_NearHomescreen.h" + +#endif diff --git a/policy_manager/stm/zipc/stm_inner.h b/policy_manager/stm/zipc/stm_inner.h new file mode 100644 index 0000000..5097fcf --- /dev/null +++ b/policy_manager/stm/zipc/stm_inner.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TMCAGLWM_STM_INNER_HPP +#define TMCAGLWM_STM_INNER_HPP + +#include "StateTransitionor/ZST_StateTransitionor_func.h" + +#endif // TMCAGLWM_STM_INNER_HPP -- 2.16.6 From e65b048f311335ee550ac51f97f8ce50468babf9 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 30 Aug 2018 14:30:16 +0900 Subject: [PATCH 05/16] Fix Window Manager crush when application terminated Fix Window Manager crush when applicaiton terminated caused by wrong handling of sd_event_source. v2. Add error check just in case Bug-AGL: SPEC-1696 Change-Id: I639a60015cde46fca6bc5a3f6e8037afd8d79330 Signed-off-by: Kazumasa Mitsunari --- policy_manager/policy_manager.cpp | 21 ++++++++------------- src/window_manager.cpp | 4 ++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp index a482e0c..c7bb007 100644 --- a/policy_manager/policy_manager.cpp +++ b/policy_manager/policy_manager.cpp @@ -688,19 +688,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,27 +705,25 @@ 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; } diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 24b6f30..42930dc 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -657,6 +657,10 @@ void WindowManager::startTransitionWrapper(std::vector &actions) { bool found; auto const &surface_id = this->lookup_id(act.role.c_str()); + if(surface_id == nullopt) + { + goto proc_remove_request; + } std::string appid = g_app_list.getAppID(*surface_id, act.role, &found); if (!found) { -- 2.16.6 From 88d27f720045b3f548f6122756ea9e637ae06150 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 4 Oct 2018 10:18:38 +0900 Subject: [PATCH 06/16] Modify .gitreview Change-Id: I5d36d56c7957e33ce1137165e6273ba2599d8006 Signed-off-by: Kazumasa Mitsunari --- .gitreview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitreview b/.gitreview index 9bb4b0c..0cbf1ee 100644 --- a/.gitreview +++ b/.gitreview @@ -1,5 +1,5 @@ [gerrit] host=gerrit.automotivelinux.org port=29418 -project=apps/agl-service-windowmanager-2017 +project=apps/agl-service-windowmanager defaultbranch=master -- 2.16.6 From f98c0d96d7a1dbbcd82031a0d6f9913a3833a7d9 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 4 Oct 2018 10:39:18 +0900 Subject: [PATCH 07/16] Add .gitignore Change-Id: Id05d447d30988afaaa35265ab928ec5fb333117f Signed-off-by: Kazumasa Mitsunari --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5acb669 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +.vscode -- 2.16.6 From f0d9414627149fe5a2b055e7459619a4fff84da6 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 4 Oct 2018 10:39:37 +0900 Subject: [PATCH 08/16] Clean: Remove split_layout structure split_layout is not used anymore. Change-Id: Iff24ebb4e827aee28394deb3aa55c96692cd0cc6 Signed-off-by: Kazumasa Mitsunari --- src/layers.cpp | 30 +----------------------------- src/layers.hpp | 18 +----------------- 2 files changed, 2 insertions(+), 46 deletions(-) diff --git a/src/layers.cpp b/src/layers.cpp index bbe7c09..b7a0fa2 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -31,35 +31,7 @@ layer::layer(nlohmann::json const &j) this->name = j["name"]; this->layer_id = j["layer_id"]; - // Init flag of normal layout only - this->is_normal_layout_only = true; - - auto split_layouts = j.find("split_layouts"); - if (split_layouts != j.end()) - { - - // Clear flag of normal layout only - this->is_normal_layout_only = false; - - auto &sls = j["split_layouts"]; - // this->layouts.reserve(sls.size()); - std::transform(std::cbegin(sls), std::cend(sls), - std::back_inserter(this->layouts), [this](json const &sl) { - struct split_layout l - { - sl["name"], sl["main_match"], sl["sub_match"] - }; - HMI_DEBUG("wm", - "layer %d add split_layout \"%s\" (main: \"%s\") (sub: " - "\"%s\")", - this->layer_id, - l.name.c_str(), l.main_match.c_str(), - l.sub_match.c_str()); - return l; - }); - } - HMI_DEBUG("wm", "layer_id:%d is_normal_layout_only:%d\n", - this->layer_id, this->is_normal_layout_only); + HMI_DEBUG("wm", "layer_id:%d name:%s", this->layer_id, this->name.c_str()); } struct result to_layer_map(nlohmann::json const &j) diff --git a/src/layers.hpp b/src/layers.hpp index f52886e..3a16985 100644 --- a/src/layers.hpp +++ b/src/layers.hpp @@ -27,13 +27,6 @@ namespace wm { -struct split_layout -{ - std::string name; - std::string main_match; - std::string sub_match; -}; - struct layer { using json = nlohmann::json; @@ -43,23 +36,14 @@ struct layer // The actual layer ID int layer_id = -1; // The rectangular region surfaces are allowed to draw on - // this layer, note however, width and hieght of the rect - // can be negative, in which case they specify that - // the actual value is computed using MAX + 1 - w - // That is; allow us to specify dimensions dependent on - // e.g. screen dimension, w/o knowing the actual screen size. + // this layer. compositor::rect rect; // Specify a role prefix for surfaces that should be // put on this layer. std::string role; - // TODO: perhaps a zorder is needed here? - std::vector layouts; mutable struct LayoutState state; - // Flag of normal layout only - bool is_normal_layout_only; - explicit layer(nlohmann::json const &j); json to_json() const; -- 2.16.6 From 2dfacacfa0376bc4b4f5dd6f6a8f3fb3dca89c08 Mon Sep 17 00:00:00 2001 From: Jose Bollo Date: Tue, 9 Oct 2018 12:01:19 +0200 Subject: [PATCH 09/16] Use feature 'required-binding' The feature "urn:AGL:widget:required-binding" is now preferred to the feature "urn:AGL:widget:required-api" for requiring a local binding. Bug-AGL: SPEC-1800 Change-Id: If24f239990536f90ccc46802fabb2c2de2e6c239 Signed-off-by: Jose Bollo --- package/root/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/root/config.xml b/package/root/config.xml index 0a2f6fd..d969b0b 100644 --- a/package/root/config.xml +++ b/package/root/config.xml @@ -12,7 +12,7 @@ - + -- 2.16.6 From e7ba7ca4eae20ab2db682bb780c7a4d5b1d394f5 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Thu, 11 Oct 2018 12:58:34 +0900 Subject: [PATCH 10/16] Drop 2017 suffix Drop 2017 suffix. Change-Id: I64fafe814b7d61dca860b9fa92489acb76abc1dd Signed-off-by: Kazumasa Mitsunari --- doc/ApplicationGuide.md | 2 +- package/root/config.xml | 4 ++-- src/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ApplicationGuide.md b/doc/ApplicationGuide.md index 2240bb1..a3c2e35 100644 --- a/doc/ApplicationGuide.md +++ b/doc/ApplicationGuide.md @@ -357,7 +357,7 @@ $ repo sync Then you can get the following recipe. -* `meta-agl-devel/meta-hmi-framework/recipes-graphics/agl-service-windowmanager-2017` +* `meta-agl-devel/meta-hmi-framework/recipes-graphics/agl-service-windowmanager` * `meta-agl-devel/meta-hmi-framework/recipes-graphics/libwindowmanager` diff --git a/package/root/config.xml b/package/root/config.xml index 0a2f6fd..f1e3669 100644 --- a/package/root/config.xml +++ b/package/root/config.xml @@ -1,6 +1,6 @@ - - windowmanager-service-2017 + + windowmanager-service Window Manager TOYOTA diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c8da4c..91908e8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -118,5 +118,5 @@ add_custom_command(TARGET ${TARGETS_WM} POST_BUILD ) add_custom_target(package DEPENDS ${PROJECT_BINARY_DIR}/package/root - COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_WM}-2017.wgt ${PROJECT_BINARY_DIR}/package/root + COMMAND wgtpkg-pack -f -o ${PROJECT_BINARY_DIR}/package/${TARGETS_WM}.wgt ${PROJECT_BINARY_DIR}/package/root ) -- 2.16.6 From 5b1cf5616ef878e237d8fb7975b4839650c6d840 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 11:35:51 +0900 Subject: [PATCH 11/16] Migrate hmi-debug into util Migrate hmi-debug into util for * simplicity * remove warnings error `-Wunused-function` Change-Id: I7d061849429e5d50cc7d19d2051c7f5d0f0ef169 Signed-off-by: Kazumasa Mitsunari --- include/hmi-debug.h | 117 ------------------------ policy_manager/CMakeLists.txt | 1 + policy_manager/policy_manager.cpp | 186 +++++++++++++++++++------------------- src/applist.cpp | 6 +- src/json_helper.cpp | 20 ++-- src/json_helper.hpp | 8 +- src/layers.cpp | 40 ++++---- src/main.cpp | 82 ++++------------- src/pm_wrapper.cpp | 32 +++---- src/util.cpp | 89 +++++++++++++----- src/util.hpp | 97 ++++++-------------- src/wayland_ivi_wm.cpp | 76 ++++++++-------- src/window_manager.cpp | 112 +++++++++++------------ src/window_manager.hpp | 16 ++-- src/wm_client.cpp | 18 ++-- 15 files changed, 368 insertions(+), 532 deletions(-) delete mode 100644 include/hmi-debug.h diff --git a/include/hmi-debug.h b/include/hmi-debug.h deleted file mode 100644 index 697ac80..0000000 --- a/include/hmi-debug.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2017 TOYOTA MOTOR CORPORATION - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __HMI_DEBUG_H__ -#define __HMI_DEBUG_H__ - -#include -#include -#include -#include -#include - -enum LOG_LEVEL{ - LOG_LEVEL_NONE = 0, - LOG_LEVEL_ERROR, - LOG_LEVEL_WARNING, - LOG_LEVEL_NOTICE, - LOG_LEVEL_INFO, - LOG_LEVEL_DEBUG, - LOG_LEVEL_MAX = LOG_LEVEL_DEBUG -}; - -#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) - -#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__) -#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) -#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__) - -#define HMI_SEQ_ERROR(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) -#define HMI_SEQ_WARNING(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) -#define HMI_SEQ_NOTICE(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) -#define HMI_SEQ_INFO(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) -#define HMI_SEQ_DEBUG(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) - -#define DUMP(args, ...) _DUMP(LOG_LEVEL_DEBUG, args, ##__VA_ARGS__) - -static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; - -static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) -{ - const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); - if(log_level < level) - { - return; - } - - char *message; - struct timespec tp; - unsigned int time; - - clock_gettime(CLOCK_REALTIME, &tp); - time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); - - va_list args; - va_start(args, log); - if (log == NULL || vasprintf(&message, log, args) < 0) - message = NULL; - fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message); - va_end(args); - free(message); -} - -static void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...){ - const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); - if(log_level < level) - { - return; - } - - char *message; - struct timespec tp; - unsigned int time; - - clock_gettime(CLOCK_REALTIME, &tp); - time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); - - va_list args; - va_start(args, log); - if (log == NULL || vasprintf(&message, log, args) < 0) - message = NULL; - fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> req %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message); - va_end(args); - free(message); -} - -static void _DUMP(enum LOG_LEVEL level, const char *log, ...) -{ - const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG")); - if (log_level < level) - { - return; - } - char *message; - va_list args; - va_start(args, log); - if (log == NULL || vasprintf(&message, log, args) < 0) - message = NULL; - fprintf(stderr, "%s \n", message); - va_end(args); - free(message); -} -#endif //__HMI_DEBUG_H__ \ No newline at end of file diff --git a/policy_manager/CMakeLists.txt b/policy_manager/CMakeLists.txt index 584d311..3ec4c39 100644 --- a/policy_manager/CMakeLists.txt +++ b/policy_manager/CMakeLists.txt @@ -45,6 +45,7 @@ add_library(${TARGETS_PM} SHARED policy_manager.cpp stm/stm.c + ../src/util.cpp ) target_include_directories(${TARGETS_PM} diff --git a/policy_manager/policy_manager.cpp b/policy_manager/policy_manager.cpp index c7bb007..999bc87 100644 --- a/policy_manager/policy_manager.cpp +++ b/policy_manager/policy_manager.cpp @@ -22,7 +22,7 @@ #include #include #include "policy_manager.hpp" -#include "hmi-debug.h" +#include "util.hpp" extern "C" { @@ -68,19 +68,19 @@ int PolicyManager::initialize() // Create convert map for (int i = StmEvtNoMin; i <= StmEvtNoMax; i++) { - HMI_DEBUG("wm:pm", "event name:%s no:%d", kStmEventName[i], i); + HMI_DEBUG("event name:%s no:%d", kStmEventName[i], i); this->eventname2no[kStmEventName[i]] = i; } for (int i = StmCtgNoMin; i <= StmCtgNoMax; i++) { - HMI_DEBUG("wm:pm", "category name:%s no:%d", kStmCategoryName[i], i); + HMI_DEBUG("category name:%s no:%d", kStmCategoryName[i], i); this->categoryname2no[kStmCategoryName[i]] = i; } for (int i = StmAreaNoMin; i <= StmAreaNoMax; i++) { - HMI_DEBUG("wm:pm", "area name:%s no:%d", kStmAreaName[i], i); + HMI_DEBUG("area name:%s no:%d", kStmAreaName[i], i); this->areaname2no[kStmAreaName[i]] = i; } @@ -88,7 +88,7 @@ int PolicyManager::initialize() ret = this->loadRoleDb(); if (0 > ret) { - HMI_ERROR("wm:pm", "Load roles.db Error!!"); + HMI_ERROR("Load roles.db Error!!"); return ret; } @@ -96,7 +96,7 @@ int PolicyManager::initialize() ret = this->loadStateDb(); if (0 > ret) { - HMI_ERROR("wm:pm", "Load states.db Error!!"); + HMI_ERROR("Load states.db Error!!"); return ret; } @@ -123,7 +123,7 @@ int PolicyManager::setInputEventData(json_object *json_in) // Check arguments if (nullptr == json_in) { - HMI_ERROR("wm:pm", "Argument is NULL!!"); + HMI_ERROR("Argument is NULL!!"); return -1; } @@ -137,17 +137,17 @@ int PolicyManager::setInputEventData(json_object *json_in) if (this->eventname2no.end() != itr) { event_no = this->eventname2no[event]; - HMI_DEBUG("wm:pm", "event(%s:%d)", event, event_no); + HMI_DEBUG("event(%s:%d)", event, event_no); } else { - HMI_ERROR("wm:pm", "Invalid event name!!"); + HMI_ERROR("Invalid event name!!"); return -1; } } else { - HMI_ERROR("wm:pm", "Event is not set!!"); + HMI_ERROR("Event is not set!!"); return -1; } @@ -157,7 +157,7 @@ int PolicyManager::setInputEventData(json_object *json_in) int category_no = StmCtgNoNone; if (nullptr != role) { - HMI_DEBUG("wm:pm", "role(%s)", role); + HMI_DEBUG("role(%s)", role); // Convert role to category auto itr = this->role2category.find(role); @@ -170,7 +170,7 @@ int PolicyManager::setInputEventData(json_object *json_in) itr = this->role2category.find("fallback"); if (this->role2category.end() != itr) { - HMI_DEBUG("wm:pm", "Role:%s is not registered in roles.db, fallback as normal app", role); + HMI_DEBUG("Role:%s is not registered in roles.db, fallback as normal app", role); category = this->role2category["fallback"]; } } @@ -179,7 +179,7 @@ int PolicyManager::setInputEventData(json_object *json_in) { // Convert name to number category_no = categoryname2no[category]; - HMI_DEBUG("wm:pm", "category(%s:%d)", category.c_str(), category_no); + HMI_DEBUG("category(%s:%d)", category.c_str(), category_no); } } if (StmCtgNoNone == category_no) @@ -205,7 +205,7 @@ int PolicyManager::setInputEventData(json_object *json_in) area = this->category2areas[category].front().c_str(); area_no = this->areaname2no[area]; } - HMI_DEBUG("wm:pm", "area(%s:%d)", area, area_no); + HMI_DEBUG("area(%s:%d)", area, area_no); } // Set event info to the queue @@ -237,17 +237,17 @@ int PolicyManager::executeStateTransition() void PolicyManager::undoState() { - HMI_DEBUG("wm:pm", "Undo State !!!"); + HMI_DEBUG("Undo State !!!"); // Undo state of STM stmUndoState(); - HMI_DEBUG("wm:pm", ">>>>>>>>>> BEFORE UNDO"); + HMI_DEBUG(">>>>>>>>>> BEFORE UNDO"); this->dumpLayerState(this->crr_layers); this->crr_layers = this->prv_layers; - HMI_DEBUG("wm:pm", ">>>>>>>>>> AFTER UNDO"); + HMI_DEBUG(">>>>>>>>>> AFTER UNDO"); this->dumpLayerState(this->crr_layers); } @@ -282,7 +282,7 @@ void PolicyManager::addStateToJson(const char *name, bool changed, { if ((nullptr == name) || (nullptr == json_out)) { - HMI_ERROR("wm:pm", "Invalid argument!!!"); + HMI_ERROR("Invalid argument!!!"); return; } @@ -296,7 +296,7 @@ void PolicyManager::addStateToJson(const char *layer_name, bool changed, { if ((nullptr == layer_name) || (nullptr == json_out)) { - HMI_ERROR("wm:pm", "Invalid argument!!!"); + HMI_ERROR("Invalid argument!!!"); return; } @@ -325,7 +325,7 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state) for (int layer_no = StmLayerNoMin; layer_no <= StmLayerNoMax; layer_no++) { - HMI_DEBUG("wm:pm", ">>> LAYER:%s CHANGED:%d LAYOUT:%s", + HMI_DEBUG(">>> LAYER:%s CHANGED:%d LAYOUT:%s", kStmLayerName[layer_no], crr_state.layer[layer_no].changed, kStmLayoutName[crr_state.layer[layer_no].state]); } @@ -343,7 +343,7 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state) int changed = crr_state.layer[layer_no].changed; if (changed) { - HMI_DEBUG("wm:pm", ">>>>>>>>>> Update layout of layer:%s", layer_name); + HMI_DEBUG(">>>>>>>>>> Update layout of layer:%s", layer_name); // Get current layout name of this layer int crr_layout_state_no = crr_state.layer[layer_no].state; @@ -363,10 +363,10 @@ void PolicyManager::updateLayer(int event_id, StmState crr_state) // Erase role for the event_id from list this->req_role_list.erase(event_id); - HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (BEFORE)"); + HMI_DEBUG(">>>>>>>>>> DUMP LAYERS (BEFORE)"); this->dumpLayerState(this->prv_layers); - HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP LAYERS (AFTER)"); + HMI_DEBUG(">>>>>>>>>> DUMP LAYERS (AFTER)"); this->dumpLayerState(this->crr_layers); this->dumpInvisibleRoleHistory(); @@ -405,17 +405,17 @@ int PolicyManager::updateLayout(int event_id, int layer_no, crr_layout_state = prv_layout_state; changed = 1; - HMI_DEBUG("wm:pm", "-- layout name previous:%s current:%s", + HMI_DEBUG("-- layout name previous:%s current:%s", prv_layout_name.c_str(), crr_layout_name.c_str()); if (prv_layout_name == crr_layout_name) { - HMI_DEBUG("wm:pm", "---- Previous layout is same with current"); + HMI_DEBUG("---- Previous layout is same with current"); } else { // If previous layout is NOT same with current, // current areas is set with default value - HMI_DEBUG("wm:pm", "---- Previous layout is NOT same with current"); + HMI_DEBUG("---- Previous layout is NOT same with current"); crr_layout_state.name = this->default_layouts[crr_layout_name].name; crr_layout_state.category_num = this->default_layouts[crr_layout_name].category_num; crr_layout_state.area_list = this->default_layouts[crr_layout_name].area_list; @@ -434,7 +434,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, // } // const char *ctg = kStmCategoryName[ctg_no]; - HMI_DEBUG("wm:pm", "-- Create candidate list for ctg:%s", ctg.c_str()); + HMI_DEBUG("-- Create candidate list for ctg:%s", ctg.c_str()); AreaList tmp_cand_list; int candidate_num = 0; @@ -447,7 +447,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, std::string used_role = ""; if ((ctg == req_ctg) && ("activate" == req_evt)) { - HMI_DEBUG("wm:pm", "---- Requested event is activate"); + HMI_DEBUG("---- Requested event is activate"); for (AreaState &as : crr_layout_state.area_list) { if (as.category == req_ctg) @@ -459,7 +459,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, as.role = req_role; used_role = req_role; blank_num--; - HMI_DEBUG("wm:pm", "------ Update current layout: area:%s category:%s role:%s", + HMI_DEBUG("------ Update current layout: area:%s category:%s role:%s", as.name.c_str(), as.category.c_str(), as.role.c_str()); break; } @@ -476,7 +476,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, // If there is the category // which is same with new category and not used for updating yet, // push it to list - HMI_DEBUG("wm:pm", "---- Push previous(category:%s role:%s) to candidate list", + HMI_DEBUG("---- Push previous(category:%s role:%s) to candidate list", area_state.category.c_str(), area_state.role.c_str()); tmp_cand_list.push_back(area_state); candidate_num++; @@ -488,7 +488,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, // so push requested role to candidate list if (request_for_this_layer && ("" == used_role)) { - HMI_DEBUG("wm:pm", "---- Push request(area:%s category:%s role:%s) to candidate list", + HMI_DEBUG("---- Push request(area:%s category:%s role:%s) to candidate list", req_area.c_str(), req_ctg.c_str(), req_role.c_str()); AreaState area_state; area_state.name = req_area; @@ -498,7 +498,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, candidate_num++; } - HMI_DEBUG("wm:pm", "---- blank_num:%d candidate_num:%d", blank_num, candidate_num); + HMI_DEBUG("---- blank_num:%d candidate_num:%d", blank_num, candidate_num); // Compare number of candidate/blank, // And remove role in order of the oldest as necessary @@ -514,10 +514,10 @@ int PolicyManager::updateLayout(int event_id, int layer_no, area_state.role = this->popInvisibleRoleHistory(ctg); if ("" == area_state.role) { - HMI_ERROR("wm:pm", "There is no role in history stack!!"); + HMI_ERROR("There is no role in history stack!!"); } tmp_cand_list.push_back(area_state); - HMI_DEBUG("wm:pm", "------ Add role:%s to candidate list", + HMI_DEBUG("------ Add role:%s to candidate list", area_state.role.c_str()); candidate_num++; } @@ -528,7 +528,7 @@ int PolicyManager::updateLayout(int event_id, int layer_no, while (candidate_num != blank_num) { std::string removed_role = tmp_cand_list.begin()->role; - HMI_DEBUG("wm:pm", "------ Remove the oldest role:%s from candidate list", + HMI_DEBUG("------ Remove the oldest role:%s from candidate list", removed_role.c_str()); tmp_cand_list.erase(tmp_cand_list.begin()); candidate_num--; @@ -555,14 +555,14 @@ int PolicyManager::updateLayout(int event_id, int layer_no, } // Update areas - HMI_DEBUG("wm:pm", "-- Update areas by using candidate list"); + HMI_DEBUG("-- Update areas by using candidate list"); for (AreaState &as : crr_layout_state.area_list) { - HMI_DEBUG("wm:pm", "---- Check area:%s category:%s role:%s", + HMI_DEBUG("---- Check area:%s category:%s role:%s", as.name.c_str(), as.category.c_str(), as.role.c_str()); if ("" == as.role) { - HMI_DEBUG("wm:pm", "------ Update this area with role:%s", + HMI_DEBUG("------ Update this area with role:%s", cand_list[as.category].begin()->role.c_str()); as.role = cand_list[as.category].begin()->role; cand_list[as.category].erase(cand_list[as.category].begin()); @@ -610,7 +610,7 @@ void PolicyManager::createOutputInformation(StmState crr_state, json_object **js int PolicyManager::transitionState(sd_event_source *source, void *data) { - HMI_DEBUG("wm:pm", ">>>>>>>>>> START STATE TRANSITION"); + HMI_DEBUG(">>>>>>>>>> START STATE TRANSITION"); int event_id = *((int *)data); @@ -618,7 +618,7 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) event_no = STM_GET_EVENT_FROM_ID(event_id); category_no = STM_GET_CATEGORY_FROM_ID(event_id); area_no = STM_GET_AREA_FROM_ID(event_id); - HMI_DEBUG("wm:pm", ">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s", + HMI_DEBUG(">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s", kStmEventName[event_no], kStmCategoryName[category_no], kStmAreaName[area_no]); @@ -628,7 +628,7 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) int ret = stmTransitionState(event_id, &crr_state); if (0 > ret) { - HMI_ERROR("wm:pm", "Failed transition state"); + HMI_ERROR("Failed transition state"); if (nullptr != this->callback.onError) { json_object *json_out = json_object_new_object(); @@ -674,13 +674,13 @@ int PolicyManager::transitionState(sd_event_source *source, void *data) this->event_source_list.erase(event_id); } - HMI_DEBUG("wm:pm", ">>>>>>>>>> FINISH STATE TRANSITION"); + HMI_DEBUG(">>>>>>>>>> FINISH STATE TRANSITION"); return 0; } int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data) { - HMI_DEBUG("wm:pm", "Call"); + HMI_DEBUG("Call"); int ret = this->transitionState(source, data); return ret; @@ -733,11 +733,11 @@ int PolicyManager::loadRoleDb() // 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); + HMI_DEBUG("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"); + HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); } else { @@ -749,21 +749,21 @@ int PolicyManager::loadRoleDb() int ret = this->inputJsonFilie(file_name.c_str(), &json_obj); if (0 > ret) { - HMI_ERROR("wm:pm", "Could not open roles.db, so use default role information"); + HMI_ERROR("Could not open roles.db, so use default role information"); json_obj = json_tokener_parse(kDefaultRoleDb); } - HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj)); + HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj)); json_object *json_roles; if (!json_object_object_get_ex(json_obj, "roles", &json_roles)) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } int len = json_object_array_length(json_roles); - HMI_DEBUG("wm:pm", "json_cfg len:%d", len); - HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_roles)); + HMI_DEBUG("json_cfg len:%d", len); + HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_roles)); json_object *json_tmp; const char *category; @@ -782,7 +782,7 @@ int PolicyManager::loadRoleDb() if ((nullptr == category) || (nullptr == roles) || (nullptr == areas) || (nullptr == layer)) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } @@ -805,24 +805,24 @@ int PolicyManager::loadRoleDb() } // Check - HMI_DEBUG("wm:pm", "Check role2category"); + HMI_DEBUG("Check role2category"); for (const auto &x : this->role2category) { - HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str()); + HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str()); } - HMI_DEBUG("wm:pm", "Check category2role"); + HMI_DEBUG("Check category2role"); for (const auto &x : this->category2role) { - HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), x.second.c_str()); + HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str()); } - HMI_DEBUG("wm:pm", "Check category2areas"); + HMI_DEBUG("Check category2areas"); for (const auto &x : this->category2areas) { for (const auto &y : x.second) { - HMI_DEBUG("wm:pm", "key:%s, val:%s", x.first.c_str(), y.c_str()); + HMI_DEBUG("key:%s, val:%s", x.first.c_str(), y.c_str()); } } return 0; @@ -830,16 +830,16 @@ int PolicyManager::loadRoleDb() int PolicyManager::loadStateDb() { - HMI_DEBUG("wm:pm", "Call"); + HMI_DEBUG("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); + HMI_DEBUG("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"); + HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); } else { @@ -851,23 +851,23 @@ int PolicyManager::loadStateDb() int ret = this->inputJsonFilie(file_name.c_str(), &json_obj); if (0 > ret) { - HMI_DEBUG("wm:pm", "Could not open states.db, so use default layout information"); + HMI_DEBUG("Could not open states.db, so use default layout information"); json_obj = json_tokener_parse(kDefaultStateDb); } - HMI_DEBUG("wm:pm", "json_obj dump:%s", json_object_get_string(json_obj)); + HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj)); // Perse states - HMI_DEBUG("wm:pm", "Perse states"); + HMI_DEBUG("Perse states"); json_object *json_cfg; if (!json_object_object_get_ex(json_obj, "states", &json_cfg)) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } int len = json_object_array_length(json_cfg); - HMI_DEBUG("wm:pm", "json_cfg len:%d", len); - HMI_DEBUG("wm:pm", "json_cfg dump:%s", json_object_get_string(json_cfg)); + HMI_DEBUG("json_cfg len:%d", len); + HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg)); const char *layout; const char *role; @@ -879,21 +879,21 @@ int PolicyManager::loadStateDb() layout = this->getStringFromJson(json_tmp, "name"); if (nullptr == layout) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } - HMI_DEBUG("wm:pm", "> layout:%s", layout); + HMI_DEBUG("> layout:%s", layout); json_object *json_area_array; if (!json_object_object_get_ex(json_tmp, "areas", &json_area_array)) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } int len_area = json_object_array_length(json_area_array); - HMI_DEBUG("wm:pm", "json_area_array len:%d", len_area); - HMI_DEBUG("wm:pm", "json_area_array dump:%s", json_object_get_string(json_area_array)); + HMI_DEBUG("json_area_array len:%d", len_area); + HMI_DEBUG("json_area_array dump:%s", json_object_get_string(json_area_array)); LayoutState layout_state; AreaState area_state; @@ -913,22 +913,22 @@ int PolicyManager::loadStateDb() const char *area = this->getStringFromJson(json_area, "name"); if (nullptr == area) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } area_state.name = std::string(area); - HMI_DEBUG("wm:pm", ">> area:%s", area); + HMI_DEBUG(">> area:%s", area); // Get app attribute of the area category = this->getStringFromJson(json_area, "category"); if (nullptr == category) { - HMI_ERROR("wm:pm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } area_state.category = std::string(category); category_num[category]++; - HMI_DEBUG("wm:pm", ">>> category:%s", category); + HMI_DEBUG(">>> category:%s", category); role = this->getStringFromJson(json_area, "role"); if (nullptr != role) @@ -940,7 +940,7 @@ int PolicyManager::loadStateDb() { area_state.role = std::string(""); } - HMI_DEBUG("wm:pm", ">>> role:%s", role); + HMI_DEBUG(">>> role:%s", role); layout_state.area_list.push_back(area_state); } @@ -960,14 +960,14 @@ int PolicyManager::loadStateDb() for (auto itr_layout = this->default_layouts.begin(); itr_layout != this->default_layouts.end(); ++itr_layout) { - HMI_DEBUG("wm:pm", ">>> layout:%s", itr_layout->first.c_str()); + HMI_DEBUG(">>> layout:%s", itr_layout->first.c_str()); for (auto itr_area = itr_layout->second.area_list.begin(); itr_area != itr_layout->second.area_list.end(); ++itr_area) { - HMI_DEBUG("wm:pm", ">>> >>> area :%s", itr_area->name.c_str()); - HMI_DEBUG("wm:pm", ">>> >>> category:%s", itr_area->category.c_str()); - HMI_DEBUG("wm:pm", ">>> >>> role :%s", itr_area->role.c_str()); + HMI_DEBUG(">>> >>> area :%s", itr_area->name.c_str()); + HMI_DEBUG(">>> >>> category:%s", itr_area->category.c_str()); + HMI_DEBUG(">>> >>> role :%s", itr_area->role.c_str()); } } @@ -1017,7 +1017,7 @@ const char *PolicyManager::getStringFromJson(json_object *obj, const char *key) json_object *tmp; if (!json_object_object_get_ex(obj, key, &tmp)) { - HMI_DEBUG("wm:pm", "Not found key \"%s\"", key); + HMI_DEBUG("Not found key \"%s\"", key); return nullptr; } @@ -1029,13 +1029,13 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj) const int input_size = 128; int ret = -1; - HMI_DEBUG("wm:pm", "Input file: %s", file); + HMI_DEBUG("Input file: %s", file); // Open json file FILE *fp = fopen(file, "rb"); if (nullptr == fp) { - HMI_ERROR("wm:pm", "Could not open file"); + HMI_ERROR("Could not open file"); return ret; } @@ -1050,7 +1050,7 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj) *obj = json_tokener_parse_ex(tokener, buffer, len); if (nullptr != *obj) { - HMI_DEBUG("wm:pm", "File input is success"); + HMI_DEBUG("File input is success"); ret = 0; break; } @@ -1058,9 +1058,9 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj) json_error = json_tokener_get_error(tokener); if ((json_tokener_continue != json_error) || (input_size > len)) { - HMI_ERROR("wm:pm", "Failed to parse file (byte:%d err:%s)", + HMI_ERROR("Failed to parse file (byte:%d err:%s)", (input_size * block_cnt), json_tokener_error_desc(json_error)); - HMI_ERROR("wm:pm", "\n%s", buffer); + HMI_ERROR("\n%s", buffer); *obj = nullptr; break; } @@ -1078,8 +1078,8 @@ int PolicyManager::inputJsonFilie(const char *file, json_object **obj) void PolicyManager::dumpLayerState(std::unordered_map &layers) { - HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------"); - HMI_DEBUG("wm:pm", "|%-15s|%s|%-20s|%-20s|%-20s|%-20s|", + HMI_DEBUG("-------------------------------------------------------------------------------------------------------"); + HMI_DEBUG("|%-15s|%s|%-20s|%-20s|%-20s|%-20s|", "LAYER", "C", "LAYOUT", "AREA", "CATEGORY", "ROLE"); for (const auto &itr : layers) { @@ -1093,21 +1093,21 @@ void PolicyManager::dumpLayerState(std::unordered_map & if (first) { first = false; - HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", + HMI_DEBUG("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", layer, changed, layout, as.name.c_str(), as.category.c_str(), as.role.c_str()); } else - HMI_DEBUG("wm:pm", "|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", + HMI_DEBUG("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|", "", "", "", as.name.c_str(), as.category.c_str(), as.role.c_str()); } } - HMI_DEBUG("wm:pm", "-------------------------------------------------------------------------------------------------------"); + HMI_DEBUG("-------------------------------------------------------------------------------------------------------"); } void PolicyManager::dumpInvisibleRoleHistory() { - HMI_DEBUG("wm:pm", ">>>>>>>>>> DUMP INVISIBLE ROLE HISTORY ( category [older > newer] )"); + HMI_DEBUG(">>>>>>>>>> DUMP INVISIBLE ROLE HISTORY ( category [older > newer] )"); for (int ctg_no = StmCtgNoMin; ctg_no <= StmCtgNoMax; ctg_no++) { if (ctg_no == StmCtgNoNone) @@ -1120,7 +1120,7 @@ void PolicyManager::dumpInvisibleRoleHistory() str += (i + " > "); str += "]"; - HMI_DEBUG("wm:pm", "%s", str.c_str()); + HMI_DEBUG("%s", str.c_str()); } } diff --git a/src/applist.cpp b/src/applist.cpp index a5ae9f0..f0dade0 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -16,7 +16,7 @@ #include #include #include "applist.hpp" -#include "../include/hmi-debug.h" +#include "util.hpp" using std::shared_ptr; using std::string; @@ -82,7 +82,7 @@ void AppList::removeClient(const string &appid) { std::lock_guard lock(this->mtx); this->app2client.erase(appid); - HMI_INFO("wm", "Remove client %s", appid.c_str()); + HMI_INFO("Remove client %s", appid.c_str()); } /** @@ -111,7 +111,7 @@ void AppList::removeSurface(unsigned surface){ { ret = x.second->removeSurfaceIfExist(surface); if(ret){ - HMI_DEBUG("wm", "remove surface %d from Client %s finish", + HMI_DEBUG("remove surface %d from Client %s finish", surface, x.second->appID().c_str()); break; } diff --git a/src/json_helper.cpp b/src/json_helper.cpp index b97f21d..cf13363 100644 --- a/src/json_helper.cpp +++ b/src/json_helper.cpp @@ -15,9 +15,7 @@ */ #include "json_helper.hpp" -#include "hmi-debug.h" - -#include +#include "util.hpp" json_object *to_json(compositor::surface_properties const &s) { @@ -117,7 +115,7 @@ const char* getStringFromJson(json_object* obj, const char* key) json_object* tmp; if (!json_object_object_get_ex(obj, key, &tmp)) { - HMI_DEBUG("wm:jh", "Not found key \"%s\"", key); + HMI_DEBUG("Not found key \"%s\"", key); return nullptr; } @@ -129,7 +127,7 @@ int getIntFromJson(json_object *obj, const char *key) json_object *tmp; if (!json_object_object_get_ex(obj, key, &tmp)) { - HMI_DEBUG("wm:jh", "Not found key \"%s\"", key); + HMI_DEBUG("Not found key \"%s\"", key); return 0; } @@ -141,7 +139,7 @@ json_bool getBoolFromJson(json_object *obj, const char *key) json_object *tmp; if (!json_object_object_get_ex(obj, key, &tmp)) { - HMI_DEBUG("wm:jh", "Not found key \"%s\"", key); + HMI_DEBUG("Not found key \"%s\"", key); return FALSE; } @@ -153,13 +151,13 @@ int inputJsonFilie(const char* file, json_object** obj) const int input_size = 128; int ret = -1; - HMI_DEBUG("wm:jh", "Input file: %s", file); + HMI_DEBUG("Input file: %s", file); // Open json file FILE *fp = fopen(file, "rb"); if (nullptr == fp) { - HMI_ERROR("wm:jh", "Could not open file"); + HMI_ERROR("Could not open file"); return ret; } @@ -174,7 +172,7 @@ int inputJsonFilie(const char* file, json_object** obj) *obj = json_tokener_parse_ex(tokener, buffer, len); if (nullptr != *obj) { - HMI_DEBUG("wm:jh", "File input is success"); + HMI_DEBUG("File input is success"); ret = 0; break; } @@ -183,9 +181,9 @@ int inputJsonFilie(const char* file, json_object** obj) if ((json_tokener_continue != json_error) || (input_size > len)) { - HMI_ERROR("wm:jh", "Failed to parse file (byte:%d err:%s)", + HMI_ERROR("Failed to parse file (byte:%d err:%s)", (input_size * block_cnt), json_tokener_error_desc(json_error)); - HMI_ERROR("wm:jh", "\n%s", buffer); + HMI_ERROR("\n%s", buffer); *obj = nullptr; break; } diff --git a/src/json_helper.hpp b/src/json_helper.hpp index 5333130..2321f8b 100644 --- a/src/json_helper.hpp +++ b/src/json_helper.hpp @@ -14,11 +14,11 @@ * limitations under the License. */ -#ifndef TMCAGLWM_JSON_HELPER_HPP -#define TMCAGLWM_JSON_HELPER_HPP +#ifndef JSON_HELPER_HPP +#define JSON_HELPER_HPP #include -#include "../include/json.hpp" +#include #include "wayland_ivi_wm.hpp" struct json_object; @@ -34,4 +34,4 @@ json_bool getBoolFromJson(json_object *obj, const char *key); int inputJsonFilie(const char* file, json_object** obj); } // namespace jh -#endif // TMCAGLWM_JSON_HELPER_HPP +#endif // JSON_HELPER_HPP diff --git a/src/layers.cpp b/src/layers.cpp index b7a0fa2..e1a232a 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -18,7 +18,7 @@ #include "layers.hpp" #include "json_helper.hpp" -#include "hmi-debug.h" +#include "util.hpp" namespace wm { @@ -31,7 +31,7 @@ layer::layer(nlohmann::json const &j) this->name = j["name"]; this->layer_id = j["layer_id"]; - HMI_DEBUG("wm", "layer_id:%d name:%s", this->layer_id, this->name.c_str()); + HMI_DEBUG("layer_id:%d name:%s", this->layer_id, this->name.c_str()); } struct result to_layer_map(nlohmann::json const &j) @@ -108,11 +108,11 @@ optional layer_map::get_layer_id(std::string const &role) auto re = std::regex(r.first); if (std::regex_match(role, re)) { - HMI_DEBUG("wm", "role %s matches layer %d", role.c_str(), r.second); + HMI_DEBUG("role %s matches layer %d", role.c_str(), r.second); return optional(r.second); } } - HMI_DEBUG("wm", "role %s does NOT match any layer", role.c_str()); + HMI_DEBUG("role %s does NOT match any layer", role.c_str()); return nullopt; } @@ -168,7 +168,7 @@ void layer_map::setupArea(double scaling) i.second.w = static_cast(scaling * i.second.w + 0.5); i.second.h = static_cast(scaling * i.second.h + 0.5); - HMI_DEBUG("wm:lm", "area:%s size(after) : x:%d y:%d w:%d h:%d", + HMI_DEBUG("area:%s size(after) : x:%d y:%d w:%d h:%d", i.first.c_str(), i.second.x, i.second.y, i.second.w, i.second.h); } } @@ -180,16 +180,14 @@ compositor::rect layer_map::getAreaSize(const std::string &area) int layer_map::loadAreaDb() { - HMI_DEBUG("wm:lm", "Call"); - // Get afm application installed dir char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR"); - HMI_DEBUG("wm:lm", "afm_app_install_dir:%s", afm_app_install_dir); + HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir); std::string file_name; if (!afm_app_install_dir) { - HMI_ERROR("wm:lm", "AFM_APP_INSTALL_DIR is not defined"); + HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); } else { @@ -201,45 +199,45 @@ int layer_map::loadAreaDb() int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj); if (0 > ret) { - HMI_DEBUG("wm:lm", "Could not open area.db, so use default area information"); + HMI_DEBUG("Could not open area.db, so use default area information"); json_obj = json_tokener_parse(kDefaultAreaDb); } - HMI_DEBUG("wm:lm", "json_obj dump:%s", json_object_get_string(json_obj)); + HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj)); // Perse areas - HMI_DEBUG("wm:lm", "Perse areas"); + HMI_DEBUG("Perse areas"); json_object *json_cfg; if (!json_object_object_get_ex(json_obj, "areas", &json_cfg)) { - HMI_ERROR("wm:lm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } int len = json_object_array_length(json_cfg); - HMI_DEBUG("wm:lm", "json_cfg len:%d", len); - HMI_DEBUG("wm:lm", "json_cfg dump:%s", json_object_get_string(json_cfg)); + HMI_DEBUG("json_cfg len:%d", len); + HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg)); const char *area; for (int i = 0; i < len; i++) { json_object *json_tmp = json_object_array_get_idx(json_cfg, i); - HMI_DEBUG("wm:lm", "> json_tmp dump:%s", json_object_get_string(json_tmp)); + HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp)); area = jh::getStringFromJson(json_tmp, "name"); if (nullptr == area) { - HMI_ERROR("wm:lm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } - HMI_DEBUG("wm:lm", "> area:%s", area); + HMI_DEBUG("> area:%s", area); json_object *json_rect; if (!json_object_object_get_ex(json_tmp, "rect", &json_rect)) { - HMI_ERROR("wm:lm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } - HMI_DEBUG("wm:lm", "> json_rect dump:%s", json_object_get_string(json_rect)); + HMI_DEBUG("> json_rect dump:%s", json_object_get_string(json_rect)); compositor::rect area_size; area_size.x = jh::getIntFromJson(json_rect, "x"); @@ -254,7 +252,7 @@ int layer_map::loadAreaDb() for (auto itr = this->area2size.begin(); itr != this->area2size.end(); ++itr) { - HMI_DEBUG("wm:lm", "area:%s x:%d y:%d w:%d h:%d", + HMI_DEBUG("area:%s x:%d y:%d w:%d h:%d", itr->first.c_str(), itr->second.x, itr->second.y, itr->second.w, itr->second.h); } diff --git a/src/main.cpp b/src/main.cpp index 0447f86..0e3c587 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,7 +18,6 @@ #include #include #include -#include "../include/json.hpp" #include "window_manager.hpp" #include "json_helper.hpp" #include "wayland_ivi_wm.hpp" @@ -61,11 +60,9 @@ int afb_instance::init() int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events, void * /*data*/) { - ST(); - if ((events & EPOLLHUP) != 0) { - HMI_ERROR("wm", "The compositor hung up, dying now."); + HMI_ERROR("The compositor hung up, dying now."); delete g_afb_instance; g_afb_instance = nullptr; goto error; @@ -74,17 +71,14 @@ int display_event_callback(sd_event_source *evs, int /*fd*/, uint32_t events, if ((events & EPOLLIN) != 0u) { { - STN(display_read_events); g_afb_instance->wmgr.display->read_events(); g_afb_instance->wmgr.set_pending_events(); } { // We want do dispatch pending wayland events from within // the API context - STN(winman_ping_api_call); afb_service_call("windowmanager", "ping", json_object_new_object(), [](void *c, int st, json_object *j) { - STN(winman_ping_api_call_return); }, nullptr); } @@ -103,17 +97,17 @@ error: int _binding_init() { - HMI_NOTICE("wm", "WinMan ver. %s", WINMAN_VERSION_STRING); + HMI_NOTICE("WinMan ver. %s", WINMAN_VERSION_STRING); if (g_afb_instance != nullptr) { - HMI_ERROR("wm", "Wayland context already initialized?"); + HMI_ERROR("Wayland context already initialized?"); return 0; } if (getenv("XDG_RUNTIME_DIR") == nullptr) { - HMI_ERROR("wm", "Environment variable XDG_RUNTIME_DIR not set"); + HMI_ERROR("Environment variable XDG_RUNTIME_DIR not set"); goto error; } @@ -126,10 +120,10 @@ int _binding_init() cnt++; if (20 <= cnt) { - HMI_ERROR("wm", "Could not connect to compositor"); + HMI_ERROR("Could not connect to compositor"); goto error; } - HMI_ERROR("wm", "Wait to start weston ..."); + HMI_ERROR("Wait to start weston ..."); sleep(1); delete g_afb_instance; g_afb_instance = new afb_instance; @@ -138,7 +132,7 @@ int _binding_init() if (g_afb_instance->init() == -1) { - HMI_ERROR("wm", "Could not connect to compositor"); + HMI_ERROR("Could not connect to compositor"); goto error; } @@ -148,7 +142,7 @@ int _binding_init() display_event_callback, g_afb_instance); if (ret < 0) { - HMI_ERROR("wm", "Could not initialize afb_instance event handler: %d", -ret); + HMI_ERROR("Could not initialize afb_instance event handler: %d", -ret); goto error; } } @@ -171,7 +165,7 @@ int binding_init() noexcept } catch (std::exception &e) { - HMI_ERROR("wm", "Uncaught exception in binding_init(): %s", e.what()); + HMI_ERROR("Uncaught exception in binding_init(): %s", e.what()); } return -1; } @@ -183,7 +177,7 @@ static void cbRemoveClientCtxt(void *data) { return; } - HMI_DEBUG("wm", "remove app %s", ctxt->name.c_str()); + HMI_DEBUG("remove app %s", ctxt->name.c_str()); // Policy Manager does not know this app was killed, // so notify it by deactivate request. @@ -192,7 +186,7 @@ static void cbRemoveClientCtxt(void *data) [](const char *errmsg) { if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); + HMI_ERROR(errmsg); return; } }); @@ -209,7 +203,7 @@ static void createSecurityContext(afb_req req, const char* appid, const char* ro // Create Security Context at first time const char *new_role = g_afb_instance->wmgr.convertRoleOldToNew(role); WMClientCtxt *ctxt = new WMClientCtxt(appid, new_role); - HMI_DEBUG("wm", "create session for %s", ctxt->name.c_str()); + HMI_DEBUG("create session for %s", ctxt->name.c_str()); afb_req_session_set_LOA(req, 1); afb_req_context_set(req, ctxt, cbRemoveClientCtxt); } @@ -218,9 +212,6 @@ static void createSecurityContext(afb_req req, const char* appid, const char* ro void windowmanager_requestsurface(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -259,9 +250,6 @@ void windowmanager_requestsurface(afb_req req) noexcept void windowmanager_requestsurfacexdg(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -311,9 +299,6 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept void windowmanager_activatewindow(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -342,7 +327,7 @@ void windowmanager_activatewindow(afb_req req) noexcept [&req](const char *errmsg) { if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); + HMI_ERROR(errmsg); afb_req_fail(req, "failed", errmsg); return; } @@ -351,7 +336,7 @@ void windowmanager_activatewindow(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "failed: Uncaught exception while calling activatesurface: %s", e.what()); + HMI_WARNING("failed: Uncaught exception while calling activatesurface: %s", e.what()); g_afb_instance->wmgr.exceptionProcessForTransition(); return; } @@ -360,9 +345,6 @@ void windowmanager_activatewindow(afb_req req) noexcept void windowmanager_deactivatewindow(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -383,7 +365,7 @@ void windowmanager_deactivatewindow(afb_req req) noexcept [&req](const char *errmsg) { if (errmsg != nullptr) { - HMI_ERROR("wm", errmsg); + HMI_ERROR(errmsg); afb_req_fail(req, "failed", errmsg); return; } @@ -392,7 +374,7 @@ void windowmanager_deactivatewindow(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "failed: Uncaught exception while calling deactivatesurface: %s", e.what()); + HMI_WARNING("failed: Uncaught exception while calling deactivatesurface: %s", e.what()); g_afb_instance->wmgr.exceptionProcessForTransition(); return; } @@ -401,9 +383,6 @@ void windowmanager_deactivatewindow(afb_req req) noexcept void windowmanager_enddraw(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -425,7 +404,7 @@ void windowmanager_enddraw(afb_req req) noexcept } catch (std::exception &e) { - HMI_WARNING("wm", "failed: Uncaught exception while calling enddraw: %s", e.what()); + HMI_WARNING("failed: Uncaught exception while calling enddraw: %s", e.what()); g_afb_instance->wmgr.exceptionProcessForTransition(); return; } @@ -434,9 +413,6 @@ void windowmanager_enddraw(afb_req req) noexcept void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -464,9 +440,6 @@ void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept void windowmanager_getareainfo_thunk(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -504,9 +477,6 @@ void windowmanager_getareainfo_thunk(afb_req req) noexcept void windowmanager_wm_subscribe(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -543,9 +513,6 @@ void windowmanager_wm_subscribe(afb_req req) noexcept void windowmanager_list_drawing_names(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -575,9 +542,6 @@ void windowmanager_list_drawing_names(afb_req req) noexcept void windowmanager_ping(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -601,9 +565,6 @@ void windowmanager_ping(afb_req req) noexcept void windowmanager_debug_status(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -630,9 +591,6 @@ void windowmanager_debug_status(afb_req req) noexcept void windowmanager_debug_layers(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -655,9 +613,6 @@ void windowmanager_debug_layers(afb_req req) noexcept void windowmanager_debug_surfaces(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); @@ -686,9 +641,6 @@ void windowmanager_debug_surfaces(afb_req req) noexcept void windowmanager_debug_terminate(afb_req req) noexcept { std::lock_guard guard(binding_m); -#ifdef ST - ST(); -#endif if (g_afb_instance == nullptr) { afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?"); diff --git a/src/pm_wrapper.cpp b/src/pm_wrapper.cpp index 1454bf9..d71e91f 100644 --- a/src/pm_wrapper.cpp +++ b/src/pm_wrapper.cpp @@ -16,7 +16,7 @@ #include "pm_wrapper.hpp" #include "json_helper.hpp" -#include "hmi-debug.h" +#include "util.hpp" namespace wm { @@ -33,7 +33,7 @@ static void onStateTransitioned(json_object *json_out) static void onError(json_object *json_out) { - HMI_DEBUG("wm", "error message from PolicyManager:%s", + HMI_DEBUG("error message from PolicyManager:%s", json_object_get_string(json_out)); g_context->processError(); @@ -50,7 +50,7 @@ int PMWrapper::initialize() ret = this->pm.initialize(); if (0 > ret) { - HMI_ERROR("wm:pmw", "Faild to initialize PolicyManager"); + HMI_ERROR("Faild to initialize PolicyManager"); } g_context = this; @@ -95,7 +95,7 @@ int PMWrapper::setInputEventData(Task task, std::string role, std::string area) ret = this->pm.setInputEventData(json_in); if (0 > ret) { - HMI_ERROR("wm:pmw", "Faild to set input event data to PolicyManager"); + HMI_ERROR("Faild to set input event data to PolicyManager"); } json_object_put(json_in); @@ -108,7 +108,7 @@ int PMWrapper::executeStateTransition() ret = this->pm.executeStateTransition(); if (0 > ret) { - HMI_ERROR("wm:pmw", "Failed to execute state transition for PolicyManager"); + HMI_ERROR("Failed to execute state transition for PolicyManager"); } return ret; @@ -125,7 +125,7 @@ void PMWrapper::updateStates(json_object *json_out) { std::vector actions; - HMI_DEBUG("wm", "json_out dump:%s", json_object_get_string(json_out)); + HMI_DEBUG("json_out dump:%s", json_object_get_string(json_out)); this->createLayoutChangeAction(json_out, actions); @@ -138,12 +138,12 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vectorprvlayer2rolestate[layer_name] = this->crrlayer2rolestate[layer_name]; @@ -180,13 +180,13 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vectorfirst.c_str(), i_prv->second.c_str()); // If current role exists in previous and area is different with previous if (area_name != i_prv->second) { - HMI_DEBUG("wm", "current role exists in previous and area is different with previous"); + HMI_DEBUG("current role exists in previous and area is different with previous"); // Set activate action bool end_draw_finished = false; @@ -232,7 +232,7 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector -#include -#include -#include -#include +#include +#include +#include +#include #include -#ifdef SCOPE_TRACING -thread_local int ScopeTrace::indent = 0; -ScopeTrace::ScopeTrace(char const *func) : f(func) -{ - fprintf(stderr, "%lu %*s%s -->\n", pthread_self(), 2 * indent++, "", this->f); -} -ScopeTrace::~ScopeTrace() { fprintf(stderr, "%lu %*s%s <--\n", pthread_self(), 2 * --indent, "", this->f); } -#endif - -unique_fd::~unique_fd() -{ - if (this->fd != -1) - { - close(this->fd); - } -} +static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}; void rectangle::fit(unsigned long to_width, unsigned long to_height) { @@ -93,3 +77,66 @@ void rectangle::set_aspect(double ratio) } } +void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...) +{ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL)?LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); + if(log_level < level) + { + return; + } + + char *message; + struct timespec tp; + unsigned int time; + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message); + va_end(args); + free(message); +} + +void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...){ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR:atoi(getenv("USE_HMI_DEBUG")); + if(log_level < level) + { + return; + } + + char *message; + struct timespec tp; + unsigned int time; + + clock_gettime(CLOCK_REALTIME, &tp); + time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000); + + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "[%10.3f] [wm %s] [%s, %s(), Line:%d] >>> req %d: %s \n", time / 1000.0, ERROR_FLAG[level], file, func, line, seq_num, message); + va_end(args); + free(message); +} + +void _DUMP(enum LOG_LEVEL level, const char *log, ...) +{ + const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG")); + if (log_level < level) + { + return; + } + char *message; + va_list args; + va_start(args, log); + if (log == NULL || vasprintf(&message, log, args) < 0) + message = NULL; + fprintf(stderr, "%s \n", message); + va_end(args); + free(message); +} \ No newline at end of file diff --git a/src/util.hpp b/src/util.hpp index 2f17845..812a130 100644 --- a/src/util.hpp +++ b/src/util.hpp @@ -19,75 +19,38 @@ #include #include -#include - #include - -#ifndef DO_NOT_USE_AFB -extern "C" -{ -#include +#include + +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#define HMI_ERROR(args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__,"wm",args, ##__VA_ARGS__) +#define HMI_WARNING(args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__) +#define HMI_NOTICE(args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__) +#define HMI_INFO(args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__) +#define HMI_DEBUG(args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, "wm", args,##__VA_ARGS__) + +#define HMI_SEQ_ERROR(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) +#define HMI_SEQ_WARNING(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) +#define HMI_SEQ_NOTICE(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) +#define HMI_SEQ_INFO(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) +#define HMI_SEQ_DEBUG(seq_num, args,...) _HMI_SEQ_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__, __LINE__, seq_num, args, ##__VA_ARGS__) + +#define DUMP(args, ...) _DUMP(LOG_LEVEL_DEBUG, args, ##__VA_ARGS__) + +enum LOG_LEVEL{ + LOG_LEVEL_NONE = 0, + LOG_LEVEL_ERROR, + LOG_LEVEL_WARNING, + LOG_LEVEL_NOTICE, + LOG_LEVEL_INFO, + LOG_LEVEL_DEBUG, + LOG_LEVEL_MAX = LOG_LEVEL_DEBUG }; -#endif - -#define CONCAT_(X, Y) X##Y -#define CONCAT(X, Y) CONCAT_(X, Y) - -#ifdef __GNUC__ -#define ATTR_FORMAT(stringindex, firsttocheck) \ - __attribute__((format(printf, stringindex, firsttocheck))) -#define ATTR_NORETURN __attribute__((noreturn)) -#else -#define ATTR_FORMAT(stringindex, firsttocheck) -#define ATTR_NORETURN -#endif - -#ifdef AFB_BINDING_VERSION -#define lognotice(...) AFB_NOTICE(__VA_ARGS__) -#define logerror(...) AFB_ERROR(__VA_ARGS__) -#define fatal(...) \ - do \ - { \ - AFB_ERROR(__VA_ARGS__); \ - abort(); \ - } while (0) -#else -#define lognotice(...) -#define logerror(...) -#define fatal(...) \ - do \ - { \ - abort(); \ - } while (0) -#endif - -#ifdef DEBUG_OUTPUT -#ifdef AFB_BINDING_VERSION -#define logdebug(...) AFB_DEBUG(__VA_ARGS__) -#else -#define logdebug(...) -#endif -#else -#define logdebug(...) -#endif - -#ifndef SCOPE_TRACING -#define ST() -#define STN(N) -#else -#define ST() \ - ScopeTrace __attribute__((unused)) CONCAT(trace_scope_, __LINE__)(__func__) -#define STN(N) \ - ScopeTrace __attribute__((unused)) CONCAT(named_trace_scope_, __LINE__)(#N) - -struct ScopeTrace -{ - thread_local static int indent; - char const *f{}; - explicit ScopeTrace(char const *func); - ~ScopeTrace(); -}; -#endif + +void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...); +void _HMI_SEQ_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, unsigned seq_num, const char* log, ...); +void _DUMP(enum LOG_LEVEL level, const char *log, ...); /** * @struct unique_fd diff --git a/src/wayland_ivi_wm.cpp b/src/wayland_ivi_wm.cpp index 8b04c64..bbf745b 100644 --- a/src/wayland_ivi_wm.cpp +++ b/src/wayland_ivi_wm.cpp @@ -15,7 +15,6 @@ */ #include "wayland_ivi_wm.hpp" -#include "hmi-debug.h" /** * namespace wl @@ -41,10 +40,8 @@ int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get int display::read_events() { - ST(); while (wl_display_prepare_read(this->d.get()) == -1) { - STN(pending_events_dispatch); if (wl_display_dispatch_pending(this->d.get()) == -1) { return -1; @@ -112,7 +109,7 @@ void registry::global_created(uint32_t name, char const *iface, uint32_t v) { b->second(this->proxy.get(), name, v); } - HMI_DEBUG("wm", "wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name, + HMI_DEBUG("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name, iface, v); } @@ -163,8 +160,7 @@ void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, int32_t subpel, char const *make, char const *model, int32_t tx) { - HMI_DEBUG("wm", - "wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i", + HMI_DEBUG("wl::output %s @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i", __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx); this->physical_width = pw; this->physical_height = ph; @@ -173,7 +169,7 @@ void output::geometry(int32_t x, int32_t y, int32_t pw, int32_t ph, void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) { - HMI_DEBUG("wm", "wl::output %s @ %p f %x w %i h %i r %i", __func__, + HMI_DEBUG("wl::output %s @ %p f %x w %i h %i r %i", __func__, this->proxy.get(), flags, w, h, r); if ((flags & WL_OUTPUT_MODE_CURRENT) != 0u) { @@ -185,7 +181,7 @@ void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r) void output::done() { - HMI_DEBUG("wm", "wl::output %s @ %p done", __func__, this->proxy.get()); + HMI_DEBUG("wl::output %s @ %p done", __func__, this->proxy.get()); // Pivot and flipped if (this->transform == WL_OUTPUT_TRANSFORM_90 || this->transform == WL_OUTPUT_TRANSFORM_270 || @@ -199,7 +195,7 @@ void output::done() void output::scale(int32_t factor) { - HMI_DEBUG("wm", "wl::output %s @ %p f %i", __func__, this->proxy.get(), factor); + HMI_DEBUG("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor); } } // namespace wl @@ -363,14 +359,14 @@ void layer_added(void *data, struct ivi_wm_screen *ivi_wm_screen, uint32_t layer_id) { - HMI_DEBUG("wm", "added layer_id:%d", layer_id); + HMI_DEBUG("added layer_id:%d", layer_id); } void connector_name(void *data, struct ivi_wm_screen *ivi_wm_screen, const char *process_name) { - HMI_DEBUG("wm", "process_name:%s", process_name); + HMI_DEBUG("process_name:%s", process_name); } void screen_error(void *data, @@ -378,7 +374,7 @@ void screen_error(void *data, uint32_t error, const char *message) { - HMI_DEBUG("wm", "screen error:%d message:%s", error, message); + HMI_DEBUG("screen error:%d message:%s", error, message); } constexpr struct ivi_wm_screen_listener screen_listener = { @@ -400,7 +396,7 @@ surface::surface(uint32_t i, struct controller *c) void surface::set_visibility(uint32_t visibility) { - HMI_DEBUG("wm", "compositor::surface id:%d v:%d", this->id, visibility); + HMI_DEBUG("compositor::surface id:%d v:%d", this->id, visibility); ivi_wm_set_surface_visibility(this->parent->proxy.get(), this->id, visibility); } @@ -459,7 +455,7 @@ screen::screen(uint32_t i, struct controller *c, struct wl_output *o) : wayland_proxy(ivi_wm_create_screen(c->proxy.get(), o)), controller_child(c, i) { - HMI_DEBUG("wm", "compositor::screen @ %p id %u o %p", this->proxy.get(), i, o); + HMI_DEBUG("compositor::screen @ %p id %u o %p", this->proxy.get(), i, o); // Add listener for screen ivi_wm_screen_add_listener(this->proxy.get(), &screen_listener, this); @@ -469,7 +465,7 @@ void screen::clear() { ivi_wm_screen_clear(this->proxy.get()); } void screen::screen_created(struct screen *screen, uint32_t id) { - HMI_DEBUG("wm", "compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(), + HMI_DEBUG("compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(), id, id, screen); this->id = id; this->parent->screens[id] = screen; @@ -484,7 +480,7 @@ void screen::set_render_order(std::vector const &ro) for (i = 0; i < ro.size(); i++) { - HMI_DEBUG("wm", "compositor::screen @ %p add layer %u", this->proxy.get(), ro[i]); + HMI_DEBUG("compositor::screen @ %p add layer %u", this->proxy.get(), ro[i]); // Add the layer to screen render order at nearest z-position ivi_wm_screen_add_layer(this->proxy.get(), ro[i]); } @@ -538,10 +534,10 @@ void controller::get_surface_properties(uint32_t surface_id, int param) void controller::layer_created(uint32_t id) { - HMI_DEBUG("wm", "compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id); + HMI_DEBUG("compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id); if (this->layers.find(id) != this->layers.end()) { - HMI_DEBUG("wm", "WindowManager has created layer %u (%x) already", id, id); + HMI_DEBUG("WindowManager has created layer %u (%x) already", id, id); } else { @@ -552,13 +548,13 @@ void controller::layer_created(uint32_t id) void controller::layer_error_detected(uint32_t object_id, uint32_t error_code, const char *error_text) { - HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s", + HMI_DEBUG("compositor::controller @ %p error o %d c %d text %s", this->proxy.get(), object_id, error_code, error_text); } void controller::surface_visibility_changed(uint32_t id, int32_t visibility) { - HMI_DEBUG("wm", "compositor::surface %s @ %d v %i", __func__, id, + HMI_DEBUG("compositor::surface %s @ %d v %i", __func__, id, visibility); this->sprops[id].visibility = visibility; this->chooks->surface_visibility(id, visibility); @@ -566,7 +562,7 @@ void controller::surface_visibility_changed(uint32_t id, int32_t visibility) void controller::surface_opacity_changed(uint32_t id, float opacity) { - HMI_DEBUG("wm", "compositor::surface %s @ %d o %f", + HMI_DEBUG("compositor::surface %s @ %d o %f", __func__, id, opacity); this->sprops[id].opacity = opacity; } @@ -575,7 +571,7 @@ void controller::surface_source_rectangle_changed(uint32_t id, int32_t x, int32_t y, int32_t width, int32_t height) { - HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__, + HMI_DEBUG("compositor::surface %s @ %d x %i y %i w %i h %i", __func__, id, x, y, width, height); this->sprops[id].src_rect = rect{width, height, x, y}; } @@ -584,7 +580,7 @@ void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x, int32_t y, int32_t width, int32_t height) { - HMI_DEBUG("wm", "compositor::surface %s @ %d x %i y %i w %i h %i", __func__, + HMI_DEBUG("compositor::surface %s @ %d x %i y %i w %i h %i", __func__, id, x, y, width, height); this->sprops[id].dst_rect = rect{width, height, x, y}; this->chooks->surface_destination_rectangle(id, x, y, width, height); @@ -593,7 +589,7 @@ void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x, void controller::surface_size_changed(uint32_t id, int32_t width, int32_t height) { - HMI_DEBUG("wm", "compositor::surface %s @ %d w %i h %i", __func__, id, + HMI_DEBUG("compositor::surface %s @ %d w %i h %i", __func__, id, width, height); this->sprops[id].size = size{uint32_t(width), uint32_t(height)}; this->surfaces[id]->set_source_rectangle(0, 0, width, height); @@ -601,20 +597,20 @@ void controller::surface_size_changed(uint32_t id, int32_t width, void controller::surface_added_to_layer(uint32_t layer_id, uint32_t surface_id) { - HMI_DEBUG("wm", "compositor::surface %s @ %d l %u", + HMI_DEBUG("compositor::surface %s @ %d l %u", __func__, layer_id, surface_id); } void controller::surface_stats_received(uint32_t surface_id, uint32_t frame_count, uint32_t pid) { - HMI_DEBUG("wm", "compositor::surface %s @ %d f %u pid %u", + HMI_DEBUG("compositor::surface %s @ %d f %u pid %u", __func__, surface_id, frame_count, pid); } void controller::surface_created(uint32_t id) { - HMI_DEBUG("wm", "compositor::controller @ %p surface %u (%x)", this->proxy.get(), id, + HMI_DEBUG("compositor::controller @ %p surface %u (%x)", this->proxy.get(), id, id); if (this->surfaces.find(id) == this->surfaces.end()) { @@ -632,7 +628,7 @@ void controller::surface_created(uint32_t id) void controller::surface_destroyed(uint32_t surface_id) { - HMI_DEBUG("wm", "compositor::surface %s @ %d", __func__, surface_id); + HMI_DEBUG("compositor::surface %s @ %d", __func__, surface_id); this->chooks->surface_removed(surface_id); this->sprops.erase(surface_id); this->surfaces.erase(surface_id); @@ -641,19 +637,19 @@ void controller::surface_destroyed(uint32_t surface_id) void controller::surface_error_detected(uint32_t object_id, uint32_t error_code, const char *error_text) { - HMI_DEBUG("wm", "compositor::controller @ %p error o %d c %d text %s", + HMI_DEBUG("compositor::controller @ %p error o %d c %d text %s", this->proxy.get(), object_id, error_code, error_text); } void controller::layer_visibility_changed(uint32_t layer_id, int32_t visibility) { - HMI_DEBUG("wm", "compositor::layer %s @ %d v %i", __func__, layer_id, visibility); + HMI_DEBUG("compositor::layer %s @ %d v %i", __func__, layer_id, visibility); this->lprops[layer_id].visibility = visibility; } void controller::layer_opacity_changed(uint32_t layer_id, float opacity) { - HMI_DEBUG("wm", "compositor::layer %s @ %d o %f", __func__, layer_id, opacity); + HMI_DEBUG("compositor::layer %s @ %d o %f", __func__, layer_id, opacity); this->lprops[layer_id].opacity = opacity; } @@ -661,7 +657,7 @@ void controller::layer_source_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y, int32_t width, int32_t height) { - HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i", + HMI_DEBUG("compositor::layer %s @ %d x %i y %i w %i h %i", __func__, layer_id, x, y, width, height); this->lprops[layer_id].src_rect = rect{width, height, x, y}; } @@ -670,14 +666,14 @@ void controller::layer_destination_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y, int32_t width, int32_t height) { - HMI_DEBUG("wm", "compositor::layer %s @ %d x %i y %i w %i h %i", + HMI_DEBUG("compositor::layer %s @ %d x %i y %i w %i h %i", __func__, layer_id, x, y, width, height); this->lprops[layer_id].dst_rect = rect{width, height, x, y}; } void controller::layer_destroyed(uint32_t layer_id) { - HMI_DEBUG("wm", "compositor::layer %s @ %d", __func__, layer_id); + HMI_DEBUG("compositor::layer %s @ %d", __func__, layer_id); this->lprops.erase(layer_id); this->layers.erase(layer_id); } @@ -685,40 +681,40 @@ void controller::layer_destroyed(uint32_t layer_id) void controller::add_proxy_to_sid_mapping(struct ivi_wm *p, uint32_t id) { - HMI_DEBUG("wm", "Add surface proxy mapping for %p (%u)", p, id); + HMI_DEBUG("Add surface proxy mapping for %p (%u)", p, id); this->surface_proxy_to_id[uintptr_t(p)] = id; this->sprops[id].id = id; } void controller::remove_proxy_to_sid_mapping(struct ivi_wm *p) { - HMI_DEBUG("wm", "Remove surface proxy mapping for %p", p); + HMI_DEBUG("Remove surface proxy mapping for %p", p); this->surface_proxy_to_id.erase(uintptr_t(p)); } void controller::add_proxy_to_lid_mapping(struct ivi_wm *p, uint32_t id) { - HMI_DEBUG("wm", "Add layer proxy mapping for %p (%u)", p, id); + HMI_DEBUG("Add layer proxy mapping for %p (%u)", p, id); this->layer_proxy_to_id[uintptr_t(p)] = id; this->lprops[id].id = id; } void controller::remove_proxy_to_lid_mapping(struct ivi_wm *p) { - HMI_DEBUG("wm", "Remove layer proxy mapping for %p", p); + HMI_DEBUG("Remove layer proxy mapping for %p", p); this->layer_proxy_to_id.erase(uintptr_t(p)); } void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) { - HMI_DEBUG("wm", "Add screen proxy mapping for %p (%u)", p, id); + HMI_DEBUG("Add screen proxy mapping for %p (%u)", p, id); this->screen_proxy_to_id[uintptr_t(p)] = id; } void controller::remove_proxy_to_id_mapping(struct wl_output *p) { - HMI_DEBUG("wm", "Remove screen proxy mapping for %p", p); + HMI_DEBUG("Remove screen proxy mapping for %p", p); this->screen_proxy_to_id.erase(uintptr_t(p)); } diff --git a/src/window_manager.cpp b/src/window_manager.cpp index 42930dc..a852529 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -68,7 +68,7 @@ result file_to_json(char const *filename) std::ifstream i(filename); if (i.fail()) { - HMI_DEBUG("wm", "Could not open config file, so use default layer information"); + HMI_DEBUG("Could not open config file, so use default layer information"); j = default_layers_json; } else @@ -81,7 +81,7 @@ result file_to_json(char const *filename) struct result load_layer_map(char const *filename) { - HMI_DEBUG("wm", "loading IDs from %s", filename); + HMI_DEBUG("loading IDs from %s", filename); auto j = file_to_json(filename); if (j.is_err()) @@ -95,7 +95,7 @@ struct result load_layer_map(char const *filename) static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata) { - HMI_NOTICE("wm", "Time out occurs because the client replys endDraw slow, so revert the request"); + HMI_NOTICE("Time out occurs because the client replys endDraw slow, so revert the request"); reinterpret_cast(userdata)->timerHandler(); return 0; } @@ -127,7 +127,7 @@ WindowManager::WindowManager(wl::display *d) std::string path; if (!path_layers_json) { - HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined"); + HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); path = std::string(path_layers_json); } else @@ -145,13 +145,13 @@ WindowManager::WindowManager(wl::display *d) } else { - HMI_ERROR("wm", "%s", l.err().value()); + HMI_ERROR("%s", l.err().value()); } } } catch (std::exception &e) { - HMI_ERROR("wm", "Loading of configuration failed: %s", e.what()); + HMI_ERROR("Loading of configuration failed: %s", e.what()); } } @@ -164,7 +164,7 @@ int WindowManager::init() if (this->layers.mapping.empty()) { - HMI_ERROR("wm", "No surface -> layer mapping loaded"); + HMI_ERROR("No surface -> layer mapping loaded"); return -1; } @@ -252,7 +252,7 @@ result WindowManager::api_request_surface(char const *appid, char const *dr * register drawing_name as fallback and make it displayed. */ lid = this->layers.get_layer_id(std::string("fallback")); - HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role); + HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { return Err("Drawing name does not match any role, fallback is disabled"); @@ -271,7 +271,7 @@ result WindowManager::api_request_surface(char const *appid, char const *dr this->layers.main_surface_name == drawing_name) { this->layers.main_surface = id; - HMI_DEBUG("wm", "Set main_surface id to %u", id); + HMI_DEBUG("Set main_surface id to %u", id); } // add client into the db @@ -291,8 +291,6 @@ result WindowManager::api_request_surface(char const *appid, char const *dr char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name, char const *ivi_id) { - ST(); - // TODO: application requests by old role, // so convert role old to new const char *role = this->convertRoleOldToNew(drawing_name); @@ -306,7 +304,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr * register drawing_name as fallback and make it displayed. */ lid = this->layers.get_layer_id(std::string("fallback")); - HMI_DEBUG("wm", "%s is not registered in layers.json, then fallback as normal app", role); + HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { return "Drawing name does not match any role, fallback is disabled"; @@ -325,7 +323,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr this->layers.add_surface(sid, *lid); // this surface is already created - HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", sid, *lid); + HMI_DEBUG("surface_id is %u, layer_id is %u", sid, *lid); this->controller->layers[*lid]->add_surface(sid); this->layout_commit(); @@ -343,8 +341,6 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr void WindowManager::api_activate_surface(char const *appid, char const *drawing_name, char const *drawing_area, const reply_func &reply) { - ST(); - // TODO: application requests by old role, // so convert role old to new const char *c_role = this->convertRoleOldToNew(drawing_name); @@ -360,7 +356,7 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_ if(ret != WMError::SUCCESS) { - HMI_ERROR("wm", errorDescription(ret)); + HMI_ERROR(errorDescription(ret)); reply("Failed to set request"); return; } @@ -390,8 +386,6 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_ void WindowManager::api_deactivate_surface(char const *appid, char const *drawing_name, const reply_func &reply) { - ST(); - // TODO: application requests by old role, // so convert role old to new const char *c_role = this->convertRoleOldToNew(drawing_name); @@ -410,7 +404,7 @@ void WindowManager::api_deactivate_surface(char const *appid, char const *drawin if (ret != WMError::SUCCESS) { - HMI_ERROR("wm", errorDescription(ret)); + HMI_ERROR(errorDescription(ret)); reply("Failed to set request"); return; } @@ -450,7 +444,7 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) if (!result) { - HMI_ERROR("wm", "%s is not in transition state", id.c_str()); + HMI_ERROR("%s is not in transition state", id.c_str()); return; } @@ -504,7 +498,7 @@ result WindowManager::api_get_display_info() result WindowManager::api_get_area_info(char const *drawing_name) { - HMI_DEBUG("wm", "called"); + HMI_DEBUG("called"); // TODO: application requests by old role, // so convert role old to new @@ -543,7 +537,7 @@ void WindowManager::api_ping() { this->dispatch_pending_events(); } void WindowManager::send_event(char const *evname, char const *label) { - HMI_DEBUG("wm", "%s: %s(%s)", __func__, evname, label); + HMI_DEBUG("%s: %s(%s)", __func__, evname, label); json_object *j = json_object_new_object(); json_object_object_add(j, kKeyDrawingName, json_object_new_string(label)); @@ -551,14 +545,14 @@ void WindowManager::send_event(char const *evname, char const *label) int ret = afb_event_push(this->map_afb_event[evname], j); if (ret != 0) { - HMI_DEBUG("wm", "afb_event_push failed: %m"); + HMI_DEBUG("afb_event_push failed: %m"); } } void WindowManager::send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h) { - HMI_DEBUG("wm", "%s: %s(%s, %s) x:%d y:%d w:%d h:%d", + HMI_DEBUG("%s: %s(%s, %s) x:%d y:%d w:%d h:%d", __func__, evname, label, area, x, y, w, h); json_object *j_rect = json_object_new_object(); @@ -575,7 +569,7 @@ void WindowManager::send_event(char const *evname, char const *label, char const int ret = afb_event_push(this->map_afb_event[evname], j); if (ret != 0) { - HMI_DEBUG("wm", "afb_event_push failed: %m"); + HMI_DEBUG("afb_event_push failed: %m"); } } @@ -589,12 +583,12 @@ void WindowManager::surface_created(uint32_t surface_id) auto layer_id = this->layers.get_layer_id(surface_id); if (!layer_id) { - HMI_DEBUG("wm", "Newly created surfce %d is not associated with any layer!", + HMI_DEBUG("Newly created surfce %d is not associated with any layer!", surface_id); return; } - HMI_DEBUG("wm", "surface_id is %u, layer_id is %u", surface_id, *layer_id); + HMI_DEBUG("surface_id is %u, layer_id is %u", surface_id, *layer_id); this->controller->layers[*layer_id]->add_surface(surface_id); this->layout_commit(); @@ -602,7 +596,7 @@ void WindowManager::surface_created(uint32_t surface_id) void WindowManager::surface_removed(uint32_t surface_id) { - HMI_DEBUG("wm", "Delete surface_id %u", surface_id); + HMI_DEBUG("Delete surface_id %u", surface_id); this->id_alloc.remove_id(surface_id); this->layers.remove_surface(surface_id); g_app_list.removeSurface(surface_id); @@ -610,7 +604,7 @@ void WindowManager::surface_removed(uint32_t surface_id) void WindowManager::removeClient(const std::string &appid) { - HMI_DEBUG("wm", "Remove clinet %s from list", appid.c_str()); + HMI_DEBUG("Remove clinet %s from list", appid.c_str()); g_app_list.removeClient(appid); } @@ -751,13 +745,13 @@ int WindowManager::init_layers() { if (!this->controller) { - HMI_ERROR("wm", "ivi_controller global not available"); + HMI_ERROR("ivi_controller global not available"); return -1; } if (this->outputs.empty()) { - HMI_ERROR("wm", "no output was set up!"); + HMI_ERROR("no output was set up!"); return -1; } @@ -773,7 +767,7 @@ int WindowManager::init_layers() uint32_t(o->physical_height)}; - HMI_DEBUG("wm", "SCALING: screen (%dx%d), physical (%dx%d)", + HMI_DEBUG("SCALING: screen (%dx%d), physical (%dx%d)", o->width, o->height, o->physical_width, o->physical_height); this->layers.loadAreaDb(); @@ -784,7 +778,7 @@ int WindowManager::init_layers() dp_bg.set_aspect(static_cast(css_bg.w) / css_bg.h); dp_bg.fit(o->width, o->height); dp_bg.center(o->width, o->height); - HMI_DEBUG("wm", "SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)", + HMI_DEBUG("SCALING: CSS BG(%dx%d) -> DDP %dx%d,(%dx%d)", css_bg.w, css_bg.h, dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); // Clear scene @@ -800,7 +794,7 @@ int WindowManager::init_layers() auto &l = layers[i.second.layer_id]; l->set_destination_rectangle(dp_bg.left(), dp_bg.top(), dp_bg.width(), dp_bg.height()); l->set_visibility(1); - HMI_DEBUG("wm", "Setting up layer %s (%d) for surface role match \"%s\"", + HMI_DEBUG("Setting up layer %s (%d) for surface role match \"%s\"", i.second.name.c_str(), i.second.layer_id, i.second.role.c_str()); } @@ -819,7 +813,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area) { if (!this->controller->surface_exists(surface_id)) { - HMI_ERROR("wm", "Surface %d does not exist", surface_id); + HMI_ERROR("Surface %d does not exist", surface_id); return; } @@ -827,7 +821,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area) if (!o_layer_id) { - HMI_ERROR("wm", "Surface %d is not associated with any layer!", surface_id); + HMI_ERROR("Surface %d is not associated with any layer!", surface_id); return; } @@ -844,7 +838,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area) int w = rect.w; int h = rect.h; - HMI_DEBUG("wm", "surface_set_layout for surface %u on layer %u", surface_id, + HMI_DEBUG("surface_set_layout for surface %u on layer %u", surface_id, layer_id); // set destination to the display rectangle @@ -856,7 +850,7 @@ void WindowManager::surface_set_layout(int surface_id, const std::string& area) this->area_info[surface_id].w = w; this->area_info[surface_id].h = h; - HMI_DEBUG("wm", "Surface %u now on layer %u with rect { %d, %d, %d, %d }", + HMI_DEBUG("Surface %u now on layer %u with rect { %d, %d, %d, %d }", surface_id, layer_id, x, y, w, h); } @@ -928,16 +922,16 @@ void WindowManager::activate(int id) this->surface_bg.erase(i); // Remove from BG layer (999) - HMI_DEBUG("wm", "Remove %s(%d) from BG layer", label, id); + HMI_DEBUG("Remove %s(%d) from BG layer", label, id); this->controller->layers[999]->remove_surface(id); // Add to FG layer (1001) - HMI_DEBUG("wm", "Add %s(%d) to FG layer", label, id); + HMI_DEBUG("Add %s(%d) to FG layer", label, id); this->controller->layers[1001]->add_surface(id); for (int j : this->surface_bg) { - HMI_DEBUG("wm", "Stored id:%d", j); + HMI_DEBUG("Stored id:%d", j); } break; } @@ -975,16 +969,16 @@ void WindowManager::deactivate(int id) this->surface_bg.push_back(id); // Remove from FG layer (1001) - HMI_DEBUG("wm", "Remove %s(%d) from FG layer", label, id); + HMI_DEBUG("Remove %s(%d) from FG layer", label, id); this->controller->layers[1001]->remove_surface(id); // Add to BG layer (999) - HMI_DEBUG("wm", "Add %s(%d) to BG layer", label, id); + HMI_DEBUG("Add %s(%d) to BG layer", label, id); this->controller->layers[999]->add_surface(id); for (int j : surface_bg) { - HMI_DEBUG("wm", "Stored id:%d", j); + HMI_DEBUG("Stored id:%d", j); } } else @@ -1281,7 +1275,7 @@ void WindowManager::emitScreenUpdated(unsigned req_num) this->map_afb_event[kListEventName[Event_ScreenUpdated]], j); if (ret != 0) { - HMI_DEBUG("wm", "afb_event_push failed: %m"); + HMI_DEBUG("afb_event_push failed: %m"); } } @@ -1289,7 +1283,7 @@ void WindowManager::setTimer() { struct timespec ts; if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) { - HMI_ERROR("wm", "Could't set time (clock_gettime() returns with error"); + HMI_ERROR("Could't set time (clock_gettime() returns with error"); return; } @@ -1301,7 +1295,7 @@ void WindowManager::setTimer() CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this); if (ret < 0) { - HMI_ERROR("wm", "Could't set timer"); + HMI_ERROR("Could't set timer"); } } else @@ -1364,7 +1358,7 @@ const char* WindowManager::convertRoleOldToNew(char const *old_role) new_role = old_role; } - HMI_DEBUG("wm", "old:%s -> new:%s", old_role, new_role); + HMI_DEBUG("old:%s -> new:%s", old_role, new_role); return new_role; } @@ -1373,12 +1367,12 @@ int WindowManager::loadOldRoleDb() { // Get afm application installed dir char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR"); - HMI_DEBUG("wm", "afm_app_install_dir:%s", afm_app_install_dir); + HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir); std::string file_name; if (!afm_app_install_dir) { - HMI_ERROR("wm", "AFM_APP_INSTALL_DIR is not defined"); + HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); } else { @@ -1390,22 +1384,22 @@ int WindowManager::loadOldRoleDb() int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj); if (0 > ret) { - HMI_ERROR("wm", "Could not open old_role.db, so use default old_role information"); + HMI_ERROR("Could not open old_role.db, so use default old_role information"); json_obj = json_tokener_parse(kDefaultOldRoleDb); } - HMI_DEBUG("wm", "json_obj dump:%s", json_object_get_string(json_obj)); + HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj)); // Perse apps json_object* json_cfg; if (!json_object_object_get_ex(json_obj, "old_roles", &json_cfg)) { - HMI_ERROR("wm", "Parse Error!!"); + HMI_ERROR("Parse Error!!"); return -1; } int len = json_object_array_length(json_cfg); - HMI_DEBUG("wm", "json_cfg len:%d", len); - HMI_DEBUG("wm", "json_cfg dump:%s", json_object_get_string(json_cfg)); + HMI_DEBUG("json_cfg len:%d", len); + HMI_DEBUG("json_cfg dump:%s", json_object_get_string(json_cfg)); for (int i=0; iroleold2new.begin(); itr != this->roleold2new.end(); ++itr) { - HMI_DEBUG("wm", ">>> role old:%s new:%s", + HMI_DEBUG(">>> role old:%s new:%s", itr->first.c_str(), itr->second.c_str()); } @@ -1462,7 +1456,7 @@ const char *WindowManager::check_surface_exist(const char *drawing_name) return "Surface is not on any layer!"; } - HMI_DEBUG("wm", "surface %d is detected", *surface_id); + HMI_DEBUG("surface %d is detected", *surface_id); return nullptr; } diff --git a/src/window_manager.hpp b/src/window_manager.hpp index 6cbd355..f23719f 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -14,21 +14,25 @@ * limitations under the License. */ -#ifndef TMCAGLWM_APP_HPP -#define TMCAGLWM_APP_HPP +#ifndef WINDOW_MANAGER_HPP +#define WINDOW_MANAGER_HPP #include #include #include #include +#include "util.hpp" #include "controller_hooks.hpp" #include "layers.hpp" #include "layout.hpp" #include "wayland_ivi_wm.hpp" #include "pm_wrapper.hpp" -#include "hmi-debug.h" #include "request.hpp" #include "wm_error.hpp" +extern "C" +{ +#include +} struct json_object; @@ -88,7 +92,7 @@ struct id_allocator unsigned sid = this->next++; this->id2name[sid] = name; this->name2id[name] = sid; - HMI_DEBUG("wm", "allocated new id %u with name %s", sid, name.c_str()); + HMI_DEBUG("allocated new id %u with name %s", sid, name.c_str()); return sid; } @@ -97,7 +101,7 @@ struct id_allocator { this->id2name[sid] = name; this->name2id[name] = sid; - HMI_DEBUG("wm", "register id %u with name %s", sid, name.c_str()); + HMI_DEBUG("register id %u with name %s", sid, name.c_str()); return; } @@ -286,4 +290,4 @@ class WindowManager } // namespace wm -#endif // TMCAGLWM_APP_HPP +#endif // WINDOW_MANAGER_HPP diff --git a/src/wm_client.cpp b/src/wm_client.cpp index 09e2e00..2e12a69 100644 --- a/src/wm_client.cpp +++ b/src/wm_client.cpp @@ -16,7 +16,7 @@ #include #include "wm_client.hpp" -#include "hmi-debug.h" +#include "util.hpp" #define INVALID_SURFACE_ID 0 @@ -137,10 +137,10 @@ void WMClient::registerLayer(unsigned layer) */ bool WMClient::addSurface(const string &role, unsigned surface) { - HMI_DEBUG("wm", "Add role %s with surface %d", role.c_str(), surface); + HMI_DEBUG("Add role %s with surface %d", role.c_str(), surface); if (0 != this->role2surface.count(role)) { - HMI_NOTICE("wm", "override surfaceID %d with %d", this->role2surface[role], surface); + HMI_NOTICE("override surfaceID %d with %d", this->role2surface[role], surface); } this->role2surface[role] = surface; return true; @@ -153,7 +153,7 @@ bool WMClient::removeSurfaceIfExist(unsigned surface) { if (surface == x.second) { - HMI_INFO("wm", "Remove surface from client %s: role %s, surface: %d", + HMI_INFO("Remove surface from client %s: role %s, surface: %d", this->id.c_str(), x.first.c_str(), x.second); this->role2surface.erase(x.first); ret = true; @@ -178,13 +178,13 @@ bool WMClient::removeRole(const string &role) bool WMClient::subscribe(afb_req req, const string &evname) { if(evname != kKeyError){ - HMI_DEBUG("wm", "error is only enabeled for now"); + HMI_DEBUG("error is only enabeled for now"); return false; } int ret = afb_req_subscribe(req, this->event2list[evname]); if (ret) { - HMI_DEBUG("wm", "Failed to subscribe %s", evname.c_str()); + HMI_DEBUG("Failed to subscribe %s", evname.c_str()); return false; } return true; @@ -193,18 +193,18 @@ bool WMClient::subscribe(afb_req req, const string &evname) void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev) { if (!afb_event_is_valid(this->event2list[kKeyError])){ - HMI_ERROR("wm", "event err is not valid"); + HMI_ERROR("event err is not valid"); return; } json_object *j = json_object_new_object(); json_object_object_add(j, kKeyError, json_object_new_int(ev)); json_object_object_add(j, kKeyErrorDesc, json_object_new_string(kErrorDescription[ev].c_str())); - HMI_DEBUG("wm", "error: %d, description:%s", ev, kErrorDescription[ev].c_str()); + HMI_DEBUG("error: %d, description:%s", ev, kErrorDescription[ev].c_str()); int ret = afb_event_push(this->event2list[kKeyError], j); if (ret != 0) { - HMI_DEBUG("wm", "afb_event_push failed: %m"); + HMI_DEBUG("afb_event_push failed: %m"); } } #endif -- 2.16.6 From 2fd5d33ca200d27c73e0fffc57987ddc751eb84a Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 14:45:32 +0900 Subject: [PATCH 12/16] Rename file names Rename layers.* to wm_layers.* Change-Id: If472c2b8f978231816f5c21edb0c53a6ee96d629 Signed-off-by: Kazumasa Mitsunari --- src/CMakeLists.txt | 2 +- src/window_manager.hpp | 2 +- src/{layers.cpp => wm_layer.cpp} | 2 +- src/{layers.hpp => wm_layer.hpp} | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/{layers.cpp => wm_layer.cpp} (99%) rename src/{layers.hpp => wm_layer.hpp} (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 91908e8..223dd33 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,7 @@ add_library(${TARGETS_WM} MODULE ${IVI_CON_PROTO} json_helper.cpp window_manager.cpp - layers.cpp + wm_layer.cpp wm_client.cpp wm_error.cpp applist.cpp diff --git a/src/window_manager.hpp b/src/window_manager.hpp index f23719f..b591149 100644 --- a/src/window_manager.hpp +++ b/src/window_manager.hpp @@ -23,7 +23,7 @@ #include #include "util.hpp" #include "controller_hooks.hpp" -#include "layers.hpp" +#include "wm_layer.hpp" #include "layout.hpp" #include "wayland_ivi_wm.hpp" #include "pm_wrapper.hpp" diff --git a/src/layers.cpp b/src/wm_layer.cpp similarity index 99% rename from src/layers.cpp rename to src/wm_layer.cpp index e1a232a..6a98884 100644 --- a/src/layers.cpp +++ b/src/wm_layer.cpp @@ -16,7 +16,7 @@ #include -#include "layers.hpp" +#include "wm_layer.hpp" #include "json_helper.hpp" #include "util.hpp" diff --git a/src/layers.hpp b/src/wm_layer.hpp similarity index 98% rename from src/layers.hpp rename to src/wm_layer.hpp index 3a16985..4dd4616 100644 --- a/src/layers.hpp +++ b/src/wm_layer.hpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef TMCAGLWM_LAYERS_H -#define TMCAGLWM_LAYERS_H +#ifndef WM_LAYERS_H +#define WM_LAYERS_H #include @@ -155,4 +155,4 @@ static const nlohmann::json default_layers_json = { }; } // namespace wm -#endif // TMCAGLWM_LAYERS_H +#endif // WM_LAYERS_H -- 2.16.6 From b87827da0ac0547fa81ee0d9ad0413bf53a1b401 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 14:50:13 +0900 Subject: [PATCH 13/16] Fix verbs afb-binding doesn't care the case of verb, but it is better to unify it with libwindowmanager. Change-Id: I775b26069cd49a72603715470ddc4cedcfd2f375 Signed-off-by: Kazumasa Mitsunari --- src/main.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0e3c587..72cc8da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -666,13 +666,13 @@ void windowmanager_debug_terminate(afb_req req) noexcept } const struct afb_verb_v2 windowmanager_verbs[] = { - {"requestsurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE}, - {"requestsurfacexdg", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE}, - {"activatewindow", windowmanager_activatewindow, nullptr, nullptr, AFB_SESSION_NONE}, - {"deactivatewindow", windowmanager_deactivatewindow, nullptr, nullptr, AFB_SESSION_NONE}, - {"enddraw", windowmanager_enddraw, nullptr, nullptr, AFB_SESSION_NONE}, - {"getdisplayinfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, - {"getareainfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, + {"requestSurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE}, + {"requestSurfaceXDG", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE}, + {"activateWindow", windowmanager_activatewindow, nullptr, nullptr, AFB_SESSION_NONE}, + {"deactivateWindow", windowmanager_deactivatewindow, nullptr, nullptr, AFB_SESSION_NONE}, + {"endDraw", windowmanager_enddraw, nullptr, nullptr, AFB_SESSION_NONE}, + {"getDisplayInfo", windowmanager_getdisplayinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, + {"getAreaInfo", windowmanager_getareainfo_thunk, nullptr, nullptr, AFB_SESSION_NONE}, {"wm_subscribe", windowmanager_wm_subscribe, nullptr, nullptr, AFB_SESSION_NONE}, {"list_drawing_names", windowmanager_list_drawing_names, nullptr, nullptr, AFB_SESSION_NONE}, {"ping", windowmanager_ping, nullptr, nullptr, AFB_SESSION_NONE}, -- 2.16.6 From 3621896847fba3b793b998262eb66ae43cee93ff Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 18:56:02 +0900 Subject: [PATCH 14/16] Omit std:: To shorten source code, omit std:: Change-Id: I251df7f503337c71800612718504bbd31dc27071 Signed-off-by: Kazumasa Mitsunari --- src/window_manager.cpp | 77 ++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/window_manager.cpp b/src/window_manager.cpp index a852529..fe8cdce 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -26,6 +26,9 @@ extern "C" #include } +using std::string; +using std::vector; + namespace wm { @@ -100,7 +103,7 @@ static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata return 0; } -static void onStateTransitioned(std::vector actions) +static void onStateTransitioned(vector actions) { g_context->startTransitionWrapper(actions); } @@ -124,15 +127,15 @@ WindowManager::WindowManager(wl::display *d) pending_events(false) { char const *path_layers_json = getenv("AFM_APP_INSTALL_DIR"); - std::string path; + string path; if (!path_layers_json) { HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); - path = std::string(path_layers_json); + path = string(path_layers_json); } else { - path = std::string(path_layers_json) + std::string("/etc/layers.json"); + path = string(path_layers_json) + string("/etc/layers.json"); } try @@ -245,13 +248,13 @@ result WindowManager::api_request_surface(char const *appid, char const *dr // so convert role old to new const char *role = this->convertRoleOldToNew(drawing_name); - auto lid = this->layers.get_layer_id(std::string(role)); + auto lid = this->layers.get_layer_id(string(role)); if (!lid) { /** * register drawing_name as fallback and make it displayed. */ - lid = this->layers.get_layer_id(std::string("fallback")); + lid = this->layers.get_layer_id(string("fallback")); HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { @@ -275,11 +278,11 @@ result WindowManager::api_request_surface(char const *appid, char const *dr } // add client into the db - std::string appid_str(appid); - g_app_list.addClient(appid_str, *lid, id, std::string(role)); + string appid_str(appid); + g_app_list.addClient(appid_str, *lid, id, string(role)); // Set role map of (new, old) - this->rolenew2old[role] = std::string(drawing_name); + this->rolenew2old[role] = string(drawing_name); return Ok(id); } @@ -295,7 +298,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr // so convert role old to new const char *role = this->convertRoleOldToNew(drawing_name); - auto lid = this->layers.get_layer_id(std::string(role)); + auto lid = this->layers.get_layer_id(string(role)); unsigned sid = std::stol(ivi_id); if (!lid) @@ -303,7 +306,7 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr /** * register drawing_name as fallback and make it displayed. */ - lid = this->layers.get_layer_id(std::string("fallback")); + lid = this->layers.get_layer_id(string("fallback")); HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role); if (!lid) { @@ -329,11 +332,11 @@ char const *WindowManager::api_request_surface(char const *appid, char const *dr this->layout_commit(); // add client into the db - std::string appid_str(appid); - g_app_list.addClient(appid_str, *lid, sid, std::string(role)); + string appid_str(appid); + g_app_list.addClient(appid_str, *lid, sid, string(role)); // Set role map of (new, old) - this->rolenew2old[role] = std::string(drawing_name); + this->rolenew2old[role] = string(drawing_name); return nullptr; } @@ -345,9 +348,9 @@ void WindowManager::api_activate_surface(char const *appid, char const *drawing_ // so convert role old to new const char *c_role = this->convertRoleOldToNew(drawing_name); - std::string id = appid; - std::string role = c_role; - std::string area = drawing_area; + string id = appid; + string role = c_role; + string area = drawing_area; Task task = Task::TASK_ALLOCATE; unsigned req_num = 0; WMError ret = WMError::UNKNOWN; @@ -393,9 +396,9 @@ void WindowManager::api_deactivate_surface(char const *appid, char const *drawin /* * Check Phase */ - std::string id = appid; - std::string role = c_role; - std::string area = ""; //drawing_area; + string id = appid; + string role = c_role; + string area = ""; //drawing_area; Task task = Task::TASK_RELEASE; unsigned req_num = 0; WMError ret = WMError::UNKNOWN; @@ -437,8 +440,8 @@ void WindowManager::api_enddraw(char const *appid, char const *drawing_name) // so convert role old to new const char *c_role = this->convertRoleOldToNew(drawing_name); - std::string id = appid; - std::string role = c_role; + string id = appid; + string role = c_role; unsigned current_req = g_app_list.currentRequestNumber(); bool result = g_app_list.setEndDrawFinished(current_req, id, role); @@ -602,7 +605,7 @@ void WindowManager::surface_removed(uint32_t surface_id) g_app_list.removeSurface(surface_id); } -void WindowManager::removeClient(const std::string &appid) +void WindowManager::removeClient(const string &appid) { HMI_DEBUG("Remove clinet %s from list", appid.c_str()); g_app_list.removeClient(appid); @@ -626,7 +629,7 @@ void WindowManager::timerHandler() this->processNextRequest(); } -void WindowManager::startTransitionWrapper(std::vector &actions) +void WindowManager::startTransitionWrapper(vector &actions) { WMError ret; unsigned req_num = g_app_list.currentRequestNumber(); @@ -655,7 +658,7 @@ void WindowManager::startTransitionWrapper(std::vector &actions) { goto proc_remove_request; } - std::string appid = g_app_list.getAppID(*surface_id, act.role, &found); + string appid = g_app_list.getAppID(*surface_id, act.role, &found); if (!found) { if (TaskVisible::INVISIBLE == act.visible) @@ -731,9 +734,9 @@ bool WindowManager::pop_pending_events() optional WindowManager::lookup_id(char const *name) { - return this->id_alloc.lookup(std::string(name)); + return this->id_alloc.lookup(string(name)); } -optional WindowManager::lookup_name(int id) +optional WindowManager::lookup_name(int id) { return this->id_alloc.lookup(id); } @@ -809,7 +812,7 @@ int WindowManager::init_layers() return 0; } -void WindowManager::surface_set_layout(int surface_id, const std::string& area) +void WindowManager::surface_set_layout(int surface_id, const string& area) { if (!this->controller->surface_exists(surface_id)) { @@ -875,7 +878,7 @@ void WindowManager::emit_syncdraw(char const *label, char const *area, int x, in this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h); } -void WindowManager::emit_syncdraw(const std::string &role, const std::string &area) +void WindowManager::emit_syncdraw(const string &role, const string &area) { compositor::rect rect = this->layers.getAreaSize(area); this->send_event(kListEventName[Event_SyncDraw], @@ -998,7 +1001,7 @@ void WindowManager::deactivate(int id) } } -WMError WindowManager::setRequest(const std::string& appid, const std::string &role, const std::string &area, +WMError WindowManager::setRequest(const string& appid, const string &role, const string &area, Task task, unsigned* req_num) { if (!g_app_list.contains(appid)) @@ -1051,7 +1054,7 @@ WMError WindowManager::checkPolicy(unsigned req_num) ret = WMError::NO_ENTRY; return ret; } - std::string req_area = trigger.area; + string req_area = trigger.area; if (trigger.task == Task::TASK_ALLOCATE) { @@ -1107,7 +1110,7 @@ WMError WindowManager::startTransition(unsigned req_num) // TODO: application requests by old role, // so convert role new to old for emitting event - std::string old_role = this->rolenew2old[action.role]; + string old_role = this->rolenew2old[action.role]; this->emit_syncdraw(old_role, action.area); /* TODO: emit event for app not subscriber @@ -1188,7 +1191,7 @@ WMError WindowManager::doEndDraw(unsigned req_num) { // TODO: application requests by old role, // so convert role new to old for emitting event - std::string old_role = this->rolenew2old[act_flush.role]; + string old_role = this->rolenew2old[act_flush.role]; this->emit_flushdraw(old_role.c_str()); } @@ -1243,7 +1246,7 @@ WMError WindowManager::visibilityChange(const WMAction &action) return WMError::SUCCESS; } -WMError WindowManager::setSurfaceSize(unsigned surface, const std::string &area) +WMError WindowManager::setSurfaceSize(unsigned surface, const string &area) { this->surface_set_layout(surface, area); @@ -1369,14 +1372,14 @@ int WindowManager::loadOldRoleDb() char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR"); HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir); - std::string file_name; + string file_name; if (!afm_app_install_dir) { HMI_ERROR("AFM_APP_INSTALL_DIR is not defined"); } else { - file_name = std::string(afm_app_install_dir) + std::string("/etc/old_roles.db"); + file_name = string(afm_app_install_dir) + string("/etc/old_roles.db"); } // Load old_role.db @@ -1419,7 +1422,7 @@ int WindowManager::loadOldRoleDb() return -1; } - this->roleold2new[old_role] = std::string(new_role); + this->roleold2new[old_role] = string(new_role); } // Check -- 2.16.6 From 7526846697e4485bca995f01a130f5e34a40b690 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 19:27:28 +0900 Subject: [PATCH 15/16] Include WMClient into WMRequest Policy Manager has to know *who* requests *which role* with *which role*. So for improvement of usability of WMRequest instead of appid. Change-Id: I452b2995922e8e303732e8e79f4f06930553b3e7 Signed-off-by: Kazumasa Mitsunari --- src/applist.cpp | 10 +++++----- src/applist.hpp | 2 +- src/pm_wrapper.cpp | 9 ++++++--- src/request.hpp | 6 +++++- src/window_manager.cpp | 19 +++++++++++-------- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/applist.cpp b/src/applist.cpp index f0dade0..79df62c 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -65,7 +65,7 @@ AppList::~AppList() {} * @attention This function should be called once for the app * Caller should take care not to be called more than once. */ -void AppList::addClient(const std::string &appid, unsigned layer, unsigned surface, const std::string &role) +void AppList::addClient(const string &appid, unsigned layer, unsigned surface, const string &role) { std::lock_guard lock(this->mtx); shared_ptr client = std::make_shared(appid, layer, surface, role); @@ -351,7 +351,7 @@ WMError AppList::setAction(unsigned req_num, const struct WMAction &action) * otherwise (visible is false) app should be invisible. Then enddraw_finished param is set to true. * This function doesn't support actions for focus yet. */ -WMError AppList::setAction(unsigned req_num, const string &appid, const string &role, const string &area, TaskVisible visible) +WMError AppList::setAction(unsigned req_num, shared_ptr client, const string &role, const string &area, TaskVisible visible) { std::lock_guard lock(this->mtx); WMError result = WMError::FAIL; @@ -363,7 +363,7 @@ WMError AppList::setAction(unsigned req_num, const string &appid, const string & } // If visible task is not invisible, redraw is required -> true bool edraw_f = (visible != TaskVisible::INVISIBLE) ? false : true; - WMAction action{appid, role, area, visible, edraw_f}; + WMAction action{req_num, client, role, area, visible, edraw_f}; x.sync_draw_req.push_back(action); result = WMError::SUCCESS; @@ -399,7 +399,7 @@ bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const st { for (auto &y : x.sync_draw_req) { - if (y.appid == appid && y.role == role) + if (y.client->appID() == appid && y.role == role) { HMI_SEQ_INFO(req_num, "Role %s finish redraw", y.role.c_str()); y.end_draw_finished = true; @@ -514,7 +514,7 @@ void AppList::reqDump() { DUMP( "Action : (APPID :%s, ROLE :%s, AREA :%s, VISIBLE : %s, END_DRAW_FINISHED: %d)", - y.appid.c_str(), + y.client->appID().c_str(), y.role.c_str(), y.area.c_str(), (y.visible == TaskVisible::INVISIBLE) ? "invisible" : "visible", diff --git a/src/applist.hpp b/src/applist.hpp index a794b53..54ccdd1 100644 --- a/src/applist.hpp +++ b/src/applist.hpp @@ -56,7 +56,7 @@ class AppList unsigned getRequestNumber(const std::string &appid) const; unsigned addRequest(WMRequest req); WMError setAction(unsigned req_num, const struct WMAction &action); - WMError setAction(unsigned req_num, const std::string &appid, + WMError setAction(unsigned req_num, std::shared_ptr client, const std::string &role, const std::string &area, TaskVisible visible); bool setEndDrawFinished(unsigned req_num, const std::string &appid, const std::string &role); bool endDrawFullfilled(unsigned req_num); diff --git a/src/pm_wrapper.cpp b/src/pm_wrapper.cpp index d71e91f..8706128 100644 --- a/src/pm_wrapper.cpp +++ b/src/pm_wrapper.cpp @@ -192,7 +192,8 @@ void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector #include +#include namespace wm { +class WMClient; + enum Task { TASK_ALLOCATE, @@ -47,7 +50,8 @@ struct WMTrigger struct WMAction { - std::string appid; + unsigned req_num; + std::shared_ptr client; std::string role; std::string area; TaskVisible visible; diff --git a/src/window_manager.cpp b/src/window_manager.cpp index fe8cdce..3e1a8bc 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -673,7 +673,9 @@ void WindowManager::startTransitionWrapper(vector &actions) goto error; } } - act.appid = appid; + auto client = g_app_list.lookUpClient(appid); + act.req_num = req_num; + act.client = client; } ret = g_app_list.setAction(req_num, act); @@ -1129,9 +1131,9 @@ WMError WindowManager::startTransition(unsigned req_num) // Make it deactivate here for (const auto &x : actions) { - if (g_app_list.contains(x.appid)) + if (g_app_list.contains(x.client->appID())) { - auto client = g_app_list.lookUpClient(x.appid); + auto client = g_app_list.lookUpClient(x.client->appID()); this->deactivate(client->surfaceID(x.role)); } } @@ -1160,7 +1162,7 @@ WMError WindowManager::doEndDraw(unsigned req_num) if(act.visible != TaskVisible::NO_CHANGE) { // layout change - if(!g_app_list.contains(act.appid)){ + if(!g_app_list.contains(act.client->appID())){ ret = WMError::NOT_REGISTERED; } ret = this->layoutChange(act); @@ -1207,7 +1209,7 @@ WMError WindowManager::layoutChange(const WMAction &action) // Visibility is not change -> no redraw is required return WMError::SUCCESS; } - auto client = g_app_list.lookUpClient(action.appid); + auto client = g_app_list.lookUpClient(action.client->appID()); unsigned surface = client->surfaceID(action.role); if (surface == 0) { @@ -1223,10 +1225,11 @@ WMError WindowManager::layoutChange(const WMAction &action) WMError WindowManager::visibilityChange(const WMAction &action) { HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Change visibility"); - if(!g_app_list.contains(action.appid)){ + if(!g_app_list.contains(action.client->appID())) + { return WMError::NOT_REGISTERED; } - auto client = g_app_list.lookUpClient(action.appid); + auto client = g_app_list.lookUpClient(action.client->appID()); unsigned surface = client->surfaceID(action.role); if(surface == 0) { @@ -1268,7 +1271,7 @@ void WindowManager::emitScreenUpdated(unsigned req_num) { if(action.visible != TaskVisible::INVISIBLE) { - json_object_array_add(jarray, json_object_new_string(action.appid.c_str())); + json_object_array_add(jarray, json_object_new_string(action.client->appID().c_str())); } } json_object_object_add(j, kKeyIds, jarray); -- 2.16.6 From 9fabd6550e183283363b61f71092477342a357d1 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Mon, 15 Oct 2018 19:58:51 +0900 Subject: [PATCH 16/16] Fix memory leak According to afb_x2_req.h, returned value of afb_req_x2_get_application_id must be freed by the caller. So release it when the function returned not Null. Bug-AGL: SPEC-1819 Change-Id: I4f23eeff6262171ac55776b4e214960dbff7ff45 Signed-off-by: Kazumasa Mitsunari --- src/main.cpp | 125 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 72 insertions(+), 53 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 72cc8da..d9f0302 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -183,13 +183,7 @@ static void cbRemoveClientCtxt(void *data) // so notify it by deactivate request. g_afb_instance->wmgr.api_deactivate_surface( ctxt->name.c_str(), ctxt->role.c_str(), - [](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - return; - } - }); + [](const char *) {}); g_afb_instance->wmgr.removeClient(ctxt->name); delete ctxt; @@ -227,18 +221,26 @@ void windowmanager_requestsurface(afb_req req) noexcept return; } - const char *appid = afb_req_get_application_id(req); - auto ret = g_afb_instance->wmgr.api_request_surface( - appid, a_drawing_name); - if (ret.is_err()) + char *appid = afb_req_get_application_id(req); + if(appid) { - afb_req_fail(req, "failed", ret.unwrap_err()); - return; + auto ret = g_afb_instance->wmgr.api_request_surface( + appid, a_drawing_name); + if (ret.is_err()) + { + afb_req_fail(req, "failed", ret.unwrap_err()); + } + else + { + createSecurityContext(req, appid, a_drawing_name); + afb_req_success(req, json_object_new_int(ret.unwrap()), "success"); + } + free(appid); + } + else + { + afb_req_fail(req, "failed", nullptr); } - - createSecurityContext(req, appid, a_drawing_name); - - afb_req_success(req, json_object_new_int(ret.unwrap()), "success"); } catch (std::exception &e) { @@ -275,19 +277,23 @@ void windowmanager_requestsurfacexdg(afb_req req) noexcept return; } char const *a_ivi_id = json_object_get_string(j_ivi_id); - char const *appid = afb_req_get_application_id(req); - auto ret = g_afb_instance->wmgr.api_request_surface( - appid, a_drawing_name, a_ivi_id); - - if (ret != nullptr) + char *appid = afb_req_get_application_id(req); + if(appid) { - afb_req_fail(req, "failed", ret); - return; - } + auto ret = g_afb_instance->wmgr.api_request_surface( + appid, a_drawing_name, a_ivi_id); - createSecurityContext(req, appid, a_drawing_name); - - afb_req_success(req, NULL, "success"); + if (ret != nullptr) + { + afb_req_fail(req, "failed", ret); + } + else + { + createSecurityContext(req, appid, a_drawing_name); + afb_req_success(req, NULL, "success"); + } + free(appid); + } } catch (std::exception &e) { @@ -321,18 +327,22 @@ void windowmanager_activatewindow(afb_req req) noexcept return; } - g_afb_instance->wmgr.api_activate_surface( - afb_req_get_application_id(req), - a_drawing_name, a_drawing_area, - [&req](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - afb_req_fail(req, "failed", errmsg); - return; - } - afb_req_success(req, NULL, "success"); - }); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_activate_surface( + appid, a_drawing_name, a_drawing_area, + [&req](const char *errmsg) { + if (errmsg != nullptr) + { + HMI_ERROR(errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); + free(appid); + } } catch (std::exception &e) { @@ -360,17 +370,22 @@ void windowmanager_deactivatewindow(afb_req req) noexcept return; } - g_afb_instance->wmgr.api_deactivate_surface( - afb_req_get_application_id(req), a_drawing_name, - [&req](const char *errmsg) { - if (errmsg != nullptr) - { - HMI_ERROR(errmsg); - afb_req_fail(req, "failed", errmsg); - return; - } - afb_req_success(req, NULL, "success"); - }); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_deactivate_surface( + appid, a_drawing_name, + [&req](const char *errmsg) { + if (errmsg != nullptr) + { + HMI_ERROR(errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); + free(appid); + } } catch (std::exception &e) { @@ -399,8 +414,12 @@ void windowmanager_enddraw(afb_req req) noexcept } afb_req_success(req, NULL, "success"); - g_afb_instance->wmgr.api_enddraw( - afb_req_get_application_id(req), a_drawing_name); + char* appid = afb_req_get_application_id(req); + if(appid) + { + g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name); + free(appid); + } } catch (std::exception &e) { -- 2.16.6