summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-11-14 12:39:54 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2018-11-14 12:39:54 +0900
commit5f9be1b9c8e6a4b6d25d64e6f5ec28deb0525854 (patch)
treef1df13a6601a8065c3ecd5c73065b9d768b56c77
parent5025144c46ad116ba2f7b0506fb9b5c0b2b7a3e4 (diff)
Add windowmanager-service and libraries
Add windowmanager-service and libraries. Change-Id: I838b149ee8a62c0dbc6cb98e1fe8e45929e19140 Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
-rw-r--r--demo3/README.md6
-rw-r--r--demo3/common/agl-service-windowmanager/CMakeLists.txt68
-rw-r--r--demo3/common/agl-service-windowmanager/LICENSE177
-rw-r--r--demo3/common/agl-service-windowmanager/LICENSE.MIT20
-rw-r--r--demo3/common/agl-service-windowmanager/README.md14
-rwxr-xr-xdemo3/common/agl-service-windowmanager/change_to_slave_mode.sh5
-rw-r--r--demo3/common/agl-service-windowmanager/doc/ApplicationGuide.md757
-rw-r--r--demo3/common/agl-service-windowmanager/export.map1
-rw-r--r--demo3/common/agl-service-windowmanager/layers.json47
-rw-r--r--demo3/common/agl-service-windowmanager/layers_setting.json69
-rw-r--r--demo3/common/agl-service-windowmanager/package/root/config.xml21
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/CMakeLists.txt104
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/config/layouts.json371
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/config/roles.json52
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc52
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc.split151
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/policy_manager.cpp1677
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/policy_manager.hpp174
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/stm.c176
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/stm.h233
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/stub/CMakeLists.txt44
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.c185
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.h27
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/CMakeLists.txt95
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/Event.h6
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/MisraCType.h16
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/ZCommonInclude.h16
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.c117
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.h41
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.c45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.h14
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c1991
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h123
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c128
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h22
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.c154
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.h45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.c45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.h14
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c112
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h39
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h14
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.c117
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.h41
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.c45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.h14
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c65
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h16
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c220
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h53
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c72
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h17
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c718
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h82
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c1003
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h94
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c81
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h18
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c117
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h41
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h14
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h15
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c178
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h13
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c56
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h20
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_include.h39
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.c1456
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.h111
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_master_apps_def.h15
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_master_remote_def.h15
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.c206
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.h45
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_inner.h22
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.c63
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.h11
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.c29
-rw-r--r--demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.h4
-rw-r--r--demo3/common/agl-service-windowmanager/protocol/ivi-wm.xml608
-rw-r--r--demo3/common/agl-service-windowmanager/src/CMakeLists.txt124
-rw-r--r--demo3/common/agl-service-windowmanager/src/applist.cpp635
-rw-r--r--demo3/common/agl-service-windowmanager/src/applist.hpp99
-rw-r--r--demo3/common/agl-service-windowmanager/src/config/areas.json204
-rw-r--r--demo3/common/agl-service-windowmanager/src/config/connection.json5
-rw-r--r--demo3/common/agl-service-windowmanager/src/config/old_roles.json68
-rw-r--r--demo3/common/agl-service-windowmanager/src/controller_hooks.hpp42
-rw-r--r--demo3/common/agl-service-windowmanager/src/json_helper.cpp149
-rw-r--r--demo3/common/agl-service-windowmanager/src/json_helper.hpp34
-rw-r--r--demo3/common/agl-service-windowmanager/src/layers.cpp382
-rw-r--r--demo3/common/agl-service-windowmanager/src/layers.hpp174
-rw-r--r--demo3/common/agl-service-windowmanager/src/low_can_client.cpp187
-rw-r--r--demo3/common/agl-service-windowmanager/src/low_can_client.hpp113
-rw-r--r--demo3/common/agl-service-windowmanager/src/main.cpp844
-rw-r--r--demo3/common/agl-service-windowmanager/src/pm_wrapper.cpp439
-rw-r--r--demo3/common/agl-service-windowmanager/src/pm_wrapper.hpp76
-rw-r--r--demo3/common/agl-service-windowmanager/src/request.cpp51
-rw-r--r--demo3/common/agl-service-windowmanager/src/request.hpp109
-rw-r--r--demo3/common/agl-service-windowmanager/src/result.hpp86
-rw-r--r--demo3/common/agl-service-windowmanager/src/util.cpp172
-rw-r--r--demo3/common/agl-service-windowmanager/src/util.hpp125
-rw-r--r--demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.cpp724
-rw-r--r--demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.hpp327
-rw-r--r--demo3/common/agl-service-windowmanager/src/window_manager.cpp2326
-rw-r--r--demo3/common/agl-service-windowmanager/src/window_manager.hpp346
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_client.cpp271
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_client.hpp92
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_connection.cpp457
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_connection.hpp64
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_error.cpp46
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_error.hpp41
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_layer.cpp271
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_layer.hpp104
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_layer_control.cpp911
-rw-r--r--demo3/common/agl-service-windowmanager/src/wm_layer_control.hpp118
-rw-r--r--demo3/common/agl-service-windowmanager/tests/wm-request74
-rw-r--r--demo3/common/libqtwindowmanager/LICENSE177
-rw-r--r--demo3/common/libqtwindowmanager/qlibwindowmanager.pro17
-rw-r--r--demo3/common/libqtwindowmanager/src/qlibwindowmanager.cpp126
-rw-r--r--demo3/common/libqtwindowmanager/src/qlibwindowmanager.h131
-rw-r--r--demo3/common/libqtwindowmanager/src/src.pro41
-rw-r--r--demo3/common/libwindowmanager/CMakeLists.txt46
-rw-r--r--demo3/common/libwindowmanager/LICENSE177
-rw-r--r--demo3/common/libwindowmanager/libwindowmanager.pc.in11
-rw-r--r--demo3/common/libwindowmanager/src/CMakeLists.txt80
-rw-r--r--demo3/common/libwindowmanager/src/hmi-debug.h70
-rw-r--r--demo3/common/libwindowmanager/src/libwindowmanager.cpp1218
-rw-r--r--demo3/common/libwindowmanager/src/libwindowmanager.h168
129 files changed, 25844 insertions, 0 deletions
diff --git a/demo3/README.md b/demo3/README.md
index e778172..87ed0d2 100644
--- a/demo3/README.md
+++ b/demo3/README.md
@@ -21,4 +21,10 @@
<br> libhomescreen branch : [ces2019](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Flibhomescreen.git;a=shortlog;h=refs%2Fheads%2Fsandbox%2Fzheng_wenlong%2Fces2019)
- qlibhomescreen
<br> qlibhomescreen branch : [ces2019](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Flibqthomescreen.git;a=shortlog;h=refs%2Fheads%2Fsandbox%2Fzheng_wenlong%2Fces2019)
+- windowmanager-service
+ <br> windowmanager-service branch : [ces2019](https://gerrit.automotivelinux.org/gerrit/gitweb?p=apps%2Fagl-service-windowmanager-2017.git;a=shortlog;h=refs%2Fheads%2Fsandbox%2Fzheng_wenlong%2Fces2019)
+- libwindowmanager
+ <br> libwindowmanager branch : [ces2019](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Flibwindowmanager.git;a=shortlog;h=refs%2Fheads%2Fsandbox%2Fzheng_wenlong%2Fces2019)
+- libqtwindowmanager
+ <br> libqtwindowmanager branch : [ces2019](https://gerrit.automotivelinux.org/gerrit/gitweb?p=src%2Flibqtwindowmanager.git;a=shortlog;h=refs%2Fheads%2Fsandbox%2Fzheng_wenlong%2Fces2019)
- ... \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/CMakeLists.txt b/demo3/common/agl-service-windowmanager/CMakeLists.txt
new file mode 100644
index 0000000..7cf640f
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/CMakeLists.txt
@@ -0,0 +1,68 @@
+#
+# 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.
+#
+
+cmake_minimum_required(VERSION 2.8)
+
+project(WindowManagerTMC)
+
+set(PACKAGE_VERSION_MAJOR 0)
+set(PACKAGE_VERSION_MINOR 0)
+set(PACKAGE_VERSION_REVISION 1)
+set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_REVISION}")
+
+find_package(PkgConfig REQUIRED)
+include(GNUInstallDirs)
+
+macro(wlproto var_basename proto_xml_basename)
+ if("${WLSCAN}" STREQUAL "")
+ find_program(WLSCAN NAMES wayland-scanner)
+ endif()
+
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/protocol)
+ set(proto_dir "${CMAKE_CURRENT_SOURCE_DIR}/protocol")
+ elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../protocol)
+ set(proto_dir "${CMAKE_CURRENT_SOURCE_DIR}/../protocol")
+ else()
+ message(FATAL_ERROR "Could not find ${CMAKE_CURRENT_SOURCE_DIR}/protocol or ${CMAKE_CURRENT_SOURCE_DIR}/../protocol")
+ endif()
+
+ add_custom_command(
+ OUTPUT
+ ${proto_xml_basename}-protocol.c
+ #${proto_xml_basename}-server-protocol.h
+ ${proto_xml_basename}-client-protocol.h
+ MAIN_DEPENDENCY ${proto_dir}/${proto_xml_basename}.xml
+ COMMAND ${WLSCAN} code < ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-protocol.c
+ #COMMAND ${WLSCAN} server-header < ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-server-protocol.h
+ COMMAND ${WLSCAN} client-header < ${proto_dir}/${proto_xml_basename}.xml > ${proto_xml_basename}-client-protocol.h
+ )
+
+ set(${var_basename}_PROTO ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-protocol.c)
+ set(${var_basename}_CLIENT ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-client-protocol.h)
+ #set(${var_basename}_SERVER ${CMAKE_CURRENT_BINARY_DIR}/${proto_xml_basename}-server-protocol.h)
+
+ include_directories(${CMAKE_CURRENT_BINARY_DIR})
+endmacro()
+
+set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none")
+
+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/demo3/common/agl-service-windowmanager/LICENSE b/demo3/common/agl-service-windowmanager/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/demo3/common/agl-service-windowmanager/LICENSE.MIT b/demo3/common/agl-service-windowmanager/LICENSE.MIT
new file mode 100644
index 0000000..0f2dc0f
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/LICENSE.MIT
@@ -0,0 +1,20 @@
+Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/demo3/common/agl-service-windowmanager/README.md b/demo3/common/agl-service-windowmanager/README.md
new file mode 100644
index 0000000..17389a8
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/README.md
@@ -0,0 +1,14 @@
+This is a WindowManager implementation for the AGL Project.
+===========================================================
+
+See http://docs.automotivelinux.org/docs/apis_services/en/dev/
+
+**NOTE**
+This Window Manager is master (meter cluster) mode by default.
+If use slave (IVI) mode, please execute sclipt `change_to_slave_mode.sh` on target as follows:
+```
+$ scp ./change_to_slave_mode.sh root@<target_ip_addr>:~
+$ ssh root@<target_ip_addr>
+# sync
+# ./change_to_slave_mode.sh
+```
diff --git a/demo3/common/agl-service-windowmanager/change_to_slave_mode.sh b/demo3/common/agl-service-windowmanager/change_to_slave_mode.sh
new file mode 100755
index 0000000..32a70ee
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/change_to_slave_mode.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+sed -i.orig -e 's/\"mode\": \"master\"/\"mode\": \"slave\"/' /var/local/lib/afm/applications/windowmanager-service-2017/0.1/etc/connection.json
+
+
diff --git a/demo3/common/agl-service-windowmanager/doc/ApplicationGuide.md b/demo3/common/agl-service-windowmanager/doc/ApplicationGuide.md
new file mode 100644
index 0000000..2240bb1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/doc/ApplicationGuide.md
@@ -0,0 +1,757 @@
+**Window Manager Application Guide**
+====
+<div align="right">Revision: 0.5</div>
+<div align="right">TOYOTA MOTOR CORPORATION</div>
+<div align="right">20th/Mar/2018</div>
+
+* * *
+<div id="Table\ of\ content"></div>
+
+Table of content
+============
+- [Introduction](#Introduction)
+ - [Intended audience](#Intended\ audience)
+ - [Scope of this Document](#Scope\ of\ this\ Document)
+ - [Known Issues](#Known\ Issues)
+ - [External libraries](#External\ libraries)
+ - [Client Library](#Client\ Library)
+- [Concepts](#Concepts)
+ - [Layers](#Layers)
+ - [Surfaces](#Surfaces)
+- [Configuration](#Configuration)
+ - [Configuration Items](#Configuration\ Items)
+- [Building and Running](#Building\ and\ Running)
+ - [Dependencies](#Dependencies)
+ - [Build Configuration](#Build\ Configuration)
+- [Implementation Notes](#Implementation\ Notes)
+ - [Structure](#Structure)
+- [Sequence](#Sequence)
+- [Binding API](#Binding\ API)
+ - [LibWindowmanager](#LibWindowmanager)
+ - [Methods](#Methods)
+ - [Errors](#Errors)
+ - [Usage](#Usage)
+ - [Events](#Events)
+- [Sample](#Sample)
+
+
+<div id="Introduction"></div>
+
+Introduction
+============
+
+This window manager implements simple layout switching of applications on
+multiple layers and with different layer layouts.
+
+<div id="Intended\ audience"></div>
+
+Intended audience
+-----------------
+
+This document is intended for developers and system integrators who
+need to know, how the window manager works and how it is to be used.
+
+<div id="Scope\ of\ this\ Document"></div>
+
+Scope of this Document
+----------------------
+
+This document covers the window manager that was implemented for TMC and
+delivered to the Automotive Grade Linux (AGL) project. It includes its
+implementation details, concepts of operation, configuration and usage.
+
+It does not include
+
+- document of the underlying architecture, see
+ [HMI-Framework](https://wiki.automotivelinux.org/hmiframework).
+
+- document of the AGL application framework and its technologies,
+ see [AGL Application
+ Framework](https://wiki.automotivelinux.org/agl-distro/app-framework).
+
+It is highly recommended to have a good understanding of these documents
+and projects before using the window manager.
+
+<div id="Known\ Issues"></div>
+
+Known Issues
+------------
+
+Currently there is a one known issues:
+
+- Only single-surface Qt applications are support through the
+ libwindowmanager library. This is a limitation of how Qt creates surface
+ IDs for the ivi-application interface.
+
+<div id="External\ libraries"></div>
+
+External libraries
+------------------
+
+This project includes a copy of version 2.1.1 the excellent [C++11 JSON
+library by Niels Lohmann](https://github.com/nlohmann/json).
+
+<div id="Client\ Library"></div>
+
+Client Library
+--------------
+
+A client library implementation that internally uses the *libafbwsc*, is
+provided in the `libwindowmanager`.
+
+<div id="Concepts"></div>
+
+Concepts
+========
+
+The window manager implements a couple of concepts in order to allow
+efficient implementation.
+
+<div id="Layers"></div>
+
+Layers
+------
+
+Layers are entities that are stacked on top of each other. Each layer
+has an ID which is used for the ivi-controller interface, but this ID
+also implicitly specifies its stacking order, from lowest to highest.
+
+Layers are always full-screen. We do not use layer dimensions as a way
+to setup the scene, rather - each layer has a layout attached to it,
+which specifies an area that is used by surfaces to draw on.
+
+Additionally, layers will generally leave surfaces on below layers
+activated, and only disable surfaces on layers the are above the
+currently used layer.
+
+It is possible to deactivate these surfaces on lower layers explicitly
+using the `DeactivateSurface` API call.
+
+<div id="Surfaces"></div>
+
+Surfaces
+--------
+
+Surfaces are *placed* on layers according to their name. The surface
+will then be resized to dimensions, according to the layer's layout
+configuration.
+
+
+<div id="Configuration"></div>
+
+Configuration
+=============
+
+The window manager is configured with the *layers.json* configuration
+file, by default it is searched in `${AFM_APP_INSTALL_DIR}/etc/layers.json`.
+Note, that the window manager will use default configuration unless this configuration is found.
+
+A sample configuration is provided with the window manager
+implementation, this sample is installed to ${AFM_APP_INSTALL_DIR}/etc/layers.json.
+
+Note:
+Currently, window manager doesn't block the application displaying because "Fallback" is set by default. If the "Fallback" is not set in layers.json, window manager blocks the application displaying. In such a situation, you have to add your role(application name) at "role" in layers.json.
+
+<div id="Configuration\ Items"></div>
+
+Configuration Items
+-------------------
+
+This section describes configuration items available through
+`layers.json`. It will do this, by first providing an example, and then
+going into its components.
+
+### main\_surface
+
+ "main_surface": {
+ "surface_role": "HomeScreen",
+ },
+
+The `main_surface` object describes a surface that will internally be
+treated as the main surface - usually this mean *HomeScreen*. The only
+special handling this surface receives, is that it is not allowed to
+deactivate it. Placement of this surface on an layer is done by the
+other configuration described below.
+
+- `surface_role` this configuration item specifies the name of the
+ main surface. Set this to e.g. `HomeScreen`.
+
+### mappings
+
+This configuration item is a list of surface-name to layer mappings.
+
+#### surface to layer mapping
+
+ "mappings": [
+ {
+ "role": "^HomeScreen$",
+ "name": "HomeScreen",
+ "layer_id": 1000,
+ "area": { "type": "full" },
+ "comment": "Single layer map for the HomeScreen"
+ },
+ {
+ "role": "MediaPlayer|Radio|Phone|Navigation|HVAC|Settings|Dashboard|POI|Mixer",
+ "name": "apps",
+ "layer_id": 1001,
+ "area": { "type": "rect", "rect": { "x": 0, "y": 218, "width": -1, "height": -433 } },
+ "comment": "Range of IDs that will always be placed on layer 1001, negative rect values are interpreted as output_size.dimension - $value",
+
+ "split_layouts": [
+ {
+ "name": "Navigation",
+ "main_match": "Navigation",
+ "sub_match": "HVAC|MediaPlayer",
+ "priority": 1000
+ }
+ ]
+ },
+ {
+ "role": "^OnScreen.*",
+ "name": "popups",
+ "layer_id": 9999,
+ "area": { "type": "rect", "rect": { "x": 0, "y": 760, "width": -1, "height": 400 } },
+ "comment": "Range of IDs that will always be placed on the popup layer, that gets a very high 'dummy' id of 9999"
+ }
+ ]
+
+Each mapping defines the following items to map corresponding surfaces
+to a layer.
+
+- `role` defines a regular expression that application drawing names
+ are matched against. If applications match this regular expression,
+ the surface will be visible on this layer.
+
+- `name` is just a name definition for this layer, it has no
+ functional use apart from identifying a layer with a name.
+
+- `layer_id` specifies which ID this layer will use.
+
+- `area` is an object that defines the area assigned to surfaces.
+
+- `split_layouts` is an optional item, that - if present - defines a
+ number of possible split-screen layouts for this layer.
+
+#### Area
+
+Areas can be either `full` or `rect`, whereas `full` means a full-screen
+layer, this is mostly useful for the main\_surface or HomeScreen layer.
+`rect` declares a layer drawing area specified as a rectangle with start
+coordinates `x` and `y` as well as its dimensions `width` and `height`.
+
+The dimensions can be specified relative to the screen dimensions. For
+this negative values for width and height must be used.
+
+For example, a full-screen surface can have the following `rect`
+definition:
+
+ "rect": { "x": 0,
+ "y": 0,
+ "width": -1,
+ "height": -1 }
+
+A surface that leaves a 200pixel margin on the top and bottom can use
+the following `rect` definition:
+
+ "rect": { "x": 0,
+ "y": 200,
+ "width": -1,
+ "height": -401 }
+
+So the expression for the actual surface dimensions when using
+screen-size-relative values will be:
+
+ actual_width = screen_width + 1 + width
+ actual_height = screen_height + 1 + height
+
+Or in other words, to leave an `N` wide border around a surface, the
+actual value in the dimension configuration needs to be `-N - 1`, and
+appropriate offsets need to be set for `x` and `y`.
+
+#### split\_layouts
+
+This configuration item allows the specification of split-screen layouts
+on layers for certain surfaces.
+
+A split screen layout always has a *main* surface and a *sub* surface.
+In order to enter a split screen layout, first the *main* surface of the
+layout must be activated, and then the *sub* surface. In order to
+disable the split layout, one of the two participating surface must be
+deactivated (or a surface on a layer below the current one must be
+activated).
+
+ "split_layouts": [
+ {
+ "name": "Navigation",
+ "main_match": "Navigation",
+ "sub_match": "HVAC|MediaPlayer",
+ }
+ ]
+
+A split layout object has the following attributes:
+
+- `name` defines its name, it has no actual function other then a way
+ to identify this split layout.
+
+- `main_match` is a regular expression that matches for the *main*
+ surface of this split layout.
+
+- `sub_match` is a regular expression that matches for the *sub*
+ surface of this layout.
+
+In the above example only the surface with drawing name
+`Navigation` will be used as the *main* surface, and the surfaces
+with drawing name `HVAC` or `MediaPlayer` can be used as a *sub* surface for
+this layout.
+
+The names must still match the layer's role match!
+
+<div id="Building\ and\ Running"></div>
+
+Building and Running
+====================
+
+<div id="Dependencies"></div>
+
+Dependencies
+------------
+
+Build dependencies are as follows:
+
+- afb-daemon &gt;= 1.0
+
+- libsystemd &gt;= 222
+
+- wayland-client &gt;= 1.11
+
+- wayland-ivi-extension &gt;= 2.0.2 (until eel, wayland-ivi-extension &gt;= 1.13)
+
+- cmake &gt;= 2.8
+
+<div id="Supported environment"></div>
+
+Supported environment
+-------------------
+
+| Item | Description |
+|:------------|:----------------------------------|
+| AGL version | Electric Eel |
+| Hardware | Renesas R-Car Starter Kit Pro(M3) |
+
+
+<div id="Build\ Configuration"></div>
+
+Build Configuration
+-------------------
+
+**Download recipe**
+If repo is already done, please start with git clone
+
+```
+$ mkdir WORK
+$ cd WORK
+$ repo init -u https://gerrit.automotivelinux.org/gerrit/AGL/AGL-repo
+$ 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/libwindowmanager`
+
+**Bitbake**
+
+```
+$ source meta-agl/scripts/aglsetup.sh -m m3ulcb agl-demo
+$ bitbake agl-demo-platform
+```
+
+<div id="Implementation\ Notes"></div>
+
+Implementation Notes
+====================
+
+The window manager is implemented as a app-framework-binder binding.
+That means, the build produces one shared object that exports a binding
+interface.
+
+<div id="Structure"></div>
+
+Structure
+---------
+
+The implementation is loosely split across the following source files:
+
+- `main.cpp`: The program entry point as used by the afb-daemon. This
+ file defines the afbBindingV2 symbol that is used by the afb-daemon
+ in order to load a binding. It also defines the wayland fd event
+ dispatcher and some globals to be used (as context for the afb calls
+ we receive).
+
+- `app.cpp` / `app.hpp`: This is the main window manager
+ logic implementation.
+
+- `config.cpp` / `config.hpp`: Very simple configuration
+ item interface.
+
+- `controller_hooks.hpp`: hook functions called by the wayland
+ controller to call into the window manager instance. Only a very limited number
+ of events are passed to the window manager, which allowed the usage of
+ such a simple interface.
+
+- `json_helper.cpp` / `json_helper.hpp`: Smaller json related
+ helper functions.
+
+- `layers.cpp` / `layers.hpp`: Actually hold all the data from
+ layers.json configuration, do some transformations and service the
+ window manager implementation.
+
+- `layout.cpp` / `layout.hpp`: Very simple layout state for the
+ implementation of split layouts and tracking of the
+ surfaces involved.
+
+- `policy.hpp`: PolicyManager implementation stub. Gets passed the
+ current and new layout on layout switch and can decide upon it being
+ valid or not.
+
+- `result.hpp`: Simple result class around
+ `std::experimental::optional` that additionally can hold a
+ `char const *` to describe the error.
+
+- `util.cpp` / `util.hpp`: general utility functions and structs - and
+ preprocessor definitions (e.g. `log*()` to AFB logging functions.
+
+- `wayland_ivi_wm.cpp` / `wayland_ivi_wm.hpp`: A C++ object-oriented
+ libwayland-client wrapper. It is instanced in `main.cpp` and handles
+ all our wayland needs. These files are in master. In eel, the name
+ of these files are `wayland.cpp` / `wayland.hpp`
+
+<div id="Sequence"></div>
+
+Sequence
+===============
+
+To understand the sequence between application and window manager, refer to the [spec document](https://wiki.automotivelinux.org/windowmanager).
+
+
+<div id="Binding\ API"></div>
+
+Binding API
+===============
+
+Each function returns a reply containing at least a failed or successful
+result of the call, additionally, when calls return something, it is
+noted.
+
+<div id="LibWindowmanager"></div>
+
+LibWindowmanager
+------
+
+This is the public interface of the class `LibWindowmanager`.
+
+ class LibWindowmanager
+ {
+ public:
+ LibWindowmanager();
+ ~LibWindowmanager();
+
+ enum EventType {
+ Event_Active = 0,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+ };
+
+ int init(int port, char const *token);
+
+ // Window manager API
+ int requestSurface(json_object *object);
+ int requestSurfaceXDG(json_object *object);
+ int activateSurface(json_object *object);
+ int deactivateSurface(json_object *object);
+ int endDraw(json_object *object);
+ int getDisplayInfo(json_object *object);
+ int getAreaInfo(json_object *in_obj, json_object *out_obj);
+
+ int getAreaInfo(const char *label, json_object *out_obj);
+
+ void set_event_handler(enum EventType et, handler_fun f);
+
+ };
+
+<div id="Methods"></div>
+
+Methods
+-------
+
+### init(int port, char const *token)
+
+Initialize the Binding communication.
+
+The `token` parameter is a string consisting of only alphanumeric characters.
+If these conditions are not met, the LibWindowmanager instance will not initialize,
+i.e. this call will return `-EINVAL`.
+
+The `port` parameter is the port the afb daemon is listening on, an
+invalid port will lead to a failure of the call and return `-EINVAL`.
+
+### requestSurface(json_object *object)
+
+**args: `{ 'kKeyDrawingName': 'application name' }`**
+This method requests a surface with the label given from the *Window Manager*.
+It will return `surface id` a client application can use, and
+`-errno` on failure. Additionally, on the standard error, messages are
+logged to help debugging the issue.
+
+### requestSurfaceXDG(json_object *object)
+
+**args: `{ 'kKeyDrawingName': 'application name', 'kKeyIviId': 'ivi id' }`**
+This method is mainly intended for *xdglauncher* that controls xdg application such as chromium.
+It will return `surface id` xdglauncher uses, and
+`-errno` on failure. Additionally, on the standard error, messages are
+logged to help debugging the issue.
+
+### activateSurface(json_object *object)
+
+**args: `{ 'kKeyDrawingName': 'application name', 'kKeyDrawingArea': 'layout' }`**
+This method is mainly intended for *manager* applications that control
+other applications (think an application manager or the *HomeScreen*).
+It instructs the window manager to activate the surface with the given
+*label*.
+
+This method only is effective after the actual window or surface was
+created by the application.
+
+### deactivateSurface(json_object *object)
+
+**args: `{ 'kKeyDrawingName': 'application name' }`**
+This method is mainly intended for *manager* applications that control other applications.
+In adition, this is for applications that overrides other applications such like popup message.
+In this case, popup surface requests to be hidden. It instructs the window manager to deactivate the surface associated with the given label. Note, that deactivating a surface also means to implicitly activate another (the last active or if not available *main surface* or *HomeScreen*.)
+
+This method only is effective after the actual window or surface was
+created by the application.
+
+### endDraw(json_object *object)
+
+**args: `{ 'kKeyDrawingName': 'application name' }`**
+This function is called from a client application when it is done
+drawing its surface content.
+
+It is not crucial to make this call at every time a drawing is finished
+- it is mainly intended to allow the window manager to synchronize
+drawing in case of layout switch. The exact semantics are explained in
+the next [Events](#_events) Section.
+
+### getDisplayInfo(json_object *object)
+
+**args: `{ }`**
+This function gets the display information as follows:
+ - width[pixel]
+ - height[pixel]
+ - width[mm]
+ - height[mm]
+
+It outputs the display information for json_object in the argument as follows:
+ `{"width_pixel": int value of width[pixel], "height_pixel": int value of height[pixel],
+ "width_mm": int value of width[mm], "height_mm": int value of height[mm]}`
+
+It should be called after calling init().
+It should not be called in the event handler because it occurs hang-up.
+
+#### NOTE
+It uses wl_output::geometry() for getting physical width[mm] and height[mm] of the display,
+but the value is different with measured value.
+
+ - value from wl_output::geometry(): width:320 height:520
+ - measured value : width:193 height:343
+
+### getAreaInfo(json_object *in_obj, json_object *out_obj)
+
+**args1: `{ 'kKeyDrawingName': 'application name' }`**
+**args2: `{ }`**
+This function gets the information of area drawn by the application as follows:
+ - x-coordinate
+ - y-coordinate
+ - width
+ - height
+
+It outputs the area information for json_object in the 2nd argument as follows:
+ `{"x": int value of x-coordinate, "y": int value of y-coordinate,
+ "width": int value of width, "height": int value of height}`
+
+It should be called after calling activateSurface().
+It should not be called in the event handler because it occurs hang-up.
+
+#### NOTE
+The same information can given by SyncDraw event.
+
+### getAreaInfo(const char *label, json_object *out_obj)
+
+**args1: String of application name**
+**args2: `{ }`**
+This function is same with `getAreaInfo(json_object *in_obj, json_object *out_obj)`,
+but only has difference of 1st argument.
+
+### set\_event\_handler(enum EventType et, handler_fun f)
+
+This method needs to be used to register event handlers for the WM
+events described in the EventType enum. Only one hendler for each
+EventType is possible, i.e. if it is called multiple times with the same
+EventType the previous handler will be replaced.
+
+The `func` handler functions will receive the label of the surface this
+event is targeted at.
+
+See Section [Events](#_events) for more detailed information about event
+delivery to client applications.
+
+<div id="Errors"></div>
+
+Errors
+------
+
+Methods returning an `int` signal successful operation when returning
+`0`. In case of an error, an error value is returned as a negative errno
+value. E.g. `-EINVAL` to signal that some input value was invalid.
+
+Additionally, logging of error messages is done on the standard error
+file descriptor to help debugging the issue.
+
+<div id="Usage"></div>
+
+Usage
+-----
+
+### Initialization of LibWindowmanager
+
+Before usage of the LibWindowmanager, the method `init()` must be
+called once, it will return `-errno` in case of an error and log
+diagnostic messages to stderr.
+
+### Request a surface
+
+When creating a surface with *Qt* - it is necessary to request a surface
+from the WM, internally this will communicate with the window manager
+binding. Only after `requestSurface()` was successful, a surface should
+be created.
+
+This is also true for *QML* applications, where only after the
+`requestSurface()` should the load of the resource be done. The method
+returns `surface id` a client application can use
+after the surface was requested successfully.
+
+#### Workings of requestSurface()
+
+`LibWindowmanager::requestSurface()` calls the AFB binding verb
+`requestsurface` of the `windowmanager` API. This API call will return a
+numeric ID to be used when creating the surface. This ID is never
+explicitly returned to the client application, instead, it is set in the
+application environment in order for *Qt* to then use it when creating
+the surface.
+
+With the current *Qt* implementation this means, that only one surface
+will be available to client applications, as subsequent windows will
+increment this numeric ID internally - which then will lead to IDs that
+cannot be known by the window manager as there is no direct
+communication from *Qt* to the WM.
+
+<div id="Events"></div>
+
+Events
+------
+
+Events are a way for the *Window Manager* to propagate information to
+client applications. It was vital for the project to implement a number
+of events, that mirror functionality that is already present in the
+wayland protocol.
+
+All events have the surface label as argument - a way to enable future
+multi-surface applications.
+
+As already stated above, this is currently not possible with the way
+*Qt* implements its surface ID setting.
+
+### Active and Inactive Events
+
+These events signal an application that it was activated or deactivated
+respectively. Usually this means it was switched visible - which means
+the surface will now be on the screen and therefor continue to render.
+
+- `Active(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name' }
+ Signal that the surface with the name
+ `kKeyDrawingName` is now active.
+
+- `Inactive(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name' }
+ Signal that the surface with the
+ name `kKeyDrawingName` is now inactive. This usually means, the layout
+ got changed, and the surface is now considered inactive
+ (or sleeping).
+
+### Visible and Invisible
+
+These events signal an application that it was switched to be visible or
+invisible respectively. These events also are handled implicitly through
+the wayland protocol by means of `wl_surface::enter` and
+`wl_surface::leave` events to the client.
+
+- `Visible(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name' }
+ Signal applications, that the
+ surface with name `kKeyDrawingName` is now visible.
+
+- `Invisible(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name' }
+ Signal applications that the
+ surface with name `kKeyDrawingName` is now invisible.
+
+### SyncDraw and FlushDraw
+
+These events instruct applications that they should redraw their surface
+contents - again, this is handled implicitly by the wayland protocol.
+
+`SyncDraw` is sent to the application when it has to redraw its surface.
+
+`FlushDraw` is sent to the application when it should swap its buffers,
+that is *signal* the compositor that its surface contains new content.
+
+- `SyncDraw(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name', 'kKeyDrawingArea': 'layout',
+ 'kKeyDrawingRect': { "x": int value of x-coordinate, "y": int value of y-coordinate,
+ "width": int value of width, "height": int value of height } }
+ Signal applications, that the
+ surface with name `kKeyDrawingArea` needs to redraw its content
+ in the layout with name `kKeyDrawingArea` - this
+ usually is sent when the surface geometry changed.
+ And the area position and size are included with name `kKeyDrawingRect`.
+
+- `FlushDraw(json_object *object)`
+ args: { 'kKeyDrawingName': 'application name' }
+ Signal applications, that the
+ surface with name `kKeyDrawingArea` can now be swapped to its newly
+ drawn content as the window manager is ready to activate a new
+ layout (i.e. a new surface geometry).
+
+<div id="Sample"></div>
+
+Sample
+============
+
+In order to enable application to use the `WM` surface registration
+function the above described steps need to be implemented.
+
+As a minimal example the usage and initialization can look like the
+following.
+
+Repo: `apps/agl-service-homescreen-2017`
+Path: `sample/template/main.c`
+
diff --git a/demo3/common/agl-service-windowmanager/export.map b/demo3/common/agl-service-windowmanager/export.map
new file mode 100644
index 0000000..ee2f413
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/export.map
@@ -0,0 +1 @@
+{ global: afbBindingV*; local: *; };
diff --git a/demo3/common/agl-service-windowmanager/layers.json b/demo3/common/agl-service-windowmanager/layers.json
new file mode 100644
index 0000000..fddd258
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/layers.json
@@ -0,0 +1,47 @@
+{
+ "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"
+ },
+ {
+ "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/demo3/common/agl-service-windowmanager/layers_setting.json b/demo3/common/agl-service-windowmanager/layers_setting.json
new file mode 100644
index 0000000..1b58a3a
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/layers_setting.json
@@ -0,0 +1,69 @@
+{
+ "description": "Layer mapping",
+ "mappings": [
+ {
+ "name": "BackGroundLayer",
+ "role" : "map|radio|music|video",
+ "type" : "stack",
+ "id_range_begin": 0,
+ "id_range_end": 0,
+ "comment": "Work Around: This is evacuation layer that not stopping event loop"
+ },
+ {
+ "name": "FarHomeScreen",
+ "role": "",
+ "type": "stack",
+ "id_range_begin": 100,
+ "id_range_end": 199,
+ "comment": "FarHomeScreen is the part of HomeScreen. The z order of this layer is lower than NearHomeScreen"
+ },
+ {
+ "name": "Apps",
+ "role": "music|video|browser|radio|phone|map|navigation|hvac|settings|dashboard|poi|mixer|sdl|launcher|receiver|tachometer|fallback",
+ "type": "tile",
+ "id_range_begin": 1000,
+ "id_range_end": 2999,
+ "comment": "Range of IDs that will always be placed on layer 1001"
+ },
+ {
+ "name": "NearHomeScreen",
+ "role": "homescreen",
+ "type": "tile",
+ "id_range_begin": 3000,
+ "id_range_end": 3000,
+ "comment": "TOYOTA special software keyboard"
+ },
+ {
+ "name": "Application Popup Layer",
+ "role": "popup*",
+ "type": "stack",
+ "id_range_begin": 4000,
+ "id_range_end": 4999,
+ "comment": "[T.B.D]This layer is for application popup layer"
+ },
+ {
+ "name": "Restriction",
+ "role": "restriction",
+ "type": "stack",
+ "id_range_begin": 5000,
+ "id_range_end": 5999,
+ "comment": "This layer is for restriction notification. This is used by restriction role"
+ },
+ {
+ "name": "OnScreen",
+ "role": "^on_screen*",
+ "type": "stack",
+ "id_range_begin": 6000,
+ "id_range_end": 6999,
+ "comment": "Range of IDs that will always be placed on the OnScreen layer, that gets a very high 'dummy' id of 9999"
+ },
+ {
+ "name": "Remote",
+ "role": "tbtnavi",
+ "type": "stack",
+ "id_range_begin": 9000,
+ "id_range_end": 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/demo3/common/agl-service-windowmanager/package/root/config.xml b/demo3/common/agl-service-windowmanager/package/root/config.xml
new file mode 100644
index 0000000..e297b28
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/package/root/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" id="windowmanager-service-2017" version="0.1">
+ <name>windowmanager-service-2017</name>
+ <content src="config.xml" type="application/vnd.agl.service"/>
+ <description>Window Manager</description>
+ <author>TOYOTA</author>
+ <license>APL 2.0</license>
+ <feature name="urn:AGL:widget:required-permission">
+ <param name="urn:AGL:permission::public:hidden" value="required" />
+ <param name="urn:AGL:permission::system:run-by-default" value="required" />
+ <param name="urn:AGL:permission:afm:system:runner" value="required" />
+ </feature>
+ <feature name="urn:AGL:widget:provided-api">
+ <param name="windowmanager" value="ws" />
+ </feature>
+ <feature name="urn:AGL:widget:required-api">
+ <param name="low-can" value="ws" />
+ <param name="lib/windowmanager-service.so" value="local" />
+ <param name="afm-main" value="ws" />
+ </feature>
+</widget>
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/CMakeLists.txt b/demo3/common/agl-service-windowmanager/policy_manager/CMakeLists.txt
new file mode 100644
index 0000000..5903340
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/CMakeLists.txt
@@ -0,0 +1,104 @@
+#
+# 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)
+set(STM_DIR zipc)
+
+# Select roles.json
+if(zipc MATCHES ${STM_DIR})
+ # if trying to show split layout, change from OFF to ON
+ set(TRY_SPLIT_LAYOUT ON CACHE BOOL "Enable to show split layout")
+
+ if(${TRY_SPLIT_LAYOUT})
+ set(ROLES_CONFIG_FILE_NAME roles.json.zipc.split)
+ else()
+ set(ROLES_CONFIG_FILE_NAME roles.json.zipc)
+ endif()
+else()
+ set(ROLES_CONFIG_FILE_NAME roles.json)
+endif()
+
+# Add STM directory
+add_subdirectory(stm/${STM_DIR})
+
+set(TARGETS_PM ${PLUGIN_PM})
+
+add_library(${TARGETS_PM}
+ SHARED
+ policy_manager.cpp
+ stm/stm.c
+ ../src/util.cpp
+)
+
+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}/config/layouts.json ${PROJECT_BINARY_DIR}/package/root/etc
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/${PLUGIN_PM}/config/${ROLES_CONFIG_FILE_NAME} ${PROJECT_BINARY_DIR}/package/root/etc/roles.json
+)
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/config/layouts.json b/demo3/common/agl-service-windowmanager/policy_manager/config/layouts.json
new file mode 100644
index 0000000..b12bce1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/config/layouts.json
@@ -0,0 +1,371 @@
+{
+ "ecus": [
+ {
+ "name": "master",
+ "layouts": [
+ {
+ "name": "homescreen",
+ "areas": [
+ {
+ "name": "fullscreen",
+ "category": "homescreen"
+ }
+ ]
+ },
+ {
+ "name": "splitable.split",
+ "areas": [
+ {
+ "name": "split.main",
+ "category": "splitable_main"
+ },
+ {
+ "name": "split.sub",
+ "category": "splitable_sub"
+ }
+ ]
+ },
+ {
+ "name": "general.normal",
+ "areas": [
+ {
+ "name": "normal.full",
+ "category": "general"
+ }
+ ]
+ },
+ {
+ "name": "software_keyboard",
+ "areas": [
+ {
+ "name": "software_keyboard",
+ "category": "software_keyboard"
+ }
+ ]
+ },
+ {
+ "name": "pop_up",
+ "areas": [
+ {
+ "name": "on_screen",
+ "category": "pop_up"
+ }
+ ]
+ },
+ {
+ "name": "system_alert",
+ "areas": [
+ {
+ "name": "on_screen",
+ "category": "system_alert"
+ }
+ ]
+ },
+ {
+ "name": "tbt",
+ "areas": [
+ {
+ "name": "normal.full",
+ "category": "tbt"
+ }
+ ]
+ },
+ {
+ "name": "remote_tbt",
+ "areas": [
+ {
+ "name": "master.split.sub",
+ "category": "tbt"
+ }
+ ]
+ },
+ {
+ "name": "meter.normal",
+ "areas": [
+ {
+ "name": "normal.full",
+ "category": "meter"
+ }
+ ]
+ },
+ {
+ "name": "meter_receiver",
+ "areas": [
+ {
+ "name": "split.main",
+ "category": "meter"
+ },
+ {
+ "name": "split.sub",
+ "category": "receiver"
+ }
+ ]
+ },
+ {
+ "name": "meter_splitable",
+ "areas": [
+ {
+ "name": "split.main",
+ "category": "meter"
+ },
+ {
+ "name": "split.sub",
+ "category": "splitable_sub"
+ }
+ ]
+ },
+ {
+ "name": "splitable_receiver",
+ "areas": [
+ {
+ "name": "split.main",
+ "category": "splitable_main"
+ },
+ {
+ "name": "split.sub",
+ "category": "receiver"
+ }
+ ]
+ },
+ {
+ "name": "receiver.split",
+ "areas": [
+ {
+ "name": "split.sub",
+ "category": "receiver"
+ }
+ ]
+ },
+ {
+ "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"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "slave",
+ "layouts": [
+ {
+ "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": "tbt",
+ "areas": [
+ {
+ "name": "normal.full",
+ "category": "tbt"
+ }
+ ]
+ },
+ {
+ "name": "remote_tbt",
+ "areas": [
+ {
+ "name": "master.split.sub",
+ "category": "tbt"
+ }
+ ]
+ },
+ {
+ "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/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json
new file mode 100644
index 0000000..c657fec
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json
@@ -0,0 +1,52 @@
+{
+ "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",
+ },
+ {
+ "category": "tbt",
+ "role": "tbt",
+ "area": "normal.full | master.split.sub",
+ "layer": "remote",
+ },
+ {
+ "category": "receiver",
+ "role": "receiver",
+ "area": "normal.full | split.main | split.sub",
+ "layer": "apps",
+ }
+ ]
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc
new file mode 100644
index 0000000..facb1d8
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.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/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc.split b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc.split
new file mode 100644
index 0000000..e21e961
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/config/roles.json.zipc.split
@@ -0,0 +1,151 @@
+{
+ "ecus": [
+ {
+ "name": "master",
+ "roles":[
+ {
+ "category": "homescreen",
+ "role": "homescreen",
+ "area": "fullscreen",
+ "layer": "homescreen",
+ },
+ {
+ "category": "general",
+ "role": "launcher | browser | debug | settings | hvac | dashboard | fallback",
+ "area": "normal.full",
+ "description": "For split test, video and music are moved to category:splitable",
+ "layer": "apps",
+ },
+ {
+ "category": "splitable_main",
+ "role": "mixer | video | phone",
+ "area": "split.main",
+ "description": "For split test, video and music are included here",
+ "layer": "apps",
+ },
+ {
+ "category": "splitable_sub",
+ "role": "music | radio | poi",
+ "area": "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": "pop_up",
+ "role": "on_screen | on_screen_phone | onscreen",
+ "area": "on_screen",
+ "layer": "on_screen",
+ },
+ {
+ "category": "system_alert",
+ "role": "system_alert",
+ "area": "on_screen",
+ "layer": "on_screen",
+ },
+ {
+ "category": "tbt",
+ "role": "tbtnavi",
+ "area": "master.split.sub",
+ "layer": "remote",
+ },
+ {
+ "category": "meter",
+ "role": "tachometer",
+ "area": "split.main | normal.full",
+ "layer": "apps",
+ },
+ {
+ "category": "receiver",
+ "role": "receiver",
+ "area": "split.sub | normal.full",
+ "layer": "apps",
+ }
+ ]
+ },
+ {
+ "name": "slave",
+ "roles":[
+ {
+ "category": "homescreen",
+ "role": "homescreen",
+ "area": "fullscreen",
+ "layer": "homescreen",
+ },
+ {
+ "category": "map",
+ "role": "navigation",
+ "area": "normal.full | split.main | fullscreen",
+ "layer": "apps",
+ },
+ {
+ "category": "general",
+ "role": "launcher | poi | browser | 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 | sdl | webbrowser | eb",
+ "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 | onscreen",
+ "area": "on_screen",
+ "layer": "on_screen",
+ },
+ {
+ "category": "system_alert",
+ "role": "system_alert",
+ "area": "on_screen",
+ "layer": "on_screen",
+ },
+ {
+ "category": "tbt",
+ "role": "tbtnavi",
+ "area": "master.split.sub",
+ "layer": "remote",
+ },
+ {
+ "category": "meter",
+ "role": "tachometer",
+ "area": "split.main | normal.full",
+ "layer": "apps",
+ },
+ {
+ "category": "receiver",
+ "role": "receiver",
+ "area": "split.sub | normal.full",
+ "layer": "apps",
+ }
+ ]
+ }
+ ]
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.cpp b/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.cpp
new file mode 100644
index 0000000..05f2ccb
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.cpp
@@ -0,0 +1,1677 @@
+/*
+ * 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 <fstream>
+#include <sstream>
+#include <istream>
+#include <thread>
+#include <map>
+#include <algorithm>
+#include <json-c/json.h>
+#include "policy_manager.hpp"
+#include "util.hpp"
+
+extern "C"
+{
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include <systemd/sd-event.h>
+#include "stm.h"
+}
+
+namespace pm
+{
+static const char kPathRolesConfigFile[] = "/etc/roles.json";
+static const char kPathLayoutsConfigFile[] = "/etc/layouts.json";
+
+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()
+{
+ this->p_crr_state = new (StmState);
+ this->p_prv_state = new (StmState);
+}
+
+PolicyManager::~PolicyManager()
+{
+ delete this->p_crr_state;
+ delete this->p_prv_state;
+}
+
+int PolicyManager::initialize(std::string ecu_name)
+{
+ int ret = 0;
+
+ // Set ECU name
+ this->ecu_name = ecu_name;
+
+ // Create convert map
+ for (int i = StmEvtNoMin; i <= StmEvtNoMax; 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("category name:%s no:%d", kStmCategoryName[i], i);
+ this->categoryname2no[kStmCategoryName[i]] = i;
+ }
+
+ for (int i = StmAreaNoMin; i <= StmAreaNoMax; i++)
+ {
+ HMI_DEBUG("area name:%s no:%d", kStmAreaName[i], i);
+ this->areaname2no[kStmAreaName[i]] = i;
+ }
+
+ // Load roles config
+ ret = this->loadRolesConfigFile();
+ if (0 > ret)
+ {
+ HMI_ERROR("Load roles config file Error!!");
+ return ret;
+ }
+
+ // Load layouts config
+ ret = this->loadLayoutsConfigFile();
+ if (0 > ret)
+ {
+ HMI_ERROR("Load layouts config file Error!!");
+ return ret;
+ }
+
+ // Initialize state which is managed by PolicyManager
+ this->initializeState();
+
+ // Initialize StateTransitioner
+ stmInitialize(ecu_name.c_str());
+
+ // 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("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("event(%s:%d)", event, event_no);
+ }
+ else
+ {
+ HMI_ERROR("Invalid event name!!");
+ return -1;
+ }
+ }
+ else
+ {
+ HMI_ERROR("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("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("Role:%s is not registered in roles config file, fallback as normal app", role);
+ category = this->role2category["fallback"];
+ }
+ }
+
+ if ("" != category)
+ {
+ // Convert name to number
+ category_no = categoryname2no[category];
+ HMI_DEBUG("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("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("Undo State !!!");
+
+ // Undo state of STM
+ stmUndoState();
+
+ HMI_DEBUG(">>>>>>>>>> BEFORE UNDO");
+ this->dumpLayerState(this->crr_layers);
+
+ this->crr_layers = this->prv_layers;
+ this->crr_invisible_role_history = this->prv_invisible_role_history;
+
+ HMI_DEBUG(">>>>>>>>>> AFTER UNDO");
+ this->dumpLayerState(this->crr_layers);
+}
+
+void PolicyManager::initializeState()
+{
+ this->initializeModeState();
+ this->initializeLayerState();
+}
+
+void PolicyManager::initializeModeState()
+{
+ Mode init_car_ele;
+ init_car_ele.state = "none";
+ init_car_ele.changed = false;
+
+ for (int i = StmCarElementNoMin; i <= StmCarElementNoMax; i++)
+ {
+ const char *car_ele_name = kStmCarElementName[i];
+ this->crr_car_elements[car_ele_name] = init_car_ele;
+ }
+
+ this->prv_car_elements = this->crr_car_elements;
+}
+
+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("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("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)
+{
+ this->updateModeState();
+ this->updateLayer(event_id);
+}
+
+void PolicyManager::updateModeState()
+{
+ int car_state_no;
+ std::string car_state;
+ bool changed;
+
+ // Store previous layers
+ this->prv_car_elements = this->crr_car_elements;
+
+ // Update car elements
+ HMI_DEBUG(">>> CAR ELEMENTS");
+ for (int car_ele_no = StmCarElementNoMin;
+ car_ele_no <= StmCarElementNoMax; car_ele_no++)
+ {
+ const char *car_ele_name = kStmCarElementName[car_ele_no];
+
+ car_state_no = this->p_crr_state->car_element[car_ele_no].state;
+ car_state = kStmCarElementStateNameList[car_ele_no][car_state_no];
+ changed = (this->p_crr_state->car_element[car_ele_no].changed) ? true : false;
+
+ this->crr_car_elements[car_ele_name].state = car_state;
+ this->crr_car_elements[car_ele_name].changed = changed;
+
+ HMI_DEBUG(">>> >>> NAME: %s", car_ele_name);
+ HMI_DEBUG(">>> >>> >>> STATE:%s", car_state.c_str());
+ HMI_DEBUG(">>> >>> >>> CHANGED:%s", (changed) ? "true" : "false");
+ }
+}
+
+void PolicyManager::updateLayer(int event_id)
+{
+ for (int layer_no = StmLayerNoMin;
+ layer_no <= StmLayerNoMax; layer_no++)
+ {
+ HMI_DEBUG(">>> LAYER:%s CHANGED:%d LAYOUT:%s",
+ kStmLayerName[layer_no], this->p_crr_state->layer[layer_no].changed,
+ kStmLayoutName[this->p_crr_state->layer[layer_no].state]);
+ }
+
+ // Store previous layers
+ this->prv_layers = this->crr_layers;
+
+ // Store previous role history
+ this->prv_invisible_role_history = this->crr_invisible_role_history;
+
+ // Update layers
+ for (int layer_no = StmLayerNoMin;
+ layer_no <= StmLayerNoMax; layer_no++)
+ {
+ const char *layer_name = kStmLayerName[layer_no];
+
+ // If restriction mode is changed to mode2 on,
+ // store current state for state of restriction mode off
+ if (this->changedRestrictionModeTo2On() ||
+ this->changedLightstatusBrakeOnToOff())
+ {
+ HMI_DEBUG("Store current state for state of restriction mode off");
+ this->prv_layers_car_stop[layer_name] = this->crr_layers[layer_name];
+ }
+
+ // This layer is changed?
+ int changed = this->p_crr_state->layer[layer_no].changed;
+ if (changed)
+ {
+ HMI_DEBUG(">>>>>>>>>> Update layout of layer:%s", layer_name);
+
+ // Get current layout name of this layer
+ int crr_layout_state_no = this->p_crr_state->layer[layer_no].state;
+ std::string crr_layout_name = std::string(kStmLayoutName[crr_layout_state_no]);
+
+ LayoutState crr_layout_state;
+ changed = 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;
+ }
+ else
+ {
+ int category_no = STM_GET_CATEGORY_FROM_ID(event_id);
+ std::string req_ctg = kStmCategoryName[category_no];
+ std::string req_role = this->req_role_list[event_id];
+ for (const auto &ctg : this->layer2categories[layer_name])
+ {
+ if (ctg == req_ctg)
+ {
+ // If layer is not changed and requested role is in this layer,
+ // push requested role to history stack
+ // because the application which has this role have been started
+ HMI_DEBUG("Add requested role to history "
+ "because the application which has this role have been started");
+ this->pushInvisibleRoleHistory(req_ctg, req_role);
+ }
+ }
+ }
+
+ // 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(">>>>>>>>>> DUMP LAYERS (BEFORE)");
+ this->dumpLayerState(this->prv_layers);
+
+ HMI_DEBUG(">>>>>>>>>> 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 = 1;
+
+ 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 (this->changedRestrictionMode2OnToOther() ||
+ this->changedLightstatusBrakeOffToOn())
+ {
+ // If restriction mode is changed from mode2 -> mode1,
+ // restore state of restriction mode off
+ HMI_DEBUG("Restriction mode is changed from mode2 -> mode1, so restore state of restriction mode off");
+ crr_layout_state = this->prv_layers_car_stop[layer_name].layout_state;
+ crr_layout_name = crr_layout_state.name;
+ if ((prv_layout_name == crr_layout_name) &&
+ (kStmAreaName[StmAreaNoNone] == crr_layout_name))
+ {
+ changed = 0;
+ }
+ else
+ {
+ // If the roles which is exist in previous layout is not in current,
+ // push to role history
+ for (const auto &prv_as : prv_layout_state.area_list)
+ {
+ for (const auto &crr_as : crr_layout_state.area_list)
+ {
+ if (prv_as.role == crr_as.role)
+ break;
+ }
+
+ this->pushInvisibleRoleHistory(prv_as.category, prv_as.role);
+ }
+ }
+ }
+ else 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("-- 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("---- Previous layout is same with current");
+ }
+ else
+ {
+ // If previous layout is NOT same with current,
+ // current areas is set with default value
+ 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;
+ }
+
+ // Create candidate list
+ std::map<std::string, AreaList> 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("-- 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("---- 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("------ 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("---- 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("---- 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("---- 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("There is no role in history stack!!");
+ }
+ tmp_cand_list.push_back(area_state);
+ HMI_DEBUG("------ 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("------ 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("-- Update areas by using candidate list");
+ for (AreaState &as : crr_layout_state.area_list)
+ {
+ 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("------ 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(json_object **json_out)
+{
+ json_object *json_tmp;
+
+ // Create car element information
+ // {
+ // "car_elements": [
+ // {
+ // "parking_brake": {
+ // "changed": <bool>,
+ // "state": <const char*>
+ // },
+ // ...
+ // },
+ json_object *json_car_ele = json_object_new_array();
+ const char *car_ele_name;
+ for (int car_ele_no = StmCarElementNoMin;
+ car_ele_no <= StmCarElementNoMax; car_ele_no++)
+ {
+ car_ele_name = kStmCarElementName[car_ele_no];
+ json_tmp = json_object_new_object();
+ this->addStateToJson(car_ele_name,
+ this->crr_car_elements[car_ele_name].changed,
+ this->crr_car_elements[car_ele_name].state,
+ &json_tmp);
+ json_object_array_add(json_car_ele, json_tmp);
+ }
+ json_object_object_add(*json_out, "car_elements", json_car_ele);
+
+ // Create layout information
+ //
+ // "layers": [
+ // {
+ // "homescreen": {
+ // "changed": <bool>,
+ // "areas": [
+ // {
+ // "name":<const char*>,
+ // "role":<const char*>
+ // }.
+ // ...
+ // ]
+ // }
+ // },
+ // ...
+ 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);
+}
+
+void PolicyManager::controlTimerEvent()
+{
+ if (this->p_crr_state->car_element[StmCarElementNoRunning].changed)
+ {
+ if (StmRunningNoRun == this->p_crr_state->car_element[StmCarElementNoRunning].state)
+ {
+ // Set delay event(restriction mode on)
+ this->setStateTransitionProcessToSystemd(StmEvtNoRestrictionModeOn,
+ 3000, "");
+ }
+ else if (StmRunningNoStop ==
+ this->p_crr_state->car_element[StmCarElementNoRunning].state)
+ {
+ // Stop timer for restriction on event
+ if (this->event_source_list.find(StmEvtNoRestrictionModeOn) !=
+ this->event_source_list.end())
+ {
+ HMI_DEBUG("Stop timer for restriction on");
+ sd_event_source *event_source = this->event_source_list[StmEvtNoRestrictionModeOn];
+ int ret = sd_event_source_set_enabled(event_source, SD_EVENT_OFF);
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to stop timer");
+ }
+ }
+
+ // Set event(restriction mode off)
+ this->setStateTransitionProcessToSystemd(StmEvtNoRestrictionModeOff, 0, "");
+ }
+ }
+}
+
+int PolicyManager::transitionState(sd_event_source *source, void *data)
+{
+ HMI_DEBUG(">>>>>>>>>> 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(">>>>>>>>>> EVENT:%s CATEGORY:%s AREA:%s",
+ kStmEventName[event_no],
+ kStmCategoryName[category_no],
+ kStmAreaName[area_no]);
+
+ // Store current state
+ *(this->p_prv_state) = *(this->p_crr_state);
+
+ // Transition state
+ int ret = stmTransitionState(event_id, this->p_crr_state);
+ if (0 > ret)
+ {
+ HMI_ERROR("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);
+
+ // Create output information for ResourceManager
+ json_object *json_out = json_object_new_object();
+ this->createOutputInformation(&json_out);
+
+ // Notify changed state
+ if (nullptr != this->callback.onStateTransitioned)
+ {
+ this->callback.onStateTransitioned(json_out);
+ }
+
+ // Start/Stop timer events
+ this->controlTimerEvent();
+
+ // 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(">>>>>>>>>> FINISH STATE TRANSITION");
+ return 0;
+}
+
+int PolicyManager::timerEvent(sd_event_source *source, uint64_t usec, void *data)
+{
+ HMI_DEBUG("Call");
+
+ int ret = this->transitionState(source, data);
+ return ret;
+}
+
+int PolicyManager::setStateTransitionProcessToSystemd(int event_id, uint64_t delay_ms, std::string role)
+{
+ struct sd_event_source *event_source;
+ HMI_DEBUG("event_id:0x%x delay:%d role:%s", event_id, delay_ms, role.c_str());
+
+ if (0 == delay_ms)
+ {
+ int ret = sd_event_add_defer(afb_daemon_get_event_loop(), &event_source,
+ &pm::transitionStateWrapper, new int(event_id));
+ if (0 > ret)
+ {
+ HMI_ERROR("Faild to sd_event_add_defer: errno:%d", ret);
+ return -1;
+ }
+ }
+ else
+ {
+ // Get current time
+ struct timespec 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
+ int ret = sd_event_add_time(afb_daemon_get_event_loop(), &event_source,
+ CLOCK_BOOTTIME, usec, 1,
+ &pm::timerEventWrapper, new int(event_id));
+ if (0 > ret)
+ {
+ HMI_ERROR("Faild to sd_event_add_time: errno:%d", ret);
+ return -1;
+ }
+ }
+ // Store event source
+ this->event_source_list[event_id] = event_source;
+ // Store requested role
+ this->req_role_list[event_id] = role;
+ return 0;
+}
+
+bool PolicyManager::changedRestrictionModeTo2On()
+{
+ // TODO: If possible thie process should be include in zipc stm in the future
+ if (this->p_crr_state->car_element[StmCarElementNoRestrictionMode].changed &&
+ (StmRestrictionModeSttNoOn != this->p_prv_state->car_element[StmCarElementNoRestrictionMode].state) &&
+ (StmRestrictionModeSttNoOn == this->p_crr_state->car_element[StmCarElementNoRestrictionMode].state))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool PolicyManager::changedRestrictionMode2OnToOther()
+{
+ // TODO: If possible thie process should be include in zipc stm in the future
+ if (this->p_crr_state->car_element[StmCarElementNoRestrictionMode].changed &&
+ (StmRestrictionModeSttNoOn == this->p_prv_state->car_element[StmCarElementNoRestrictionMode].state) &&
+ (StmRestrictionModeSttNoOn != this->p_crr_state->car_element[StmCarElementNoRestrictionMode].state))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool PolicyManager::changedLightstatusBrakeOffToOn()
+{
+ // TODO: For master
+ // If possible thie process should be include in zipc stm in the future
+ if (("master" == this->ecu_name) &&
+ this->p_crr_state->car_element[StmCarElementNoLightstatusBrake].changed &&
+ (StmLightstatusBrakeSttNoOff == this->p_prv_state->car_element[StmCarElementNoLightstatusBrake].state) &&
+ (StmLightstatusBrakeSttNoOn == this->p_crr_state->car_element[StmCarElementNoLightstatusBrake].state))
+ {
+ return true;
+ }
+ return false;
+}
+
+bool PolicyManager::changedLightstatusBrakeOnToOff()
+{
+ // TODO: For master
+ // If possible thie process should be include in zipc stm in the future
+ if (("master" == this->ecu_name) &&
+ this->p_crr_state->car_element[StmCarElementNoLightstatusBrake].changed &&
+ (StmLightstatusBrakeSttNoOn == this->p_prv_state->car_element[StmCarElementNoLightstatusBrake].state) &&
+ (StmLightstatusBrakeSttNoOff == this->p_crr_state->car_element[StmCarElementNoLightstatusBrake].state))
+ {
+ return true;
+ }
+ return false;
+}
+
+int PolicyManager::loadRolesConfigFile()
+{
+ std::string file_name;
+
+ // Get afm application installed dir
+ char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
+
+ 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(pm::kPathRolesConfigFile);
+ }
+
+ // Load roles config file
+ json_object *json_obj;
+ int ret = this->inputJsonFilie(file_name.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_ERROR("Could not open %s, so use default role information", pm::kPathRolesConfigFile);
+ json_obj = json_tokener_parse(kDefaultRolesConfig);
+ }
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
+
+ // Parse ecus
+ json_object *json_cfg;
+ if (!json_object_object_get_ex(json_obj, "ecus", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ int num_ecu = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(ecus) len:%d", num_ecu);
+
+ const char* c_ecu_name;
+ json_object *json_ecu;
+ for (int i = 0; i < num_ecu; i++)
+ {
+ json_ecu= json_object_array_get_idx(json_cfg, i);
+
+ c_ecu_name = this->getStringFromJson(json_ecu, "name");
+ if (nullptr == c_ecu_name)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ if (std::string(c_ecu_name) == this->ecu_name)
+ {
+ break;
+ }
+ else
+ {
+ json_ecu = nullptr;
+ }
+ }
+
+ if (!json_ecu)
+ {
+ HMI_ERROR("Areas for ecu:%s is NOT exist!!", this->ecu_name.c_str());
+ return -1;
+ }
+
+ // Parse roles
+ json_object *json_roles;
+ if (!json_object_object_get_ex(json_ecu, "roles", &json_roles))
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ int len = json_object_array_length(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;
+ 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("Parse Error!!");
+ return -1;
+ }
+
+ // Parse roles by '|'
+ std::vector<std::string> 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("Check role2category");
+ for (const auto &x : this->role2category)
+ {
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str());
+ }
+
+ HMI_DEBUG("Check category2role");
+ for (const auto &x : this->category2role)
+ {
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), x.second.c_str());
+ }
+
+ HMI_DEBUG("Check category2areas");
+ for (const auto &x : this->category2areas)
+ {
+ for (const auto &y : x.second)
+ {
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), y.c_str());
+ }
+ }
+
+ HMI_DEBUG("Check layer2categories");
+ for (const auto &x : this->layer2categories)
+ {
+ for (const auto &y : x.second)
+ {
+ HMI_DEBUG("key:%s, val:%s", x.first.c_str(), y.c_str());
+ }
+ }
+ return 0;
+}
+
+int PolicyManager::loadLayoutsConfigFile()
+{
+ HMI_DEBUG("Call");
+
+ // Get afm application installed dir
+ 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;
+ 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(pm::kPathLayoutsConfigFile);
+ }
+
+ // Load states config file
+ json_object *json_obj;
+ int ret = this->inputJsonFilie(file_name.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_DEBUG("Could not open %s, so use default layout information", pm::kPathLayoutsConfigFile);
+ json_obj = json_tokener_parse(kDefaultLayoutsConfig);
+ }
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
+
+ // Parse ecus
+ json_object *json_cfg;
+ if (!json_object_object_get_ex(json_obj, "ecus", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ int num_ecu = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(ecus) len:%d", num_ecu);
+
+ const char* c_ecu_name;
+ json_object *json_ecu;
+ for (int i = 0; i < num_ecu; i++)
+ {
+ json_ecu= json_object_array_get_idx(json_cfg, i);
+
+ c_ecu_name = this->getStringFromJson(json_ecu, "name");
+ if (nullptr == c_ecu_name)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ if (std::string(c_ecu_name) == this->ecu_name)
+ {
+ break;
+ }
+ else
+ {
+ json_ecu = nullptr;
+ }
+ }
+
+ if (!json_ecu)
+ {
+ HMI_ERROR("Areas for ecu:%s is NOT exist!!", this->ecu_name.c_str());
+ return -1;
+ }
+
+ // Perse layouts
+ HMI_DEBUG("Perse layouts");
+ json_object *json_layouts;
+ if (!json_object_object_get_ex(json_ecu, "layouts", &json_layouts))
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ int len = json_object_array_length(json_layouts);
+ HMI_DEBUG("json_layouts len:%d", len);
+ HMI_DEBUG("json_layouts dump:%s", json_object_get_string(json_layouts));
+
+ 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_layouts, i);
+
+ layout = this->getStringFromJson(json_tmp, "name");
+ if (nullptr == layout)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+ HMI_DEBUG("> layout:%s", layout);
+
+ json_object *json_area_array;
+ if (!json_object_object_get_ex(json_tmp, "areas", &json_area_array))
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ int len_area = json_object_array_length(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;
+ std::map<std::string, int> 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("Parse Error!!");
+ return -1;
+ }
+ area_state.name = std::string(area);
+ HMI_DEBUG(">> area:%s", area);
+
+ // Get app attribute of the area
+ category = this->getStringFromJson(json_area, "category");
+ if (nullptr == category)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+ area_state.category = std::string(category);
+ category_num[category]++;
+ HMI_DEBUG(">>> 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(">>> 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(">>> 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(">>> >>> 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());
+ }
+ }
+
+ // 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->crr_invisible_role_history[category].begin(),
+ this->crr_invisible_role_history[category].end(),
+ [role](std::string x) { return (role == x); });
+
+ if (this->crr_invisible_role_history[category].end() != i)
+ {
+ this->crr_invisible_role_history[category].erase(i);
+ }
+
+ this->crr_invisible_role_history[category].push_back(role);
+
+ if (pm::kInvisibleRoleHistoryNum < crr_invisible_role_history[category].size())
+ {
+ this->crr_invisible_role_history[category].erase(
+ this->crr_invisible_role_history[category].begin());
+ }
+}
+
+std::string PolicyManager::popInvisibleRoleHistory(std::string category)
+{
+ std::string role;
+ if (crr_invisible_role_history[category].empty())
+ {
+ role = "";
+ }
+ else
+ {
+ role = this->crr_invisible_role_history[category].back();
+ this->crr_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("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("Input file: %s", file);
+
+ // Open json file
+ FILE *fp = fopen(file, "rb");
+ if (nullptr == fp)
+ {
+ HMI_ERROR("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("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("Failed to parse file (byte:%d err:%s)",
+ (input_size * block_cnt), json_tokener_error_desc(json_error));
+ HMI_ERROR("\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<std::string, LayerState> &layers)
+{
+ HMI_DEBUG("-------------------------------------------------------------------------------------------------------");
+ HMI_DEBUG("|%-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("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
+ layer, changed, layout,
+ as.name.c_str(), as.category.c_str(), as.role.c_str());
+ }
+ else
+ HMI_DEBUG("|%-15s|%1s|%-20s|%-20s|%-20s|%-20s|",
+ "", "", "", as.name.c_str(), as.category.c_str(), as.role.c_str());
+ }
+ }
+ HMI_DEBUG("-------------------------------------------------------------------------------------------------------");
+}
+
+void PolicyManager::dumpInvisibleRoleHistory()
+{
+ HMI_DEBUG(">>>>>>>>>> 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->crr_invisible_role_history[category])
+ str += (i + " > ");
+
+ str += "]";
+ HMI_DEBUG("%s", str.c_str());
+ }
+}
+
+std::vector<std::string> PolicyManager::parseString(std::string str, char delimiter)
+{
+ // Parse string by delimiter
+ std::vector<std::string> 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::kDefaultRolesConfig = "{ \
+ \"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::kDefaultLayoutsConfig = "{ \
+ \"layouts\": [ \
+ { \
+ \"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/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.hpp b/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.hpp
new file mode 100644
index 0000000..61fbf06
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/policy_manager.hpp
@@ -0,0 +1,174 @@
+/*
+ * 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 <functional>
+#include <unordered_map>
+#include <vector>
+#include <queue>
+
+struct json_object;
+struct sd_event;
+struct sd_event_source;
+struct StmState;
+
+class PolicyManager
+{
+ public:
+ explicit PolicyManager();
+ ~PolicyManager();
+
+ using Handler = std::function<void(json_object *)>;
+
+ typedef struct
+ {
+ Handler onStateTransitioned;
+ Handler onError;
+ } CallbackTable;
+
+ int initialize(std::string ecu_name);
+ 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<AreaState> AreaList;
+ typedef struct LayoutState
+ {
+ std::string name;
+ std::map<std::string, int> category_num;
+ AreaList area_list;
+ } LayoutState;
+
+ typedef struct LayerState
+ {
+ std::string name;
+ LayoutState layout_state;
+ bool changed;
+ } LayerState;
+
+ typedef struct Mode
+ {
+ std::string state;
+ bool changed;
+ } Mode;
+
+ typedef std::vector<std::string> Areas;
+ typedef std::vector<std::string> Categories;
+ typedef std::vector<std::string> Roles;
+
+ StmState *p_crr_state;
+ StmState *p_prv_state;
+
+ // Convert map
+ std::unordered_map<std::string, int> eventname2no;
+ std::unordered_map<std::string, int> categoryname2no;
+ std::unordered_map<std::string, int> areaname2no;
+
+ std::unordered_map<std::string, std::string> role2category;
+ std::unordered_map<std::string, std::string> category2role;
+ std::unordered_map<std::string, Areas> category2areas;
+ std::unordered_map<std::string, Categories> layer2categories;
+
+ std::queue<EventInfo> event_info_queue;
+ std::map<int, struct sd_event_source *> event_source_list;
+ std::map<int, std::string> req_role_list;
+
+ CallbackTable callback;
+
+ std::unordered_map<std::string, Mode> prv_car_elements;
+ std::unordered_map<std::string, Mode> crr_car_elements;
+
+ std::unordered_map<std::string, LayerState> prv_layers;
+ std::unordered_map<std::string, LayerState> crr_layers;
+
+ std::unordered_map<std::string, LayerState> prv_layers_car_stop;
+
+ std::unordered_map<std::string, LayoutState> default_layouts;
+
+ std::map<std::string, Roles> crr_invisible_role_history;
+ std::map<std::string, Roles> prv_invisible_role_history;
+
+ std::string ecu_name;
+
+ void initializeState();
+ void initializeModeState();
+ void initializeLayerState();
+ void updateState(int event_id);
+ void updateModeState();
+ void updateLayer(int event_id);
+ int updateLayout(int event_id, int layer_no,
+ std::string crr_layout_name, LayoutState &crr_layout_state);
+ void createOutputInformation(json_object **json_out);
+ void controlTimerEvent();
+ 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);
+
+ bool changedRestrictionModeTo2On();
+ bool changedRestrictionMode2OnToOther();
+ bool changedLightstatusBrakeOffToOn();
+ bool changedLightstatusBrakeOnToOff();
+
+ int loadRolesConfigFile();
+ int loadLayoutsConfigFile();
+
+ void dumpLayerState(std::unordered_map<std::string, LayerState> &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<std::string> parseString(std::string str, char delimiter);
+ std::string deleteSpace(std::string str);
+
+ static const char *kDefaultRolesConfig;
+ static const char *kDefaultLayoutsConfig;
+};
+
+#endif // TMCAGLWM_POLICY_MANAGER_HPP
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.c
new file mode 100644
index 0000000..1c4170d
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.c
@@ -0,0 +1,176 @@
+/*
+ * 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 <string.h>
+#include "stm.h"
+#include "stm_inner.h"
+
+const char* kStmEventName[] = {
+ "none",
+ "activate",
+ "deactivate",
+ "trans_gear_neutral",
+ "trans_gear_not_neutral",
+ "parking_brake_off",
+ "parking_brake_on",
+ "accel_pedal_off",
+ "accel_pedal_on",
+ "lamp_off",
+ "lamp_on",
+ "lightstatus_brake_off",
+ "lightstatus_brake_on",
+ "restriction_mode_off",
+ "restriction_mode_on",
+ "undo",
+};
+
+const char* kStmCategoryName[] = {
+ "none",
+ "homescreen",
+ "map",
+ "general",
+ "splitable",
+ "splitable_main",
+ "splitable_sub",
+ "pop_up",
+ "system_alert",
+ "restriction",
+ "system",
+ "software_keyboard",
+ "tbt",
+ "meter",
+ "receiver",
+ "debug",
+};
+
+const char* kStmAreaName[] = {
+ "none",
+ "fullscreen",
+ "normal.full",
+ "split.main",
+ "split.sub",
+ "on_screen",
+ "restriction.normal",
+ "restriction.split.main",
+ "restriction.split.sub",
+ "software_keyboard",
+ "master.split.sub",
+};
+
+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",
+ "tbt",
+ "remote_tbt",
+ "meter.normal",
+ "meter_receiver",
+ "meter_splitable",
+ "splitable_receiver",
+ "receiver.split",
+ "debug.normal",
+ "debug.split.main",
+ "debug.split.sub",
+ "debug.fullscreen",
+};
+
+const char* kStmLayerName[] = {
+ "homescreen",
+ "apps",
+ "near_homescreen",
+ "restriction",
+ "on_screen",
+ "remote",
+};
+
+const char* kStmCarElementName[] = {
+ "trans_gear",
+ "parking_brake",
+ "accel_pedal",
+ "running",
+ "lamp",
+ "lightstatus_brake",
+ "restriction_mode",
+};
+
+const char* kStmTransGearStateName[] = {
+ "neutral",
+ "not_neutral"
+};
+
+const char* kStmParkingBrakeStateName[] = {
+ "off",
+ "on"
+};
+
+const char* kStmAccelPedalStateName[] = {
+ "off",
+ "on"
+};
+
+const char* kStmRunningSttNo2Name[] = {
+ "stop",
+ "run"
+};
+
+const char* kStmLampStateName[] = {
+ "off",
+ "on"
+};
+
+const char* kStmLightstatusBrakeStateName[] = {
+ "off",
+ "on"
+};
+
+const char* kStmRestrictionModeStateName[] = {
+ "off",
+ "on",
+};
+
+const char** kStmCarElementStateNameList[] = {
+ kStmTransGearStateName,
+ kStmParkingBrakeStateName,
+ kStmAccelPedalStateName,
+ kStmRunningSttNo2Name,
+ kStmLampStateName,
+ kStmLightstatusBrakeStateName,
+ kStmRestrictionModeStateName,
+};
+
+void stmInitialize(const char *ecu_name) {
+ stmInitializeInner(ecu_name);
+}
+
+int stmTransitionState(int event, StmState* state) {
+ return stmTransitionStateInner(event, state);
+}
+
+void stmUndoState() {
+ stmUndoStateInner();
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.h
new file mode 100644
index 0000000..685a43b
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/stm.h
@@ -0,0 +1,233 @@
+/*
+ * 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,
+ StmEvtNoTransGearN,
+ StmEvtNoTransGearNotN,
+ StmEvtNoParkingBrakeOff,
+ StmEvtNoParkingBrakeOn,
+ StmEvtNoAccelPedalOff,
+ StmEvtNoAccelPedalOn,
+ StmEvtNoLampOff,
+ StmEvtNoLampOn,
+ StmEvtNoLightstatusBrakeOff,
+ StmEvtNoLightstatusBrakeOn,
+ StmEvtNoRestrictionModeOff,
+ StmEvtNoRestrictionModeOn,
+ StmEvtNoUndo,
+
+ StmEvtNoNum,
+
+ StmEvtNoMin = StmEvtNoNone,
+ StmEvtNoMax = StmEvtNoNum - 1,
+};
+
+// Category number
+enum StmCtgNo {
+ StmCtgNoNone = 0,
+ StmCtgNoHomescreen,
+ StmCtgNoMap,
+ StmCtgNoGeneral,
+ StmCtgNoSplitable,
+ StmCtgNoSplitableMain,
+ StmCtgNoSplitableSub,
+ StmCtgNoPopUp,
+ StmCtgNoSystemAlert,
+ StmCtgNoRestriction,
+ StmCtgNoSystem,
+ StmCtgNoSoftwareKeyboard,
+ StmCtgNoTbt,
+ StmCtgNoMeter,
+ StmCtgNoReceiver,
+ StmCtgNoDebug,
+
+ StmCtgNoNum,
+
+ StmCtgNoMin = StmCtgNoNone,
+ StmCtgNoMax = StmCtgNoNum - 1,
+};
+
+// Area number
+enum StmAreaNo {
+ StmAreaNoNone = 0,
+ StmAreaNoFullscreen,
+ StmAreaNoNormal,
+ StmAreaNoSplitMain,
+ StmAreaNoSplitSub,
+ StmAreaNoOnScreen,
+ StmAreaNoRestrictionNormal,
+ StmAreaNoRestrictionSplitMain,
+ StmAreaNoRestrictionSplitSub,
+ StmAreaNoSoftwareKyeboard,
+ StmAreaNoMasterSplitSub,
+
+ StmAreaNoNum,
+
+ StmAreaNoMin = StmAreaNoNone,
+ StmAreaNoMax = StmAreaNoNum - 1,
+};
+
+// Layer number
+enum StmLayerNo {
+ StmLayerNoHomescreen = 0,
+ StmLayerNoApps,
+ StmLayerNoNearHomescreen,
+ StmLayerNoRestriction,
+ StmLayerNoOnScreen,
+ StmLayerNoRemote,
+
+ 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,
+ StmLayoutNoTbt,
+ StmLayoutNoRmtTbt,
+ StmLayoutNoMtrNml,
+ StmLayoutNoMtrRcv,
+ StmLayoutNoMtrSpl,
+ StmLayoutNoSplRcv,
+ StmLayoutNoRcvSpl,
+ StmLayoutNoDbgNml,
+ StmLayoutNoDbgSplMain,
+ StmLayoutNoDbgSplSub,
+ StmLayoutNoDbgFll,
+
+ StmLayoutNoNum,
+
+ StmLayoutNoMin = StmLayoutNoNone,
+ StmLayoutNoMax = StmLayoutNoNum - 1,
+};
+
+// Enum for mode state
+enum StmTransGearStt {
+ StmTransGearSttNoN = 0,
+ StmTransGearSttNoNotN
+};
+
+enum StmParkingBrakeStt {
+ StmParkingBrakeSttNoOff = 0,
+ StmParkingBrakeSttNoOn
+};
+
+enum StmAccelPedalStt {
+ StmAccelPedalSttNoOff = 0,
+ StmAccelPedalSttNoOn
+};
+
+enum StmCarStt {
+ StmRunningNoStop = 0,
+ StmRunningNoRun
+};
+
+enum StmLampStt {
+ StmLampSttNoOff = 0,
+ StmLampSttNoOn
+};
+
+enum StmLightstatusBrakeStt {
+ StmLightstatusBrakeSttNoOff = 0,
+ StmLightstatusBrakeSttNoOn
+};
+
+enum StmRestrictionModeSttNo {
+ StmRestrictionModeSttNoOff = 0,
+ StmRestrictionModeSttNoOn,
+};
+
+// Mode kind number
+enum StmCarElementNo {
+ StmCarElementNoTransGear = 0,
+ StmCarElementNoParkingBrake,
+ StmCarElementNoAccelPedal,
+ StmCarElementNoRunning,
+ StmCarElementNoLamp,
+ StmCarElementNoLightstatusBrake,
+ StmCarElementNoRestrictionMode,
+
+ StmCarElementNoNum,
+
+ StmCarElementNoMin = StmCarElementNoTransGear,
+ StmCarElementNoMax = StmCarElementNoNum - 1,
+};
+
+// 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* kStmCarElementName[];
+extern const char** kStmCarElementStateNameList[];
+
+// Struct for state
+typedef struct StmBaseState {
+ int changed;
+ int state;
+} StmBaseState;
+
+typedef struct StmState {
+ StmBaseState car_element[StmCarElementNoNum];
+ StmBaseState layer[StmLayerNoNum];
+} StmState;
+
+// API
+void stmInitialize(const char *ecu_name);
+int stmTransitionState(int event_no, StmState* state);
+void stmUndoState();
+
+
+#endif // TMCAGLWM_STM_HPP
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/CMakeLists.txt b/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/CMakeLists.txt
new file mode 100644
index 0000000..81f0e00
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.c
new file mode 100644
index 0000000..2ae2cf0
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.c
@@ -0,0 +1,185 @@
+/*
+ * 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 <string.h>
+#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 (StmCtgNoTbt == category_no)
+ {
+ if (StmAreaNoMasterSplitSub == area_no)
+ {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoRcvSpl;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoRmtTbt;
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_TRUE;
+ }
+ else if (StmAreaNoNormal == area_no)
+ {
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoTbt;
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_TRUE;
+ }
+ }
+ else if (StmCtgNoReceiver == category_no)
+ {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoRcvSpl;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+ }
+ else if (StmCtgNoMeter == category_no)
+ {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMtrNml;
+ g_stm_crr_state.layer[StmLayerNoApps].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;
+ }
+ }
+ else if (StmCtgNoTbt == category_no)
+ {
+ if (StmLayoutNoRmtTbt == g_stm_prv_state.layer[StmLayerNoRemote].state)
+ {
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoNone;
+ g_stm_crr_state.layer[StmLayerNoRemote].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/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/stub/stm_inner.h
new file mode 100644
index 0000000..7079447
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/CMakeLists.txt b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/CMakeLists.txt
new file mode 100644
index 0000000..abbdc41
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/CMakeLists.txt
@@ -0,0 +1,95 @@
+#
+# 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)
+set(ST_DIR_AP ${ST_DIR}/AccelPedal)
+set(ST_DIR_CS ${ST_DIR}/CarState)
+set(ST_DIR_LSB ${ST_DIR}/LightStatusBrake)
+
+set(ST_DIR_MST_AL ${ST_DIR}/master/layer/apps)
+set(ST_DIR_MST_RMT ${ST_DIR}/master/layer/remote)
+
+
+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
+ ${ST_DIR_AP}/ZACCEL_AccelPedal.c
+ ${ST_DIR_AP}/ZACCEL_AccelPedalState_func.c
+ ${ST_DIR_CS}/ZCAR_CarState.c
+ ${ST_DIR_CS}/ZCAR_CarState_func.c
+ ${ST_DIR_LSB}/ZLIGHT_LightstatusBrake.c
+ ${ST_DIR_LSB}/ZLIGHT_LightstatusBrakeStatus_func.c
+ ./stm_master_apps.c
+ ./stm_master_remote.c
+ ${ST_DIR_MST_AL}/Zmaster_apps_apps_main.c
+ ${ST_DIR_MST_RMT}/Zmaster_remote_remote.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_AP}
+ ./${ST_DIR_CS}
+ ./${ST_DIR_LSB}
+ ./${ST_DIR_MST_AL}
+ ./${ST_DIR_MST_RMT}
+ ./${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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/Event.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/Event.h
new file mode 100644
index 0000000..3601b08
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/MisraCType.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/MisraCType.h
new file mode 100644
index 0000000..5a535fb
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/ZCommonInclude.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/Common/ZCommonInclude.h
new file mode 100644
index 0000000..6b9b84b
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.c
new file mode 100644
index 0000000..fa692ee
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.c
@@ -0,0 +1,117 @@
+/************************************************************/
+/* ZACCEL_AccelPedal.c */
+/* AccelPedal State transition model source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/* State management variable */
+static uint8_t ZACCEL_AccelPedalState[ZACCEL_ACCELPEDALSTATENOMAX];
+
+static void ZACCEL_AccelPedals0e1( void );
+static void ZACCEL_AccelPedals1e0( void );
+static void ZACCEL_AccelPedals0Event( void );
+static void ZACCEL_AccelPedals1Event( void );
+
+/****************************************/
+/* Action function */
+/* STM : AccelPedal */
+/* State : accel_pedal_off( No 0 ) */
+/* Event : evt_accel_pedal_on( No 1 ) */
+/****************************************/
+static void ZACCEL_AccelPedals0e1( void )
+{
+ ZACCEL_AccelPedalState[ZACCEL_ACCELPEDAL] = ( uint8_t )ZACCEL_ACCELPEDALS1;
+ stm_aps_start_activity_accel_pedal_on();
+}
+
+/****************************************/
+/* Action function */
+/* STM : AccelPedal */
+/* State : accel_pedal_on( No 1 ) */
+/* Event : evt_accel_pedal_off( No 0 )*/
+/****************************************/
+static void ZACCEL_AccelPedals1e0( void )
+{
+ ZACCEL_AccelPedalState[ZACCEL_ACCELPEDAL] = ( uint8_t )ZACCEL_ACCELPEDALS0;
+ stm_aps_start_activity_accel_pedal_off();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : AccelPedal */
+/* State : accel_pedal_off( No 0 ) */
+/****************************************/
+static void ZACCEL_AccelPedals0Event( void )
+{
+ /*evt_accel_pedal_on*/
+ if( g_stm_event == StmEvtNoAccelPedalOn )
+ {
+ ZACCEL_AccelPedals0e1();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : AccelPedal */
+/* State : accel_pedal_on( No 1 ) */
+/****************************************/
+static void ZACCEL_AccelPedals1Event( void )
+{
+ /*evt_accel_pedal_off*/
+ if( g_stm_event == StmEvtNoAccelPedalOff )
+ {
+ ZACCEL_AccelPedals1e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event call function */
+/* STM : AccelPedal */
+/****************************************/
+void stm_aps_event_call( void )
+{
+ stm_aps_start_stm();
+ switch( ZACCEL_AccelPedalState[ZACCEL_ACCELPEDAL] )
+ {
+ case ZACCEL_ACCELPEDALS0:
+ ZACCEL_AccelPedals0Event();
+ break;
+ case ZACCEL_ACCELPEDALS1:
+ ZACCEL_AccelPedals1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : AccelPedal */
+/****************************************/
+void stm_aps_initialize( void )
+{
+ ZACCEL_AccelPedalState[ZACCEL_ACCELPEDAL] = ( uint8_t )ZACCEL_ACCELPEDALS0;
+ stm_aps_start_activity_accel_pedal_off();
+}
+
+/****************************************/
+/* Terminate function */
+/* STM : AccelPedal */
+/****************************************/
+void ZACCEL_AccelPedalTerminate( void )
+{
+ ZACCEL_AccelPedalState[ZACCEL_ACCELPEDAL] = ( uint8_t )ZACCEL_ACCELPEDALTERMINATE;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.h
new file mode 100644
index 0000000..40da956
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedal.h
@@ -0,0 +1,41 @@
+/************************************************************/
+/* ZACCEL_AccelPedal.h */
+/* AccelPedal State transition model header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZACCEL_ACCELPEDAL_H
+#define ZHEADER_ZACCEL_ACCELPEDAL_H
+
+/*State management variable access define*/
+#define ZACCEL_ACCELPEDAL ( 0U )
+#define ZACCEL_ACCELPEDALS0 ( 0U )
+#define ZACCEL_ACCELPEDALS1 ( 1U )
+#define ZACCEL_ACCELPEDALSTATENOMAX ( 1U )
+
+/*End state define*/
+#define ZACCEL_ACCELPEDALEND ( 2U )
+/*Terminate state define*/
+#define ZACCEL_ACCELPEDALTERMINATE ( ZACCEL_ACCELPEDALEND + 1U )
+
+/*State no define*/
+#define ZACCEL_ACCELPEDALS0STATENO ( 0U )
+#define ZACCEL_ACCELPEDALS1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZACCEL_ACCELPEDALS0STATESERIALNO ( 0U )
+#define ZACCEL_ACCELPEDALS1STATESERIALNO ( 1U )
+
+/*Event no define*/
+#define ZACCEL_ACCELPEDALE0EVENTNO ( 0U )
+#define ZACCEL_ACCELPEDALE1EVENTNO ( 1U )
+
+/*Event serial no define*/
+#define ZACCEL_ACCELPEDALE0EVENTSERIALNO ( 0U )
+#define ZACCEL_ACCELPEDALE1EVENTSERIALNO ( 1U )
+
+/*Extern function*/
+extern void stm_aps_event_call( void );
+extern void stm_aps_initialize( void );
+extern void ZACCEL_AccelPedalTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.c
new file mode 100644
index 0000000..1fd9c2a
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.c
@@ -0,0 +1,45 @@
+/************************************************************/
+/* ZACCEL_AccelPedalState_func.c */
+/* Function and variable source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/*************************************************************
+ Function definition
+*************************************************************/
+
+/*
+ * @name stm_aps_start_activity_accel_pedal_off
+ */
+void stm_aps_start_activity_accel_pedal_off() {
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state = StmAccelPedalSttNoOff;
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_aps_start_activity_accel_pedal_on
+ */
+void stm_aps_start_activity_accel_pedal_on() {
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state = StmAccelPedalSttNoOn;
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_aps_initialize_variable
+ */
+void stm_aps_initialize_variable() {
+ g_stm_prv_state.car_element[StmCarElementNoAccelPedal].state = StmAccelPedalSttNoOff;
+ g_stm_prv_state.car_element[StmCarElementNoAccelPedal].changed = STM_FALSE;
+
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state = StmAccelPedalSttNoOff;
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].changed = STM_FALSE;
+}
+
+/*
+ * @name stm_aps_start_stm
+ */
+void stm_aps_start_stm() {
+ g_stm_prv_state.car_element[StmCarElementNoAccelPedal].state = g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state;
+ g_stm_crr_state.car_element[StmCarElementNoAccelPedal].changed = STM_FALSE;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.h
new file mode 100644
index 0000000..7d36cd0
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AccelPedal/ZACCEL_AccelPedalState_func.h
@@ -0,0 +1,14 @@
+/************************************************************/
+/* ZACCEL_AccelPedalState_func.h */
+/* Function and variable header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZACCEL_ACCELPEDALSTATE_FUNC_H
+#define ZHEADER_ZACCEL_ACCELPEDALSTATE_FUNC_H
+
+extern void stm_aps_start_activity_accel_pedal_off();
+extern void stm_aps_start_activity_accel_pedal_on();
+extern void stm_aps_initialize_variable();
+extern void stm_aps_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c
new file mode 100644
index 0000000..9002810
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.c
@@ -0,0 +1,1991 @@
+/************************************************************/
+/* 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_RestrictionModeOffs1e8( void );
+static void ZAPL_RestrictionModeOffs1e14( void );
+static void ZAPL_RestrictionModeOffs2e3( void );
+static void ZAPL_RestrictionModeOffs3e16( void );
+static void ZAPL_RestrictionModeOffs4e17( 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_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_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_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( No 1 ) */
+/* Event : stt_prv_layer_apps_map_nml( No 14 ) */
+/****************************************/
+static void ZAPL_RestrictionModeOffs1e14( void )
+{
+ stm_apl_start_activity_map();
+}
+
+/****************************************/
+/* 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 : stt_prv_layer_apps_map_fll( No 16 ) */
+/****************************************/
+static void ZAPL_RestrictionModeOffs3e16( void )
+{
+ stm_apl_start_activity_map_fullscreen();
+}
+
+/****************************************/
+/* Action function */
+/* STM : RestrictionModeOff */
+/* State : splitable_normal( No 4 ) */
+/* Event : stt_prv_layer_apps_spl_nml( No 17 ) */
+/****************************************/
+static void ZAPL_RestrictionModeOffs4e17( 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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ stm_apl_event_restriction_mode_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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_map*/
+ if( g_stm_category == StmCtgNoMap )
+ {
+ /*ara_fullscreen*/
+ 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_RestrictionModeOffs1e14();
+ }
+ /*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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].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();
+ }
+ 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_RestrictionModeOffs3e16();
+ }
+ /*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.car_element[StmCarElementNoRestrictionMode].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_split_main*/
+ 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_RestrictionModeOffs4e17();
+ }
+ /*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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].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_on( No 1 )*/
+/****************************************/
+static void ZAPL_AppsLayers1Event( void )
+{
+ /*stt_restriction_mode_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ /*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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ /*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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_AppsLayer.h
new file mode 100644
index 0000000..4cbbc10
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.c
new file mode 100644
index 0000000..d2e7075
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_apl_event_restriction_mode_on
+ */
+void stm_apl_event_restriction_mode_on() {
+ g_prv_apps_state_car_stop = 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/AppsLayer/ZAPL_Apps_func.h
new file mode 100644
index 0000000..4f74c9f
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_on();
+extern void stm_apl_initialize_variable();
+extern void stm_apl_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.c
new file mode 100644
index 0000000..8e20123
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.c
@@ -0,0 +1,154 @@
+/************************************************************/
+/* ZCAR_CarState.c */
+/* CarState State transition model source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/* State management variable */
+static uint8_t ZCAR_CarStateState[ZCAR_CARSTATESTATENOMAX];
+
+static void ZCAR_CarStates0e1( void );
+static void ZCAR_CarStates1e0( void );
+static void ZCAR_CarStates0Event( void );
+static void ZCAR_CarStates1Event( void );
+
+/****************************************/
+/* Action function */
+/* STM : CarState */
+/* State : car_stop( No 0 ) */
+/* Event : stt_accel_pedal_on( No 1 ) */
+/****************************************/
+static void ZCAR_CarStates0e1( void )
+{
+ ZCAR_CarStateState[ZCAR_CARSTATE] = ( uint8_t )ZCAR_CARSTATES1;
+ stm_rns_start_activity_car_run();
+}
+
+/****************************************/
+/* Action function */
+/* STM : CarState */
+/* State : car_run( No 1 ) */
+/* Event : stt_accel_pedal_off( No 0 )*/
+/****************************************/
+static void ZCAR_CarStates1e0( void )
+{
+ ZCAR_CarStateState[ZCAR_CARSTATE] = ( uint8_t )ZCAR_CARSTATES0;
+ stm_rns_start_activity_car_stop();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : CarState */
+/* State : car_stop( No 0 ) */
+/****************************************/
+static void ZCAR_CarStates0Event( void )
+{
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*stt_accel_pedal_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state == StmAccelPedalSttNoOn )
+ {
+ ZCAR_CarStates0e1();
+ }
+ 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 : CarState */
+/* State : car_run( No 1 ) */
+/****************************************/
+static void ZCAR_CarStates1Event( void )
+{
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*stt_accel_pedal_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state == StmAccelPedalSttNoOff )
+ {
+ ZCAR_CarStates1e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*stt_lightstatus_brake_on*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*stt_accel_pedal_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state == StmAccelPedalSttNoOff )
+ {
+ ZCAR_CarStates1e0();
+ }
+ /*stt_accel_pedal_on*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoAccelPedal].state == StmAccelPedalSttNoOn )
+ {
+ ZCAR_CarStates1e0();
+ }
+ 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 : CarState */
+/****************************************/
+void stm_rns_event_call( void )
+{
+ stm_rns_start_stm();
+ switch( ZCAR_CarStateState[ZCAR_CARSTATE] )
+ {
+ case ZCAR_CARSTATES0:
+ ZCAR_CarStates0Event();
+ break;
+ case ZCAR_CARSTATES1:
+ ZCAR_CarStates1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : CarState */
+/****************************************/
+void stm_rns_initialize( void )
+{
+ ZCAR_CarStateState[ZCAR_CARSTATE] = ( uint8_t )ZCAR_CARSTATES0;
+ stm_rns_start_activity_car_stop();
+}
+
+/****************************************/
+/* Terminate function */
+/* STM : CarState */
+/****************************************/
+void ZCAR_CarStateTerminate( void )
+{
+ ZCAR_CarStateState[ZCAR_CARSTATE] = ( uint8_t )ZCAR_CARSTATETERMINATE;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.h
new file mode 100644
index 0000000..18003a7
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState.h
@@ -0,0 +1,45 @@
+/************************************************************/
+/* ZCAR_CarState.h */
+/* CarState State transition model header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZCAR_CARSTATE_H
+#define ZHEADER_ZCAR_CARSTATE_H
+
+/*State management variable access define*/
+#define ZCAR_CARSTATE ( 0U )
+#define ZCAR_CARSTATES0 ( 0U )
+#define ZCAR_CARSTATES1 ( 1U )
+#define ZCAR_CARSTATESTATENOMAX ( 1U )
+
+/*End state define*/
+#define ZCAR_CARSTATEEND ( 2U )
+/*Terminate state define*/
+#define ZCAR_CARSTATETERMINATE ( ZCAR_CARSTATEEND + 1U )
+
+/*State no define*/
+#define ZCAR_CARSTATES0STATENO ( 0U )
+#define ZCAR_CARSTATES1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZCAR_CARSTATES0STATESERIALNO ( 0U )
+#define ZCAR_CARSTATES1STATESERIALNO ( 1U )
+
+/*Event no define*/
+#define ZCAR_CARSTATEE0EVENTNO ( 0U )
+#define ZCAR_CARSTATEE1EVENTNO ( 1U )
+#define ZCAR_CARSTATEE2EVENTNO ( 2U )
+#define ZCAR_CARSTATEE3EVENTNO ( 3U )
+
+/*Event serial no define*/
+#define ZCAR_CARSTATEE0EVENTSERIALNO ( 0U )
+#define ZCAR_CARSTATEE1EVENTSERIALNO ( 1U )
+#define ZCAR_CARSTATEE2EVENTSERIALNO ( 2U )
+#define ZCAR_CARSTATEE3EVENTSERIALNO ( 3U )
+
+/*Extern function*/
+extern void stm_rns_event_call( void );
+extern void stm_rns_initialize( void );
+extern void ZCAR_CarStateTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.c
new file mode 100644
index 0000000..d6cd5d1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.c
@@ -0,0 +1,45 @@
+/************************************************************/
+/* ZCAR_CarState_func.c */
+/* Function and variable source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/*************************************************************
+ Function definition
+*************************************************************/
+
+/*
+ * @name stm_rns_start_activity_car_stop
+ */
+void stm_rns_start_activity_car_stop() {
+ g_stm_crr_state.car_element[StmCarElementNoRunning].state = StmRunningNoStop;
+ g_stm_crr_state.car_element[StmCarElementNoRunning].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_rns_start_activity_car_run
+ */
+void stm_rns_start_activity_car_run() {
+ g_stm_crr_state.car_element[StmCarElementNoRunning].state = StmRunningNoRun;
+ g_stm_crr_state.car_element[StmCarElementNoRunning].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_rns_initialize_variable
+ */
+void stm_rns_initialize_variable() {
+ g_stm_prv_state.car_element[StmCarElementNoRunning].state = StmRunningNoStop;
+ g_stm_prv_state.car_element[StmCarElementNoRunning].changed = STM_FALSE;
+
+ g_stm_crr_state.car_element[StmCarElementNoRunning].state = StmRunningNoStop;
+ g_stm_crr_state.car_element[StmCarElementNoRunning].changed = STM_FALSE;
+}
+
+/*
+ * @name stm_rns_start_stm
+ */
+void stm_rns_start_stm() {
+ g_stm_prv_state.car_element[StmCarElementNoRunning].state = g_stm_crr_state.car_element[StmCarElementNoRunning].state;
+ g_stm_crr_state.car_element[StmCarElementNoRunning].changed = STM_FALSE;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.h
new file mode 100644
index 0000000..8c1dc93
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/CarState/ZCAR_CarState_func.h
@@ -0,0 +1,14 @@
+/************************************************************/
+/* ZCAR_CarState_func.h */
+/* Function and variable header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZCAR_CARSTATE_FUNC_H
+#define ZHEADER_ZCAR_CARSTATE_FUNC_H
+
+extern void stm_rns_start_activity_car_stop();
+extern void stm_rns_start_activity_car_run();
+extern void stm_rns_initialize_variable();
+extern void stm_rns_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c
new file mode 100644
index 0000000..1375c66
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.c
@@ -0,0 +1,112 @@
+/************************************************************/
+/* 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_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();
+}
+
+/****************************************/
+/* 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 )
+{
+}
+
+/****************************************/
+/* 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen.h
new file mode 100644
index 0000000..ffa8552
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.c
new file mode 100644
index 0000000..4d50ab0
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/HomeScreenLayer/ZHSL_HomeScreen_func.h
new file mode 100644
index 0000000..d5f4ab9
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.c
new file mode 100644
index 0000000..8f65d32
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.c
@@ -0,0 +1,117 @@
+/************************************************************/
+/* ZLIGHT_LightstatusBrake.c */
+/* LightstatusBrake State transition model source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/* State management variable */
+static uint8_t ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKESTATENOMAX];
+
+static void ZLIGHT_LightstatusBrakes0e1( void );
+static void ZLIGHT_LightstatusBrakes1e0( void );
+static void ZLIGHT_LightstatusBrakes0Event( void );
+static void ZLIGHT_LightstatusBrakes1Event( void );
+
+/****************************************/
+/* Action function */
+/* STM : LightstatusBrake */
+/* State : lightstatus_brake_on( No 0 ) */
+/* Event : evt_lightstatus_brake_off( No 1 ) */
+/****************************************/
+static void ZLIGHT_LightstatusBrakes0e1( void )
+{
+ ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKE] = ( uint8_t )ZLIGHT_LIGHTSTATUSBRAKES1;
+ stm_lbs_start_activity_lightstatus_brake_off();
+}
+
+/****************************************/
+/* Action function */
+/* STM : LightstatusBrake */
+/* State : lightstatus_brake_off( No 1 ) */
+/* Event : evt_lightstatus_brake_on( No 0 ) */
+/****************************************/
+static void ZLIGHT_LightstatusBrakes1e0( void )
+{
+ ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKE] = ( uint8_t )ZLIGHT_LIGHTSTATUSBRAKES0;
+ stm_lbs_start_activity_lightstatus_brake_on();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : LightstatusBrake */
+/* State : lightstatus_brake_on( No 0 ) */
+/****************************************/
+static void ZLIGHT_LightstatusBrakes0Event( void )
+{
+ /*evt_lightstatus_brake_off*/
+ if( g_stm_event == StmEvtNoLightstatusBrakeOff )
+ {
+ ZLIGHT_LightstatusBrakes0e1();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : LightstatusBrake */
+/* State : lightstatus_brake_off( No 1 ) */
+/****************************************/
+static void ZLIGHT_LightstatusBrakes1Event( void )
+{
+ /*evt_lightstatus_brake_on*/
+ if( g_stm_event == StmEvtNoLightstatusBrakeOn )
+ {
+ ZLIGHT_LightstatusBrakes1e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event call function */
+/* STM : LightstatusBrake */
+/****************************************/
+void stm_lbs_event_call( void )
+{
+ stm_lbs_start_stm();
+ switch( ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKE] )
+ {
+ case ZLIGHT_LIGHTSTATUSBRAKES0:
+ ZLIGHT_LightstatusBrakes0Event();
+ break;
+ case ZLIGHT_LIGHTSTATUSBRAKES1:
+ ZLIGHT_LightstatusBrakes1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : LightstatusBrake */
+/****************************************/
+void stm_lbs_initialize( void )
+{
+ ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKE] = ( uint8_t )ZLIGHT_LIGHTSTATUSBRAKES0;
+ stm_lbs_start_activity_lightstatus_brake_on();
+}
+
+/****************************************/
+/* Terminate function */
+/* STM : LightstatusBrake */
+/****************************************/
+void ZLIGHT_LightstatusBrakeTerminate( void )
+{
+ ZLIGHT_LightstatusBrakeState[ZLIGHT_LIGHTSTATUSBRAKE] = ( uint8_t )ZLIGHT_LIGHTSTATUSBRAKETERMINATE;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.h
new file mode 100644
index 0000000..0ced0ec
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrake.h
@@ -0,0 +1,41 @@
+/************************************************************/
+/* ZLIGHT_LightstatusBrake.h */
+/* LightstatusBrake State transition model header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZLIGHT_LIGHTSTATUSBRAKE_H
+#define ZHEADER_ZLIGHT_LIGHTSTATUSBRAKE_H
+
+/*State management variable access define*/
+#define ZLIGHT_LIGHTSTATUSBRAKE ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKES0 ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKES1 ( 1U )
+#define ZLIGHT_LIGHTSTATUSBRAKESTATENOMAX ( 1U )
+
+/*End state define*/
+#define ZLIGHT_LIGHTSTATUSBRAKEEND ( 2U )
+/*Terminate state define*/
+#define ZLIGHT_LIGHTSTATUSBRAKETERMINATE ( ZLIGHT_LIGHTSTATUSBRAKEEND + 1U )
+
+/*State no define*/
+#define ZLIGHT_LIGHTSTATUSBRAKES0STATENO ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKES1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZLIGHT_LIGHTSTATUSBRAKES0STATESERIALNO ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKES1STATESERIALNO ( 1U )
+
+/*Event no define*/
+#define ZLIGHT_LIGHTSTATUSBRAKEE0EVENTNO ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKEE1EVENTNO ( 1U )
+
+/*Event serial no define*/
+#define ZLIGHT_LIGHTSTATUSBRAKEE0EVENTSERIALNO ( 0U )
+#define ZLIGHT_LIGHTSTATUSBRAKEE1EVENTSERIALNO ( 1U )
+
+/*Extern function*/
+extern void stm_lbs_event_call( void );
+extern void stm_lbs_initialize( void );
+extern void ZLIGHT_LightstatusBrakeTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.c
new file mode 100644
index 0000000..70c7478
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.c
@@ -0,0 +1,45 @@
+/************************************************************/
+/* ZLIGHT_LightstatusBrakeStatus_func.c */
+/* Function and variable source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../ZST_include.h"
+
+/*************************************************************
+ Function definition
+*************************************************************/
+
+/*
+ * @name stm_lbs_start_activity_lightstatus_brake_off
+ */
+void stm_lbs_start_activity_lightstatus_brake_off() {
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state = StmLightstatusBrakeSttNoOff;
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_lbs_start_activity_lightstatus_brake_on
+ */
+void stm_lbs_start_activity_lightstatus_brake_on() {
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state = StmLightstatusBrakeSttNoOn;
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_lbs_initialize_variable
+ */
+void stm_lbs_initialize_variable() {
+ g_stm_prv_state.car_element[StmCarElementNoLightstatusBrake].state = StmLightstatusBrakeSttNoOn;
+ g_stm_prv_state.car_element[StmCarElementNoLightstatusBrake].changed = STM_FALSE;
+
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state = StmLightstatusBrakeSttNoOn;
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].changed = STM_FALSE;
+}
+
+/*
+ * @name stm_lbs_start_stm
+ */
+void stm_lbs_start_stm() {
+ g_stm_prv_state.car_element[StmCarElementNoLightstatusBrake].state = g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state;
+ g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].changed = STM_FALSE;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.h
new file mode 100644
index 0000000..5ebd5b1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.h
@@ -0,0 +1,14 @@
+/************************************************************/
+/* ZLIGHT_LightstatusBrakeStatus_func.h */
+/* Function and variable header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZLIGHT_LIGHTSTATUSBRAKESTATUS_FUNC_H
+#define ZHEADER_ZLIGHT_LIGHTSTATUSBRAKESTATUS_FUNC_H
+
+extern void stm_lbs_start_activity_lightstatus_brake_off();
+extern void stm_lbs_start_activity_lightstatus_brake_on();
+extern void stm_lbs_initialize_variable();
+extern void stm_lbs_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.c
new file mode 100644
index 0000000..dad2484
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop;
+ g_stm_crr_state.layer[StmLayerNoNearHomescreen].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_nhl_event_restriction_mode_on
+ */
+void stm_nhl_event_restriction_mode_on() {
+ g_prv_near_homescreen_state_car_stop = 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomeScreen_func.h
new file mode 100644
index 0000000..d2b13f7
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c
new file mode 100644
index 0000000..1c024b8
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.c
@@ -0,0 +1,220 @@
+/************************************************************/
+/* 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_NearHomescreens1e2( void );
+static void ZNHL_NearHomescreens1e4( 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 : ctg_software_keyboard( No 2 ) */
+/****************************************/
+static void ZNHL_NearHomescreens1e2( void )
+{
+ ZNHL_NearHomescreenState[ZNHL_NEARHOMESCREEN] = ( uint8_t )ZNHL_NEARHOMESCREENS0;
+ stm_nhl_start_activity_none();
+}
+
+/****************************************/
+/* Action function */
+/* STM : NearHomescreen */
+/* State : software_keyboard( No 1 ) */
+/* Event : stt_prv_layer_near_homescreen_sft_kbd( No 4 ) */
+/****************************************/
+static void ZNHL_NearHomescreens1e4( void )
+{
+ stm_nhl_start_activity_software_keyboard();
+}
+
+/****************************************/
+/* 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_deactivate*/
+ 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_NearHomescreens1e4();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*stt_lightstatus_brake_off*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/NearHomeScreen/ZNHL_NearHomescreen.h
new file mode 100644
index 0000000..f23775e
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.c
new file mode 100644
index 0000000..c131608
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop;
+ g_stm_crr_state.layer[StmLayerNoOnScreen].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_osl_event_restriction_mode_on
+ */
+void stm_osl_event_restriction_mode_on() {
+ g_prv_on_screen_state_car_stop = 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OnScreen_func.h
new file mode 100644
index 0000000..3edef28
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_on();
+extern void stm_osl_initialize_variable();
+extern void stm_osl_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c
new file mode 100644
index 0000000..6b60219
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.c
@@ -0,0 +1,718 @@
+/************************************************************/
+/* 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_OslRestOffs2e6( void );
+static void ZOSL_OslRestOns0e0( void );
+static void ZOSL_OslRestOns0e2( void );
+static void ZOSL_OslRestOns1e1( void );
+static void ZOSL_OslRestOns1e3( 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_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_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 : stt_prv_layer_on_screen_sys_alt( No 6 ) */
+/****************************************/
+static void ZOSL_OslRestOffs2e6( 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 : ctg_systemalert( No 1 ) */
+/****************************************/
+static void ZOSL_OslRestOns1e1( void )
+{
+ ZOSL_OslMainState[ZOSL_OSLMAINS1F] = ( uint8_t )ZOSL_OSLRESTONS0;
+ stm_osl_start_activity_none();
+}
+
+/****************************************/
+/* Action function */
+/* STM : OslRestOn */
+/* State : system_alert( No 1 ) */
+/* Event : stt_prv_layer_on_screen_sys_alt( No 3 ) */
+/****************************************/
+static void ZOSL_OslRestOns1e3( void )
+{
+ stm_osl_start_activity_system_alert();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : OslMain */
+/* State : restriction_mode_off( No 0 ) */
+/****************************************/
+static void ZOSL_OslMains0Event( void )
+{
+ /*stt_restriction_mode_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ stm_rel_event_restriction_mode_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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].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.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*evt_deactivate*/
+ 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_OslRestOffs2e6();
+ }
+ 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_on( No 1 )*/
+/****************************************/
+static void ZOSL_OslMains1Event( void )
+{
+ /*stt_restriction_mode_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ /*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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ /*evt_deactivate*/
+ 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_OslRestOns1e3();
+ }
+ 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/OnScreenlayer/ZOSL_OslMain.h
new file mode 100644
index 0000000..ee45304
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c
new file mode 100644
index 0000000..4c390ff
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.c
@@ -0,0 +1,1003 @@
+/************************************************************/
+/* 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_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_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_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_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOn )
+ {
+ stm_rel_event_restriction_mode_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_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*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.*/
+ }
+ }
+ /*evt_undo*/
+ else 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_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*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_lightstatus_brake_on*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*stt_prv_layer_rst_not_none*/
+ if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone )
+ {
+ ZREL_RelRestOffs1e4();
+ }
+ 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_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_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*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_lightstatus_brake_on*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*stt_prv_layer_rst_not_none*/
+ if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone )
+ {
+ ZREL_RelRestOffs1e4();
+ }
+ 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_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_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state == StmRestrictionModeSttNoOff )
+ {
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*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_lightstatus_brake_on*/
+ else if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*stt_prv_layer_rst_not_none*/
+ if( g_stm_prv_state.layer[StmLayerNoRestriction].state != StmLayoutNoNone )
+ {
+ ZREL_RelRestOffs1e4();
+ }
+ 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_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_on( No 1 )*/
+/****************************************/
+static void ZREL_RelMains1Event( void )
+{
+ /*stt_restriction_mode_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_RelMain.h
new file mode 100644
index 0000000..ce82e7a
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.c
new file mode 100644
index 0000000..a1aa213
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop;
+ g_stm_crr_state.layer[StmLayerNoRestriction].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_rel_event_restriction_mode_on
+ */
+void stm_rel_event_restriction_mode_on() {
+ g_prv_restriction_state_car_stop = 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionLayer/ZREL_Restriction_func.h
new file mode 100644
index 0000000..3763820
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_on();
+extern void stm_rel_initialize_variable();
+extern void stm_rel_start_stm();
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c
new file mode 100644
index 0000000..2ba6a87
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.c
@@ -0,0 +1,117 @@
+/************************************************************/
+/* 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_RestrictionModes1e0( void );
+static void ZREM_RestrictionModes0Event( void );
+static void ZREM_RestrictionModes1Event( void );
+
+/****************************************/
+/* Action function */
+/* STM : RestrictionMode */
+/* State : restriction_mode_on( No 0 )*/
+/* Event : evt_restriction_mode_off( No 1 ) */
+/****************************************/
+static void ZREM_RestrictionModes0e1( void )
+{
+ ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES1;
+ stm_rem_start_activity_restriction_mode_off();
+}
+
+/****************************************/
+/* Action function */
+/* STM : RestrictionMode */
+/* State : restriction_mode_off( No 1 ) */
+/* Event : evt_restriction_mode_on( No 0 ) */
+/****************************************/
+static void ZREM_RestrictionModes1e0( void )
+{
+ ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES0;
+ stm_rem_start_activity_restriction_mode_on();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : RestrictionMode */
+/* State : restriction_mode_on( No 0 )*/
+/****************************************/
+static void ZREM_RestrictionModes0Event( void )
+{
+ /*evt_restriction_mode_off*/
+ if( g_stm_event == StmEvtNoRestrictionModeOff )
+ {
+ ZREM_RestrictionModes0e1();
+ }
+ 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_off( No 1 ) */
+/****************************************/
+static void ZREM_RestrictionModes1Event( void )
+{
+ /*evt_restriction_mode_on*/
+ if( g_stm_event == StmEvtNoRestrictionModeOn )
+ {
+ ZREM_RestrictionModes1e0();
+ }
+ 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;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : RestrictionMode */
+/****************************************/
+void stm_rem_initialize( void )
+{
+ ZREM_RestrictionModeState[ZREM_RESTRICTIONMODE] = ( uint8_t )ZREM_RESTRICTIONMODES1;
+ 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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h
new file mode 100644
index 0000000..4ce0cac
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode.h
@@ -0,0 +1,41 @@
+/************************************************************/
+/* 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_RESTRICTIONMODESTATENOMAX ( 1U )
+
+/*End state define*/
+#define ZREM_RESTRICTIONMODEEND ( 2U )
+/*Terminate state define*/
+#define ZREM_RESTRICTIONMODETERMINATE ( ZREM_RESTRICTIONMODEEND + 1U )
+
+/*State no define*/
+#define ZREM_RESTRICTIONMODES0STATENO ( 0U )
+#define ZREM_RESTRICTIONMODES1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZREM_RESTRICTIONMODES0STATESERIALNO ( 0U )
+#define ZREM_RESTRICTIONMODES1STATESERIALNO ( 1U )
+
+/*Event no define*/
+#define ZREM_RESTRICTIONMODEE0EVENTNO ( 0U )
+#define ZREM_RESTRICTIONMODEE1EVENTNO ( 1U )
+
+/*Event serial no define*/
+#define ZREM_RESTRICTIONMODEE0EVENTSERIALNO ( 0U )
+#define ZREM_RESTRICTIONMODEE1EVENTSERIALNO ( 1U )
+
+/*Extern function*/
+extern void stm_rem_event_call( void );
+extern void stm_rem_initialize( void );
+extern void ZREM_RestrictionModeTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c
new file mode 100644
index 0000000..e920916
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.c
@@ -0,0 +1,45 @@
+/************************************************************/
+/* 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_on
+ */
+void stm_rem_start_activity_restriction_mode_on() {
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state = StmRestrictionModeSttNoOn;
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_rem_start_activity_restriction_mode_off
+ */
+void stm_rem_start_activity_restriction_mode_off() {
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state = StmRestrictionModeSttNoOff;
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].changed = STM_TRUE;
+}
+
+/*
+ * @name stm_rem_initialize_variable
+ */
+void stm_rem_initialize_variable() {
+ g_stm_prv_state.car_element[StmCarElementNoRestrictionMode].state = StmRestrictionModeSttNoOff;
+ g_stm_prv_state.car_element[StmCarElementNoRestrictionMode].changed = STM_FALSE;
+
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state = StmRestrictionModeSttNoOff;
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].changed = STM_FALSE;
+}
+
+/*
+ * @name stm_rem_start_stm
+ */
+void stm_rem_start_stm() {
+ g_stm_prv_state.car_element[StmCarElementNoRestrictionMode].state = g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].state;
+ g_stm_crr_state.car_element[StmCarElementNoRestrictionMode].changed = STM_FALSE;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h
new file mode 100644
index 0000000..bbb6edf
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/RestrictionMode/ZREM_RestrictionMode_func.h
@@ -0,0 +1,14 @@
+/************************************************************/
+/* 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_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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_def.h
new file mode 100644
index 0000000..0212a95
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c
new file mode 100644
index 0000000..daea2ca
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.c
@@ -0,0 +1,178 @@
+/************************************************************/
+/* ZST_StateTransitionor_func.c */
+/* Function and variable source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "ZST_include.h"
+#include "../stm_master_apps.h"
+#include "../stm_master_remote.h"
+
+/*************************************************************
+ Function definition
+*************************************************************/
+
+#include <string.h>
+#include <stdbool.h>
+
+static bool isMaster = false;
+
+//=================================
+// API
+//=================================
+/**
+ * Initialize STM
+ */
+void stmInitializeInner(const char *ecu_name) {
+
+ // TODO: Set master mode
+ if (0 == strcmp("master", ecu_name))
+ {
+ isMaster = true;
+ }
+
+ // 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 LightstatusBrake state */
+ stm_lbs_initialize();
+ stm_lbs_initialize_variable();
+
+ /* Initialize AccelPedal state */
+ stm_aps_initialize();
+ stm_aps_initialize_variable();
+
+ /* Initialize car state */
+ stm_rns_initialize();
+ stm_rns_initialize_variable();
+
+ /* Initialize restriction mode state */
+ stm_rem_initialize();
+ stm_rem_initialize_variable();
+
+ // Initialize homecsreen layer
+ stm_hsl_initialize();
+ stm_hsl_initialize_variable();
+
+ if (isMaster)
+ {
+ // Initialize apps layer on master ecu
+ stm_master_apl_initialize();
+ stm_master_apl_initialize_valiable();
+ }
+ else
+ {
+ // 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();
+
+ if (isMaster)
+ {
+ // Initialize remote layer on master ecu
+ stm_mst_rmt_initialize();
+ stm_mst_rmt_initialize_valiable();
+ }
+
+ 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);
+
+ // LightstatusBrake state
+ stm_lbs_event_call();
+
+ // AccelPedal state
+ stm_aps_event_call();
+
+ // Car state
+ stm_rns_event_call();
+
+ // restriction mode
+ stm_rem_event_call();
+
+ // homescreen layer
+ stm_hsl_event_call();
+
+ if (isMaster)
+ {
+ // apps layer on master ecu
+ stm_master_apl_event_call();
+ }
+ else
+ {
+ // 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();
+
+ if (isMaster)
+ {
+ // remote layer on master ecu
+ stm_mst_rmt_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;
+
+ if (isMaster)
+ {
+ // apps layer on master ecu
+ stm_master_apl_event_call();
+ }
+ else
+ {
+ // 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();
+
+ if (isMaster)
+ {
+ // remote layer on master ecu
+ stm_mst_rmt_event_call();
+ }
+
+ g_stm_crr_state = g_stm_prv_state;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_func.h
new file mode 100644
index 0000000..78c4636
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.c
new file mode 100644
index 0000000..a5e67ff
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop
+ */
+int g_prv_apps_state_car_stop;
+
+/**
+ * g_prv_near_homescreen_state_car_stop
+ */
+int g_prv_near_homescreen_state_car_stop;
+
+/**
+ * g_prv_restriction_state_car_stop
+ */
+int g_prv_restriction_state_car_stop;
+
+/**
+ * g_prv_on_screen_state_car_stop
+ */
+int g_prv_on_screen_state_car_stop;
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_StateTransitionor_var.h
new file mode 100644
index 0000000..4cabced
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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_car_stop;
+extern int g_prv_near_homescreen_state_car_stop;
+extern int g_prv_restriction_state_car_stop;
+extern int g_prv_on_screen_state_car_stop;
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_include.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_include.h
new file mode 100644
index 0000000..2158660
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/ZST_include.h
@@ -0,0 +1,39 @@
+/************************************************************/
+/* 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 "master/layer/apps/Zmaster_apps_master_apps_def.h"
+#include "master/layer/remote/Zmaster_remote_master_remote_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 "AccelPedal/ZACCEL_AccelPedalState_func.h"
+#include "CarState/ZCAR_CarState_func.h"
+#include "LightStatusBrake/ZLIGHT_LightstatusBrakeStatus_func.h"
+#include "master/layer/apps/Zmaster_apps_apps_main.h"
+#include "master/layer/remote/Zmaster_remote_remote.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"
+#include "AccelPedal/ZACCEL_AccelPedal.h"
+#include "CarState/ZCAR_CarState.h"
+#include "LightStatusBrake/ZLIGHT_LightstatusBrake.h"
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.c
new file mode 100644
index 0000000..af46ea9
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.c
@@ -0,0 +1,1456 @@
+/************************************************************/
+/* Zmaster_apps_apps_main.c */
+/* apps_main State transition model source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../../../ZST_include.h"
+
+/* State management variable */
+static uint8_t Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINSTATENOMAX];
+
+static void Zmaster_apps_apps_mains0StateEntry( void );
+static void Zmaster_apps_apps_mains1StateEntry( void );
+static void Zmaster_apps_apps_mains0e1( void );
+static void Zmaster_apps_apps_mains1e0( void );
+static void Zmaster_apps_apps_car_stops0e0( void );
+static void Zmaster_apps_apps_car_stops0e2( void );
+static void Zmaster_apps_apps_car_stops0e3( void );
+static void Zmaster_apps_apps_car_stops0e4( void );
+static void Zmaster_apps_apps_car_stops0e11( void );
+static void Zmaster_apps_apps_car_stops0e15( void );
+static void Zmaster_apps_apps_car_runs0e0( void );
+static void Zmaster_apps_apps_car_runs0e3( void );
+static void Zmaster_apps_apps_mains0Event( void );
+static void Zmaster_apps_apps_car_stops0Event( void );
+static void Zmaster_apps_apps_car_stops1Event( void );
+static void Zmaster_apps_apps_car_stops2Event( void );
+static void Zmaster_apps_apps_car_stops3Event( void );
+static void Zmaster_apps_apps_car_stops4Event( void );
+static void Zmaster_apps_apps_car_stops5Event( void );
+static void Zmaster_apps_apps_mains1Event( void );
+static void Zmaster_apps_apps_car_runs0Event( void );
+static void Zmaster_apps_apps_car_runs1Event( void );
+
+/****************************************/
+/* State start activity function */
+/* STM : apps_main */
+/* State : lightstatus_brake_on( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains0StateEntry( void )
+{
+ switch( Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] )
+ {
+ case ZMASTER_APPS_APPS_CAR_STOPS0:
+ stm_mst_apl_start_activity_none();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS1:
+ stm_mst_apl_start_activity_meter_receiver();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS2:
+ stm_mst_apl_start_activity_meter_splitable();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS3:
+ stm_mst_apl_start_activity_splitable_receiver();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS4:
+ stm_mst_apl_start_activity_splitable_split();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS5:
+ stm_mst_apl_start_activity_general();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* State start activity function */
+/* STM : apps_main */
+/* State : lightstatus_brake_off( No 1 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains1StateEntry( void )
+{
+ switch( Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] )
+ {
+ case ZMASTER_APPS_APPS_CAR_RUNS0:
+ stm_mst_apl_start_activity_meter_receiver();
+ break;
+ case ZMASTER_APPS_APPS_CAR_RUNS1:
+ stm_mst_apl_start_activity_meter();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_main */
+/* State : lightstatus_brake_on( No 0 ) */
+/* Event : stt_lightstatus_brake_off( No 1 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains0e1( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAIN] = ( uint8_t )ZMASTER_APPS_APPS_MAINS1;
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_RUNS0;
+ Zmaster_apps_apps_mains1StateEntry();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_main */
+/* State : lightstatus_brake_off( No 1 ) */
+/* Event : stt_lightstatus_brake_on( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains1e0( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAIN] = ( uint8_t )ZMASTER_APPS_APPS_MAINS0;
+ Zmaster_apps_apps_mains0StateEntry();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : ara_split_main( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e0( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS1;
+ stm_mst_apl_start_activity_meter_receiver();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : ara_split_main( No 2 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e2( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS3;
+ stm_mst_apl_start_activity_splitable_receiver();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : ara_split_sub( No 3 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e3( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS2;
+ stm_mst_apl_start_activity_meter_splitable();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : ara_normal( No 4 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e4( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS5;
+ stm_mst_apl_start_activity_general();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : stt_prv_layer_apps_none( No 11 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e11( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS0;
+ stm_mst_apl_start_activity_none();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/* Event : stt_prv_layer_apps_splitable_split( No 15 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0e15( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS4;
+ stm_mst_apl_start_activity_splitable_split();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_run */
+/* State : meter_receiver( No 0 ) */
+/* Event : ara_normal( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_runs0e0( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_RUNS1;
+ stm_mst_apl_start_activity_meter();
+}
+
+/****************************************/
+/* Action function */
+/* STM : apps_car_run */
+/* State : meter_receiver( No 0 ) */
+/* Event : stt_prv_layer_apps_meter_receiver( No 3 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_runs0e3( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_RUNS0;
+ stm_mst_apl_start_activity_meter_receiver();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : apps_main */
+/* State : lightstatus_brake_on( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains0Event( void )
+{
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ stm_mst_apl_event_lightstatus_brake_off();
+ Zmaster_apps_apps_mains0e1();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : apps_car_stop */
+/* State : none( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops0Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_receiver*/
+ else if( g_stm_category == StmCtgNoReceiver )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_car_stop */
+/* State : meter_receiver( No 1 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops1Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_splitable_main*/
+ if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*ctg_receiver*/
+ else if( g_stm_category == StmCtgNoReceiver )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_car_stop */
+/* State : meter_splitable( No 2 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops2Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_receiver*/
+ if( g_stm_category == StmCtgNoReceiver )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_car_stop */
+/* State : splitable_receiver( No 3 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops3Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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_receiver*/
+ if( g_stm_category == StmCtgNoReceiver )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_car_stop */
+/* State : splitable_split( No 4 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops4Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_receiver*/
+ else if( g_stm_category == StmCtgNoReceiver )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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_main*/
+ if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_car_stop */
+/* State : general( No 5 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_stops5Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_receiver*/
+ else if( g_stm_category == StmCtgNoReceiver )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_main*/
+ else if( g_stm_category == StmCtgNoSplitableMain )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_splitable_sub*/
+ else if( g_stm_category == StmCtgNoSplitableSub )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ 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 )
+ {
+ Zmaster_apps_apps_car_stops0e11();
+ }
+ /*stt_prv_layer_apps_meter_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_stops0e0();
+ }
+ /*stt_prv_layer_apps_meter_splitable*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrSpl )
+ {
+ Zmaster_apps_apps_car_stops0e3();
+ }
+ /*stt_prv_layer_apps_splitable_receiver*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplRcv )
+ {
+ Zmaster_apps_apps_car_stops0e2();
+ }
+ /*stt_prv_layer_apps_splitable_split*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoSplSpl )
+ {
+ Zmaster_apps_apps_car_stops0e15();
+ }
+ /*stt_prv_layer_apps_gen_nml*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoGenNml )
+ {
+ Zmaster_apps_apps_car_stops0e4();
+ }
+ 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 : apps_main */
+/* State : lightstatus_brake_off( No 1 ) */
+/****************************************/
+static void Zmaster_apps_apps_mains1Event( void )
+{
+ /*stt_lightstatus_brake_on*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOn )
+ {
+ stm_mst_apl_event_lightstatus_brake_on();
+ Zmaster_apps_apps_mains1e0();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : apps_car_run */
+/* State : meter_receiver( No 0 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_runs0Event( void )
+{
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_normal*/
+ if( g_stm_area == StmAreaNoNormal )
+ {
+ Zmaster_apps_apps_car_runs0e0();
+ }
+ 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_meter_receiver*/
+ if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_runs0e3();
+ }
+ /*stt_prv_layer_apps_meter*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrNml )
+ {
+ Zmaster_apps_apps_car_runs0e0();
+ }
+ 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 : apps_car_run */
+/* State : meter( No 1 ) */
+/****************************************/
+static void Zmaster_apps_apps_car_runs1Event( void )
+{
+ /*stt_lightstatus_brake_off*/
+ if( g_stm_crr_state.car_element[StmCarElementNoLightstatusBrake].state == StmLightstatusBrakeSttNoOff )
+ {
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_meter*/
+ if( g_stm_category == StmCtgNoMeter )
+ {
+ /*ara_split_main*/
+ if( g_stm_area == StmAreaNoSplitMain )
+ {
+ Zmaster_apps_apps_car_runs0e3();
+ }
+ else
+ {
+ /*Else and default design have not done.*/
+ /*Please confirm the STM and design else and default.*/
+ }
+ }
+ /*ctg_receiver*/
+ else if( g_stm_category == StmCtgNoReceiver )
+ {
+ /*ara_split_sub*/
+ if( g_stm_area == StmAreaNoSplitSub )
+ {
+ Zmaster_apps_apps_car_runs0e3();
+ }
+ 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_meter_receiver*/
+ if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrRcv )
+ {
+ Zmaster_apps_apps_car_runs0e3();
+ }
+ /*stt_prv_layer_apps_meter*/
+ else if( g_stm_prv_state.layer[StmLayerNoApps].state == StmLayoutNoMtrNml )
+ {
+ Zmaster_apps_apps_car_runs0e0();
+ }
+ 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 : apps_main */
+/****************************************/
+void stm_master_apl_event_call( void )
+{
+ stm_mst_apl_start_stm();
+ switch( Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAIN] )
+ {
+ case ZMASTER_APPS_APPS_MAINS0:
+ switch( Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] )
+ {
+ case ZMASTER_APPS_APPS_CAR_STOPS0:
+ Zmaster_apps_apps_car_stops0Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS1:
+ Zmaster_apps_apps_car_stops1Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS2:
+ Zmaster_apps_apps_car_stops2Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS3:
+ Zmaster_apps_apps_car_stops3Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS4:
+ Zmaster_apps_apps_car_stops4Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_STOPS5:
+ Zmaster_apps_apps_car_stops5Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+ Zmaster_apps_apps_mains0Event();
+ break;
+ case ZMASTER_APPS_APPS_MAINS1:
+ switch( Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] )
+ {
+ case ZMASTER_APPS_APPS_CAR_RUNS0:
+ Zmaster_apps_apps_car_runs0Event();
+ break;
+ case ZMASTER_APPS_APPS_CAR_RUNS1:
+ Zmaster_apps_apps_car_runs1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+ Zmaster_apps_apps_mains1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : apps_main */
+/****************************************/
+void stm_master_apl_initialize( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAIN] = ( uint8_t )ZMASTER_APPS_APPS_MAINS0;
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS0F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_STOPS0;
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAINS1F] = ( uint8_t )ZMASTER_APPS_APPS_CAR_RUNS0;
+ Zmaster_apps_apps_mains0StateEntry();
+}
+
+/****************************************/
+/* Terminate function */
+/* STM : apps_main */
+/****************************************/
+void Zmaster_apps_apps_mainTerminate( void )
+{
+ Zmaster_apps_apps_mainState[ZMASTER_APPS_APPS_MAIN] = ( uint8_t )ZMASTER_APPS_APPS_MAINTERMINATE;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.h
new file mode 100644
index 0000000..afa2e67
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_apps_main.h
@@ -0,0 +1,111 @@
+/************************************************************/
+/* Zmaster_apps_apps_main.h */
+/* apps_main State transition model header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZMASTER_APPS_APPS_MAIN_H
+#define ZHEADER_ZMASTER_APPS_APPS_MAIN_H
+
+/*State management variable access define*/
+#define ZMASTER_APPS_APPS_MAIN ( 0U )
+#define ZMASTER_APPS_APPS_MAINS0F ( 1U )
+#define ZMASTER_APPS_APPS_MAINS1F ( 2U )
+#define ZMASTER_APPS_APPS_MAINS0 ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPS0 ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPS1 ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPS2 ( 2U )
+#define ZMASTER_APPS_APPS_CAR_STOPS3 ( 3U )
+#define ZMASTER_APPS_APPS_CAR_STOPS4 ( 4U )
+#define ZMASTER_APPS_APPS_CAR_STOPS5 ( 5U )
+#define ZMASTER_APPS_APPS_MAINS1 ( 1U )
+#define ZMASTER_APPS_APPS_CAR_RUNS0 ( 0U )
+#define ZMASTER_APPS_APPS_CAR_RUNS1 ( 1U )
+#define ZMASTER_APPS_APPS_MAINSTATENOMAX ( 3U )
+
+/*End state define*/
+#define ZMASTER_APPS_APPS_MAINEND ( 6U )
+/*Terminate state define*/
+#define ZMASTER_APPS_APPS_MAINTERMINATE ( ZMASTER_APPS_APPS_MAINEND + 1U )
+
+/*State no define*/
+#define ZMASTER_APPS_APPS_MAINS0STATENO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPS0STATENO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPS1STATENO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPS2STATENO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_STOPS3STATENO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_STOPS4STATENO ( 4U )
+#define ZMASTER_APPS_APPS_CAR_STOPS5STATENO ( 5U )
+#define ZMASTER_APPS_APPS_MAINS1STATENO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_RUNS0STATENO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_RUNS1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZMASTER_APPS_APPS_MAINS0STATESERIALNO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPS0STATESERIALNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPS1STATESERIALNO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_STOPS2STATESERIALNO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_STOPS3STATESERIALNO ( 4U )
+#define ZMASTER_APPS_APPS_CAR_STOPS4STATESERIALNO ( 5U )
+#define ZMASTER_APPS_APPS_CAR_STOPS5STATESERIALNO ( 6U )
+#define ZMASTER_APPS_APPS_MAINS1STATESERIALNO ( 7U )
+#define ZMASTER_APPS_APPS_CAR_RUNS0STATESERIALNO ( 8U )
+#define ZMASTER_APPS_APPS_CAR_RUNS1STATESERIALNO ( 9U )
+
+/*Event no define*/
+#define ZMASTER_APPS_APPS_MAINE0EVENTNO ( 0U )
+#define ZMASTER_APPS_APPS_MAINE1EVENTNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPE0EVENTNO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPE1EVENTNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPE2EVENTNO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_STOPE3EVENTNO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_STOPE4EVENTNO ( 4U )
+#define ZMASTER_APPS_APPS_CAR_STOPE5EVENTNO ( 5U )
+#define ZMASTER_APPS_APPS_CAR_STOPE6EVENTNO ( 6U )
+#define ZMASTER_APPS_APPS_CAR_STOPE7EVENTNO ( 7U )
+#define ZMASTER_APPS_APPS_CAR_STOPE8EVENTNO ( 8U )
+#define ZMASTER_APPS_APPS_CAR_STOPE9EVENTNO ( 9U )
+#define ZMASTER_APPS_APPS_CAR_STOPE10EVENTNO ( 10U )
+#define ZMASTER_APPS_APPS_CAR_STOPE11EVENTNO ( 11U )
+#define ZMASTER_APPS_APPS_CAR_STOPE12EVENTNO ( 12U )
+#define ZMASTER_APPS_APPS_CAR_STOPE13EVENTNO ( 13U )
+#define ZMASTER_APPS_APPS_CAR_STOPE14EVENTNO ( 14U )
+#define ZMASTER_APPS_APPS_CAR_STOPE15EVENTNO ( 15U )
+#define ZMASTER_APPS_APPS_CAR_STOPE16EVENTNO ( 16U )
+#define ZMASTER_APPS_APPS_CAR_RUNE0EVENTNO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_RUNE1EVENTNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_RUNE2EVENTNO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_RUNE3EVENTNO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_RUNE4EVENTNO ( 4U )
+
+/*Event serial no define*/
+#define ZMASTER_APPS_APPS_MAINE0EVENTSERIALNO ( 0U )
+#define ZMASTER_APPS_APPS_MAINE1EVENTSERIALNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPE0EVENTNO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_STOPE1EVENTNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_STOPE2EVENTNO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_STOPE3EVENTNO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_STOPE4EVENTNO ( 4U )
+#define ZMASTER_APPS_APPS_CAR_STOPE5EVENTNO ( 5U )
+#define ZMASTER_APPS_APPS_CAR_STOPE6EVENTNO ( 6U )
+#define ZMASTER_APPS_APPS_CAR_STOPE7EVENTNO ( 7U )
+#define ZMASTER_APPS_APPS_CAR_STOPE8EVENTNO ( 8U )
+#define ZMASTER_APPS_APPS_CAR_STOPE9EVENTNO ( 9U )
+#define ZMASTER_APPS_APPS_CAR_STOPE10EVENTNO ( 10U )
+#define ZMASTER_APPS_APPS_CAR_STOPE11EVENTNO ( 11U )
+#define ZMASTER_APPS_APPS_CAR_STOPE12EVENTNO ( 12U )
+#define ZMASTER_APPS_APPS_CAR_STOPE13EVENTNO ( 13U )
+#define ZMASTER_APPS_APPS_CAR_STOPE14EVENTNO ( 14U )
+#define ZMASTER_APPS_APPS_CAR_STOPE15EVENTNO ( 15U )
+#define ZMASTER_APPS_APPS_CAR_STOPE16EVENTNO ( 16U )
+#define ZMASTER_APPS_APPS_CAR_RUNE0EVENTNO ( 0U )
+#define ZMASTER_APPS_APPS_CAR_RUNE1EVENTNO ( 1U )
+#define ZMASTER_APPS_APPS_CAR_RUNE2EVENTNO ( 2U )
+#define ZMASTER_APPS_APPS_CAR_RUNE3EVENTNO ( 3U )
+#define ZMASTER_APPS_APPS_CAR_RUNE4EVENTNO ( 4U )
+
+/*Extern function*/
+extern void stm_master_apl_event_call( void );
+extern void stm_master_apl_initialize( void );
+extern void Zmaster_apps_apps_mainTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_master_apps_def.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_master_apps_def.h
new file mode 100644
index 0000000..5c22ae6
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/apps/Zmaster_apps_master_apps_def.h
@@ -0,0 +1,15 @@
+/************************************************************/
+/* Zmaster_apps_master_apps_def.h */
+/* Define header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZMASTER_APPS_MASTER_APPS_DEF_H
+#define ZHEADER_ZMASTER_APPS_MASTER_APPS_DEF_H
+
+/*************************************************************
+ Define definition
+*************************************************************/
+
+#include "../../../../stm_master_apps.h"
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_master_remote_def.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_master_remote_def.h
new file mode 100644
index 0000000..7cd92cd
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_master_remote_def.h
@@ -0,0 +1,15 @@
+/************************************************************/
+/* Zmaster_remote_master_remote_def.h */
+/* Define header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZMASTER_REMOTE_MASTER_REMOTE_DEF_H
+#define ZHEADER_ZMASTER_REMOTE_MASTER_REMOTE_DEF_H
+
+/*************************************************************
+ Define definition
+*************************************************************/
+
+#include "../../../../stm_master_remote.h"
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.c
new file mode 100644
index 0000000..53ceafa
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.c
@@ -0,0 +1,206 @@
+/************************************************************/
+/* Zmaster_remote_remote.c */
+/* remote State transition model source file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#include "../../../ZST_include.h"
+
+/* State management variable */
+static uint8_t Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTESTATENOMAX];
+
+static void Zmaster_remote_remotes0e0( void );
+static void Zmaster_remote_remotes0e2( void );
+static void Zmaster_remote_remotes1e1( void );
+static void Zmaster_remote_remotes1e3( void );
+static void Zmaster_remote_remotes0Event( void );
+static void Zmaster_remote_remotes1Event( void );
+
+/****************************************/
+/* Action function */
+/* STM : remote */
+/* State : none( No 0 ) */
+/* Event : ara_master_split_sub( No 0 ) */
+/****************************************/
+static void Zmaster_remote_remotes0e0( void )
+{
+ Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTE] = ( uint8_t )ZMASTER_REMOTE_REMOTES1;
+ stm_mst_rmt_start_activity_tbt();
+}
+
+/****************************************/
+/* Action function */
+/* STM : remote */
+/* State : none( No 0 ) */
+/* Event : stt_prv_layer_remote_none( No 2 ) */
+/****************************************/
+static void Zmaster_remote_remotes0e2( void )
+{
+ stm_mst_rmt_start_activity_none();
+}
+
+/****************************************/
+/* Action function */
+/* STM : remote */
+/* State : tbt( No 1 ) */
+/* Event : ctg_tbt( No 1 ) */
+/****************************************/
+static void Zmaster_remote_remotes1e1( void )
+{
+ Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTE] = ( uint8_t )ZMASTER_REMOTE_REMOTES0;
+ stm_mst_rmt_start_activity_none();
+}
+
+/****************************************/
+/* Action function */
+/* STM : remote */
+/* State : tbt( No 1 ) */
+/* Event : stt_prv_layer_remote_tbt( No 3 ) */
+/****************************************/
+static void Zmaster_remote_remotes1e3( void )
+{
+ stm_mst_rmt_start_activity_tbt();
+}
+
+/****************************************/
+/* Event appraisal function */
+/* STM : remote */
+/* State : none( No 0 ) */
+/****************************************/
+static void Zmaster_remote_remotes0Event( void )
+{
+ /*evt_activate*/
+ if( g_stm_event == StmEvtNoActivate )
+ {
+ /*ctg_tbt*/
+ if( g_stm_category == StmCtgNoTbt )
+ {
+ /*ara_master_split_sub*/
+ if( g_stm_area == StmAreaNoMasterSplitSub )
+ {
+ Zmaster_remote_remotes0e0();
+ }
+ 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_remote_none*/
+ if( g_stm_prv_state.layer[StmLayerNoRemote].state == StmLayoutNoNone )
+ {
+ Zmaster_remote_remotes0e2();
+ }
+ /*stt_prv_layer_remote_tbt*/
+ else if( g_stm_prv_state.layer[StmLayerNoRemote].state == StmLayoutNoRmtTbt )
+ {
+ Zmaster_remote_remotes0e0();
+ }
+ 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 : remote */
+/* State : tbt( No 1 ) */
+/****************************************/
+static void Zmaster_remote_remotes1Event( void )
+{
+ /*evt_deactivate*/
+ if( g_stm_event == StmEvtNoDeactivate )
+ {
+ /*ctg_tbt*/
+ if( g_stm_category == StmCtgNoTbt )
+ {
+ Zmaster_remote_remotes1e1();
+ }
+ 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_remote_none*/
+ if( g_stm_prv_state.layer[StmLayerNoRemote].state == StmLayoutNoNone )
+ {
+ Zmaster_remote_remotes1e1();
+ }
+ /*stt_prv_layer_remote_tbt*/
+ else if( g_stm_prv_state.layer[StmLayerNoRemote].state == StmLayoutNoRmtTbt )
+ {
+ Zmaster_remote_remotes1e3();
+ }
+ 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 : remote */
+/****************************************/
+void stm_mst_rmt_event_call( void )
+{
+ stm_mst_rmt_start_stm();
+ switch( Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTE] )
+ {
+ case ZMASTER_REMOTE_REMOTES0:
+ Zmaster_remote_remotes0Event();
+ break;
+ case ZMASTER_REMOTE_REMOTES1:
+ Zmaster_remote_remotes1Event();
+ break;
+ default:
+ /*Not accessible to this else (default).*/
+ break;
+ }
+}
+
+/****************************************/
+/* Initial function */
+/* STM : remote */
+/****************************************/
+void stm_mst_rmt_initialize( void )
+{
+ Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTE] = ( uint8_t )ZMASTER_REMOTE_REMOTES0;
+ stm_mst_rmt_start_activity_none();
+}
+
+/****************************************/
+/* Terminate function */
+/* STM : remote */
+/****************************************/
+void Zmaster_remote_remoteTerminate( void )
+{
+ Zmaster_remote_remoteState[ZMASTER_REMOTE_REMOTE] = ( uint8_t )ZMASTER_REMOTE_REMOTETERMINATE;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.h
new file mode 100644
index 0000000..5899b07
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/StateTransitionor/master/layer/remote/Zmaster_remote_remote.h
@@ -0,0 +1,45 @@
+/************************************************************/
+/* Zmaster_remote_remote.h */
+/* remote State transition model header file */
+/* ZIPC Designer Version 1.2.0 */
+/************************************************************/
+#ifndef ZHEADER_ZMASTER_REMOTE_REMOTE_H
+#define ZHEADER_ZMASTER_REMOTE_REMOTE_H
+
+/*State management variable access define*/
+#define ZMASTER_REMOTE_REMOTE ( 0U )
+#define ZMASTER_REMOTE_REMOTES0 ( 0U )
+#define ZMASTER_REMOTE_REMOTES1 ( 1U )
+#define ZMASTER_REMOTE_REMOTESTATENOMAX ( 1U )
+
+/*End state define*/
+#define ZMASTER_REMOTE_REMOTEEND ( 2U )
+/*Terminate state define*/
+#define ZMASTER_REMOTE_REMOTETERMINATE ( ZMASTER_REMOTE_REMOTEEND + 1U )
+
+/*State no define*/
+#define ZMASTER_REMOTE_REMOTES0STATENO ( 0U )
+#define ZMASTER_REMOTE_REMOTES1STATENO ( 1U )
+
+/*State serial no define*/
+#define ZMASTER_REMOTE_REMOTES0STATESERIALNO ( 0U )
+#define ZMASTER_REMOTE_REMOTES1STATESERIALNO ( 1U )
+
+/*Event no define*/
+#define ZMASTER_REMOTE_REMOTEE0EVENTNO ( 0U )
+#define ZMASTER_REMOTE_REMOTEE1EVENTNO ( 1U )
+#define ZMASTER_REMOTE_REMOTEE2EVENTNO ( 2U )
+#define ZMASTER_REMOTE_REMOTEE3EVENTNO ( 3U )
+
+/*Event serial no define*/
+#define ZMASTER_REMOTE_REMOTEE0EVENTSERIALNO ( 0U )
+#define ZMASTER_REMOTE_REMOTEE1EVENTSERIALNO ( 1U )
+#define ZMASTER_REMOTE_REMOTEE2EVENTSERIALNO ( 2U )
+#define ZMASTER_REMOTE_REMOTEE3EVENTSERIALNO ( 3U )
+
+/*Extern function*/
+extern void stm_mst_rmt_event_call( void );
+extern void stm_mst_rmt_initialize( void );
+extern void Zmaster_remote_remoteTerminate( void );
+
+#endif
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_inner.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_inner.h
new file mode 100644
index 0000000..5097fcf
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/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
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.c
new file mode 100644
index 0000000..a8cc0e2
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.c
@@ -0,0 +1,63 @@
+#include "./StateTransitionor/ZST_include.h"
+
+void stm_mst_apl_start_activity_none() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoNone;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_meter_receiver() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMtrRcv;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_meter_splitable() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMtrSpl;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_splitable_receiver() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoSplRcv;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_splitable_split() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoSplSpl;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_general() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoGenNml;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_start_activity_meter() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = StmLayoutNoMtrNml;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_event_lightstatus_brake_on() {
+ g_stm_crr_state.layer[StmLayerNoApps].state = g_prv_apps_state_car_stop;
+ g_stm_crr_state.layer[StmLayerNoApps].changed = STM_TRUE;
+}
+
+void stm_mst_apl_event_lightstatus_brake_off() {
+ g_prv_apps_state_car_stop = g_stm_prv_state.layer[StmLayerNoApps].state;
+}
+
+void stm_master_apl_initialize_valiable() {
+ 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;
+}
+
+void stm_mst_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/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.h
new file mode 100644
index 0000000..d10e56b
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_apps.h
@@ -0,0 +1,11 @@
+extern void stm_mst_apl_start_activity_none();
+extern void stm_mst_apl_start_activity_meter_receiver();
+extern void stm_mst_apl_start_activity_meter_splitable();
+extern void stm_mst_apl_start_activity_splitable_receiver();
+extern void stm_mst_apl_start_activity_splitable_split();
+extern void stm_mst_apl_start_activity_general();
+extern void stm_mst_apl_start_activity_meter();
+extern void stm_mst_apl_event_lightstatus_brake_on();
+extern void stm_mst_apl_event_lightstatus_brake_off();
+extern void stm_master_apl_initialize_valiable();
+extern void stm_mst_apl_start_stm();
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.c b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.c
new file mode 100644
index 0000000..d63cba1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.c
@@ -0,0 +1,29 @@
+#include "./StateTransitionor/ZST_include.h"
+
+void stm_mst_rmt_start_activity_none() {
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoNone;
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_TRUE;
+}
+
+void stm_mst_rmt_start_activity_tbt() {
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoRmtTbt;
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_TRUE;
+}
+
+void stm_mst_rmt_initialize_valiable() {
+ g_stm_prv_state.layer[StmLayerNoRemote].state = StmLayoutNoNone;
+ g_stm_prv_state.layer[StmLayerNoRemote].changed = STM_FALSE;
+
+ g_stm_crr_state.layer[StmLayerNoRemote].state = StmLayoutNoNone;
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_FALSE;
+}
+
+void stm_mst_rmt_start_stm() {
+ if (g_stm_event == StmEvtNoUndo) {
+ // nop
+ }
+ else {
+ g_stm_prv_state.layer[StmLayerNoRemote].state = g_stm_crr_state.layer[StmLayerNoRemote].state;
+ }
+ g_stm_crr_state.layer[StmLayerNoRemote].changed = STM_FALSE;
+}
diff --git a/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.h b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.h
new file mode 100644
index 0000000..45d77c7
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/policy_manager/stm/zipc/stm_master_remote.h
@@ -0,0 +1,4 @@
+extern void stm_mst_rmt_start_activity_none();
+extern void stm_mst_rmt_start_activity_tbt();
+extern void stm_mst_rmt_initialize_valiable();
+extern void stm_mst_rmt_start_stm();
diff --git a/demo3/common/agl-service-windowmanager/protocol/ivi-wm.xml b/demo3/common/agl-service-windowmanager/protocol/ivi-wm.xml
new file mode 100644
index 0000000..da45c7e
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/protocol/ivi-wm.xml
@@ -0,0 +1,608 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<protocol name="ivi_wm">
+
+ <copyright>
+ Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ </copyright>
+
+ <interface name="ivi_wm_screen" version="1">
+ <description summary="controller interface to screen in ivi compositor"/>
+
+ <request name="destroy" type="destructor">
+ <description summary="destroy ivi_wm_screen">
+ Request to destroy the ivi_wm_screen.
+ </description>
+ </request>
+
+ <request name="clear">
+ <description summary="remove all layers from screen render order">
+ A screen has no content assigned to itself, it is a container for layers.
+ This request removes all layers from the screen render order.
+ Note: the layers are not destroyed, they are just no longer contained by
+ the screen.
+ </description>
+ </request>
+
+ <request name="add_layer">
+ <description summary="add a layer to screen render order at nearest z-position">
+ A screen has no content assigned to itself, it is a container for layers.
+ This request adds a layers to the topmost position of the screen render order.
+ The added layer will cover all other layers of the screen.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ </request>
+
+ <request name="remove_layer">
+ <description summary="remove a layer to screen render order">
+ A screen has no content assigned to itself, it is a container for layers.
+ This request removes a layer.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ </request>
+
+ <request name="screenshot">
+ <description summary="take screenshot of screen">
+ An ivi_screenshot object is created which will receive the screenshot
+ data of the specified output.
+ </description>
+ <arg name="screenshot" type="new_id" interface="ivi_screenshot"/>
+ </request>
+
+ <request name="get">
+ <description summary="get a parameter of a screen in ivi compositor">
+ After this request, compositor sends the requested parameter.
+ </description>
+ <arg name="param" type="int"/>
+ </request>
+
+ <event name="screen_id">
+ <description summary="advertise server side id of the ivi-screen">
+ Sent immediately after creating the ivi_wm_screen object.
+ </description>
+ <arg name="id" type="uint"/>
+ </event>
+
+ <event name="layer_added">
+ <description summary="update render order of the screen">
+ A layer is added to the render order lisf of the screen
+ </description>
+ <arg name="layer_id" type="uint"/>
+ </event>
+
+ <event name="connector_name">
+ <description summary="advertise connector name of the corresponding output">
+ Sent immediately after creating the ivi_wm_screen object.
+ </description>
+ <arg name="process_name" type="string"/>
+ </event>
+
+ <enum name="error">
+ <entry name="no_layer" value="0"
+ summary="the layer with given id does not exist"/>
+ <entry name="no_screen" value="1"
+ summary="the output is already destroyed"/>
+ <entry name="bad_param" value="2"
+ summary="the given parameter is not valid"/>
+ </enum>
+
+ <event name="error">
+ <description summary="error event">
+ The error event is sent out when an error has occurred.
+ </description>
+ <arg name="error" type="uint" summary="error code"/>
+ <arg name="message" type="string" summary="error description"/>
+ </event>
+ </interface>
+
+ <interface name="ivi_screenshot" version="1">
+ <description summary="screenshot of an output or a surface">
+ An ivi_screenshot object receives a single "done" or "error" event.
+ The server will destroy this resource after the event has been send,
+ so the client shall then destroy its proxy too.
+ </description>
+
+ <event name="done">
+ <description summary="screenshot finished">
+ This event contains a filedescriptor for a file with raw image data.
+ Furthermore size, stride, format and timestamp of screenshot are
+ provided.
+ </description>
+ <arg name="fd" type="fd" summary="fd for file containing image data"/>
+ <arg name="width" type="int" summary="image width in pixels"/>
+ <arg name="height" type="int" summary="image height in pixels"/>
+ <arg name="stride" type="int" summary="number of bytes per pixel row"/>
+ <arg name="format" type="uint" summary="image format of type wl_shm.format"/>
+ <arg name="timestamp" type="uint" summary="timestamp in milliseconds"/>
+ </event>
+
+ <enum name="error">
+ <entry name="io_error" value="0"
+ summary="screenshot file could not be created"/>
+ <entry name="not_supported" value="1"
+ summary="screenshot can not be read"/>
+ <entry name="no_output" value="2"
+ summary="output has been destroyed"/>
+ <entry name="no_surface" value="3"
+ summary="surface has been destroyed"/>
+ <entry name="no_content" value="4"
+ summary="surface has no content"/>
+ </enum>
+
+ <event name="error">
+ <description summary="error event">
+ The error event is sent when the screenshot could not be created.
+ </description>
+ <arg name="error" type="uint" enum="error" summary="error code"/>
+ <arg name="message" type="string" summary="error description"/>
+ </event>
+ </interface>
+
+ <interface name="ivi_wm" version="1">
+ <description summary="interface for ivi managers to use ivi compositor features"/>
+
+ <request name="commit_changes">
+ <description summary="commit all changes requested by client">
+ All requests are not applied directly to scene object, so a controller
+ can set different properties and apply the changes all at once.
+ Note: there's an exception to this. Creation and destruction of
+ scene objects is executed immediately.
+ </description>
+ </request>
+
+ <request name="create_screen">
+ <description summary="create a screen in ivi-compositor">
+ Ask the ivi-wm to create a ivi-screen for given wl_output.
+ </description>
+ <arg name="output" type="object" interface="wl_output"/>
+ <arg name="id" type="new_id" interface="ivi_wm_screen" summary="the new ivi-screen"/>
+ </request>
+
+ <request name="set_surface_visibility">
+ <description summary="set the visibility of a surface in ivi compositor">
+ If visibility argument is 0, the surface in the ivi compositor is set to invisible.
+ If visibility argument is not 0, the surface in the ivi compositor is set to visible.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="visibility" type="uint"/>
+ </request>
+
+ <request name="set_layer_visibility">
+ <description summary="set visibility of layer in ivi compositor">
+ If visibility argument is 0, the layer in the ivi compositor is set to invisible.
+ If visibility argument is not 0, the layer in the ivi compositor is set to visible.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="visibility" type="uint"/>
+ </request>
+
+ <request name="set_surface_opacity">
+ <description summary="set the opacity of a surface in ivi compositor">
+ The valid range for opacity is 0.0 (fully transparent) to 1.0 (fully opaque).
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="opacity" type="fixed"/>
+ </request>
+
+ <request name="set_layer_opacity">
+ <description summary="set opacity of layer in ivi compositor">
+ The valid range for opacity is 0.0 (fully transparent) to 1.0 (fully opaque).
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="opacity" type="fixed"/>
+ </request>
+
+ <request name="set_surface_source_rectangle">
+ <description summary="set the scanout area of a surface in ivi compositor">
+ The source rectangle defines the part of the surface content, that is used for
+ compositing the surface. It can be used, if valid content of the surface is smaller
+ than the surface. Effectively it can be used to zoom the content of the surface.
+ If a parameter is less than 0, that value is not changed.
+ x: horizontal start position of scanout area within the surface
+ y: vertical start position of scanout area within the surface
+ width: width of scanout area within the surface
+ height: height of scanout area within the surface
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="set_layer_source_rectangle">
+ <description summary="set the scanout area of a layer in ivi compositor">
+ The source rectangle defines the part of the layer content, that is used for
+ compositing the screen. It can be used, if valid content of the layer is smaller
+ than the layer. Effectively it can be used to zoom the content of the layer.
+ If a parameter is less than 0, that value is not changed.
+ x: horizontal start position of scanout area within the layer
+ y: vertical start position of scanout area within the layer
+ width: width of scanout area within the layer
+ height: height of scanout area within the layer
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="set_surface_destination_rectangle">
+ <description summary="Set the destination area of a surface within a layer">
+ The destination rectangle defines the position and size of a surface on a layer.
+ The surface will be scaled to this rectangle for rendering.
+ If a parameter is less than 0, that value is not changed.
+ x: horizontal start position of surface within the layer
+ y: vertical start position of surface within the layer
+ width : width of surface within the layer
+ height: height of surface within the layer
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="set_layer_destination_rectangle">
+ <description summary="Set the destination area of a layer within a screen">
+ The destination rectangle defines the position and size of a layer on a screen.
+ The layer will be scaled to this rectangle for rendering.
+ If a parameter is less than 0, that value is not changed.
+ x: horizontal start position of layer within the screen
+ y: vertical start position of layer within the screen
+ width : width of surface within the screen
+ height: height of surface within the screen
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <enum name="sync">
+ <description summary="sync request states">
+ </description>
+ <entry name="add" value="0"/>
+ <entry name="remove" value="1"/>
+ </enum>
+
+ <request name="surface_sync">
+ <description summary="request to synchronize of a surface in ivi compositor">
+ After this request, compositor sends the properties of the surface.
+ If sync_state argument is 0, compositor sends the properties continously.
+ If sync_state argument is not 0, compositor stops sending the properties
+ continously.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="sync_state" type="int"/>
+ </request>
+
+ <request name="layer_sync">
+ <description summary="request to synchronize of a layer in ivi compositor">
+ After this request, compositor sends the properties of the layer.
+ If sync_state argument is 0, compositor sends the properties continously.
+ If sync_state argument is not 0, compositor stops sending the properties
+ continously.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="sync_state" type="int"/>
+ </request>
+
+ <enum name="param" bitfield="true">
+ <description summary="parameter types">
+ The HMI controller can request different types of parameters of an
+ ivi-object.
+ </description>
+ <entry name="opacity" value="1"/>
+ <entry name="visibility" value="2"/>
+ <entry name="size" value="4"/>
+ <entry name="render_order" value="8"/>
+ </enum>
+
+ <request name="surface_get">
+ <description summary="get a parameter of an ivi_layout_surface in ivi compositor">
+ After this request, compositor sends the requested parameter.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="param" type="int"/>
+ </request>
+
+ <request name="layer_get">
+ <description summary="get a parameter of an ivi_layout_layer in ivi compositor">
+ After this request, compositor sends the requested parameter.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="param" type="int"/>
+ </request>
+
+ <request name="surface_screenshot">
+ <description summary="take screenshot of surface">
+ An ivi_screenshot object is created which will receive an image of the
+ buffer currently attached to the surface with the given id. If there
+ is no surface with such name the server will respond with an
+ ivi_screenshot.error event.
+ </description>
+ <arg name="screenshot" type="new_id" interface="ivi_screenshot"/>
+ <arg name="surface_id" type="uint"/>
+ </request>
+
+ <enum name="surface_type">
+ <description summary="hint for the compositor">
+ If a surface is restricted type, visible contents of the surface is strictly
+ controlled by the compositor. Its content is not allowed to be go out of
+ its destination region. If the application resizes its buffers or uses
+ wp_viewporter protocol to scale its contents, the old destination region
+ would causes visible glitches.
+ To avoid these issues, the controller process mark a surface as desktop
+ compatible. Source and destination regions of a desktop compatible
+ surface will be modified accordingly,when application sends a request
+ for resizing or scaling its contents. Therefore, applications contents
+ will be drawn according to application's wishes.
+ On the other hand, source and destination regions will be strictly
+ enforced, when the surface's type is restricted. The default type for
+ a surface is ivi.
+ </description>
+ <entry name="restricted" value="0" summary="strictly controlled"/>
+ <entry name="desktop" value="1" summary="free to resize and scale"/>
+ </enum>
+
+ <request name="set_surface_type">
+ <description summary="request to set a type for the surface in ivi compositor">
+ After this request, compositor changes the type of the surface.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="type" type="int"/>
+ </request>
+
+ <request name="layer_clear">
+ <description summary="remove all surfaces from layer render order">
+ A layer has no content assigned to itself, it is a container for surfaces.
+ This request removes all surfaces from the layer render order.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ </request>
+
+ <request name="layer_add_surface">
+ <description summary="add a surface to layer render order at nearest z-position">
+ A layer has no content assigned to itself, it is a container for surfaces.
+ This request adds a surface to the topmost position of the layer render order.
+ The added surface will cover all other surfaces of the layer.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="surface_id" type="uint"/>
+ </request>
+
+ <request name="layer_remove_surface">
+ <description summary="remove a surface from layer render order">
+ A layer has no content assigned to itself, it is a container for surfaces.
+ This request removes one surfaces from the layer render order.
+ Note: the surface is not destroyed, it is just no longer contained by
+ the layer.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="surface_id" type="uint"/>
+ </request>
+
+ <request name="create_layout_layer">
+ <description summary="create an ivi_layout_layer in ivi compositor">
+ After this request, compositor creates an ivi_layout_layer
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </request>
+
+ <request name="destroy_layout_layer">
+ <description summary="destroy an ivi_layout_layer in ivi compositor">
+ After this request, compositor destroyes an existing ivi_layout_layer.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ </request>
+
+ <event name="surface_visibility">
+ <description summary="the visibility of the surface in ivi compositor has changed">
+ The new visibility state is provided in argument visibility.
+ If visibility is 0, the surface has become invisible.
+ If visibility is not 0, the surface has become visible.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="visibility" type="int"/>
+ </event>
+
+ <event name="layer_visibility">
+ <description summary="the visibility of the layer in ivi compositor has changed">
+ The new visibility state is provided in argument visibility.
+ If visibility is 0, the layer has become invisible.
+ If visibility is not 0, the layer has become visible.
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="visibility" type="int"/>
+ </event>
+
+ <event name="surface_opacity">
+ <description summary="the opacity of surface in ivi compositor has changed">
+ The new opacity state is provided in argument opacity.
+ The valid range for opactiy is 0.0 (fully transparent) to 1.0 (fully opaque).
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="opacity" type="fixed"/>
+ </event>
+
+ <event name="layer_opacity">
+ <description summary="the opacity of layer in ivi compositor has changed">
+ The new opacity state is provided in argument opacity.
+ The valid range for opactiy is 0.0 (fully transparent) to 1.0 (fully opaque).
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="opacity" type="fixed"/>
+ </event>
+
+ <event name="surface_source_rectangle">
+ <description summary="the source rectangle of surface in ivi compositor has changed">
+ The scanout region of the surface content has changed.
+ The new values for source rectangle are provided by
+ x: new horizontal start position of scanout area within the surface
+ y: new vertical start position of scanout area within the surface
+ width: new width of scanout area within the surface
+ height: new height of scanout area within the surface
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="layer_source_rectangle">
+ <description summary="the source rectangle of layer in ivi compositor has changed">
+ The scanout region of the layer content has changed.
+ The new values for source rectangle are provided by
+ x: new horizontal start position of scanout area within the layer
+ y: new vertical start position of scanout area within the layer
+ width: new width of scanout area within the layer
+ height: new height of scanout area within the layer
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="surface_destination_rectangle">
+ <description summary="the destination rectangle of surface in ivi compositor has changed">
+ The new values for source rectangle are provided by
+ x: new horizontal start position of surface within the layer
+ y: new vertical start position of surface within the layer
+ width : new width of surface within the layer
+ height: new height of surface within the layer
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="layer_destination_rectangle">
+ <description summary="the destination rectangle of layer in ivi compositor has changed">
+ The new values for source rectangle are provided by
+ x: new horizontal start position of layer within the screen
+ y: new vertical start position of layer within the screen
+ width : new width of layer within the screen
+ height: new height of layer within the screen
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="x" type="int"/>
+ <arg name="y" type="int"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="surface_created">
+ <description summary="ivi_layout_surface was created"/>
+ <arg name="surface_id" type="uint"/>
+ </event>
+
+ <event name="layer_created">
+ <description summary="ivi_layout_layer was created"/>
+ <arg name="layer_id" type="uint"/>
+ </event>
+
+ <event name="surface_destroyed">
+ <description summary="ivi_layout_surface was destroyed"/>
+ <arg name="surface_id" type="uint"/>
+ </event>
+
+ <event name="layer_destroyed">
+ <description summary="ivi_layout_layer was destroyed"/>
+ <arg name="layer_id" type="uint"/>
+ </event>
+
+ <enum name="surface_error">
+ <entry name="no_surface" value="0"
+ summary="the surface with given id does not exist"/>
+ <entry name="bad_param" value="1"
+ summary="the given parameter is not valid"/>
+ <entry name="not_supported" value="2"
+ summary="the request is not supported"/>
+ </enum>
+
+ <event name="surface_error">
+ <description summary="error event">
+ The error event is sent out when an error has occurred.
+ </description>
+ <arg name="object_id" type="uint" summary="id of a layer or surface"/>
+ <arg name="error" type="uint" summary="error code"/>
+ <arg name="message" type="string" summary="error description"/>
+ </event>
+
+ <enum name="layer_error">
+ <entry name="no_surface" value="0"
+ summary="the surface with given id does not exist"/>
+ <entry name="no_layer" value="1"
+ summary="the layer with given id does not exist"/>
+ <entry name="bad_param" value="2"
+ summary="the given parameter is not valid"/>
+ </enum>
+
+ <event name="layer_error">
+ <description summary="error event">
+ The error event is sent out when an error has occurred.
+ </description>
+ <arg name="object_id" type="uint" summary="id of a layer or surface"/>
+ <arg name="error" type="uint" summary="error code"/>
+ <arg name="message" type="string" summary="error description"/>
+ </event>
+
+ <event name="surface_size">
+ <description summary="the surface size in ivi compositor has changed">
+ The client providing content for this surface modified size of the surface.
+ The modified surface size is provided by arguments width and height.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="width" type="int"/>
+ <arg name="height" type="int"/>
+ </event>
+
+ <event name="surface_stats">
+ <description summary="receive updated statistics for surface in ivi compositor">
+ The information contained in this event is essential for monitoring, debugging,
+ logging and tracing support in IVI systems.
+ </description>
+ <arg name="surface_id" type="uint"/>
+ <arg name="frame_count" type="uint"/>
+ <arg name="pid" type="uint"/>
+ </event>
+
+ <event name="layer_surface_added">
+ <description summary="update render order of the layer">
+ A surface is added to the render order of the layer
+ </description>
+ <arg name="layer_id" type="uint"/>
+ <arg name="surface_id" type="uint"/>
+ </event>
+ </interface>
+
+</protocol>
+
diff --git a/demo3/common/agl-service-windowmanager/src/CMakeLists.txt b/demo3/common/agl-service-windowmanager/src/CMakeLists.txt
new file mode 100644
index 0000000..9fa4b73
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/CMakeLists.txt
@@ -0,0 +1,124 @@
+#
+# 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(ILM REQUIRED ilmControl ilmCommon)
+pkg_check_modules(SD REQUIRED libsystemd>=222)
+
+# We do not want a prefix for our module
+set(CMAKE_SHARED_MODULE_PREFIX "")
+
+set(TARGETS_WM windowmanager-service)
+
+add_library(${TARGETS_WM} MODULE
+ main.cpp
+ util.cpp
+ json_helper.cpp
+ applist.cpp
+ request.cpp
+ pm_wrapper.cpp
+ window_manager.cpp
+ wm_client.cpp
+ wm_error.cpp
+ wm_layer.cpp
+ wm_layer_control.cpp
+ wm_connection.cpp
+ low_can_client.cpp)
+
+target_include_directories(${TARGETS_WM}
+ PRIVATE
+ ${AFB_INCLUDE_DIRS}
+ ${SD_INCLUDE_DIRS}
+ ${ILM_INCLUDE_DIRS}
+ ../include
+ ../src
+ ../${PLUGIN_PM})
+
+target_link_libraries(${TARGETS_WM}
+ PRIVATE
+ ${AFB_LIBRARIES}
+ ${WLC_LIBRARIES}
+ ${ILM_LIBRARIES}
+ ${SD_LIBRARIES}
+ ${PLUGIN_PM})
+
+target_compile_definitions(${TARGETS_WM}
+ PRIVATE
+ AFB_BINDING_VERSION=2
+ # We do not want source location of messages
+ AFB_BINDING_PRAGMA_NO_VERBOSE_DETAILS
+ WINMAN_VERSION_STRING="${PACKAGE_VERSION}"
+ _GNU_SOURCE)
+
+if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ target_compile_definitions(${TARGETS_WM}
+ PRIVATE
+ _GLIBCXX_DEBUG)
+endif()
+
+target_compile_options(${TARGETS_WM}
+ PRIVATE
+ -Wall -Wextra -Wno-unused-parameter -Wno-comment)
+
+set_target_properties(${TARGETS_WM}
+ PROPERTIES
+ # INTERPROCEDURAL_OPTIMIZATION ON
+
+ CXX_EXTENSIONS OFF
+ CXX_STANDARD 14
+ CXX_STANDARD_REQUIRED ON
+
+ C_EXTENSIONS OFF
+ C_STANDARD 99
+ C_STANDARD_REQUIRED ON
+
+ 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++ -Wl,-rpath,'$ORIGIN'")
+endif()
+
+if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "")
+ target_compile_options(${TARGETS_WM}
+ PRIVATE
+ -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer)
+ set_target_properties(${TARGETS_WM}
+ PROPERTIES
+ LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g")
+endif()
+
+if(NOT EXISTS ${PROJECT_BINARY_DIR}/package)
+ add_custom_command(TARGET ${TARGETS_WM} POST_BUILD
+ COMMAND cp -rf ${PROJECT_SOURCE_DIR}/package ${PROJECT_BINARY_DIR}
+ )
+endif()
+
+add_custom_command(TARGET ${TARGETS_WM} POST_BUILD
+ COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/lib
+ COMMAND cp -rf ${PROJECT_BINARY_DIR}/src/${TARGETS_WM}.so ${PROJECT_BINARY_DIR}/package/root/lib
+ COMMAND mkdir -p ${PROJECT_BINARY_DIR}/package/root/etc
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/layers_setting.json ${PROJECT_BINARY_DIR}/package/root/etc
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/src/config/old_roles.json ${PROJECT_BINARY_DIR}/package/root/etc
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/src/config/areas.json ${PROJECT_BINARY_DIR}/package/root/etc
+ COMMAND cp -f ${PROJECT_SOURCE_DIR}/src/config/connection.json ${PROJECT_BINARY_DIR}/package/root/etc
+)
+
+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
+)
diff --git a/demo3/common/agl-service-windowmanager/src/applist.cpp b/demo3/common/agl-service-windowmanager/src/applist.cpp
new file mode 100644
index 0000000..44865f6
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/applist.cpp
@@ -0,0 +1,635 @@
+/*
+ * 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 <iostream>
+#include <algorithm>
+#include "applist.hpp"
+#include "util.hpp"
+
+using std::shared_ptr;
+using std::string;
+using std::vector;
+
+namespace wm
+{
+
+const static int kReserveClientSize = 100;
+const static int kReserveReqSize = 10;
+
+/**
+ * AppList Constructor.
+ *
+ * Reserve the container size to avoid re-allocating memory.
+ *
+ * @note Size should be changed according to the system.
+ * If the number of applications becomes over the size, re-allocating memory will happen.
+ */
+AppList::AppList()
+ : req_list(),
+ app2client(),
+ current_req(1)
+{
+ this->app2client.reserve(kReserveClientSize);
+ this->req_list.reserve(kReserveReqSize);
+}
+
+AppList::~AppList() {}
+
+// =================== Client Date container API ===================
+
+/**
+ * Add Client to the list
+ *
+ * Add Client to the list.
+ * The Client means application which has role, layer, surface
+ * This function should be called once for the app.
+ * Caller should take care not to be called more than once.
+ *
+ * @param string[in] Application id. This will be the key to withdraw the information.
+ * @param unsigned[in] Layer ID in which the application is
+ * @param unsigned[in] surface ID which the application has
+ * @param string[in] Role which means what behavior the application will do.
+ * @return None
+ * @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 string &appid, unsigned layer, unsigned surface, const string &role)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, surface, role);
+ this->app2client[appid] = client;
+ this->clientDump();
+}
+
+void AppList::addClient(const string &appid, unsigned layer, const string &role)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ shared_ptr<WMClient> client = std::make_shared<WMClient>(appid, layer, role);
+ this->app2client[appid] = client;
+ this->clientDump();
+}
+
+/**
+ * Remove WMClient from the list
+ *
+ * @param string[in] Application id. This will be the key to withdraw the information.
+ */
+void AppList::removeClient(const string &appid)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ this->app2client.erase(appid);
+ HMI_INFO("Remove client %s", appid.c_str());
+}
+
+/**
+ * Check this class stores the appid.
+ *
+ * @param string[in] Application id. This will be the key to withdraw the information.
+ * @return true if the class has the requested key(appid)
+ */
+bool AppList::contains(const string &appid) const
+{
+ auto result = this->app2client.find(appid);
+ return (this->app2client.end() != result) ? true : false;
+}
+
+/**
+ * Remove surface from client
+ *
+ * @param unsigned[in] surface id.
+ * @return None
+ */
+void AppList::removeSurface(unsigned surface){
+ // This function may be very slow
+ std::lock_guard<std::mutex> lock(this->mtx);
+ bool ret = false;
+ for (auto &x : this->app2client)
+ {
+ ret = x.second->removeSurfaceIfExist(surface);
+ if(ret){
+ HMI_DEBUG("remove surface %d from Client %s finish",
+ surface, x.second->appID().c_str());
+ break;
+ }
+ }
+
+}
+
+/**
+ * Get WMClient object.
+ *
+ * After get the WMClient object, caller can call the client method.
+ * Before call this function, caller must call "contains"
+ * to check the key is contained, otherwise, you have to take care of std::out_of_range.
+ *
+ * @param string[in] application id(key)
+ * @return WMClient object
+ * @attention Must call cantains to check appid is stored before this function.
+ */
+shared_ptr<WMClient> AppList::lookUpClient(const string &appid)
+{
+ if(this->app2client.count(appid) != 0)
+ {
+ return this->app2client.at(appid);
+ }
+ else
+ {
+ return nullptr;
+ }
+}
+
+/**
+ * Count Client.
+ *
+ * Returns the number of client stored in the list.
+ *
+ * @param None
+ * @return The number of client
+ */
+int AppList::countClient() const
+{
+ return this->app2client.size();
+}
+
+/**
+ * Get AppID with surface and role.
+ *
+ * Returns AppID if found.
+ *
+ * @param unsigned[in] surfaceID
+ * @param string[in] role
+ * @param bool[in,out] AppID is found or not
+ * @return AppID
+ * @attention If AppID is not found, param found will be false.
+ */
+/* string AppList::getAppID(unsigned surface, const string& role, bool* found) const
+{
+ *found = false;
+ for (const auto &x : this->app2client)
+ {
+ if(x.second->surfaceID(role) == surface){
+ *found = true;
+ return x.second->appID();
+ }
+ }
+ return string("");
+} */
+
+string AppList::getAppID(unsigned surface, bool* found) const
+{
+ *found = false;
+ for (const auto &x : this->app2client)
+ {
+ if(x.second->surfaceID() == surface){
+ *found = true;
+ return x.second->appID();
+ }
+ }
+ return string("");
+}
+
+WMError AppList::popFloatingSurface(unsigned pid, unsigned *surface)
+{
+ WMError ret = WMError::NO_ENTRY;
+
+ auto fwd_itr = std::remove_if(this->floating_surfaces.begin(), this->floating_surfaces.end(),
+ [pid, surface, &ret](FloatingSurface x) {
+ if(pid == x.pid){
+ *surface = x.surface_id;
+ ret = WMError::SUCCESS;
+ return true;
+ }
+ else{
+ return false;
+ }
+ });
+ if (fwd_itr != this->floating_surfaces.cend())
+ {
+ HMI_INFO("pop floating surface: %d", *surface);
+ }
+ this->floating_surfaces.erase(fwd_itr, this->floating_surfaces.end());
+ return ret;
+}
+
+// =================== Floating(Temporary) surface/client API ===================
+
+// TODO: After testing setRole, remove these API
+
+WMError AppList::popFloatingSurface(const string &appid, unsigned *surface)
+{
+ HMI_ERROR("This function is not implemented");
+ return WMError::SUCCESS;
+}
+
+void AppList::addFloatingClient(const string &appid, unsigned layer, const string &role)
+{
+}
+
+void AppList::addFloatingSurface(const string &appid, unsigned surface, unsigned pid)
+{
+ struct FloatingSurface fsurface{appid, surface, pid};
+ this->floating_surfaces.push_back(fsurface);
+ this->dumpFloatingSurfaces();
+}
+
+void AppList::removeFloatingSurface(unsigned surface)
+{
+ this->dumpFloatingSurfaces();
+ auto fwd_itr = std::remove_if(
+ this->floating_surfaces.begin(), this->floating_surfaces.end(),
+ [surface](FloatingSurface x) {
+ return x.surface_id == surface;
+ });
+ if(fwd_itr != this->floating_surfaces.cend()){
+ HMI_INFO("remove floating surface: %d", surface);
+ }
+ this->floating_surfaces.erase(fwd_itr, this->floating_surfaces.end());
+}
+
+// =================== Request Date container API ===================
+
+/**
+ * Get current request number
+ *
+ * Request number is the numeric ID to designate the request.
+ * But returned request number from this function doesn't mean the request exists.
+ * This number is used as key to withdraw the WMRequest object.
+ *
+ * @param None
+ * @return current request number.
+ * @note request number is more than 0.
+ */
+unsigned AppList::currentRequestNumber() const
+{
+ return this->current_req;
+}
+
+/**
+ * Get request number
+ *
+ * Request number is the numeric ID to designate the request.
+ * But returned request number from this function doesn't mean the request exists.
+ * This number is used as key to withdraw the WMRequest object.
+ *
+ * @param None
+ * @return request number.
+ * @attention If returned value is 0, no request exists.
+ */
+unsigned AppList::getRequestNumber(const string &appid) const
+{
+ for (const auto &x : this->req_list)
+ {
+ // Since app will not request twice and more, comparing appid is enough?
+ if ((x.trigger.appid == appid))
+ {
+ return x.req_num;
+ }
+ }
+ return 0;
+}
+
+/**
+ * Add Request
+ *
+ * Request number is the numeric ID to designate the request.
+ * But returned request number from this function doesn't mean the request exists.
+ * This number is used as key to withdraw the WMRequest object.
+ *
+ * @param WMRequest[in] WMRequest object caller creates
+ * @return Request number
+ * @attention If the request number is different with curent request number,
+ * it means the previous request is not finished.
+ */
+unsigned AppList::addRequest(WMRequest req)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ if (this->req_list.size() == 0)
+ {
+ req.req_num = current_req;
+ }
+ else
+ {
+ HMI_SEQ_INFO(this->current_req, "add: %d", this->req_list.back().req_num + 1);
+ req.req_num = this->req_list.back().req_num + 1;
+ }
+ this->req_list.push_back(req);
+ return req.req_num;
+}
+
+/**
+ * Get trigger which the application requests
+ *
+ * WMTrigger contains which application requests what role and where to put(area) and task.
+ * This is used for input event to Window Policy Manager(state machine).
+ *
+ * @param unsigned[in] request number
+ * @param bool[in,out] Check request number of the parameter is valid.
+ * @return WMTrigger which associates with the request number
+ * @attention If the request number is not valid, parameter "found" is false
+ * and return value will be meaningless value.
+ * Caller can check the request parameter is valid.
+ */
+struct WMTrigger AppList::getRequest(unsigned req_num, bool *found)
+{
+ *found = false;
+ for (const auto &x : this->req_list)
+ {
+ if (req_num == x.req_num)
+ {
+ *found = true;
+ return x.trigger;
+ }
+ }
+ HMI_SEQ_ERROR(req_num, "Couldn't get request : %d", req_num);
+ return WMTrigger{"", "", "", Task::TASK_INVALID};
+}
+
+/**
+ * Get actions which the application requests
+ *
+ * WMAciton contains the information of state transition.
+ * In other words, it contains actions of Window Manager,
+ * which role should be put to the area.
+ *
+ * @param unsigned[in] request number
+ * @param bool[in,out] Check request number of the parameter is valid.
+ * @return WMTrigger which associates with the request number
+ * @attention If the request number is not valid, parameter "found" is false
+ * and return value will be no reference pointer.
+ * Caller must check the request parameter is valid.
+ */
+const vector<struct WMAction> &AppList::getActions(unsigned req_num, bool* found)
+{
+ *found = false;
+ for (auto &x : this->req_list)
+ {
+ if (req_num == x.req_num)
+ {
+ *found = true;
+ return x.sync_draw_req;
+ }
+ }
+ HMI_SEQ_ERROR(req_num, "Couldn't get action with the request : %d", req_num);
+}
+
+/**
+ * Set actions to the request.
+ *
+ * Add actions to the request.
+ * This function can be called many times, and actions increase.
+ * This function is used for decision of actions of Window Manager
+ * according to the result of Window Policy Manager.
+ *
+ * @param unsigned[in] request number
+ * @param WMAction[in] Action of Window Manager.
+ * @return WMError If request number is not valid, FAIL will be returned.
+ */
+WMError AppList::setAction(unsigned req_num, const struct WMAction &action)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ WMError result = WMError::FAIL;
+ for (auto &x : this->req_list)
+ {
+ if (req_num != x.req_num)
+ {
+ continue;
+ }
+ x.sync_draw_req.push_back(action);
+ result = WMError::SUCCESS;
+ break;
+ }
+ return result;
+}
+
+/**
+ * Note:
+ * @note This function set action with parameters.
+ * If visible is true, it means app should be visible, so enddraw_finished parameter should be false.
+ * 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.
+ */
+/**
+ * Set actions to the request.
+ *
+ * This function is overload function.
+ * The feature is same as other one.
+ *
+ * @param unsigned[in] request number
+ * @param string[in] application id
+ * @param string[in] role
+ * @param string[in] area
+ * @param Task[in] the role should be visible or not.
+ * @return WMError If request number is not valid, FAIL will be returned.
+ * @attention This function set action with parameters, then caller doesn't need to create WMAction object.
+ * If visible is true, it means app should be visible, so enddraw_finished parameter will be false.
+ * 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, shared_ptr<WMClient> client, const string &role, const string &area, TaskVisible visible)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ WMError result = WMError::FAIL;
+ for (auto &x : req_list)
+ {
+ if (req_num != x.req_num)
+ {
+ continue;
+ }
+ // If visible task is not invisible, redraw is required -> true
+ bool edraw_f = (visible != TaskVisible::INVISIBLE) ? false : true;
+ WMAction action{req_num, client, role, area, visible, edraw_f, TaskCarState::NO_TASK};
+
+ x.sync_draw_req.push_back(action);
+ result = WMError::SUCCESS;
+ break;
+ }
+ return result;
+}
+
+/**
+ * Set end_draw_finished param is true
+ *
+ * This function checks
+ * - req_num is equal to current request number
+ * - appid and role are equeal to the appid and role stored in action list
+ * If it is valid, set the action is finished.
+ *
+ * @param unsigned[in] request number
+ * @param string[in] application id
+ * @param string[in] role
+ * @return If the parameters are not valid in action list, returns false
+ */
+bool AppList::setEndDrawFinished(unsigned req_num, const string &appid, const string &role)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ bool result = false;
+ for (auto &x : req_list)
+ {
+ if (req_num < x.req_num)
+ {
+ break;
+ }
+ if (req_num == x.req_num)
+ {
+ for (auto &y : x.sync_draw_req)
+ {
+ if (nullptr != y.client)
+ {
+ 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;
+ result = true;
+ }
+ }
+ else
+ {
+ if (y.role == role)
+ {
+ HMI_SEQ_INFO(req_num, "Role %s finish redraw", y.role.c_str());
+ y.end_draw_finished = true;
+ result = true;
+ }
+ }
+ }
+ }
+ }
+ this->reqDump();
+ return result;
+}
+
+/**
+ * Check all actions of the requested sequence is finished
+ *
+ * @param unsigned[in] request_number
+ * @return true if all action is set.
+ */
+bool AppList::endDrawFullfilled(unsigned req_num)
+{
+ bool result = false;
+ for (const auto &x : req_list)
+ {
+ if (req_num < x.req_num)
+ {
+ break;
+ }
+ if (req_num == x.req_num)
+ {
+ result = true;
+ for (const auto &y : x.sync_draw_req)
+ {
+ result &= y.end_draw_finished;
+ if (!result)
+ {
+ break;
+ }
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * Finish the request, then remove it.
+ *
+ * @param unsigned[in] request_number
+ * @return None
+ * @note Please call next after this function to receive or process next request.
+ */
+void AppList::removeRequest(unsigned req_num)
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ this->req_list.erase(remove_if(this->req_list.begin(), this->req_list.end(),
+ [req_num](WMRequest x) {
+ return x.req_num == req_num;
+ }));
+}
+
+/**
+ * Move the current request to next
+ *
+ * @param None
+ * @return None
+ */
+void AppList::next()
+{
+ std::lock_guard<std::mutex> lock(this->mtx);
+ ++this->current_req;
+ if (0 == this->current_req)
+ {
+ this->current_req = 1;
+ }
+}
+
+/**
+ * Check the request exists is in request list
+ *
+ * @param None
+ * @return true if WMRequest exists in the request list
+ */
+bool AppList::haveRequest() const
+{
+ return !this->req_list.empty();
+}
+
+void AppList::clientDump()
+{
+ DUMP("======= client dump =====");
+ for (const auto &x : this->app2client)
+ {
+ const auto &y = x.second;
+ y->dumpInfo();
+ }
+ DUMP("======= client dump end=====");
+}
+
+void AppList::reqDump()
+{
+ DUMP("======= req dump =====");
+ DUMP("current request : %d", current_req);
+ for (const auto &x : req_list)
+ {
+ DUMP("requested : %d", x.req_num);
+ DUMP("Trigger : (APPID :%s, ROLE :%s, AREA :%s, TASK: %d)",
+ x.trigger.appid.c_str(),
+ x.trigger.role.c_str(),
+ x.trigger.area.c_str(),
+ x.trigger.task);
+
+ for (const auto &y : x.sync_draw_req)
+ {
+ DUMP(
+ "Action : (APPID :%s, ROLE :%s, AREA :%s, VISIBLE : %s, END_DRAW_FINISHED: %d)",
+ (y.client) ? y.client->appID().c_str() : "-",
+ y.role.c_str(),
+ y.area.c_str(),
+ (y.visible == TaskVisible::INVISIBLE) ? "invisible" : "visible",
+ y.end_draw_finished);
+ }
+ }
+ DUMP("======= req dump end =====");
+}
+
+void AppList::dumpFloatingSurfaces()
+{
+ DUMP("======= floating surface dump =====");
+ for (const auto &x : this->floating_surfaces)
+ {
+ DUMP("surface : %d, pid : %d", x.surface_id, x.pid);
+ }
+ DUMP("======= floating surface dump end =====\n");
+}
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/applist.hpp b/demo3/common/agl-service-windowmanager/src/applist.hpp
new file mode 100644
index 0000000..36e0524
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/applist.hpp
@@ -0,0 +1,99 @@
+/*
+ * 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 ALLOCATE_LIST_HPP
+#define ALLOCATE_LIST_HPP
+#include <vector>
+#include <string>
+#include <map>
+#include <memory>
+#include <mutex>
+#include "wm_client.hpp"
+#include "request.hpp"
+#include "wm_error.hpp"
+
+namespace wm
+{
+
+/* using std::experimental::nullopt;
+using std::experimental::optional; */
+
+struct FloatingSurface
+{
+ std::string appid;
+ unsigned surface_id;
+ unsigned pid;
+};
+
+class AppList
+{
+ public:
+ AppList();
+ virtual ~AppList();
+ AppList(const AppList &obj) = delete;
+
+ // Client Database Interface
+ /* TODO: consider, which is better WMClient as parameter or not
+ If the WMClient should be more flexible, I think this param should be WMClient class
+ */
+ void addClient(const std::string &appid, unsigned layer,
+ unsigned surface, const std::string &role);
+ void addClient(const std::string &appid, unsigned layer, const std::string &role);
+ void removeClient(const std::string &appid);
+ bool contains(const std::string &appid) const;
+ int countClient() const;
+ std::shared_ptr<WMClient> lookUpClient(const std::string &appid);
+ void removeSurface(unsigned surface);
+ std::string getAppID(unsigned surface, bool* found) const; // TODO: remove
+
+
+ // Floating surface
+ void addFloatingClient(const std::string &appid, unsigned layer, const std::string &role);
+ void addFloatingSurface(const std::string &appid, unsigned surface, unsigned pid);
+ WMError popFloatingSurface(unsigned pid, unsigned *surface);
+ WMError popFloatingSurface(const std::string &appid, unsigned *surface);
+ void removeFloatingSurface(unsigned surface);
+
+ // Request Interface
+ unsigned currentRequestNumber() const;
+ 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, std::shared_ptr<WMClient> 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);
+ void removeRequest(unsigned req_num);
+ void next();
+ bool haveRequest() const;
+
+ struct WMTrigger getRequest(unsigned req_num, bool* found);
+ const std::vector<struct WMAction> &getActions(unsigned req_num, bool* found);
+
+ void clientDump();
+ void reqDump();
+ void dumpFloatingSurfaces();
+
+ private:
+ std::vector<WMRequest> req_list;
+ std::unordered_map<std::string, std::shared_ptr<WMClient>> app2client;
+ unsigned current_req;
+ std::mutex mtx;
+ std::vector<struct FloatingSurface> floating_surfaces;
+};
+
+} // namespace wm
+#endif // ALLOCATE_LIST_HPP \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/src/config/areas.json b/demo3/common/agl-service-windowmanager/src/config/areas.json
new file mode 100644
index 0000000..d4f3531
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/config/areas.json
@@ -0,0 +1,204 @@
+{
+ "ecus": [
+ {
+ "name": "master",
+ "screens": [
+ {
+ "id": 0,
+ "areas": [
+ {
+ "name": "fullscreen",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 720
+ }
+ },
+ {
+ "name": "normal.full",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 720
+ }
+ },
+ {
+ "name": "split.main",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1280,
+ "h": 720
+ }
+ },
+ {
+ "name": "split.sub",
+ "rect": {
+ "x": 1280,
+ "y": 0,
+ "w": 640,
+ "h": 720
+ }
+ },
+ {
+ "name": "software_keyboard",
+ "rect": {
+ "x": 0,
+ "y": 962,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "restriction.normal",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 1080
+ }
+ },
+ {
+ "name": "restriction.split.main",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1920,
+ "h": 540
+ }
+ },
+ {
+ "name": "restriction.split.sub",
+ "rect": {
+ "x": 0,
+ "y": 540,
+ "w": 1920,
+ "h": 540
+ }
+ },
+ {
+ "name": "on_screen",
+ "rect": {
+ "x": 1280,
+ "y": 0,
+ "w": 640,
+ "h": 720
+ }
+ },
+ {
+ "name": "master.split.sub",
+ "rect": {
+ "x": 1280,
+ "y": 0,
+ "w": 640,
+ "h": 720
+ }
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "slave",
+ "screens": [
+ {
+ "id": 0,
+ "areas": [
+ {
+ "name": "fullscreen",
+ "rect": {
+ "x": 0,
+ "y": 0,
+ "w": 1080,
+ "h": 1920
+ }
+ },
+ {
+ "name": "normal.full",
+ "rect": {
+ "x": 0,
+ "y": 218,
+ "w": 1080,
+ "h": 1488
+ }
+ },
+ {
+ "name": "split.main",
+ "rect": {
+ "x": 0,
+ "y": 218,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "split.sub",
+ "rect": {
+ "x": 0,
+ "y": 962,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "software_keyboard",
+ "rect": {
+ "x": 0,
+ "y": 962,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "restriction.normal",
+ "rect": {
+ "x": 0,
+ "y": 218,
+ "w": 1080,
+ "h": 1488
+ }
+ },
+ {
+ "name": "restriction.split.main",
+ "rect": {
+ "x": 0,
+ "y": 218,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "restriction.split.sub",
+ "rect": {
+ "x": 0,
+ "y": 962,
+ "w": 1080,
+ "h": 744
+ }
+ },
+ {
+ "name": "on_screen",
+ "rect": {
+ "x": 0,
+ "y": 218,
+ "w": 1080,
+ "h": 1488
+ }
+ },
+ {
+ "name": "master.split.sub",
+ "rect": {
+ "x": 0,
+ "y": 180,
+ "w": 640,
+ "h": 720
+ }
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/demo3/common/agl-service-windowmanager/src/config/connection.json b/demo3/common/agl-service-windowmanager/src/config/connection.json
new file mode 100644
index 0000000..3ee06c3
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/config/connection.json
@@ -0,0 +1,5 @@
+{
+ "mode": "master",
+ "master_ip": "10.4.1.78",
+ "master_port": 54400
+}
diff --git a/demo3/common/agl-service-windowmanager/src/config/old_roles.json b/demo3/common/agl-service-windowmanager/src/config/old_roles.json
new file mode 100644
index 0000000..02a4c2d
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/config/old_roles.json
@@ -0,0 +1,68 @@
+{
+ "old_roles": [
+ {
+ "name": "HomeScreen",
+ "new": "homescreen"
+ },
+ {
+ "name": "Music",
+ "new": "music"
+ },
+ {
+ "name": "MediaPlayer",
+ "new": "music"
+ },
+ {
+ "name": "Video",
+ "new": "video"
+ },
+ {
+ "name": "VideoPlayer",
+ "new": "video"
+ },
+ {
+ "name": "WebBrowser",
+ "new": "browser"
+ },
+ {
+ "name": "Radio",
+ "new": "radio"
+ },
+ {
+ "name": "Phone",
+ "new": "phone"
+ },
+ {
+ "name": "Navigation",
+ "new": "map"
+ },
+ {
+ "name": "HVAC",
+ "new": "hvac"
+ },
+ {
+ "name": "Settings",
+ "new": "settings"
+ },
+ {
+ "name": "Dashboard",
+ "new": "dashboard"
+ },
+ {
+ "name": "POI",
+ "new": "poi"
+ },
+ {
+ "name": "Mixer",
+ "new": "mixer"
+ },
+ {
+ "name": "Restriction",
+ "new": "restriction"
+ },
+ {
+ "name": "^OnScreen.*",
+ "new": "on_screen"
+ }
+ ]
+}
diff --git a/demo3/common/agl-service-windowmanager/src/controller_hooks.hpp b/demo3/common/agl-service-windowmanager/src/controller_hooks.hpp
new file mode 100644
index 0000000..ae88187
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/controller_hooks.hpp
@@ -0,0 +1,42 @@
+/*
+ * 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 TMCAGLWM_CONTROLLER_HOOKS_HPP
+#define TMCAGLWM_CONTROLLER_HOOKS_HPP
+
+#include <cstdint>
+
+#include <functional>
+
+namespace wm
+{
+
+class WindowManager;
+
+struct controller_hooks
+{
+ WindowManager *wmgr;
+
+ void surface_created(uint32_t surface_id);
+ void surface_removed(uint32_t surface_id);
+ void surface_visibility(uint32_t surface_id, uint32_t v);
+ void surface_destination_rectangle(uint32_t surface_id, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+ void surface_properties(uint32_t surface_id, uint32_t pid);
+};
+
+} // namespace wm
+
+#endif // TMCAGLWM_CONTROLLER_HOOKS_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/json_helper.cpp b/demo3/common/agl-service-windowmanager/src/json_helper.cpp
new file mode 100644
index 0000000..d9cf5eb
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/json_helper.cpp
@@ -0,0 +1,149 @@
+/*
+ * 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 "json_helper.hpp"
+#include "util.hpp"
+
+template <typename T>
+json_object *to_json_(T const &s)
+{
+ auto a = json_object_new_array();
+
+ if (!s.empty())
+ {
+ for (auto const &i : s)
+ {
+ json_object_array_add(a, to_json(i.second));
+ }
+ }
+
+ return a;
+}
+
+json_object *to_json(std::vector<uint32_t> const &v)
+{
+ auto a = json_object_new_array();
+ for (const auto i : v)
+ {
+ json_object_array_add(a, json_object_new_int(i));
+ }
+ return a;
+}
+
+namespace jh {
+
+const char* getStringFromJson(json_object* obj, const char* key)
+{
+ json_object* tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ HMI_DEBUG("Not found key \"%s\"", key);
+ return nullptr;
+ }
+
+ return json_object_get_string(tmp);
+}
+
+int getIntFromJson(json_object *obj, const char *key)
+{
+ json_object *tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ HMI_DEBUG("Not found key \"%s\"", key);
+ return 0;
+ }
+
+ return json_object_get_int(tmp);
+}
+
+double getDoubleFromJson(json_object *obj, const char *key)
+{
+ json_object *tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ HMI_DEBUG("Not found key \"%s\"", key);
+ return 0;
+ }
+
+ return json_object_get_double(tmp);
+}
+
+json_bool getBoolFromJson(json_object *obj, const char *key)
+{
+ json_object *tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ HMI_DEBUG("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;
+ int ret = -1;
+
+ HMI_DEBUG("Input file: %s", file);
+
+ // Open json file
+ FILE *fp = fopen(file, "rb");
+ if (nullptr == fp)
+ {
+ HMI_ERROR("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("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("Failed to parse file (byte:%d err:%s)",
+ (input_size * block_cnt), json_tokener_error_desc(json_error));
+ HMI_ERROR("\n%s", buffer);
+ *obj = nullptr;
+ break;
+ }
+ block_cnt++;
+ }
+
+ // Close json file
+ fclose(fp);
+
+ // Free json_tokener
+ json_tokener_free(tokener);
+
+ return ret;
+}
+
+} // namespace jh
diff --git a/demo3/common/agl-service-windowmanager/src/json_helper.hpp b/demo3/common/agl-service-windowmanager/src/json_helper.hpp
new file mode 100644
index 0000000..d4ae85a
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/json_helper.hpp
@@ -0,0 +1,34 @@
+/*
+ * 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 JSON_HELPER_HPP
+#define JSON_HELPER_HPP
+
+#include <json-c/json.h>
+#include <vector>
+
+struct json_object;
+json_object *to_json(std::vector<uint32_t> const &v);
+
+namespace jh {
+const char* getStringFromJson(json_object* obj, const char* key);
+int getIntFromJson(json_object *obj, const char *key);
+double getDoubleFromJson(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
+
+#endif // JSON_HELPER_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/layers.cpp b/demo3/common/agl-service-windowmanager/src/layers.cpp
new file mode 100644
index 0000000..05d404d
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/layers.cpp
@@ -0,0 +1,382 @@
+/*
+ * 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 <regex>
+
+#include "layers.hpp"
+#include "json_helper.hpp"
+#include "util.hpp"
+
+namespace wm
+{
+
+using json = nlohmann::json;
+
+layer::layer(nlohmann::json const &j)
+{
+ this->role = j["role"];
+ 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("layer_id:%d is_normal_layout_only:%d\n",
+ this->layer_id, this->is_normal_layout_only);
+}
+
+struct result<struct layer_map> to_layer_map(nlohmann::json const &j)
+{
+ try
+ {
+ layer_map stl{};
+ auto m = j["mappings"];
+
+ std::transform(std::cbegin(m), std::cend(m),
+ std::inserter(stl.mapping, stl.mapping.end()),
+ [](nlohmann::json const &j) {
+ return std::pair<int, struct layer>(
+ j.value("layer_id", -1), layer(j));
+ });
+
+ // TODO: add sanity checks here?
+ // * check for double IDs
+ // * check for double names/roles
+
+ stl.layers.reserve(m.size());
+ std::transform(std::cbegin(stl.mapping), std::cend(stl.mapping),
+ std::back_inserter(stl.layers),
+ [&stl](std::pair<int, struct layer> const &k) {
+ stl.roles.emplace_back(
+ std::make_pair(k.second.role, k.second.layer_id));
+ return unsigned(k.second.layer_id);
+ });
+
+ std::sort(stl.layers.begin(), stl.layers.end());
+
+ for (auto i : stl.mapping)
+ {
+ if (i.second.name.empty())
+ {
+ return Err<struct layer_map>("Found mapping w/o name");
+ }
+ if (i.second.layer_id == -1)
+ {
+ return Err<struct layer_map>("Found invalid/unset IDs in mapping");
+ }
+ }
+
+ auto msi = j.find("main_surface");
+ if (msi != j.end())
+ {
+ stl.main_surface_name = msi->value("surface_role", "");
+ stl.main_surface = -1;
+ }
+
+ return Ok(stl);
+ }
+ catch (std::exception &e)
+ {
+ return Err<struct layer_map>(e.what());
+ }
+}
+
+optional<int>
+layer_map::get_layer_id(int surface_id)
+{
+ auto i = this->surfaces.find(surface_id);
+ if (i != this->surfaces.end())
+ {
+ return optional<int>(i->second);
+ }
+ return nullopt;
+}
+
+optional<int> layer_map::get_layer_id(std::string const &role)
+{
+ for (auto const &r : this->roles)
+ {
+ auto re = std::regex(r.first);
+ if (std::regex_match(role, re))
+ {
+ HMI_DEBUG("role %s matches layer %d", role.c_str(), r.second);
+ return optional<int>(r.second);
+ }
+ }
+ HMI_DEBUG("role %s does NOT match any layer", role.c_str());
+ return nullopt;
+}
+
+json layer::to_json() const
+{
+ auto is_full = this->rect == compositor::full_rect;
+
+ json r{};
+ if (is_full)
+ {
+ r = {{"type", "full"}};
+ }
+ else
+ {
+ r = {{"type", "rect"},
+ {"rect",
+ {{"x", this->rect.x},
+ {"y", this->rect.y},
+ {"width", this->rect.w},
+ {"height", this->rect.h}}}};
+ }
+
+ return {
+ {"name", this->name},
+ {"role", this->role},
+ {"layer_id", this->layer_id},
+ {"area", r},
+ };
+}
+
+json layer_map::to_json() const
+{
+ json j{};
+ for (auto const &i : this->mapping)
+ {
+ j.push_back(i.second.to_json());
+ }
+ return j;
+}
+
+void layer_map::setupArea(double scaling)
+{
+ compositor::rect rct;
+
+ rct = this->area2size["normal.full"];
+ this->area2size["normalfull"] = rct;
+ this->area2size["normal"] = rct;
+
+ for (auto &i : this->area2size)
+ {
+ i.second.x = static_cast<int>(scaling * i.second.x + 0.5);
+ i.second.y = static_cast<int>(scaling * i.second.y + 0.5);
+ i.second.w = static_cast<int>(scaling * i.second.w + 0.5);
+ i.second.h = static_cast<int>(scaling * i.second.h + 0.5);
+
+ HMI_DEBUG("wm:lm", "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);
+ }
+}
+
+compositor::rect layer_map::getAreaSize(const std::string &area)
+{
+ return area2size[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);
+
+ std::string file_name;
+ if (!afm_app_install_dir)
+ {
+ HMI_ERROR("wm:lm", "AFM_APP_INSTALL_DIR is not defined");
+ }
+ else
+ {
+ file_name = std::string(afm_app_install_dir) + std::string("/etc/areas.db");
+ }
+
+ // Load area.db
+ json_object *json_obj;
+ 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");
+ json_obj = json_tokener_parse(kDefaultAreaDb);
+ }
+ HMI_DEBUG("wm:lm", "json_obj dump:%s", json_object_get_string(json_obj));
+
+ // Perse areas
+ HMI_DEBUG("wm:lm", "Perse areas");
+ json_object *json_cfg;
+ if (!json_object_object_get_ex(json_obj, "areas", &json_cfg))
+ {
+ HMI_ERROR("wm:lm", "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));
+
+ 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));
+
+ area = jh::getStringFromJson(json_tmp, "name");
+ if (nullptr == area)
+ {
+ HMI_ERROR("wm:lm", "Parse Error!!");
+ return -1;
+ }
+ HMI_DEBUG("wm:lm", "> area:%s", area);
+
+ json_object *json_rect;
+ if (!json_object_object_get_ex(json_tmp, "rect", &json_rect))
+ {
+ HMI_ERROR("wm:lm", "Parse Error!!");
+ return -1;
+ }
+ HMI_DEBUG("wm:lm", "> json_rect dump:%s", json_object_get_string(json_rect));
+
+ compositor::rect area_size;
+ area_size.x = jh::getIntFromJson(json_rect, "x");
+ area_size.y = jh::getIntFromJson(json_rect, "y");
+ area_size.w = jh::getIntFromJson(json_rect, "w");
+ area_size.h = jh::getIntFromJson(json_rect, "h");
+
+ this->area2size[area] = area_size;
+ }
+
+ // Check
+ 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",
+ itr->first.c_str(), itr->second.x, itr->second.y,
+ itr->second.w, itr->second.h);
+ }
+
+ // Release json_object
+ json_object_put(json_obj);
+
+ return 0;
+}
+
+const char* layer_map::kDefaultAreaDb = "{ \
+ \"areas\": [ \
+ { \
+ \"name\": \"fullscreen\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 0, \
+ \"w\": 1080, \
+ \"h\": 1920 \
+ } \
+ }, \
+ { \
+ \"name\": \"normal.full\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 218, \
+ \"w\": 1080, \
+ \"h\": 1488 \
+ } \
+ }, \
+ { \
+ \"name\": \"split.main\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 218, \
+ \"w\": 1080, \
+ \"h\": 744 \
+ } \
+ }, \
+ { \
+ \"name\": \"split.sub\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 962, \
+ \"w\": 1080, \
+ \"h\": 744 \
+ } \
+ }, \
+ { \
+ \"name\": \"software_keyboard\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 962, \
+ \"w\": 1080, \
+ \"h\": 744 \
+ } \
+ }, \
+ { \
+ \"name\": \"restriction.normal\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 218, \
+ \"w\": 1080, \
+ \"h\": 1488 \
+ } \
+ }, \
+ { \
+ \"name\": \"restriction.split.main\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 218, \
+ \"w\": 1080, \
+ \"h\": 744 \
+ } \
+ }, \
+ { \
+ \"name\": \"restriction.split.sub\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 962, \
+ \"w\": 1080, \
+ \"h\": 744 \
+ } \
+ }, \
+ { \
+ \"name\": \"on_screen\", \
+ \"rect\": { \
+ \"x\": 0, \
+ \"y\": 218, \
+ \"w\": 1080, \
+ \"h\": 1488 \
+ } \
+ } \
+ ] \
+}";
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/layers.hpp b/demo3/common/agl-service-windowmanager/src/layers.hpp
new file mode 100644
index 0000000..f52886e
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/layers.hpp
@@ -0,0 +1,174 @@
+/*
+ * 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 TMCAGLWM_LAYERS_H
+#define TMCAGLWM_LAYERS_H
+
+#include <string>
+
+#include "../include/json.hpp"
+#include "layout.hpp"
+#include "result.hpp"
+#include "wayland_ivi_wm.hpp"
+
+namespace wm
+{
+
+struct split_layout
+{
+ std::string name;
+ std::string main_match;
+ std::string sub_match;
+};
+
+struct layer
+{
+ using json = nlohmann::json;
+
+ // A more or less descriptive name?
+ std::string name = "";
+ // 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.
+ 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<struct split_layout> 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;
+};
+
+struct layer_map
+{
+ using json = nlohmann::json;
+
+ using storage_type = std::map<int, struct layer>;
+ using layers_type = std::vector<uint32_t>;
+ using role_to_layer_map = std::vector<std::pair<std::string, int>>;
+ using addsurf_layer_map = std::map<int, int>;
+
+ storage_type mapping; // map surface_id to layer
+ layers_type layers; // the actual layer IDs we have
+ int main_surface;
+ std::string main_surface_name;
+ role_to_layer_map roles;
+ addsurf_layer_map surfaces; // additional surfaces on layers
+
+ optional<int> get_layer_id(int surface_id);
+ optional<int> get_layer_id(std::string const &role);
+ optional<struct LayoutState *> get_layout_state(int surface_id)
+ {
+ int layer_id = *this->get_layer_id(surface_id);
+ auto i = this->mapping.find(layer_id);
+ return i == this->mapping.end()
+ ? nullopt
+ : optional<struct LayoutState *>(&i->second.state);
+ }
+ optional<struct layer> get_layer(int layer_id)
+ {
+ auto i = this->mapping.find(layer_id);
+ return i == this->mapping.end() ? nullopt
+ : optional<struct layer>(i->second);
+ }
+
+ layers_type::size_type get_layers_count() const
+ {
+ return this->layers.size();
+ }
+
+ void add_surface(int surface_id, int layer_id)
+ {
+ this->surfaces[surface_id] = layer_id;
+ }
+
+ void remove_surface(int surface_id)
+ {
+ this->surfaces.erase(surface_id);
+ }
+
+ json to_json() const;
+ void setupArea(double scaling);
+ compositor::rect getAreaSize(const std::string &area);
+ int loadAreaDb();
+
+ private:
+ std::unordered_map<std::string, compositor::rect> area2size;
+
+ static const char *kDefaultAreaDb;
+};
+
+struct result<struct layer_map> to_layer_map(nlohmann::json const &j);
+
+static const nlohmann::json default_layers_json = {
+ {"main_surface", {
+ {"surface_role", "HomeScreen"}
+ }},
+ {"mappings", {
+ {
+ {"role", "^HomeScreen$"},
+ {"name", "HomeScreen"},
+ {"layer_id", 1000},
+ {"area", {
+ {"type", "full"}
+ }}
+ },
+ {
+ {"role", "MediaPlayer|Radio|Phone|Navigation|HVAC|Settings|Dashboard|POI|Mixer"},
+ {"name", "apps"},
+ {"layer_id", 1001},
+ {"area", {
+ {"type", "rect"},
+ {"rect", {
+ {"x", 0},
+ {"y", 218},
+ {"width", -1},
+ {"height", -433}
+ }}
+ }}
+ },
+ {
+ {"role", "^OnScreen.*"},
+ {"name", "popups"},
+ {"layer_id", 9999},
+ {"area", {
+ {"type", "rect"},
+ {"rect", {
+ {"x", 0},
+ {"y", 760},
+ {"width", -1},
+ {"height", 400}
+ }}
+ }}
+ }
+ }}
+};
+} // namespace wm
+
+#endif // TMCAGLWM_LAYERS_H
diff --git a/demo3/common/agl-service-windowmanager/src/low_can_client.cpp b/demo3/common/agl-service-windowmanager/src/low_can_client.cpp
new file mode 100644
index 0000000..090aa14
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/low_can_client.cpp
@@ -0,0 +1,187 @@
+/*
+ * 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 "low_can_client.hpp"
+#include "json_helper.hpp"
+#include "util.hpp"
+
+extern "C"
+{
+#include <afb/afb-binding.h>
+}
+
+namespace wm
+{
+
+LowCanClient::LowCanClient()
+ : vehicle_speed(0),
+ trans_gear_pos(0),
+ headlamp_status(FALSE),
+ parking_brake_status(TRUE),
+ accel_pedal_pos(0),
+ accel_pedal_stt(FALSE),
+ lightstatus_brake_status(TRUE),
+ is_changed_accel_pedal_stt(false)
+{
+}
+
+void LowCanClient::initialize()
+{
+ int ret;
+
+ // Require API "low-can"
+ ret = afb_daemon_require_api_v2("low-can", 1);
+ if (0 > ret)
+ {
+ HMI_INFO("Requirement API \"low-can\" failed");
+ return;
+ }
+
+ // Subscribe low-level-can
+ // low-can subscribe { "event": "vehicle.speed" }
+ // low-can subscribe { "event": "transmission_gear_position" }
+ // low-can subscribe { "event": "headlamp_status" }
+ // low-can subscribe { "event": "parking_brake_status" }
+ // low-can subscribe { "event": "accelerator.pedal.position" }
+ // low-can subscribe { "event": "lightstatus.brake" }
+ for (int i = SignalNoMin; i <= SignalNoMax; i++)
+ {
+ // Set Event
+ json_object *json_obj = json_object_new_object();
+ json_object_object_add(json_obj, "event",
+ json_object_new_string(this->kSignalName[i]));
+
+ // Set filter
+ if (0 != strcmp("", this->kFilterValue[i]))
+ {
+ json_object_object_add(json_obj, "filter",
+ json_tokener_parse(this->kFilterValue[i]));
+ }
+ HMI_DEBUG("subscribe message:%s", json_object_get_string(json_obj));
+
+ // Subscribe
+ afb_service_call("low-can", "subscribe", json_obj,
+ [](void *closure, int status, json_object *result) {
+ HMI_DEBUG("subscribe result:%s", json_object_get_string(result));
+ },
+ nullptr);
+ }
+
+ return;
+}
+
+const char *LowCanClient::analyzeCanSignal(struct json_object *object)
+{
+ HMI_DEBUG("object:%s", json_object_get_string(object));
+
+ const char *name = jh::getStringFromJson(object, "name");
+ HMI_DEBUG("CAN signal name:%s", name);
+
+ if (strstr(name, this->kSignalName[SignalNoVehicliSpeed]))
+ {
+ // Update vehicle speed
+ this->vehicle_speed = jh::getIntFromJson(object, "value");
+ HMI_DEBUG("Update vehicle speed:%d", this->vehicle_speed);
+ }
+ else if (strstr(name, this->kSignalName[SignalNoTransGearPos]))
+ {
+ // Update transmission gear position
+ this->trans_gear_pos = jh::getIntFromJson(object, "value");
+ HMI_DEBUG("Update transmission gear position:%d", this->trans_gear_pos);
+ }
+ else if (strstr(name, this->kSignalName[SignalNoHeadlame]))
+ {
+ // Update headlamp status
+ this->headlamp_status = jh::getBoolFromJson(object, "value");
+ HMI_DEBUG("Update headlamp status:%d", this->headlamp_status);
+ }
+ else if (strstr(name, this->kSignalName[SignalNoParkingBrake]))
+ {
+ // Update parking gear status
+ this->parking_brake_status = jh::getBoolFromJson(object, "value");
+ HMI_DEBUG("Update parking brake status:%d", this->parking_brake_status);
+ }
+ else if (strstr(name, this->kSignalName[SignalNoAccelPedalPos]))
+ {
+ // Clear flag for whether accel pedal state is changed
+ this->is_changed_accel_pedal_stt = false;
+
+ // Update accelerator pedal status
+ this->accel_pedal_pos = jh::getDoubleFromJson(object, "value");
+ HMI_DEBUG("Update accelerator pedal position:%lf", this->accel_pedal_pos);
+
+ bool accel_pedal_stt;
+ if (0 != this->accel_pedal_pos)
+ {
+ accel_pedal_stt = true;
+ }
+ else
+ {
+ accel_pedal_stt = false;
+ }
+
+ if (accel_pedal_stt != this->accel_pedal_stt)
+ {
+ this->is_changed_accel_pedal_stt = true;
+ this->accel_pedal_stt = accel_pedal_stt;
+ }
+ }
+ else if (strstr(name, this->kSignalName[SignalNoLightstatusBrake]))
+ {
+ // Update lightstatus brake status
+ this->lightstatus_brake_status = jh::getBoolFromJson(object, "value");
+ HMI_DEBUG("Update lightstatus brake status:%d", this->lightstatus_brake_status);
+ }
+
+ return name;
+}
+
+bool LowCanClient::isChangedAccelPedalState()
+{
+ return this->is_changed_accel_pedal_stt;
+}
+
+int LowCanClient::getCurrentTransGearState()
+{
+ return this->trans_gear_pos;
+}
+
+bool LowCanClient::getCurrentHeadlampState()
+{
+ return (bool)this->headlamp_status;
+}
+
+bool LowCanClient::getCurrentParkingBrakeState()
+{
+ return (bool)this->parking_brake_status;
+}
+
+double LowCanClient::getCurrentAccelPedalPosition()
+{
+ return this->accel_pedal_pos;
+}
+
+bool LowCanClient::getCurrentAccelPedalState()
+{
+ return this->accel_pedal_stt;
+}
+
+bool LowCanClient::getCurrentLightstatusBrakeState()
+{
+ return (bool)this->lightstatus_brake_status;
+}
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/low_can_client.hpp b/demo3/common/agl-service-windowmanager/src/low_can_client.hpp
new file mode 100644
index 0000000..9b7f509
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/low_can_client.hpp
@@ -0,0 +1,113 @@
+/*
+ * 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 TMCAGLWM_LOW_CAN_CLIENT_HPP
+#define TMCAGLWM_LOW_CAN_CLIENT_HPP
+
+#include <string>
+#include <vector>
+#include <json-c/json.h>
+
+namespace wm
+{
+
+class LowCanClient
+{
+
+ public:
+ explicit LowCanClient();
+ ~LowCanClient() = default;
+
+ enum SignalNo
+ {
+ SignalNoVehicliSpeed = 0,
+ SignalNoTransGearPos,
+ SignalNoHeadlame,
+ SignalNoParkingBrake,
+ SignalNoAccelPedalPos,
+ SignalNoLightstatusBrake,
+
+ SignalNum,
+
+ SignalNoMin = SignalNoVehicliSpeed,
+ SignalNoMax = SignalNum - 1,
+ };
+
+ const std::vector<const char *> kSignalName{
+ "vehicle.speed",
+ "transmission_gear_position",
+ "headlamp_status",
+ "parking_brake_status",
+ "accelerator.pedal.position",
+ "lightstatus.brake",
+ };
+
+ void initialize();
+ const char *analyzeCanSignal(struct json_object *object);
+
+ int getCurrentTransGearState();
+ bool getCurrentHeadlampState();
+ bool getCurrentParkingBrakeState();
+ double getCurrentAccelPedalPosition();
+ bool getCurrentAccelPedalState();
+ bool getCurrentLightstatusBrakeState();
+
+ bool isChangedAccelPedalState();
+
+ private:
+ // Disable copy and move
+ LowCanClient(LowCanClient const &) = delete;
+ LowCanClient &operator=(LowCanClient const &) = delete;
+ LowCanClient(LowCanClient &&) = delete;
+ LowCanClient &operator=(LowCanClient &&) = delete;
+
+ enum TransGearPosVal
+ {
+ TransGearPosValD1 = 1,
+ TransGearPosValD2,
+ TransGearPosValD3,
+ TransGearPosValD4,
+ TransGearPosValD5,
+ TransGearPosValD6,
+ TransGearPosValD7,
+ TransGearPosValD8,
+ TransGearPosValR,
+ TransGearPosValN,
+ };
+
+ const std::vector<const char *> kFilterValue{
+ "", // vehicle.speed
+ "", // transmission_gear_position
+ "", // headlamp_status
+ "", // parking_brake_status
+ "", // accelerator.pedal.position
+ "", // lightstatus.brake
+ };
+
+ int vehicle_speed;
+ int trans_gear_pos;
+ json_bool headlamp_status;
+ json_bool parking_brake_status;
+ double accel_pedal_pos;
+ bool accel_pedal_stt;
+ json_bool lightstatus_brake_status;
+
+ bool is_changed_accel_pedal_stt;
+};
+
+} // namespace wm
+
+#endif // TMCAGLWM_LOW_CAN_CLIENT_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/main.cpp b/demo3/common/agl-service-windowmanager/src/main.cpp
new file mode 100644
index 0000000..3766152
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/main.cpp
@@ -0,0 +1,844 @@
+/*
+ * 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 <unistd.h>
+#include <algorithm>
+#include <mutex>
+#include <json.h>
+#include <stdlib.h>
+#include <vector>
+#include "window_manager.hpp"
+#include "json_helper.hpp"
+
+extern "C"
+{
+#include <afb/afb-binding.h>
+#include <systemd/sd-event.h>
+}
+
+typedef struct WMClientCtxt
+{
+ std::string name;
+ std::string role;
+ WMClientCtxt(const char *appName, const char* appRole)
+ {
+ name = appName;
+ role = appRole;
+ }
+} WMClientCtxt;
+
+struct afb_instance
+{
+ wm::WindowManager wmgr;
+
+ afb_instance() : wmgr() {}
+ ~afb_instance() = default;
+
+ int init();
+};
+
+struct afb_instance *g_afb_instance;
+std::mutex binding_m;
+
+int afb_instance::init()
+{
+ return this->wmgr.init();
+}
+
+int _binding_init()
+{
+ HMI_NOTICE("WinMan ver. %s", WINMAN_VERSION_STRING);
+
+ g_afb_instance = new afb_instance;
+
+ if (g_afb_instance->init() == -1)
+ {
+ HMI_ERROR("Could not connect to compositor");
+ goto error;
+ }
+
+ atexit([] { delete g_afb_instance; });
+
+ return 0;
+
+error:
+ delete g_afb_instance;
+ g_afb_instance = nullptr;
+ return -1;
+}
+
+int binding_init() noexcept
+{
+ try
+ {
+ return _binding_init();
+ }
+ catch (std::exception &e)
+ {
+ HMI_ERROR("Uncaught exception in binding_init(): %s", e.what());
+ }
+ return -1;
+}
+
+static void cbRemoveClientCtxt(void *data)
+{
+ WMClientCtxt *ctxt = (WMClientCtxt *)data;
+ if (ctxt == nullptr)
+ {
+ return;
+ }
+ HMI_DEBUG("remove app %s", ctxt->name.c_str());
+
+ // 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 *) {});
+
+ g_afb_instance->wmgr.removeClient(ctxt->name);
+ delete ctxt;
+}
+
+static void createSecurityContext(afb_req req, const char* appid, const char* role)
+{
+ WMClientCtxt *ctxt = (WMClientCtxt *)afb_req_context_get(req);
+ if (!ctxt)
+ {
+ // 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("create session for %s", ctxt->name.c_str());
+ afb_req_session_set_LOA(req, 1);
+ afb_req_context_set(req, ctxt, cbRemoveClientCtxt);
+ }
+}
+
+void windowmanager_requestsurface(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ const char *a_drawing_name = afb_req_value(req, "drawing_name");
+ if (!a_drawing_name)
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ 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);
+ }
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurface: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_requestsurfacexdg(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ json_object *jreq = afb_req_json(req);
+
+ json_object *j_drawing_name = nullptr;
+ if (!json_object_object_get_ex(jreq, "drawing_name", &j_drawing_name))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+ char const *a_drawing_name = json_object_get_string(j_drawing_name);
+
+ json_object *j_ivi_id = nullptr;
+ if (!json_object_object_get_ex(jreq, "ivi_id", &j_ivi_id))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument ivi_id");
+ return;
+ }
+ char const *a_ivi_id = json_object_get_string(j_ivi_id);
+ char *appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ auto ret = g_afb_instance->wmgr.api_request_surface(
+ appid, a_drawing_name, a_ivi_id);
+ 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)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurfacexdg: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_setrole(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+ try
+ {
+ json_object *jreq = afb_req_json(req);
+
+ json_object *j_role = nullptr;
+ if (!json_object_object_get_ex(jreq, "role", &j_role))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument role");
+ return;
+ }
+ char const *a_role = json_object_get_string(j_role);
+ char *appid = afb_req_get_application_id(req);
+
+ if(appid)
+ {
+ auto ret = g_afb_instance->wmgr.api_set_role(appid, a_role);
+ if (!ret)
+ {
+ afb_req_fail(req, "failed", "Couldn't register");
+ }
+ else
+ {
+ createSecurityContext(req, appid, a_role);
+ afb_req_success(req, NULL, "success");
+ }
+ free(appid);
+ }
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling requestsurfacexdg: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_activatewindow(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ const char *a_drawing_name = afb_req_value(req, "drawing_name");
+ if (!a_drawing_name)
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+
+ const char *a_drawing_area = afb_req_value(req, "drawing_area");
+ if (!a_drawing_area)
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_area");
+ return;
+ }
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ auto reply = [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR(errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ };
+
+ if (g_afb_instance->wmgr.wmcon.isMasterMode() ||
+ !g_afb_instance->wmgr.wmcon.isMasterArea(a_drawing_area))
+ {
+ g_afb_instance->wmgr.api_activate_surface(
+ appid, a_drawing_name, a_drawing_area, reply);
+ }
+ else
+ {
+ // TODO: temporarily
+ if (!g_afb_instance->wmgr.wmcon.isConnecting())
+ {
+ g_afb_instance->wmgr.wmcon.connectToMaster();
+ }
+
+ // If Window Manager is slave and this request is for master,
+ // request activateWindow to master
+ g_afb_instance->wmgr.api_activate_surface_to_master(
+ appid, a_drawing_name, a_drawing_area, reply);
+ }
+ free(appid);
+ }
+ }
+ catch (std::exception &e)
+ {
+ HMI_WARNING("failed: Uncaught exception while calling activatesurface: %s", e.what());
+ g_afb_instance->wmgr.exceptionProcessForTransition();
+ return;
+ }
+}
+
+void windowmanager_deactivatewindow(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ const char *a_drawing_name = afb_req_value(req, "drawing_name");
+ if (!a_drawing_name)
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ auto reply = [&req](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR(errmsg);
+ afb_req_fail(req, "failed", errmsg);
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ };
+
+ // TODO: Check whether role is tbtnavi to request remote invisible
+ if (g_afb_instance->wmgr.wmcon.isMasterMode() ||
+ ("tbtnavi" != std::string(a_drawing_name)))
+ {
+ g_afb_instance->wmgr.api_deactivate_surface(
+ appid, a_drawing_name, reply);
+ }
+ else
+ {
+ // If Window Manager is slave and this request is for master,
+ // request deactivateWindow to master
+ g_afb_instance->wmgr.api_deactivate_surface_to_master(
+ appid, a_drawing_name, reply);
+ }
+ free(appid);
+ }
+ }
+ catch (std::exception &e)
+ {
+ HMI_WARNING("failed: Uncaught exception while calling deactivatesurface: %s", e.what());
+ g_afb_instance->wmgr.exceptionProcessForTransition();
+ return;
+ }
+}
+
+void windowmanager_enddraw(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ const char *a_drawing_name = afb_req_value(req, "drawing_name");
+ if (!a_drawing_name)
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ if (g_afb_instance->wmgr.wmcon.isMasterMode() ||
+ !g_afb_instance->wmgr.wmcon.isSyncDrawingForRemote(appid))
+ {
+ g_afb_instance->wmgr.api_enddraw(appid, a_drawing_name);
+ }
+ else
+ {
+ // If Window Manager is slave and requesting app is syncDrawing,
+ // request endDraw to master
+ g_afb_instance->wmgr.api_enddraw_for_remote(appid, a_drawing_name);
+ }
+ free(appid);
+ }
+ }
+ catch (std::exception &e)
+ {
+ HMI_WARNING("failed: Uncaught exception while calling enddraw: %s", e.what());
+ g_afb_instance->wmgr.exceptionProcessForTransition();
+ return;
+ }
+}
+
+void windowmanager_getdisplayinfo_thunk(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ auto ret = g_afb_instance->wmgr.api_get_display_info();
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling getdisplayinfo: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_getareainfo_thunk(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ json_object *jreq = afb_req_json(req);
+
+ json_object *j_drawing_name = nullptr;
+ if (!json_object_object_get_ex(jreq, "drawing_name", &j_drawing_name))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument drawing_name");
+ return;
+ }
+ char const *a_drawing_name = json_object_get_string(j_drawing_name);
+
+ auto ret = g_afb_instance->wmgr.api_get_area_info(a_drawing_name);
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling getareainfo: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_getcarinfo_thunk(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ json_object *jreq = afb_req_json(req);
+
+ json_object *j_label = nullptr;
+ if (! json_object_object_get_ex(jreq, "label", &j_label))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument label");
+ return;
+ }
+ char const* a_label = json_object_get_string(j_label);
+
+ auto ret = g_afb_instance->wmgr.api_get_car_info(a_label);
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling getcarinfo: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_set_render_order(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ json_object *jreq = afb_req_json(req);
+ json_object *j_ro; // Do not free this. binder frees jreq, then free j_ro
+ if (json_object_object_get_ex(jreq, "render_order", &j_ro))
+ {
+ int size = json_object_array_length(j_ro);
+ std::vector<std::string> ro(size);
+ for(int i = 0; i < size; i++)
+ {
+ ro[i] = json_object_get_string(json_object_array_get_idx(j_ro, i));
+ }
+
+ auto ret = g_afb_instance->wmgr.api_client_set_render_order(appid, ro);
+ if (!ret)
+ {
+ afb_req_fail(req, "failed", nullptr);
+ }
+ else
+ {
+ afb_req_success(req, nullptr, nullptr);
+ }
+ }
+ free(appid);
+ }
+ else
+ {
+ afb_req_fail(req, "failed", nullptr);
+ }
+}
+
+void windowmanager_attach_app(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ json_object *jreq = afb_req_json(req);
+ json_object *j_dest, *j_id; // Do not free this. binder frees jreq, then free j_ro
+ if (json_object_object_get_ex(jreq, "destination", &j_dest) &&
+ json_object_object_get_ex(jreq, "service_surface", &j_id))
+ {
+ const char* dest_app = json_object_get_string(j_dest);
+ const char* service = json_object_get_string(j_id);
+
+ std::string uuid = g_afb_instance->wmgr.api_client_attach_service_surface(appid, dest_app, service);
+ if (uuid.empty())
+ {
+ afb_req_fail(req, "failed", nullptr);
+ }
+ else
+ {
+ json_object *resp = json_object_new_object();
+ json_object_object_add(resp, "uuid", json_object_new_string(uuid.c_str()));
+ afb_req_success(req, resp, nullptr);
+ }
+ }
+ free(appid);
+ }
+ else
+ {
+ afb_req_fail(req, "failed", nullptr);
+ }
+}
+
+void windowmanager_wm_subscribe(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ json_object *jreq = afb_req_json(req);
+ json_object *j = nullptr;
+ if (!json_object_object_get_ex(jreq, "event", &j))
+ {
+ afb_req_fail(req, "failed", "Need char const* argument event");
+ return;
+ }
+ int event_type = json_object_get_int(j);
+ const char *event_name = g_afb_instance->wmgr.kListEventName[event_type];
+ struct afb_event event = g_afb_instance->wmgr.map_afb_event[event_name];
+ int ret = afb_req_subscribe(req, event);
+ if (ret)
+ {
+ afb_req_fail(req, "failed", "Error: afb_req_subscribe()");
+ return;
+ }
+ afb_req_success(req, NULL, "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling wm_subscribe: %s", e.what());
+ return;
+ }
+}
+
+void windowmanager_list_drawing_names(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ /* if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+
+ nlohmann::json j = g_afb_instance->wmgr.id_alloc.name2id;
+ auto ret = wm::Ok(json_tokener_parse(j.dump().c_str()));
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling list_drawing_names: %s", e.what());
+ return;
+ } */
+}
+
+void windowmanager_ping(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+ else
+ {
+ afb_req_success(req, NULL, "success");
+ }
+}
+
+void windowmanager_debug_status(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ /* if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+
+ json_object *jr = json_object_new_object();
+ json_object_object_add(jr, "surfaces",
+ to_json(g_afb_instance->wmgr.controller->sprops));
+ json_object_object_add(jr, "layers", to_json(g_afb_instance->wmgr.controller->lprops));
+
+ afb_req_success(req, jr, "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_status: %s", e.what());
+ return;
+ } */
+}
+
+void windowmanager_debug_layers(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ /* if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+ auto ret = wm::Ok(json_tokener_parse(g_afb_instance->wmgr.layers.to_json().dump().c_str()));
+
+ afb_req_success(req, ret, "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_layers: %s", e.what());
+ return;
+ } */
+}
+
+void windowmanager_debug_surfaces(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ /* if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+
+ auto ret = wm::Ok(to_json(g_afb_instance->wmgr.controller->sprops));
+ if (ret.is_err())
+ {
+ afb_req_fail(req, "failed", ret.unwrap_err());
+ return;
+ }
+
+ afb_req_success(req, ret.unwrap(), "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_surfaces: %s", e.what());
+ return;
+ } */
+}
+
+void windowmanager_debug_terminate(afb_req req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ try
+ {
+
+ if (getenv("WINMAN_DEBUG_TERMINATE") != nullptr)
+ {
+ raise(SIGKILL); // afb-daemon kills it's pgroup using TERM, which
+ // doesn't play well with perf
+ }
+
+ afb_req_success(req, NULL, "success");
+ }
+ catch (std::exception &e)
+ {
+ afb_req_fail_f(req, "failed", "Uncaught exception while calling debug_terminate: %s", e.what());
+ return;
+ }
+}
+
+void on_event(const char *event, struct json_object *object)
+{
+ g_afb_instance->wmgr.analyzeReceivedEvent(event, object);
+}
+
+const struct afb_verb_v2 windowmanager_verbs[] = {
+ {"requestSurface", windowmanager_requestsurface, nullptr, nullptr, AFB_SESSION_NONE},
+ {"requestSurfaceXdg", windowmanager_requestsurfacexdg, nullptr, nullptr, AFB_SESSION_NONE},
+ {"setRole", windowmanager_setrole, 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},
+ {"getCarInfo", windowmanager_getcarinfo_thunk, nullptr, nullptr, AFB_SESSION_NONE },
+ {"setRenderOrder", windowmanager_set_render_order, nullptr, nullptr, AFB_SESSION_NONE},
+ {"attachApp", windowmanager_attach_app, 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},
+ {"debug_status", windowmanager_debug_status, nullptr, nullptr, AFB_SESSION_NONE},
+ {"debug_layers", windowmanager_debug_layers, nullptr, nullptr, AFB_SESSION_NONE},
+ {"debug_surfaces", windowmanager_debug_surfaces, nullptr, nullptr, AFB_SESSION_NONE},
+ {"debug_terminate", windowmanager_debug_terminate, nullptr, nullptr, AFB_SESSION_NONE},
+ {}};
+
+extern "C" const struct afb_binding_v2 afbBindingV2 = {
+ "windowmanager", nullptr, nullptr, windowmanager_verbs, nullptr, binding_init, on_event, 0};
diff --git a/demo3/common/agl-service-windowmanager/src/pm_wrapper.cpp b/demo3/common/agl-service-windowmanager/src/pm_wrapper.cpp
new file mode 100644
index 0000000..7cf90f0
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/pm_wrapper.cpp
@@ -0,0 +1,439 @@
+/*
+ * 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 "util.hpp"
+
+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("error message from PolicyManager:%s",
+ json_object_get_string(json_out));
+
+ g_context->processError();
+}
+
+} // namespace
+
+PMWrapper::PMWrapper() {}
+
+int PMWrapper::initialize(std::string ecu_name)
+{
+ int ret = 0;
+
+ ret = this->pm.initialize(ecu_name);
+ 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 if (Task::TASK_PARKING_BRAKE_OFF == task)
+ {
+ event = "parking_brake_off";
+ }
+ else if (Task::TASK_PARKING_BRAKE_ON == task)
+ {
+ event = "parking_brake_on";
+ }
+ else if (Task::TASK_ACCEL_PEDAL_OFF == task)
+ {
+ event = "accel_pedal_off";
+ }
+ else if (Task::TASK_ACCEL_PEDAL_ON == task)
+ {
+ event = "accel_pedal_on";
+ }
+ else if (Task::TASK_HEDLAMP_OFF == task)
+ {
+ event = "headlamp_off";
+ }
+ else if (Task::TASK_HEDLAMP_ON == task)
+ {
+ event = "headlamp_on";
+ }
+ else if (Task::TASK_LIGHTSTATUS_BRAKE_OFF == task)
+ {
+ event = "lightstatus_brake_off";
+ }
+ else if (Task::TASK_LIGHTSTATUS_BRAKE_ON == task)
+ {
+ event = "lightstatus_brake_on";
+ }
+ 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<WMAction> actions;
+
+ HMI_DEBUG("json_out dump:%s", json_object_get_string(json_out));
+
+ this->createCarStateChangeAction(json_out, actions);
+ this->createLayoutChangeAction(json_out, actions);
+
+ this->on_state_transitioned(actions);
+}
+
+void PMWrapper::createCarStateChangeAction(json_object *json_out, std::vector<WMAction> &actions)
+{
+ json_object *json_car_ele;
+ if (!json_object_object_get_ex(json_out, "car_elements", &json_car_ele))
+ {
+ HMI_DEBUG("Not found key \"car_elements\"");
+ return;
+ }
+
+ int len = json_object_array_length(json_car_ele);
+ HMI_DEBUG("json_car_ele len:%d", len);
+
+ for (int i = 0; i < len; i++)
+ {
+ json_object *json_tmp = json_object_array_get_idx(json_car_ele, i);
+
+ std::string car_ele_name = jh::getStringFromJson(json_tmp, "name");
+ std::string state = jh::getStringFromJson(json_tmp, "state");
+ json_bool changed = jh::getBoolFromJson(json_tmp, "changed");
+ HMI_DEBUG("car_element:%s changed:%d", car_ele_name.c_str(), changed);
+
+ if (changed)
+ {
+ TaskCarState task = TaskCarState::NO_TASK;
+ if ("parking_brake" == car_ele_name)
+ {
+ if ("off" == state)
+ {
+ task = TaskCarState::PARKING_BRAKE_OFF;
+ }
+ else if ("on" == state)
+ {
+ task = TaskCarState::PARKING_BRAKE_ON;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown parking brake state: %s", state.c_str());
+ }
+ }
+ else if ("accel_pedal" == car_ele_name)
+ {
+ if ("off" == state)
+ {
+ task = TaskCarState::ACCEL_PEDAL_OFF;
+ }
+ else if ("on" == state)
+ {
+ task = TaskCarState::ACCEL_PEDAL_ON;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown accel pedal state: %s", state.c_str());
+ }
+ }
+ else if ("lamp" == car_ele_name)
+ {
+ if ("off" == state)
+ {
+ task = TaskCarState::HEDLAMP_OFF;
+ }
+ else if ("on" == state)
+ {
+ task = TaskCarState::HEDLAMP_ON;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown lamp state: %s", state.c_str());
+ }
+ }
+ else if ("lightstatus_brake" == car_ele_name)
+ {
+ if ("off" == state)
+ {
+ task = TaskCarState::LIGHTSTATUS_BRAKE_OFF;
+ }
+ else if ("on" == state)
+ {
+ task = TaskCarState::LIGHTSTATUS_BRAKE_ON;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown lightstatus brake state: %s", state.c_str());
+ }
+ }
+ else if ("running" == car_ele_name)
+ {
+ if ("stop" == state)
+ {
+ task = TaskCarState::CAR_STOP;
+ }
+ else if ("run" == state)
+ {
+ task = TaskCarState::CAR_RUN;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown car state: %s", state.c_str());
+ }
+ }
+ else if ("restriction_mode" == car_ele_name)
+ {
+ if ("off" == state)
+ {
+ task = TaskCarState::RESTRICTION_MODE_OFF;
+ }
+ else if ("on" == state)
+ {
+ task = TaskCarState::RESTRICTION_MODE_ON;
+ }
+ else
+ {
+ HMI_DEBUG("Unknown car state: %s", state.c_str());
+ }
+ }
+ else
+ {
+ HMI_DEBUG("Unknown car element: %s", car_ele_name.c_str());
+ }
+
+ // Set action
+ if (TaskCarState::NO_TASK != task)
+ {
+ bool end_draw_finished = true;
+ WMAction act
+ {
+ 0,
+ nullptr,
+ "",
+ "",
+ TaskVisible::NO_CHANGE,
+ end_draw_finished,
+ task
+ };
+ actions.push_back(act);
+ }
+ }
+ }
+}
+
+void PMWrapper::createLayoutChangeAction(json_object *json_out, std::vector<WMAction> &actions)
+{
+ // Get displayed roles from previous layout
+ json_object *json_layers;
+ if (!json_object_object_get_ex(json_out, "layers", &json_layers))
+ {
+ HMI_DEBUG("Not found key \"layers\"");
+ return;
+ }
+
+ int len = json_object_array_length(json_layers);
+ HMI_DEBUG("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("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("Not found key \"areas\"");
+ return;
+ }
+
+ int len = json_object_array_length(json_areas);
+ HMI_DEBUG("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("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("current role does not exist in previous");
+
+ // Set activate action
+ bool end_draw_finished = false;
+ WMAction act
+ {
+ 0,
+ nullptr,
+ role_name,
+ area_name,
+ TaskVisible::VISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+ actions.push_back(act);
+ }
+ else
+ {
+ HMI_DEBUG("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("current role exists in previous and area is different with previous");
+
+ // Set activate action
+ bool end_draw_finished = false;
+ WMAction act
+ {
+ 0,
+ nullptr,
+ role_name,
+ area_name,
+ TaskVisible::VISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+ 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("Deactivate role:%s", i_prv.first.c_str());
+
+ // Set deactivate action
+ bool end_draw_finished = true;
+ WMAction act
+ {
+ 0,
+ nullptr,
+ i_prv.first,
+ "",
+ TaskVisible::INVISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+ 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/demo3/common/agl-service-windowmanager/src/pm_wrapper.hpp b/demo3/common/agl-service-windowmanager/src/pm_wrapper.hpp
new file mode 100644
index 0000000..84d68df
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/pm_wrapper.hpp
@@ -0,0 +1,76 @@
+/*
+ * 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 <functional>
+#include <vector>
+#include <string>
+#include <map>
+#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<void(std::vector<WMAction>)>;
+ using ErrorHandler = std::function<void(void)>;
+
+ int initialize(std::string ecu_name);
+ 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<std::string, std::string> RoleState;
+
+ PolicyManager pm;
+ StateTransitionHandler on_state_transitioned;
+ ErrorHandler on_error;
+ std::map<std::string, RoleState> prvlayer2rolestate;
+ std::map<std::string, RoleState> crrlayer2rolestate;
+
+ void createCarStateChangeAction(json_object *json_out, std::vector<WMAction> &actions);
+ void createLayoutChangeAction(json_object *json_out, std::vector<WMAction> &actions);
+};
+
+} // namespace wm
+
+#endif // TMCAGLWM_PM_WRAPPER_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/request.cpp b/demo3/common/agl-service-windowmanager/src/request.cpp
new file mode 100644
index 0000000..0d8e5d4
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/request.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "request.hpp"
+
+namespace wm
+{
+
+using std::string;
+
+WMRequest::WMRequest() {}
+
+WMRequest::WMRequest(string appid, string role, string area, Task task)
+ : req_num(0),
+ trigger{appid, role, area, task},
+ sync_draw_req(0)
+{
+}
+
+WMRequest::WMRequest(Task task)
+ : req_num(0),
+ trigger{"", "", "", task},
+ sync_draw_req(0)
+{
+}
+
+WMRequest::~WMRequest()
+{
+}
+
+WMRequest::WMRequest(const WMRequest &obj)
+{
+ this->req_num = obj.req_num;
+ this->trigger = obj.trigger;
+ this->sync_draw_req = obj.sync_draw_req;
+}
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/request.hpp b/demo3/common/agl-service-windowmanager/src/request.hpp
new file mode 100644
index 0000000..bb203e3
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/request.hpp
@@ -0,0 +1,109 @@
+/*
+ * 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 WMREQUEST_HPP
+#define WMREQUEST_HPP
+
+#include <string>
+#include <vector>
+#include <memory>
+
+namespace wm
+{
+
+class WMClient;
+
+enum Task
+{
+ TASK_ALLOCATE,
+ TASK_RELEASE,
+ TASK_PARKING_BRAKE_OFF,
+ TASK_PARKING_BRAKE_ON,
+ TASK_ACCEL_PEDAL_OFF,
+ TASK_ACCEL_PEDAL_ON,
+ TASK_HEDLAMP_OFF,
+ TASK_HEDLAMP_ON,
+ TASK_LIGHTSTATUS_BRAKE_OFF,
+ TASK_LIGHTSTATUS_BRAKE_ON,
+ TASK_RESTRICTION_MODE_OFF,
+ TASK_RESTRICTION_MODE_ON,
+ TASK_INVALID
+};
+
+enum TaskVisible
+{
+ VISIBLE,
+ INVISIBLE,
+ REQ_REMOTE_VISIBLE,
+ REQ_REMOTE_INVISIBLE,
+ REMOTE_VISIBLE,
+ REMOTE_INVISIBLE,
+ NO_CHANGE
+};
+
+enum TaskCarState
+{
+ PARKING_BRAKE_OFF,
+ PARKING_BRAKE_ON,
+ ACCEL_PEDAL_OFF,
+ ACCEL_PEDAL_ON,
+ HEDLAMP_OFF,
+ HEDLAMP_ON,
+ LIGHTSTATUS_BRAKE_OFF,
+ LIGHTSTATUS_BRAKE_ON,
+ CAR_STOP,
+ CAR_RUN,
+ RESTRICTION_MODE_OFF,
+ RESTRICTION_MODE_ON,
+ NO_TASK,
+};
+
+struct WMTrigger
+{
+ std::string appid;
+ std::string role;
+ std::string area;
+ Task task;
+};
+
+struct WMAction
+{
+ unsigned req_num;
+ std::shared_ptr<WMClient> client;
+ std::string role;
+ std::string area;
+ TaskVisible visible;
+ bool end_draw_finished;
+ TaskCarState car_state;
+};
+
+struct WMRequest
+{
+ WMRequest();
+ explicit WMRequest(std::string appid, std::string role,
+ std::string area, Task task);
+ explicit WMRequest(Task task);
+ virtual ~WMRequest();
+ WMRequest(const WMRequest &obj);
+
+ unsigned req_num;
+ struct WMTrigger trigger;
+ std::vector<struct WMAction> sync_draw_req;
+};
+
+} // namespace wm
+
+#endif //WMREQUEST_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/result.hpp b/demo3/common/agl-service-windowmanager/src/result.hpp
new file mode 100644
index 0000000..8a59a90
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/result.hpp
@@ -0,0 +1,86 @@
+/*
+ * 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 TMCAGLWM_RESULT_HPP
+#define TMCAGLWM_RESULT_HPP
+
+#include <experimental/optional>
+#include <functional>
+
+namespace wm
+{
+
+using std::experimental::nullopt;
+using std::experimental::optional;
+
+// We only ever return a string as an error - so just parametrize
+// this over result type T
+template <typename T>
+struct result
+{
+ char const *e;
+ optional<T> t;
+
+ bool is_ok() const { return this->t != nullopt; }
+ bool is_err() const { return this->e != nullptr; }
+
+ T unwrap()
+ {
+ if (this->e != nullptr)
+ {
+ throw std::logic_error(this->e);
+ }
+ return this->t.value();
+ }
+
+ operator T() { return this->unwrap(); }
+
+ char const *unwrap_err() { return this->e; }
+
+ optional<T> const &ok() const { return this->t; }
+ optional<char const *> err() const
+ {
+ return this->e ? optional<char const *>(this->e) : nullopt;
+ }
+
+ result<T> map_err(std::function<char const *(char const *)> f);
+};
+
+template <typename T>
+struct result<T> Err(char const *e)
+{
+ return result<T>{e, nullopt};
+}
+
+template <typename T>
+struct result<T> Ok(T t)
+{
+ return result<T>{nullptr, t};
+}
+
+template <typename T>
+result<T> result<T>::map_err(std::function<char const *(char const *)> f)
+{
+ if (this->is_err())
+ {
+ return Err<T>(f(this->e));
+ }
+ return *this;
+}
+
+} // namespace wm
+
+#endif // TMCAGLWM_RESULT_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/util.cpp b/demo3/common/agl-service-windowmanager/src/util.cpp
new file mode 100644
index 0000000..b22a704
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/util.cpp
@@ -0,0 +1,172 @@
+/*
+ * 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 "util.hpp"
+
+#include <sstream>
+#include <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+
+#include <unistd.h>
+
+static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
+
+void rectangle::fit(unsigned long to_width, unsigned long to_height)
+{
+ // fit rect within (to_width x to_height)
+
+ if (to_width <= width()) {
+ // scale to fit with
+ set_bottom(top() + (static_cast<long>(to_width) * height() / width()) - 1);
+ set_right(left() + to_width - 1);
+ } else {
+ // scale to fit height
+ set_right(left() + (static_cast<long>(to_height) * width () / height()) - 1);
+ set_bottom(top() + to_height - 1);
+ }
+}
+
+void rectangle::center(unsigned long outer_w, unsigned long outer_h)
+{
+ long inner_w = width();
+ long inner_h = height();
+
+ set_left((outer_w - inner_w) / 2);
+ set_right(left() + inner_w - 1);
+ set_top((outer_h - inner_h) / 2);
+ set_bottom(top() + inner_h - 1);
+}
+
+void rectangle::set_aspect(double ratio)
+{
+ // aspect ratio is width:height (= width/height)
+ // e.g. Landscape of HD's ratio is 16:9 (= 1.777...)
+ // Portrait of HD's ratio is 9:16 (= 0.5625)
+ //
+ // width / height = ratio
+ // width * height = area
+ //
+ // width = sqrt(ratio * area)
+ // height = width / ratio
+
+ long orig_w = width();
+ long orig_h = height();
+
+ if (ratio >= 1) {
+ // width >= height
+ // try to keep width
+ set_right(left() + orig_w - 1);
+ set_bottom(top() + static_cast<long>(orig_w / ratio + 0.5) - 1);
+ } else {
+ set_bottom(top() + orig_h - 1);
+ set_right(left() + static_cast<long>(orig_h * ratio + 0.5) - 1);
+ }
+}
+
+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);
+}
+
+std::vector<std::string> parseString(std::string str, char delimiter)
+{
+ // Parse string by delimiter
+ std::vector<std::string> 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(deleteSpace(buf));
+ }
+ }
+ return vct;
+}
+
+std::string 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;
+}
+
diff --git a/demo3/common/agl-service-windowmanager/src/util.hpp b/demo3/common/agl-service-windowmanager/src/util.hpp
new file mode 100644
index 0000000..d049fff
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/util.hpp
@@ -0,0 +1,125 @@
+/*
+ * 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 WM_UTIL_HPP
+#define WM_UTIL_HPP
+
+#include <functional>
+#include <thread>
+#include <string>
+#include <vector>
+#include <sys/poll.h>
+#include <string.h>
+
+#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
+};
+
+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, ...);
+
+std::vector<std::string> parseString(std::string str, char delimiter);
+std::string deleteSpace(std::string str);
+
+struct rect
+{
+ int32_t w, h;
+ int32_t x, y;
+};
+
+struct size
+{
+ uint32_t w, h;
+};
+
+class rectangle
+{
+ public:
+ explicit rectangle(long wd, long ht) : _right(wd - 1), _bottom(ht - 1) {};
+
+ void set_left(long l) {
+ _left = l;
+ }
+ long left() const { return _left; };
+
+ void set_right(long r) {
+ _right = r;
+ }
+ long right() const { return _right; };
+
+ void set_top(long t) {
+ _top = t;
+ }
+ long top() const { return _top; };
+
+ void set_bottom(long b) {
+ _bottom = b;
+ }
+ long bottom() const { return _bottom; }
+
+ long width() const {
+ if (is_valid())
+ return 0;
+ else
+ return _right - _left + 1;
+ }
+
+ long height() const {
+ if (is_valid())
+ return 0;
+ else
+ return _bottom - _top + 1;
+ }
+
+ void set_aspect(double ratio);
+ void fit(unsigned long to_width, unsigned long to_height);
+ void center(unsigned long outer_w, unsigned long outer_h);
+
+ private:
+ bool is_valid() const {
+ return (_top > _bottom || _left > _right);
+ }
+
+ long _left = 0;
+ long _top = 0;
+ long _right;
+ long _bottom;
+};
+
+#endif // !WM_UTIL_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.cpp b/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.cpp
new file mode 100644
index 0000000..28bd024
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.cpp
@@ -0,0 +1,724 @@
+/*
+ * 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 "wayland_ivi_wm.hpp"
+
+/**
+ * namespace wl
+ */
+namespace wl
+{
+
+/**
+ * display
+ */
+display::display()
+ : d(std::unique_ptr<struct wl_display, void (*)(struct wl_display *)>(
+ wl_display_connect(nullptr), &wl_display_disconnect)),
+ r(d.get()) {}
+
+bool display::ok() const { return d && wl_display_get_error(d.get()) == 0; }
+
+void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
+
+int display::dispatch() { return wl_display_dispatch(this->d.get()); }
+
+int display::dispatch_pending() { return wl_display_dispatch_pending(this->d.get()); }
+
+int display::read_events()
+{
+ ;
+ while (wl_display_prepare_read(this->d.get()) == -1)
+ {
+ if (wl_display_dispatch_pending(this->d.get()) == -1)
+ {
+ return -1;
+ }
+ }
+
+ if (wl_display_flush(this->d.get()) == -1)
+ {
+ return -1;
+ }
+
+ if (wl_display_read_events(this->d.get()) == -1)
+ {
+ wl_display_cancel_read(this->d.get());
+ }
+
+ return 0;
+}
+
+void display::flush() { wl_display_flush(this->d.get()); }
+
+int display::get_fd() const { return wl_display_get_fd(this->d.get()); }
+
+int display::get_error() { return wl_display_get_error(this->d.get()); }
+
+/**
+ * registry
+ */
+namespace
+{
+void registry_global_created(void *data, struct wl_registry * /*r*/, uint32_t name,
+ char const *iface, uint32_t v)
+{
+ static_cast<struct registry *>(data)->global_created(name, iface, v);
+}
+
+void registry_global_removed(void *data, struct wl_registry * /*r*/,
+ uint32_t name)
+{
+ static_cast<struct registry *>(data)->global_removed(name);
+}
+
+constexpr struct wl_registry_listener registry_listener = {
+ registry_global_created, registry_global_removed};
+} // namespace
+
+registry::registry(struct wl_display *d)
+ : wayland_proxy(d == nullptr ? nullptr : wl_display_get_registry(d))
+{
+ if (this->proxy != nullptr)
+ {
+ wl_registry_add_listener(this->proxy.get(), &registry_listener, this);
+ }
+}
+
+void registry::add_global_handler(char const *iface, binder bind)
+{
+ this->bindings[iface] = std::move(bind);
+}
+
+void registry::global_created(uint32_t name, char const *iface, uint32_t v)
+{
+ auto b = this->bindings.find(iface);
+ if (b != this->bindings.end())
+ {
+ b->second(this->proxy.get(), name, v);
+ }
+ HMI_DEBUG("wl::registry @ %p global n %u i %s v %u", this->proxy.get(), name,
+ iface, v);
+}
+
+void registry::global_removed(uint32_t /*name*/) {}
+
+/**
+ * output
+ */
+namespace
+{
+void output_geometry(void *data, struct wl_output * /*wl_output*/, int32_t x,
+ int32_t y, int32_t physical_width, int32_t physical_height,
+ int32_t subpixel, const char *make, const char *model,
+ int32_t transform)
+{
+ static_cast<struct output *>(data)->geometry(
+ x, y, physical_width, physical_height, subpixel, make, model, transform);
+}
+
+void output_mode(void *data, struct wl_output * /*wl_output*/, uint32_t flags,
+ int32_t width, int32_t height, int32_t refresh)
+{
+ static_cast<struct output *>(data)->mode(flags, width, height, refresh);
+}
+
+void output_done(void *data, struct wl_output * /*wl_output*/)
+{
+ static_cast<struct output *>(data)->done();
+}
+
+void output_scale(void *data, struct wl_output * /*wl_output*/,
+ int32_t factor)
+{
+ static_cast<struct output *>(data)->scale(factor);
+}
+
+constexpr struct wl_output_listener output_listener = {
+ output_geometry, output_mode, output_done, output_scale};
+} // namespace
+
+output::output(struct wl_registry *r, uint32_t name, uint32_t v)
+ : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v))
+{
+ wl_output_add_listener(this->proxy.get(), &output_listener, this);
+}
+
+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",
+ __func__, this->proxy.get(), x, y, pw, ph, subpel, make, model, tx);
+ this->physical_width = pw;
+ this->physical_height = ph;
+ this->transform = tx;
+}
+
+void output::mode(uint32_t flags, int32_t w, int32_t h, int32_t r)
+{
+ 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)
+ {
+ this->width = w;
+ this->height = h;
+ this->refresh = r;
+ }
+}
+
+void output::done()
+{
+ 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 ||
+ this->transform == WL_OUTPUT_TRANSFORM_FLIPPED_90 ||
+ this->transform == WL_OUTPUT_TRANSFORM_FLIPPED_270)
+ {
+ std::swap(this->width, this->height);
+ std::swap(this->physical_width, this->physical_height);
+ }
+}
+
+void output::scale(int32_t factor)
+{
+ HMI_DEBUG("wl::output %s @ %p f %i", __func__, this->proxy.get(), factor);
+}
+} // namespace wl
+
+/**
+ * namespace compositor
+ */
+namespace compositor
+{
+
+namespace
+{
+
+void surface_visibility_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t surface_id, int32_t visibility)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_visibility_changed(surface_id, visibility);
+}
+
+void surface_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t surface_id, wl_fixed_t opacity)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_opacity_changed(surface_id, float(wl_fixed_to_double(opacity)));
+}
+
+void surface_source_rectangle_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_source_rectangle_changed(surface_id, x, y, width, height);
+}
+
+void surface_destination_rectangle_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_destination_rectangle_changed(surface_id, x, y, width, height);
+}
+
+void surface_created(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t id_surface)
+{
+ static_cast<struct controller *>(data)->surface_created(id_surface);
+}
+
+void surface_destroyed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_destroyed(surface_id);
+}
+
+void surface_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
+ uint32_t error_code, const char *error_text)
+{
+ static_cast<struct controller *>(data)->surface_error_detected(
+ object_id, error_code, error_text);
+}
+
+void surface_size_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t surface_id,
+ int32_t width, int32_t height)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_size_changed(surface_id, width, height);
+}
+
+void surface_stats_received(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t surface_id, uint32_t frame_count, uint32_t pid)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_stats_received(surface_id, frame_count, pid);
+}
+
+void surface_added_to_layer(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t layer_id, uint32_t surface_id)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->surface_added_to_layer(layer_id, surface_id);
+}
+
+void layer_visibility_changed(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t layer_id, int32_t visibility)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->layer_visibility_changed(layer_id, visibility);
+}
+
+void layer_opacity_changed(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t layer_id, wl_fixed_t opacity)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->layer_opacity_changed(layer_id, float(wl_fixed_to_double(opacity)));
+}
+
+void layer_source_rectangle_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->layer_source_rectangle_changed(layer_id, x, y, width, height);
+}
+
+void layer_destination_rectangle_changed(
+ void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id,
+ int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->layer_destination_rectangle_changed(layer_id, x, y, width, height);
+}
+
+void layer_created(void *data, struct ivi_wm * /*ivi_wm*/,
+ uint32_t id_layer)
+{
+ static_cast<struct controller *>(data)->layer_created(id_layer);
+}
+
+void layer_destroyed(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t layer_id)
+{
+ auto c = static_cast<struct controller *>(data);
+ c->layer_destroyed(layer_id);
+}
+
+void layer_error_detected(void *data, struct ivi_wm * /*ivi_wm*/, uint32_t object_id,
+ uint32_t error_code, const char *error_text)
+{
+ static_cast<struct controller *>(data)->layer_error_detected(
+ object_id, error_code, error_text);
+}
+
+constexpr struct ivi_wm_listener listener = {
+ surface_visibility_changed,
+ layer_visibility_changed,
+ surface_opacity_changed,
+ layer_opacity_changed,
+ surface_source_rectangle_changed,
+ layer_source_rectangle_changed,
+ surface_destination_rectangle_changed,
+ layer_destination_rectangle_changed,
+ surface_created,
+ layer_created,
+ surface_destroyed,
+ layer_destroyed,
+ surface_error_detected,
+ layer_error_detected,
+ surface_size_changed,
+ surface_stats_received,
+ surface_added_to_layer,
+};
+
+void screen_created(void *data, struct ivi_wm_screen *ivi_wm_screen, uint32_t id)
+{
+ static_cast<struct screen *>(data)->screen_created((struct screen *)data, id);
+}
+
+void layer_added(void *data,
+ struct ivi_wm_screen *ivi_wm_screen,
+ uint32_t 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("process_name:%s", process_name);
+}
+
+void screen_error(void *data,
+ struct ivi_wm_screen *ivi_wm_screen,
+ uint32_t error,
+ const char *message)
+{
+ HMI_DEBUG("screen error:%d message:%s", error, message);
+}
+
+constexpr struct ivi_wm_screen_listener screen_listener = {
+ screen_created,
+ layer_added,
+ connector_name,
+ screen_error,
+};
+} // namespace
+
+/**
+ * surface
+ */
+surface::surface(uint32_t i, struct controller *c)
+ : controller_child(c, i)
+{
+ this->parent->add_proxy_to_sid_mapping(this->parent->proxy.get(), i);
+}
+
+void surface::set_visibility(uint32_t visibility)
+{
+ HMI_DEBUG("compositor::surface id:%d v:%d", this->id, visibility);
+ ivi_wm_set_surface_visibility(this->parent->proxy.get(), this->id, visibility);
+}
+
+void surface::set_source_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ ivi_wm_set_surface_source_rectangle(this->parent->proxy.get(), this->id,
+ x, y, width, height);
+}
+
+void surface::set_destination_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ ivi_wm_set_surface_destination_rectangle(this->parent->proxy.get(), this->id,
+ x, y, width, height);
+}
+
+/**
+ * layer
+ */
+layer::layer(uint32_t i, struct controller *c) : layer(i, 0, 0, c) {}
+
+layer::layer(uint32_t i, int32_t w, int32_t h, struct controller *c)
+ : controller_child(c, i)
+{
+ this->parent->add_proxy_to_lid_mapping(this->parent->proxy.get(), i);
+ ivi_wm_create_layout_layer(c->proxy.get(), i, w, h);
+}
+
+void layer::set_visibility(uint32_t visibility)
+{
+ ivi_wm_set_layer_visibility(this->parent->proxy.get(), this->id, visibility);
+}
+
+void layer::set_destination_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ ivi_wm_set_layer_destination_rectangle(this->parent->proxy.get(), this->id,
+ x, y, width, height);
+}
+
+void layer::add_surface(uint32_t surface_id)
+{
+ ivi_wm_layer_add_surface(this->parent->proxy.get(), this->id, surface_id);
+}
+
+void layer::remove_surface(uint32_t surface_id)
+{
+ ivi_wm_layer_remove_surface(this->parent->proxy.get(), this->id, surface_id);
+}
+
+/**
+ * screen
+ */
+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("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);
+}
+
+void screen::clear() { ivi_wm_screen_clear(this->proxy.get()); }
+
+void screen::screen_created(struct screen *screen, uint32_t id)
+{
+ HMI_DEBUG("compositor::screen @ %p screen %u (%x) @ %p", this->proxy.get(),
+ id, id, screen);
+ this->id = id;
+ this->parent->screens[id] = screen;
+}
+
+void screen::set_render_order(std::vector<uint32_t> const &ro)
+{
+ std::size_t i;
+
+ // Remove all layers from the screen render order
+ ivi_wm_screen_clear(this->proxy.get());
+
+ for (i = 0; i < ro.size(); 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]);
+ }
+}
+
+/**
+ * controller
+ */
+controller::controller(struct wl_registry *r, uint32_t name, uint32_t version)
+ : wayland_proxy(
+ wl_registry_bind(r, name, &ivi_wm_interface, version)),
+ output_size{}
+{
+ ivi_wm_add_listener(this->proxy.get(), &listener, this);
+}
+
+void controller::layer_create(uint32_t id, int32_t w, int32_t h)
+{
+ this->layers[id] = std::make_unique<struct layer>(id, w, h, this);
+}
+
+void controller::surface_create(uint32_t id)
+{
+ this->surfaces[id] = std::make_unique<struct surface>(id, this);
+
+ // TODO: If Clipping is necessary, this process should be modified.
+ {
+ // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
+ // for resizing wayland surface when switching from split to full surface.
+ ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
+
+ // Set source reactangle even if we should not need to set it
+ // for enable setting for destination region.
+ this->surfaces[id]->set_source_rectangle(0, 0, this->output_size.w, this->output_size.h);
+
+ // Flush display
+ this->display->flush();
+ }
+}
+
+void controller::create_screen(struct wl_output *output)
+{
+ // TODO: screen id is 0 (WM manages one screen for now)
+ this->screen = std::make_unique<struct screen>(0, this, output);
+}
+
+void controller::get_surface_properties(uint32_t surface_id, int param)
+{
+ ivi_wm_surface_get(this->proxy.get(), surface_id, param);
+}
+
+void controller::layer_created(uint32_t id)
+{
+ HMI_DEBUG("compositor::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
+ if (this->layers.find(id) != this->layers.end())
+ {
+ HMI_DEBUG("WindowManager has created layer %u (%x) already", id, id);
+ }
+ else
+ {
+ this->layers[id] = std::make_unique<struct layer>(id, this);
+ }
+}
+
+void controller::layer_error_detected(uint32_t object_id,
+ uint32_t error_code, const char *error_text)
+{
+ 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("compositor::surface %s @ %d v %i", __func__, id,
+ visibility);
+ this->sprops[id].visibility = visibility;
+ this->chooks->surface_visibility(id, visibility);
+}
+
+void controller::surface_opacity_changed(uint32_t id, float opacity)
+{
+ HMI_DEBUG("compositor::surface %s @ %d o %f",
+ __func__, id, opacity);
+ this->sprops[id].opacity = opacity;
+}
+
+void controller::surface_source_rectangle_changed(uint32_t id, int32_t x,
+ int32_t y, int32_t width,
+ int32_t height)
+{
+ 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};
+}
+
+void controller::surface_destination_rectangle_changed(uint32_t id, int32_t x,
+ int32_t y, int32_t width,
+ int32_t height)
+{
+ 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);
+}
+
+void controller::surface_size_changed(uint32_t id, int32_t width,
+ int32_t height)
+{
+ 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);
+}
+
+void controller::surface_added_to_layer(uint32_t layer_id, uint32_t surface_id)
+{
+ 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("compositor::surface %s @ %d f %u pid %u",
+ __func__, surface_id, frame_count, pid);
+ this->sprops[surface_id].pid = pid;
+}
+
+void controller::surface_created(uint32_t id)
+{
+ HMI_DEBUG("compositor::controller @ %p surface %u (%x)", this->proxy.get(), id,
+ id);
+ if (this->surfaces.find(id) == this->surfaces.end())
+ {
+ this->surfaces[id] = std::make_unique<struct surface>(id, this);
+ this->chooks->surface_created(id);
+
+ // Set surface type:IVI_WM_SURFACE_TYPE_DESKTOP)
+ // for resizing wayland surface when switching from split to full surface.
+ ivi_wm_set_surface_type(this->proxy.get(), id, IVI_WM_SURFACE_TYPE_DESKTOP);
+
+ // Flush display
+ this->display->flush();
+ }
+}
+
+void controller::surface_destroyed(uint32_t 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);
+}
+
+void controller::surface_error_detected(uint32_t object_id,
+ uint32_t error_code, const char *error_text)
+{
+ 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("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("compositor::layer %s @ %d o %f", __func__, layer_id, opacity);
+ this->lprops[layer_id].opacity = opacity;
+}
+
+void controller::layer_source_rectangle_changed(uint32_t layer_id,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ 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};
+}
+
+void controller::layer_destination_rectangle_changed(uint32_t layer_id,
+ int32_t x, int32_t y,
+ int32_t width, int32_t height)
+{
+ 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("compositor::layer %s @ %d", __func__, layer_id);
+ this->lprops.erase(layer_id);
+ this->layers.erase(layer_id);
+}
+
+void controller::add_proxy_to_sid_mapping(struct ivi_wm *p,
+ uint32_t 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("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("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("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("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("Remove screen proxy mapping for %p", p);
+ this->screen_proxy_to_id.erase(uintptr_t(p));
+}
+
+} // namespace compositor
diff --git a/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.hpp b/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.hpp
new file mode 100644
index 0000000..d8915a1
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wayland_ivi_wm.hpp
@@ -0,0 +1,327 @@
+/*
+ * 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 WM_WAYLAND_HPP
+#define WM_WAYLAND_HPP
+
+#include "controller_hooks.hpp"
+#include "ivi-wm-client-protocol.h"
+#include "util.hpp"
+
+#include <functional>
+#include <memory>
+#include <unordered_map>
+#include <vector>
+
+/**
+ * @struct wayland_proxy
+ */
+template <typename ProxyT>
+struct wayland_proxy
+{
+ std::unique_ptr<ProxyT, std::function<void(ProxyT *)>> proxy;
+ wayland_proxy(wayland_proxy const &) = delete;
+ wayland_proxy &operator=(wayland_proxy const &) = delete;
+ wayland_proxy(void *p)
+ : wayland_proxy(p,
+ reinterpret_cast<void (*)(ProxyT *)>(wl_proxy_destroy)) {}
+ wayland_proxy(void *p, std::function<void(ProxyT *)> &&p_del)
+ : proxy(std::unique_ptr<ProxyT, std::function<void(ProxyT *)>>(
+ static_cast<ProxyT *>(p), p_del)) {}
+};
+
+/**
+ * namespace wl
+ */
+namespace wl
+{
+
+/**
+ * @struct registry
+ */
+struct registry : public wayland_proxy<struct wl_registry>
+{
+ typedef std::function<void(struct wl_registry *, uint32_t, uint32_t)> binder;
+ std::unordered_map<std::string, binder> bindings;
+
+ registry(registry const &) = delete;
+ registry &operator=(registry const &) = delete;
+ registry(struct wl_display *d);
+
+ void add_global_handler(char const *iface, binder bind);
+
+ // Events
+ void global_created(uint32_t name, char const *iface, uint32_t v);
+ void global_removed(uint32_t name);
+};
+
+/**
+ * @struct display
+ */
+struct display
+{
+ std::unique_ptr<struct wl_display, void (*)(struct wl_display *)> d;
+ struct registry r;
+
+ display(display const &) = delete;
+ display &operator=(display const &) = delete;
+ display();
+ bool ok() const;
+ void roundtrip();
+ int dispatch();
+ int dispatch_pending();
+ int read_events();
+ void flush();
+ int get_fd() const;
+ int get_error();
+
+ // Lets just proxy this for the registry
+ inline void add_global_handler(char const *iface, registry::binder bind)
+ {
+ this->r.add_global_handler(iface, bind);
+ }
+};
+
+/**
+ * @struct output
+ */
+struct output : public wayland_proxy<struct wl_output>
+{
+ int width{};
+ int height{};
+ int physical_width{};
+ int physical_height{};
+ int refresh{};
+ int transform{};
+
+ output(output const &) = delete;
+ output &operator=(output const &) = delete;
+ output(struct wl_registry *r, uint32_t name, uint32_t v);
+
+ // Events
+ void 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);
+ void mode(uint32_t flags, int32_t w, int32_t h, int32_t r);
+ void done();
+ void scale(int32_t factor);
+};
+} // namespace wl
+
+/**
+ * namespace compositor
+ */
+namespace compositor
+{
+
+struct size
+{
+ uint32_t w, h;
+};
+
+struct rect
+{
+ int32_t w, h;
+ int32_t x, y;
+};
+
+static const constexpr rect full_rect = rect{-1, -1, 0, 0};
+
+inline bool operator==(struct rect a, struct rect b)
+{
+ return a.w == b.w && a.h == b.h && a.x == b.x && a.y == b.y;
+}
+
+struct controller;
+
+struct controller_child
+{
+ struct controller *parent;
+ uint32_t id;
+
+ controller_child(controller_child const &) = delete;
+ controller_child &operator=(controller_child const &) = delete;
+ controller_child(struct controller *c, uint32_t i) : parent(c), id(i) {}
+ virtual ~controller_child() {}
+};
+
+struct surface_properties
+{
+ uint32_t id; // let's just save an ID here too
+ struct rect dst_rect;
+ struct rect src_rect;
+ struct size size;
+ int32_t orientation;
+ int32_t visibility;
+ float opacity;
+ uint32_t pid;
+};
+
+/**
+ * @struct surface
+ */
+struct surface : public controller_child
+{
+ surface(surface const &) = delete;
+ surface &operator=(surface const &) = delete;
+ surface(uint32_t i, struct controller *c);
+
+ // Requests
+ void set_visibility(uint32_t visibility);
+ void set_source_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void set_destination_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height);
+};
+
+/**
+ * @struct layer
+ */
+struct layer : public controller_child
+{
+ layer(layer const &) = delete;
+ layer &operator=(layer const &) = delete;
+ layer(uint32_t i, struct controller *c);
+ layer(uint32_t i, int32_t w, int32_t h, struct controller *c);
+
+ // Requests
+ void set_visibility(uint32_t visibility);
+ void set_destination_rectangle(int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void add_surface(uint32_t surface_id);
+ void remove_surface(uint32_t surface_id);
+};
+
+/**
+ * @struct screen
+ */
+struct screen : public wayland_proxy<struct ivi_wm_screen>,
+ public controller_child
+{
+ screen(screen const &) = delete;
+ screen &operator=(screen const &) = delete;
+ screen(uint32_t i, struct controller *c, struct wl_output *o);
+
+ void clear();
+ void screen_created(struct screen *screen, uint32_t id);
+ void set_render_order(std::vector<uint32_t> const &ro);
+};
+
+/**
+ * @struct controller
+ */
+struct controller : public wayland_proxy<struct ivi_wm>
+{
+ // This controller is still missing ivi-input
+
+ typedef std::unordered_map<uintptr_t, uint32_t> proxy_to_id_map_type;
+ typedef std::unordered_map<uint32_t, std::unique_ptr<struct surface>>
+ surface_map_type;
+ typedef std::unordered_map<uint32_t, std::unique_ptr<struct layer>>
+ layer_map_type;
+ typedef std::unordered_map<uint32_t, struct screen *> screen_map_type;
+ typedef std::unordered_map<uint32_t, struct surface_properties> props_map;
+
+ // HACK:
+ // The order of these member is mandatory, as when objects are destroyed
+ // they will call their parent (that's us right here!) and remove their
+ // proxy-to-id mapping. I.e. the *_proxy_to_id members need to be valid
+ // when the surfaces/layers/screens maps are destroyed. This sucks, but
+ // I cannot see a better solution w/o globals or some other horrible
+ // call-our-parent construct.
+ proxy_to_id_map_type surface_proxy_to_id;
+ proxy_to_id_map_type layer_proxy_to_id;
+ proxy_to_id_map_type screen_proxy_to_id;
+
+ props_map sprops;
+ props_map lprops;
+
+ surface_map_type surfaces;
+ layer_map_type layers;
+ screen_map_type screens;
+
+ std::unique_ptr<struct screen> screen;
+
+ size output_size; // Display size[pixel]
+ size physical_size; // Display size[mm]
+
+ // Scale for conversion CSS PX -> DP(Device Pixel)
+ double scale;
+
+ wm::controller_hooks *chooks;
+
+ struct wl::display *display;
+
+ void add_proxy_to_sid_mapping(struct ivi_wm *p, uint32_t id);
+ void remove_proxy_to_sid_mapping(struct ivi_wm *p);
+
+ void add_proxy_to_lid_mapping(struct ivi_wm *p, uint32_t id);
+ void remove_proxy_to_lid_mapping(struct ivi_wm *p);
+
+ void add_proxy_to_id_mapping(struct wl_output *p, uint32_t id);
+ void remove_proxy_to_id_mapping(struct wl_output *p);
+
+ bool surface_exists(uint32_t id) const
+ {
+ return this->surfaces.find(id) != this->surfaces.end();
+ }
+
+ bool layer_exists(uint32_t id) const
+ {
+ return this->layers.find(id) != this->layers.end();
+ }
+
+ controller(struct wl_registry *r, uint32_t name, uint32_t version);
+
+ // Requests
+ void commit_changes() const
+ {
+ ivi_wm_commit_changes(this->proxy.get());
+ }
+ void layer_create(uint32_t id, int32_t w, int32_t h);
+ void surface_create(uint32_t id);
+ void create_screen(struct wl_output *output);
+ void get_surface_properties(uint32_t surface_id, int param = 0);
+
+ // Events
+ void surface_visibility_changed(uint32_t id, int32_t visibility);
+ void surface_opacity_changed(uint32_t id, float opacity);
+ void surface_source_rectangle_changed(uint32_t id, int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void surface_destination_rectangle_changed(uint32_t id, int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void surface_created(uint32_t id);
+ void surface_destroyed(uint32_t surface_id);
+ void surface_error_detected(uint32_t object_id,
+ uint32_t error_code, char const *error_text);
+ void surface_size_changed(uint32_t id, int32_t width, int32_t height);
+ void surface_stats_received(uint32_t surface_id,
+ uint32_t frame_count, uint32_t pid);
+ void surface_added_to_layer(uint32_t layer_id, uint32_t surface_id);
+
+ void layer_visibility_changed(uint32_t layer_id, int32_t visibility);
+ void layer_opacity_changed(uint32_t layer_id, float opacity);
+ void layer_source_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void layer_destination_rectangle_changed(uint32_t layer_id, int32_t x, int32_t y,
+ int32_t width, int32_t height);
+ void layer_created(uint32_t id);
+ void layer_destroyed(uint32_t layer_id);
+ void layer_error_detected(uint32_t object_id,
+ uint32_t error_code, char const *error_text);
+};
+} // namespace compositor
+
+#endif // !WM_WAYLAND_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/window_manager.cpp b/demo3/common/agl-service-windowmanager/src/window_manager.cpp
new file mode 100644
index 0000000..f209f12
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/window_manager.cpp
@@ -0,0 +1,2326 @@
+/*
+ * 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 <fstream>
+#include <regex>
+#include <sstream>
+
+#include "window_manager.hpp"
+#include "json_helper.hpp"
+#include "applist.hpp"
+
+extern "C"
+{
+#include <systemd/sd-event.h>
+}
+
+using std::string;
+using std::vector;
+
+namespace wm
+{
+
+static const uint64_t kTimeOut = 3ULL; /* 3s */
+
+/* DrawingArea name used by "{layout}.{area}" */
+const char kNameLayoutNormal[] = "normal";
+const char kNameLayoutSplit[] = "split";
+const char kNameAreaFull[] = "full";
+const char kNameAreaMain[] = "main";
+const char kNameAreaSub[] = "sub";
+
+/* Key for json obejct */
+const char kKeyDrawingName[] = "drawing_name";
+const char kKeyDrawingArea[] = "drawing_area";
+const char kKeyDrawingRect[] = "drawing_rect";
+const char kKeyX[] = "x";
+const char kKeyY[] = "y";
+const char kKeyWidth[] = "width";
+const char kKeyHeight[] = "height";
+const char kKeyWidthPixel[] = "width_pixel";
+const char kKeyHeightPixel[] = "height_pixel";
+const char kKeyWidthMm[] = "width_mm";
+const char kKeyHeightMm[] = "height_mm";
+const char kKeyScale[] = "scale";
+const char kKeyIds[] = "ids";
+
+static const char kPathOldRolesConfigFile[] = "/etc/old_roles.json";
+
+static sd_event_source *g_timer_ev_src = nullptr;
+static AppList g_app_list;
+static WindowManager *g_context;
+
+struct AfbClosure {
+public:
+ AfbClosure(unsigned pid, unsigned ppid, unsigned surface)
+ : pid(pid), ppid(ppid), surface(surface) {}
+ ~AfbClosure() = default;
+ unsigned pid;
+ unsigned ppid;
+ unsigned surface;
+};
+
+namespace
+{
+
+static int processTimerHandler(sd_event_source *s, uint64_t usec, void *userdata)
+{
+ HMI_NOTICE("Time out occurs because the client replys endDraw slow, so revert the request");
+ reinterpret_cast<wm::WindowManager *>(userdata)->timerHandler();
+ return 0;
+}
+
+static void onStateTransitioned(vector<WMAction> actions)
+{
+ g_context->startTransitionWrapper(actions);
+}
+
+static void onError()
+{
+ g_context->processError(WMError::LAYOUT_CHANGE_FAIL);
+}
+
+static void onReceiveRemoteRequest(json_object *data)
+{
+ g_context->processForRemoteRequest(data);
+}
+} // namespace
+
+/**
+ * WindowManager Impl
+ */
+WindowManager::WindowManager()
+ : wmcon{},
+ id_alloc{}
+{
+ const char *path = getenv("AFM_APP_INSTALL_DIR");
+ if (!path)
+ {
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
+ }
+ string root = path;
+
+ // TODO: ECU name should be decide by config file
+ // Get mode and decide ECU name
+ string ecu_name = this->wmcon.getEcuName();
+
+ this->lc = std::make_shared<LayerControl>(root, ecu_name);
+
+ HMI_DEBUG("Layer Controller initialized");
+}
+
+int WindowManager::init()
+{
+ LayerControlCallbacks lmcb;
+ lmcb.surfaceCreated = [&](unsigned pid, unsigned surface){
+ this->surface_created(pid, surface);
+ };
+ lmcb.surfaceDestroyed = [&](unsigned surface){
+ this->surface_removed(surface);
+ };
+ this->lc->init(lmcb);
+
+ // TODO: application requests by old role,
+ // so create role map (old, new)
+ // Load old_roles config file
+ this->loadOldRolesConfigFile();
+
+ // Initialize LowCanClient
+ this->lcc.initialize();
+
+ // Store my context for calling callback from PolicyManager
+ g_context = this;
+
+ // Initialize PMWrapper
+ this->pmw.initialize(this->wmcon.getEcuName());
+
+ // Register callback to PolicyManager
+ this->pmw.registerCallback(onStateTransitioned, onError);
+
+ // Initialize WMConnection
+ this->wmcon.initialize();
+
+ // Register callback to WMConnection
+ this->wmcon.registerCallback(onReceiveRemoteRequest);
+
+ // Make afb event
+ for (int i = Event_Val_Min; i <= Event_Val_Max; i++)
+ {
+ map_afb_event[kListEventName[i]] = afb_daemon_make_event(kListEventName[i]);
+ }
+
+ const struct rect css_bg = this->lc->getAreaSize("fullscreen");
+ Screen screen = this->lc->getScreenInfo();
+ rectangle dp_bg(screen.width(), screen.height());
+
+ dp_bg.set_aspect(static_cast<double>(css_bg.w) / css_bg.h);
+ dp_bg.fit(screen.width(), screen.height());
+ dp_bg.center(screen.width(), screen.height());
+ 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());
+
+ double scale = static_cast<double>(dp_bg.height()) / css_bg.h;
+ this->lc->setupArea(dp_bg, scale);
+
+ return 0; //init_layers();
+}
+
+result<int> WindowManager::api_request_surface(char const *appid, char const *drawing_name)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *role = this->convertRoleOldToNew(drawing_name);
+ string l_name;
+ string s_appid = appid;
+ string s_role = role;
+
+ if(!g_app_list.contains(s_appid))
+ {
+ // auto lid = this->layers.get_layer_id(string(role));
+ unsigned l_id = this->lc->getNewLayerID(s_role, &l_name);
+ if (l_id == 0)
+ {
+ /**
+ * register drawing_name as fallback and make it displayed.
+ */
+ l_id = this->lc->getNewLayerID("fallback", &l_name);
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
+ if (l_id == 0)
+ {
+ return Err<int>("Designated role does not match any role, fallback is disabled");
+ }
+ }
+
+ // TODO: remote layer size is fixed value
+ if ("Remote" == l_name)
+ {
+ this->lc->createNewRemoteLayer(l_id);
+ }
+ else
+ {
+ this->lc->createNewLayer(l_id);
+ }
+
+ // add client into the db
+ g_app_list.addClient(s_appid, l_id, s_role);
+ }
+
+ // generate surface ID for ivi-shell application
+
+ auto rname = this->id_alloc.lookup(string(role));
+ if (!rname)
+ {
+ // name does not exist yet, allocate surface id...
+ auto id = int(this->id_alloc.generate_id(role));
+ this->tmp_surface2app[id] = {s_appid, 0};
+
+ // Work Around
+ HMI_NOTICE("WORK AROUND: add surface on request surface");
+ auto client = g_app_list.lookUpClient(s_appid);
+ client->addSurface(id);
+ ///////////////
+
+ // Set role map of (new, old)
+ this->rolenew2old[role] = string(drawing_name);
+
+ return Ok<int>(id);
+ }
+
+ // Check currently registered drawing names if it is already there.
+ return Err<int>("Surface already present");
+}
+
+char const *WindowManager::api_request_surface(char const *appid, char const *drawing_name,
+ char const *ivi_id)
+{
+ unsigned sid = std::stol(ivi_id);
+
+ HMI_DEBUG("This API(requestSurfaceXDG) is for XDG Application using runXDG");
+ /*
+ * IVI-shell doesn't send surface_size event via ivi-wm protocol
+ * if the application is using XDG surface.
+ * So WM has to set surface size with original size here
+ */
+ WMError ret = this->lc->setXDGSurfaceOriginSize(sid);
+ if(ret != SUCCESS)
+ {
+ HMI_ERROR("%s", errorDescription(ret));
+ HMI_WARNING("The main user of this API is runXDG");
+ return "fail";
+ }
+
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *role = this->convertRoleOldToNew(drawing_name);
+ string s_role = role;
+ string s_appid = appid;
+ string l_name;
+
+ if(!g_app_list.contains(s_appid))
+ {
+ // auto lid = this->layers.get_layer_id(string(role));
+ unsigned l_id = this->lc->getNewLayerID(s_role, &l_name);
+ if (l_id == 0)
+ {
+ /**
+ * register drawing_name as fallback and make it displayed.
+ */
+ l_id = this->lc->getNewLayerID("fallback", &l_name);
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
+ if (l_id == 0)
+ {
+ return "Designated role does not match any role, fallback is disabled";
+ }
+ }
+
+ // TODO: remote layer size is fixed value
+ if ("Remote" == l_name)
+ {
+ this->lc->createNewRemoteLayer(l_id);
+ }
+ else
+ {
+ this->lc->createNewLayer(l_id);
+ }
+
+ // add client into the db
+ g_app_list.addClient(s_appid, l_id, s_role);
+ }
+
+ auto rname = this->id_alloc.lookup(s_role);
+ if (rname)
+ {
+ return "Surface already present";
+ }
+
+ // register pair drawing_name and ivi_id
+ this->id_alloc.register_name_id(role, sid);
+
+ auto client = g_app_list.lookUpClient(s_appid);
+ client->addSurface(sid);
+
+ // Set role map of (new, old)
+ this->rolenew2old[role] = string(drawing_name);
+
+ return nullptr;
+}
+
+bool WindowManager::api_set_role(char const *appid, char const *drawing_name)
+{
+ bool ret = false;
+
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *role = this->convertRoleOldToNew(drawing_name);
+ string s_role = role;
+ string s_appid = appid;
+ string l_name;
+
+ // Create WMClient
+ if(!g_app_list.contains(s_appid))
+ {
+ // auto lid = this->layers.get_layer_id(string(role));
+ unsigned l_id = this->lc->getNewLayerID(s_role, &l_name);
+ if (l_id == 0)
+ {
+ /**
+ * register drawing_name as fallback and make it displayed.
+ */
+ l_id = this->lc->getNewLayerID("fallback", &l_name);
+ HMI_DEBUG("%s is not registered in layers.json, then fallback as normal app", role);
+ if (l_id == 0)
+ {
+ HMI_ERROR("Designated role does not match any role, fallback is disabled");
+ return ret;
+ }
+ }
+
+ // TODO: remote layer size is fixed value
+ if ("Remote" == l_name)
+ {
+ this->lc->createNewRemoteLayer(l_id);
+ }
+ else
+ {
+ this->lc->createNewLayer(l_id);
+ }
+
+ // add client into the db
+ g_app_list.addClient(s_appid, l_id, s_role);
+ // Set role map of (new, old)
+ this->rolenew2old[role] = string(drawing_name);
+ }
+
+ // for(auto itr = this->tmp_surface2app.begin();
+ // itr != this->tmp_surface2app.end() ; ++itr)
+ // {
+ for(auto& x : this->tmp_surface2app)
+ {
+ if(x.second.appid == s_appid)
+ {
+ unsigned surface = x.first;
+ auto client = g_app_list.lookUpClient(s_appid);
+ client->addSurface(surface);
+ this->tmp_surface2app.erase(surface);
+ this->id_alloc.register_name_id(s_role, surface);
+ break;
+ }
+ }
+
+/* if(0 != pid){
+ // search floating surfaceID from pid if pid is designated.
+ wm_err = g_app_list.popFloatingSurface(pid, &surface);
+ }
+ else{
+ // get floating surface with appid. If WM queries appid from pid,
+ // WM can bind surface and role with appid(not implemented yet)
+ //wm_err = g_app_list.popFloatingSurface(id);
+ }
+ if(wm_err != WMError::SUCCESS){
+ HMI_ERROR("No floating surface for app: %s", id.c_str());
+ g_app_list.addFloatingClient(id, lid, role);
+ HMI_NOTICE("%s : Waiting for surface creation", id.c_str());
+ return ret;
+ }
+
+ ret = true;
+ if (g_app_list.contains(id))
+ {
+ HMI_INFO("Add role: %s with surface: %d. Client %s has multi surfaces.",
+ role.c_str(), surface, id.c_str());
+ auto client = g_app_list.lookUpClient(id);
+ client->appendRole(role);
+ }
+ else{
+ HMI_INFO("Create new client: %s, surface: %d into layer: %d with role: %s",
+ id.c_str(), surface, lid, role.c_str());
+ g_app_list.addClient(id, lid, role);
+ } */
+
+ // register pair drawing_name and ivi_id
+
+ return true;
+}
+
+void WindowManager::api_activate_surface(char const *appid, char const *drawing_name,
+ char const *drawing_area, const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ string id = appid;
+ string role = c_role;
+ string area = drawing_area;
+
+ if(!g_app_list.contains(id))
+ {
+ reply("app doesn't request 'requestSurface' or 'setRole' yet");
+ return;
+ }
+ auto client = g_app_list.lookUpClient(id);
+
+ // unsigned srfc = client->surfaceID(role);
+ // unsigned layer = client->layerID();
+
+ // g_app_list.removeFloatingSurface(client->surfaceID());
+ // g_app_list.removeFloatingSurface(client);
+
+ Task task = Task::TASK_ALLOCATE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(id, role, area, task, &req_num);
+
+ //vector<WMLayerState> current_states = this->lc->getCurrentStates();
+ // ret = this->setRequest(id, role, area, task, current_states, &req_num);
+
+ if(ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ ret = this->checkPolicy(req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+}
+
+void WindowManager::api_activate_surface_for_slave(
+ char const *appid, char const *drawing_name,
+ char const *drawing_area, const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ string id = appid;
+ string role = c_role;
+ string area = drawing_area;
+
+ if(!g_app_list.contains(id))
+ {
+ // Request surface of app in slave to register app information
+ this->api_request_surface(appid, drawing_name);
+
+ // Set role of app in slave to register app information
+ this->api_set_role(appid, drawing_name);
+ }
+ auto client = g_app_list.lookUpClient(id);
+
+ // unsigned srfc = client->surfaceID(role);
+ // unsigned layer = client->layerID();
+
+ // g_app_list.removeFloatingSurface(client->surfaceID());
+ // g_app_list.removeFloatingSurface(client);
+
+ Task task = Task::TASK_ALLOCATE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequestForSlave(id, role, area, task, &req_num);
+
+ //vector<WMLayerState> current_states = this->lc->getCurrentStates();
+ // ret = this->setRequest(id, role, area, task, current_states, &req_num);
+
+ if(ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ ret = this->checkPolicyForSlave(req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+}
+
+void WindowManager::api_activate_surface_to_master(
+ char const *appid, char const *drawing_name,
+ char const *drawing_area, const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ string id = appid;
+ string role = c_role;
+ string area = drawing_area;
+
+ if(!g_app_list.contains(id))
+ {
+ reply("app doesn't request 'requestSurface' or 'setRole' yet");
+ return;
+ }
+ auto client = g_app_list.lookUpClient(id);
+
+ // unsigned srfc = client->surfaceID(role);
+ // unsigned layer = client->layerID();
+
+ // g_app_list.removeFloatingSurface(client->surfaceID());
+ // g_app_list.removeFloatingSurface(client);
+
+ Task task = Task::TASK_ALLOCATE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(id, role, area, task, &req_num);
+
+ //vector<WMLayerState> current_states = this->lc->getCurrentStates();
+ // ret = this->setRequest(id, role, area, task, current_states, &req_num);
+
+ if(ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ int i_ret = this->wmcon.sendRequest("activateWindow", appid,
+ drawing_name, drawing_area);
+ if (0 > i_ret)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+
+ this->setTimer();
+}
+
+void WindowManager::api_deactivate_surface(char const *appid, char const *drawing_name,
+ const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ /*
+ * Check Phase
+ */
+ string id = appid;
+ string role = c_role;
+ string area = ""; //drawing_area;
+ Task task = Task::TASK_RELEASE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(id, role, area, task, &req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ ret = this->checkPolicy(req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+}
+
+void WindowManager::api_deactivate_surface_for_slave(char const *appid, char const *drawing_name,
+ const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ /*
+ * Check Phase
+ */
+ string id = appid;
+ string role = c_role;
+ string area = "";//drawing_area;
+ Task task = Task::TASK_RELEASE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(id, role, area, task, &req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ ret = this->checkPolicyForSlave(req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+}
+
+void WindowManager::api_deactivate_surface_to_master(char const *appid, char const *drawing_name,
+ const reply_func &reply)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ /*
+ * Check Phase
+ */
+ string id = appid;
+ string role = c_role;
+ string area = "";//drawing_area;
+ Task task = Task::TASK_RELEASE;
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(id, role, area, task, &req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ reply("Failed to set request");
+ return;
+ }
+
+ reply(nullptr);
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ int i_ret = this->wmcon.sendRequest("deactivateWindow", appid,
+ drawing_name, "");
+ if (0 > i_ret)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+
+ this->setTimer();
+}
+
+void WindowManager::api_enddraw(char const *appid, char const *drawing_name)
+{
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ string id = appid;
+ string role = c_role;
+ unsigned current_req = g_app_list.currentRequestNumber();
+ bool result = g_app_list.setEndDrawFinished(current_req, id, role);
+
+ if (!result)
+ {
+ HMI_ERROR("%s is not in transition state", id.c_str());
+ return;
+ }
+
+ if (g_app_list.endDrawFullfilled(current_req))
+ {
+ // do task for endDraw
+ this->stopTimer();
+ WMError ret = this->doEndDraw(current_req);
+
+ if(ret != WMError::SUCCESS)
+ {
+ //this->emit_error();
+
+ // Undo state of PolicyManager
+ this->pmw.undoState();
+ this->lc->undoUpdate();
+ }
+ this->emitScreenUpdated(current_req);
+ HMI_SEQ_INFO(current_req, "Finish request status: %s", errorDescription(ret));
+
+ g_app_list.removeRequest(current_req);
+
+ this->processNextRequest();
+ }
+ else
+ {
+ HMI_SEQ_INFO(current_req, "Wait other App call endDraw");
+ return;
+ }
+}
+
+void WindowManager::api_enddraw_for_remote(char const *appid, char const *drawing_name)
+{
+ int ret = this->wmcon.sendRequest("endDraw", appid, drawing_name, "");
+ if (0 > ret)
+ {
+ //this->emit_error()
+
+ this->pmw.undoState();
+ this->lc->undoUpdate();
+
+ unsigned current_req = g_app_list.currentRequestNumber();
+ g_app_list.removeRequest(current_req);
+ this->processNextRequest();
+
+ return;
+ }
+
+ this->api_enddraw(appid, drawing_name);
+}
+
+bool WindowManager::api_client_set_render_order(char const* appid, const vector<string>& render_order)
+{
+ bool ret = false;
+ string id = appid;
+ auto client = g_app_list.lookUpClient(id);
+ if(client)
+ {
+ client->setRenderOrder(render_order);
+ }
+ return ret;
+}
+
+string WindowManager::api_client_attach_service_surface
+ (const char* appid, const char* dest, const char* service_surface)
+{
+ string uuid, s_dest = dest;
+ auto client = g_app_list.lookUpClient(s_dest);
+ if(!client)
+ {
+ HMI_ERROR("Failed to look up destination [%s]", dest);
+ return uuid;
+ }
+ uuid = client->attachTmpServiceSurface(appid, service_surface);
+ this->tmp_services.emplace_back(TmpService{appid, dest, service_surface, uuid});
+ return uuid;
+}
+
+result<json_object *> WindowManager::api_get_display_info()
+{
+ Screen screen = this->lc->getScreenInfo();
+
+ json_object *object = json_object_new_object();
+ json_object_object_add(object, kKeyWidthPixel, json_object_new_int(screen.width()));
+ json_object_object_add(object, kKeyHeightPixel, json_object_new_int(screen.height()));
+ // TODO: set size
+ json_object_object_add(object, kKeyWidthMm, json_object_new_int(0));
+ json_object_object_add(object, kKeyHeightMm, json_object_new_int(0));
+ json_object_object_add(object, kKeyScale, json_object_new_double(this->lc->scale()));
+
+ return Ok<json_object *>(object);
+}
+
+result<json_object *> WindowManager::api_get_area_info(char const *drawing_name)
+{
+ HMI_DEBUG("called");
+
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *role = this->convertRoleOldToNew(drawing_name);
+
+ // Check drawing name, surface/layer id
+ auto const &surface_id = this->id_alloc.lookup(string(role));
+ if (!surface_id)
+ {
+ return Err<json_object *>("Surface does not exist");
+ }
+
+ // Set area rectangle
+ rect area_info = this->area_info[*surface_id];
+ json_object *object = json_object_new_object();
+ json_object_object_add(object, kKeyX, json_object_new_int(area_info.x));
+ json_object_object_add(object, kKeyY, json_object_new_int(area_info.y));
+ json_object_object_add(object, kKeyWidth, json_object_new_int(area_info.w));
+ json_object_object_add(object, kKeyHeight, json_object_new_int(area_info.h));
+
+ return Ok<json_object *>(object);
+}
+
+result<json_object *> WindowManager::api_get_car_info(char const *label)
+{
+ json_object *j_in = nullptr;
+ json_object *j_out = nullptr;
+
+ if (0 == strcmp("parking_brake_status", label))
+ {
+ // Get parking brake status
+ json_bool val = (this->crr_car_info.parking_brake_stt) ? TRUE : FALSE;
+ j_in = json_object_new_boolean(val);
+ }
+ else if (0 == strcmp("accelerator.pedal.position", label))
+ {
+ // Get accelerator pedal position
+ double val = this->crr_car_info.accel_pedal_pos;
+ j_in = json_object_new_double(val);
+ }
+ else if (0 == strcmp("car_state", label))
+ {
+ // Get running state
+ const char* val = (this->crr_car_info.running_stt) ? "run" : "stop";
+ j_in = json_object_new_string(val);
+ }
+ else if (0 == strcmp("lightstatus.brake", label)) {
+ // Get lightstatus brake status
+ json_bool val = (this->crr_car_info.lightstatus_brake_stt) ? TRUE : FALSE;
+ j_in = json_object_new_boolean(val);
+ }
+ else
+ {
+ return Err<json_object *>("Car info does not exist");
+ }
+
+ // Create output object
+ j_out = json_object_new_object();
+ json_object_object_add(j_out, "value", j_in);
+
+ return Ok<json_object *>(j_out);
+}
+
+void WindowManager::send_event(char const *evname)
+{
+ HMI_DEBUG("%s: %s", __func__, evname);
+
+ int ret = afb_event_push(this->map_afb_event[evname], nullptr);
+ if (ret != 0)
+ {
+ HMI_DEBUG("afb_event_push: %m");
+ }
+}
+
+void WindowManager::send_event(char const *evname, char const *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));
+
+ int ret = afb_event_push(this->map_afb_event[evname], j);
+ if (ret != 0)
+ {
+ 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("%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();
+ json_object_object_add(j_rect, kKeyX, json_object_new_int(x));
+ json_object_object_add(j_rect, kKeyY, json_object_new_int(y));
+ json_object_object_add(j_rect, kKeyWidth, json_object_new_int(w));
+ json_object_object_add(j_rect, kKeyHeight, json_object_new_int(h));
+
+ json_object *j = json_object_new_object();
+ json_object_object_add(j, kKeyDrawingName, json_object_new_string(label));
+ json_object_object_add(j, kKeyDrawingArea, json_object_new_string(area));
+ json_object_object_add(j, kKeyDrawingRect, j_rect);
+
+ int ret = afb_event_push(this->map_afb_event[evname], j);
+ if (ret != 0)
+ {
+ HMI_DEBUG("afb_event_push failed: %m");
+ }
+}
+
+string WindowManager::searchApp(unsigned pid, unsigned ppid, unsigned surface, json_object* resp)
+{
+ // retrieve appid from pid from application manager
+ string appid;
+ // check appid then add it to the client
+ HMI_INFO("Runners:%s", json_object_get_string(resp));
+ int size = json_object_array_length(resp);
+ HMI_INFO("pid %d, ppid %d, surface %d",pid, ppid, surface);
+ for(int i = 0; i < size; i++)
+ {
+ json_object *j = json_object_array_get_idx(resp, i);
+ int runid = jh::getIntFromJson(j, "runid");
+ const char* id = jh::getStringFromJson(j, "id");
+ HMI_DEBUG("Appid %s, runid %d", id, runid);
+ if(id && (runid == ppid))
+ {
+ string s_id = id;
+ s_id.erase(s_id.find('@'));
+ appid = s_id;
+ HMI_INFO("App found %s", appid.c_str());
+ break;
+ }
+ }
+ if(appid.empty())
+ {
+ HMI_WARNING("Failed to retrieve id");
+ }
+ return appid;
+}
+
+void WindowManager::storeSurface(const string& appid, unsigned ppid, unsigned surface)
+{
+ auto elem = std::find_if(this->tmp_services.begin(), this->tmp_services.end(),
+ [&appid](TmpService& ts){
+ return (ts.dest == appid );
+ });
+
+ this->lc->setXDGSurfaceOriginSize(surface);
+ if(elem != this->tmp_services.end())
+ {
+ // attachApp
+ auto client = g_app_list.lookUpClient(elem->dest);
+ if(client == nullptr)
+ {
+ return;
+ }
+ HMI_INFO("Attach surface %d (service %s) to app %s", surface, elem->service.c_str(), elem->dest.c_str());
+ client->attachServiceSurface(elem->service, surface);
+ }
+ else
+ {
+ // setRole
+ auto client = g_app_list.lookUpClient(appid);
+ if(client != nullptr)
+ {
+ client->addSurface(surface);
+ this->id_alloc.register_name_id(client->role(), surface);
+ }
+ else
+ {
+ // Store tmp surface and appid for application
+ // who requests setRole after creating shell surface
+ this->tmp_surface2app.emplace(surface, TmpClient{appid, ppid});
+ }
+ }
+}
+
+/**
+ * proxied events
+ */
+void WindowManager::surface_created(unsigned pid, unsigned surface_id)
+{
+ // requestSurface
+ if(this->tmp_surface2app.count(surface_id) != 0)
+ {
+ string appid = this->tmp_surface2app[surface_id].appid;
+ auto client = g_app_list.lookUpClient(appid);
+ if(client != nullptr)
+ {
+ WMError ret = client->addSurface(surface_id);
+ HMI_INFO("Add surface %d to \"%s\"", surface_id, appid.c_str());
+ if(ret != WMError::SUCCESS)
+ {
+ HMI_ERROR("Failed to add surface to client %s", client->appID().c_str());
+ }
+ }
+ this->tmp_surface2app.erase(surface_id);
+ }
+ else
+ {
+ HMI_NOTICE("Unknown surface %d", surface_id);
+ // retrieve ppid
+ std::ostringstream os;
+ os << pid ;
+ string path = "/proc/" + os.str() + "/stat";
+ std::ifstream ifs(path.c_str());
+ string str;
+ unsigned ppid = 0;
+ if(!ifs.fail() && std::getline(ifs, str))
+ {
+ std::sscanf(str.data(), "%*d %*s %*c %d", &ppid);
+ HMI_INFO("Retrieve ppid %d", ppid);
+ }
+ else
+ {
+ HMI_ERROR("Failed to open /proc/%d/stat", pid);
+ HMI_ERROR("File system may be different");
+ return;
+ }
+ struct AfbClosure* c = new struct AfbClosure(pid, ppid, surface_id);
+ // search pid from surfaceID
+ afb_service_call("afm-main", "runners", json_object_new_object(),
+ [](void* closure, int stat, json_object* resp){
+ HMI_DEBUG("check %s", json_object_get_string(resp));
+ struct AfbClosure* c = static_cast<struct AfbClosure*>(closure);
+ HMI_DEBUG("check");
+ if(stat != 0)
+ {
+ HMI_ERROR("Failed to call runners");
+ }
+ else
+ {
+ json_object* j;
+ json_object_object_get_ex(resp, "response", &j);
+ string appid = g_context->searchApp(c->pid, c->ppid, c->surface, j);
+ if(!appid.empty())
+ {
+ g_context->storeSurface(appid, c->ppid, c->surface);
+ }
+ }
+ json_object_put(resp);
+ delete c;
+ }, c);
+ }
+}
+
+void WindowManager::surface_removed(unsigned 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);
+}
+
+void WindowManager::removeClient(const string &appid)
+{
+ HMI_DEBUG("Remove clinet %s from list", appid.c_str());
+ auto client = g_app_list.lookUpClient(appid);
+ this->lc->terminateApp(client);
+ g_app_list.removeClient(appid);
+}
+
+void WindowManager::exceptionProcessForTransition()
+{
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_NOTICE(req_num, "Process exception handling for request. Remove current request %d", req_num);
+ g_app_list.removeRequest(req_num);
+ HMI_SEQ_NOTICE(g_app_list.currentRequestNumber(), "Process next request if exists");
+ this->processNextRequest();
+}
+
+void WindowManager::analyzeReceivedEvent(const char *event, struct json_object *object)
+{
+ HMI_DEBUG("event:%s", event);
+
+ // If receive low can signal
+ if (strstr(event, "low-can"))
+ {
+ // Analyze low can signal
+ const char *signal_name = this->lcc.analyzeCanSignal(object);
+
+ // Create task for car state and input it to PolicyManager
+ Task task = this->convertCanSignalToCarStateTask(signal_name);
+ if (Task::TASK_INVALID != task)
+ {
+ this->inputCarStateTask(task);
+ }
+ }
+}
+
+void WindowManager::timerHandler()
+{
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_DEBUG(req_num, "Timer expired remove Request");
+ g_app_list.reqDump();
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+}
+
+void WindowManager::startTransitionWrapper(vector<WMAction> &actions)
+{
+ WMError ret = WMError::UNKNOWN;
+ // req_num is guaranteed by Window Manager
+ unsigned req_num = g_app_list.currentRequestNumber();
+ Task task = Task::TASK_INVALID;
+
+ 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;
+ }
+ }
+
+ // Check weather there is the no request task
+ // [The no request task]
+ // - TaskCarState::RESTRICTION_MODE_OFF
+ // - TaskCarState::RESTRICTION_MODE_ON
+ for (const auto &act : actions)
+ {
+ if (TaskCarState::RESTRICTION_MODE_OFF == act.car_state)
+ {
+ task = Task::TASK_RESTRICTION_MODE_OFF;
+ break;
+ }
+ else if (TaskCarState::RESTRICTION_MODE_ON == act.car_state)
+ {
+ task = Task::TASK_RESTRICTION_MODE_ON;
+ break;
+ }
+ }
+
+ // If there is the request-less task, set request here
+ if (Task::TASK_INVALID != task) {
+ unsigned req_num;
+ ret = this->setRequest(task, &req_num);
+
+ if(ret != WMError::SUCCESS)
+ {
+ goto error;
+ }
+ }
+
+ for (auto &act : actions)
+ {
+ if ("" != act.role)
+ {
+ bool found;
+ auto const &surface_id = this->id_alloc.lookup(act.role.c_str());
+ if(surface_id == nullopt)
+ {
+ HMI_SEQ_DEBUG(req_num, "There is not surface id for role:%s", act.role.c_str());
+ continue;
+ }
+
+ std::string appid = g_app_list.getAppID(*surface_id, &found);
+ if (!found)
+ {
+ if (TaskVisible::INVISIBLE == act.visible)
+ {
+ HMI_SEQ_DEBUG(req_num, "role:%s is killed, so do not set this action", act.role.c_str());
+ continue;
+ }
+ else
+ {
+ HMI_SEQ_ERROR(req_num, "appid of role:%s which is visible is not found", act.role.c_str());
+ ret = WMError::FAIL;
+ goto error;
+ }
+ }
+ auto client = g_app_list.lookUpClient(appid);
+ act.req_num = req_num;
+ act.client = client;
+
+ // If Window Manager is master and this action is for slave,
+ // change TaskVisible
+ if (this->wmcon.isMasterMode())
+ {
+ if (this->wmcon.isMasterArea(act.area.c_str()))
+ {
+ HMI_DEBUG("Set TaskVisible::REQ_REMOTE_VISIBLE");
+ act.visible = TaskVisible::REQ_REMOTE_VISIBLE;
+ }
+ // TODO: Check whether role is tbtnavi to request remote invisible
+ else if (("tbtnavi" == act.role) &&
+ (TaskVisible::INVISIBLE == act.visible))
+ {
+ HMI_DEBUG("Set TaskVisible::REQ_REMOTE_INVISIBLE");
+ act.visible = TaskVisible::REQ_REMOTE_INVISIBLE;
+ }
+ }
+ }
+
+ 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();
+}
+
+void WindowManager::processForRemoteRequest(json_object *data)
+{
+ const char *req = jh::getStringFromJson(data, "req");
+ const char *appid = jh::getStringFromJson(data, "appid");
+ const char *drawing_name = jh::getStringFromJson(data, "drawing_name");
+ const char *drawing_area = jh::getStringFromJson(data, "drawing_area");
+
+ if (!req || !drawing_name)
+ {
+ HMI_ERROR("Parse Error!!");
+ return;
+ }
+
+ if (this->wmcon.isMasterMode())
+ {
+ if (!appid)
+ {
+ HMI_ERROR("Parse Error!!");
+ return;
+ }
+
+ auto reply = [](const char *errmsg) {
+ if (errmsg != nullptr)
+ {
+ HMI_ERROR(errmsg);
+ return;
+ }
+ };
+
+ if ("activateWindow" == std::string(req))
+ {
+ if (!drawing_area)
+ {
+ HMI_ERROR("Parse Error!!");
+ return;
+ }
+
+ this->api_activate_surface_for_slave(
+ appid, drawing_name, drawing_area, reply);
+ }
+ else if ("deactivateWindow" == std::string(req))
+ {
+ this->api_deactivate_surface_for_slave(
+ appid, drawing_name, reply);
+ }
+ else if ("endDraw" == std::string(req))
+ {
+ this->api_enddraw(appid, drawing_name);
+ }
+ }
+ else
+ {
+ if ("syncDraw" == std::string(req))
+ {
+ this->stopTimer();
+
+ if (!appid || !drawing_area)
+ {
+ HMI_ERROR("Parse Error!!");
+ return;
+ }
+
+ unsigned req_num = g_app_list.currentRequestNumber();
+ auto client = g_app_list.lookUpClient(appid);
+
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ // Create action
+ bool end_draw_finished = false;
+ WMAction act
+ {
+ req_num,
+ client,
+ string(c_role),
+ string(drawing_area),
+ TaskVisible::REMOTE_VISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+
+ // Set action
+ WMError ret = g_app_list.setAction(req_num, act);
+ if (ret != WMError::SUCCESS)
+ {
+ HMI_SEQ_ERROR(req_num, "Setting action is failed");
+ return;
+ }
+
+ this->emit_syncdraw(string(drawing_name), string(drawing_area));
+ this->wmcon.startSyncDrawForRemote(appid);
+ this->setTimer();
+ }
+ else if ("activated" == std::string(req))
+ {
+ this->emit_visible(drawing_name);
+ this->emit_activated(drawing_name);
+ }
+ else if ("deactivated" == std::string(req))
+ {
+ this->stopTimer();
+
+ if (!appid || !drawing_area)
+ {
+ HMI_ERROR("Parse Error!!");
+ return;
+ }
+
+ unsigned req_num = g_app_list.currentRequestNumber();
+ auto client = g_app_list.lookUpClient(appid);
+
+ // TODO: application requests by old role,
+ // so convert role old to new
+ const char *c_role = this->convertRoleOldToNew(drawing_name);
+
+ // Create action
+ bool end_draw_finished = true;
+ WMAction act
+ {
+ req_num,
+ client,
+ string(c_role),
+ "",
+ TaskVisible::REMOTE_INVISIBLE,
+ end_draw_finished,
+ TaskCarState::NO_TASK
+ };
+
+ this->lc->visibilityChange(act);
+ this->lc->renderLayers();
+ this->lc->renderLayersRemote();
+
+ this->emit_invisible(drawing_name);
+ this->emit_deactivated(drawing_name);
+ this->emitScreenUpdated(req_num);
+
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+ else if ("flushDraw" == std::string(req))
+ {
+ this->emit_flushdraw(drawing_name);
+ }
+ }
+}
+
+/*
+ ******* Private Functions *******
+ */
+
+void WindowManager::emit_activated(char const *label)
+{
+ this->send_event(kListEventName[Event_Active], label);
+}
+
+void WindowManager::emit_deactivated(char const *label)
+{
+ this->send_event(kListEventName[Event_Inactive], label);
+}
+
+void WindowManager::emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h)
+{
+ this->send_event(kListEventName[Event_SyncDraw], label, area, x, y, w, h);
+}
+
+void WindowManager::emit_syncdraw(const string &role, const string &area)
+{
+ rect rect = this->lc->getAreaSize(area);
+ this->send_event(kListEventName[Event_SyncDraw],
+ role.c_str(), area.c_str(), rect.x, rect.y, rect.w, rect.h);
+}
+
+void WindowManager::emit_flushdraw(char const *label)
+{
+ this->send_event(kListEventName[Event_FlushDraw], label);
+}
+
+void WindowManager::emit_visible(char const *label, bool is_visible)
+{
+ this->send_event(is_visible ? kListEventName[Event_Visible] : kListEventName[Event_Invisible], label);
+}
+
+void WindowManager::emit_invisible(char const *label)
+{
+ return emit_visible(label, false);
+}
+
+void WindowManager::emit_visible(char const *label) { return emit_visible(label, true); }
+
+void WindowManager::emitHeadlampOff()
+{
+ // Send HeadlampOff event for all application
+ this->send_event(kListEventName[Event_HeadlampOff]);
+}
+
+void WindowManager::emitHeadlampOn()
+{
+ // Send HeadlampOn event for all application
+ this->send_event(kListEventName[Event_HeadlampOn]);
+}
+
+void WindowManager::emitParkingBrakeOff()
+{
+ // Send ParkingBrakeOff event for all application
+ this->send_event(kListEventName[Event_ParkingBrakeOff]);
+}
+
+void WindowManager::emitParkingBrakeOn()
+{
+ // Send ParkingBrakeOn event for all application
+ this->send_event(kListEventName[Event_ParkingBrakeOn]);
+}
+
+void WindowManager::emitLightstatusBrakeOff()
+{
+ // Send LightstatusBrakeOff event for all application
+ this->send_event(kListEventName[Event_LightstatusBrakeOff]);
+}
+
+void WindowManager::emitLightstatusBrakeOn()
+{
+ // Send LightstatusBrakeOn event for all application
+ this->send_event(kListEventName[Event_LightstatusBrakeOn]);
+}
+
+void WindowManager::emitCarStop()
+{
+ // Send CarStop event for all application
+ this->send_event(kListEventName[Event_CarStop]);
+}
+
+void WindowManager::emitCarRun()
+{
+ // Send CarRun event for all application
+ this->send_event(kListEventName[Event_CarRun]);
+}
+
+WMError WindowManager::setRequest(const string& appid, const string &role, const string &area,
+ Task task, unsigned* req_num)
+{
+ if (!g_app_list.contains(appid))
+ {
+ return WMError::NOT_REGISTERED;
+ }
+
+ auto client = g_app_list.lookUpClient(appid);
+
+ /*
+ * Queueing Phase
+ */
+ unsigned current = g_app_list.currentRequestNumber();
+ unsigned requested_num = g_app_list.getRequestNumber(appid);
+ if (requested_num != 0)
+ {
+ HMI_SEQ_INFO(requested_num,
+ "%s %s %s request is already queued", appid.c_str(), role.c_str(), area.c_str());
+ return REQ_REJECTED;
+ }
+
+ WMRequest req = WMRequest(appid, role, area, task);
+ unsigned new_req = g_app_list.addRequest(req);
+ *req_num = new_req;
+ g_app_list.reqDump();
+
+ HMI_SEQ_DEBUG(current, "%s start sequence with %s, %s", appid.c_str(), role.c_str(), area.c_str());
+
+ return WMError::SUCCESS;
+}
+
+WMError WindowManager::setRequest(Task task, unsigned* req_num)
+{
+ /*
+ * Queueing Phase
+ */
+ unsigned current = g_app_list.currentRequestNumber();
+
+ WMRequest req = WMRequest(task);
+ unsigned new_req = g_app_list.addRequest(req);
+ *req_num = new_req;
+ g_app_list.reqDump();
+
+ HMI_SEQ_DEBUG(current, "start sequence for task:%d", task);
+
+ return WMError::SUCCESS;
+}
+
+WMError WindowManager::setRequestForSlave(const string& appid, const string &role, const string &area,
+ Task task, unsigned* req_num)
+{
+ /*
+ * Queueing Phase
+ */
+ unsigned current = g_app_list.currentRequestNumber();
+ unsigned requested_num = g_app_list.getRequestNumber(appid);
+ if (requested_num != 0)
+ {
+ HMI_SEQ_INFO(requested_num,
+ "%s %s %s request is already queued", appid.c_str(), role.c_str(), area.c_str());
+ return REQ_REJECTED;
+ }
+
+ WMRequest req = WMRequest(appid, role, area, task);
+ unsigned new_req = g_app_list.addRequest(req);
+ *req_num = new_req;
+ g_app_list.reqDump();
+
+ HMI_SEQ_DEBUG(current, "%s start sequence with %s, %s", appid.c_str(), role.c_str(), area.c_str());
+
+ return WMError::SUCCESS;
+}
+
+WMError WindowManager::checkPolicy(unsigned req_num)
+{
+ /*
+ * Check Policy
+ */
+ // get current trigger
+ bool found = false;
+ WMError ret = WMError::LAYOUT_CHANGE_FAIL;
+ auto trigger = g_app_list.getRequest(req_num, &found);
+ if (!found)
+ {
+ ret = WMError::NO_ENTRY;
+ return ret;
+ }
+ string req_area = trigger.area;
+
+ if (trigger.task == Task::TASK_ALLOCATE)
+ {
+ const char *msg = this->check_surface_exist(trigger.role.c_str());
+
+ if (msg)
+ {
+ HMI_SEQ_ERROR(req_num, msg);
+ return ret;
+ }
+ }
+
+ // Input event data to PolicyManager
+ if (0 > this->pmw.setInputEventData(trigger.task, trigger.role, trigger.area))
+ {
+ HMI_SEQ_ERROR(req_num, "Failed to set input event data to PolicyManager");
+ return ret;
+ }
+
+ // Execute state transition of PolicyManager
+ if (0 > this->pmw.executeStateTransition())
+ {
+ HMI_SEQ_ERROR(req_num, "Failed to execute state transition of PolicyManager");
+ return ret;
+ }
+
+ ret = WMError::SUCCESS;
+
+ g_app_list.reqDump();
+
+ return ret;
+}
+
+WMError WindowManager::checkPolicyForSlave(unsigned req_num)
+{
+ /*
+ * Check Policy
+ */
+ // get current trigger
+ bool found = false;
+ WMError ret = WMError::LAYOUT_CHANGE_FAIL;
+ auto trigger = g_app_list.getRequest(req_num, &found);
+ if (!found)
+ {
+ ret = WMError::NO_ENTRY;
+ return ret;
+ }
+ string req_area = trigger.area;
+
+ // Input event data to PolicyManager
+ if (0 > this->pmw.setInputEventData(trigger.task, trigger.role, trigger.area))
+ {
+ HMI_SEQ_ERROR(req_num, "Failed to set input event data to PolicyManager");
+ return ret;
+ }
+
+ // Execute state transition of PolicyManager
+ if (0 > this->pmw.executeStateTransition())
+ {
+ HMI_SEQ_ERROR(req_num, "Failed to execute state transition of PolicyManager");
+ return ret;
+ }
+
+ ret = WMError::SUCCESS;
+
+ g_app_list.reqDump();
+
+ return ret;
+}
+
+WMError WindowManager::startTransition(unsigned req_num)
+{
+ bool sync_draw_happen = false;
+ bool found = false;
+ WMError ret = WMError::SUCCESS;
+ auto actions = g_app_list.getActions(req_num, &found);
+ if (!found)
+ {
+ ret = WMError::NO_ENTRY;
+ HMI_SEQ_ERROR(req_num,
+ "Window Manager bug :%s : Action is not set", errorDescription(ret));
+ return ret;
+ }
+
+ g_app_list.reqDump();
+ for (const auto &action : actions)
+ {
+ // TODO: application requests by old role,
+ // so convert role new to old for emitting event
+ string old_role = this->rolenew2old[action.role];
+
+ if (action.visible == TaskVisible::VISIBLE)
+ {
+ sync_draw_happen = true;
+
+ this->emit_syncdraw(old_role, action.area);
+ /* TODO: emit event for app not subscriber
+ if(g_app_list.contains(y.appid))
+ g_app_list.lookUpClient(y.appid)->emit_syncdraw(y.role, y.area); */
+ }
+ else if(action.visible == TaskVisible::REQ_REMOTE_VISIBLE)
+ {
+ // If this action is for slave, send to slave
+ this->wmcon.sendRequest("syncDraw", action.client->appID().c_str(),
+ old_role.c_str(), action.area.c_str());
+ }
+ else if (action.car_state != TaskCarState::NO_TASK)
+ {
+ this->transitionCarState(action.car_state);
+ }
+ }
+
+ if (sync_draw_happen)
+ {
+ this->setTimer();
+ }
+ else
+ {
+ // deactivate only, no syncDraw
+ // Make it deactivate here
+ for (const auto &x : actions)
+ {
+ this->lc->visibilityChange(x);
+ string old_role = this->rolenew2old[x.role];
+
+ if (x.visible == TaskVisible::INVISIBLE)
+ {
+ emit_deactivated(old_role.c_str());
+ }
+ else if (x.visible == TaskVisible::REQ_REMOTE_INVISIBLE)
+ {
+ // If this action is for slave, send to slave
+ int i_ret = this->wmcon.sendRequest("deactivated", x.client->appID().c_str(),
+ old_role.c_str(), "");
+ if (0 > i_ret)
+ {
+ ret = WMError::FAIL;
+ }
+ }
+
+ /* if (g_app_list.contains(x.appid))
+ {
+ auto client = g_app_list.lookUpClient(x.appid);
+ //this->deactivate(client->surfaceID(x.role));
+ } */
+ }
+ this->lc->renderLayers();
+ this->lc->renderLayersRemote();
+ ret = WMError::NO_LAYOUT_CHANGE;
+ }
+ return ret;
+}
+
+void WindowManager::transitionCarState(TaskCarState task)
+{
+ if (TaskCarState::PARKING_BRAKE_OFF == task)
+ {
+ this->crr_car_info.parking_brake_stt = false;
+ this->emitParkingBrakeOff();
+ }
+ else if (TaskCarState::PARKING_BRAKE_ON == task)
+ {
+ this->crr_car_info.parking_brake_stt = true;
+ this->emitParkingBrakeOn();
+ }
+ else if (TaskCarState::ACCEL_PEDAL_OFF == task)
+ {
+ this->crr_car_info.accel_pedal_stt = false;
+ }
+ else if (TaskCarState::ACCEL_PEDAL_ON == task)
+ {
+ this->crr_car_info.accel_pedal_stt = true;
+ }
+ else if (TaskCarState::HEDLAMP_OFF == task)
+ {
+ this->crr_car_info.headlamp_stt = false;
+ this->emitHeadlampOff();
+ }
+ else if (TaskCarState::HEDLAMP_ON == task)
+ {
+ this->crr_car_info.headlamp_stt = true;
+ this->emitHeadlampOn();
+ }
+ else if (TaskCarState::LIGHTSTATUS_BRAKE_OFF == task)
+ {
+ this->crr_car_info.lightstatus_brake_stt = false;
+ this->emitLightstatusBrakeOff();
+ }
+ else if (TaskCarState::LIGHTSTATUS_BRAKE_ON == task)
+ {
+ this->crr_car_info.lightstatus_brake_stt = true;
+ this->emitLightstatusBrakeOn();
+ }
+ else if (TaskCarState::CAR_STOP == task)
+ {
+ this->crr_car_info.running_stt = false;
+ this->emitCarStop();
+ }
+ else if (TaskCarState::CAR_RUN == task)
+ {
+ this->crr_car_info.running_stt = true;
+ this->emitCarRun();
+ }
+}
+
+WMError WindowManager::doEndDraw(unsigned req_num)
+{
+ // get actions
+ bool found;
+ auto actions = g_app_list.getActions(req_num, &found);
+ WMError ret = WMError::SUCCESS;
+ if (!found)
+ {
+ ret = WMError::NO_ENTRY;
+ return ret;
+ }
+
+ HMI_SEQ_INFO(req_num, "do endDraw");
+
+ // layout change and make it visible
+ for (const auto &act : actions)
+ {
+ if(act.visible != TaskVisible::NO_CHANGE)
+ {
+ // layout change
+ ret = this->lc->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->lc->visibilityChange(act);
+
+ // Emit active/deactive event
+ string old_role = this->rolenew2old[act.role];
+ if(act.visible == TaskVisible::VISIBLE)
+ {
+ emit_visible(old_role.c_str());
+ emit_activated(old_role.c_str());
+ }
+ else if(act.visible == TaskVisible::REQ_REMOTE_VISIBLE)
+ {
+ // If this action is for slave, send to slave
+ int i_ret = this->wmcon.sendRequest("activated", "", old_role.c_str(), "");
+ if (0 > i_ret)
+ {
+ ret = WMError::FAIL;
+ }
+ }
+ else if(act.visible == TaskVisible::REQ_REMOTE_INVISIBLE)
+ {
+ // If this action is for slave, send to slave
+ int i_ret = this->wmcon.sendRequest("deactivated", "", old_role.c_str(), "");
+ if (0 > i_ret)
+ {
+ ret = WMError::FAIL;
+ }
+ }
+ else if((act.visible == TaskVisible::REMOTE_VISIBLE) ||
+ (act.visible == TaskVisible::REMOTE_INVISIBLE))
+ {
+ // nop because emit active/deactive by event from remote
+ }
+ else
+ {
+ emit_invisible(old_role.c_str());
+ emit_deactivated(old_role.c_str());
+ }
+
+ 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->lc->renderLayers();
+ this->lc->renderLayersRemote();
+
+ HMI_SEQ_INFO(req_num, "emit flushDraw");
+
+ for(const auto &act_flush : actions)
+ {
+ // TODO: application requests by old role,
+ // so convert role new to old for emitting event
+ string old_role = this->rolenew2old[act_flush.role];
+
+ if(act_flush.visible == TaskVisible::VISIBLE)
+ {
+ this->emit_flushdraw(old_role.c_str());
+ }
+ else if(act_flush.visible == TaskVisible::REQ_REMOTE_VISIBLE)
+ {
+ // If this action is for slave, send to slave
+ this->wmcon.sendRequest("flushDraw", "", old_role.c_str(), "");
+ }
+ }
+
+ return ret;
+}
+
+void WindowManager::emitScreenUpdated(unsigned req_num)
+{
+ // Get visible apps
+ HMI_SEQ_DEBUG(req_num, "emit screen updated");
+ bool found = false;
+ auto actions = g_app_list.getActions(req_num, &found);
+
+ HMI_DEBUG("@@@@@");
+ // create json object
+ json_object *j = json_object_new_object();
+ json_object *jarray = json_object_new_array();
+
+ for(const auto& action: actions)
+ {
+ if((action.visible == TaskVisible::VISIBLE) ||
+ (action.visible == TaskVisible::REMOTE_VISIBLE))
+ {
+ json_object_array_add(jarray, json_object_new_string(action.client->appID().c_str()));
+ }
+ }
+ json_object_object_add(j, kKeyIds, jarray);
+ HMI_SEQ_INFO(req_num, "Visible app: %s", json_object_get_string(j));
+
+ int ret = afb_event_push(
+ this->map_afb_event[kListEventName[Event_ScreenUpdated]], j);
+ if (ret != 0)
+ {
+ HMI_DEBUG("afb_event_push failed: %m");
+ }
+}
+
+void WindowManager::setTimer()
+{
+ struct timespec ts;
+ if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) {
+ HMI_ERROR("Could't set time (clock_gettime() returns with error");
+ return;
+ }
+
+ HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate");
+ if (g_timer_ev_src == nullptr)
+ {
+ // firsttime set into sd_event
+ int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src,
+ CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this);
+ if (ret < 0)
+ {
+ HMI_ERROR("Could't set timer");
+ }
+ }
+ else
+ {
+ // update timer limitation after second time
+ sd_event_source_set_time(g_timer_ev_src, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL);
+ sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_ONESHOT);
+ }
+}
+
+void WindowManager::stopTimer()
+{
+ unsigned req_num = g_app_list.currentRequestNumber();
+ HMI_SEQ_DEBUG(req_num, "Timer stop");
+ int rc = sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_OFF);
+ if (rc < 0)
+ {
+ HMI_SEQ_ERROR(req_num, "Timer stop failed");
+ }
+}
+
+void WindowManager::processNextRequest()
+{
+ g_app_list.next();
+ g_app_list.reqDump();
+ unsigned req_num = g_app_list.currentRequestNumber();
+ if (g_app_list.haveRequest())
+ {
+ HMI_SEQ_DEBUG(req_num, "Process next request");
+ WMError rc = checkPolicy(req_num);
+ if (rc != WMError::SUCCESS)
+ {
+ HMI_SEQ_ERROR(req_num, errorDescription(rc));
+ }
+ }
+ else
+ {
+ HMI_SEQ_DEBUG(req_num, "Nothing Request. Waiting Request");
+ }
+}
+
+const char* WindowManager::convertRoleOldToNew(char const *old_role)
+{
+ const char *new_role = nullptr;
+
+ for (auto const &on : this->roleold2new)
+ {
+ std::regex regex = std::regex(on.first);
+ if (std::regex_match(old_role, regex))
+ {
+ // role is old. So convert to new.
+ new_role = on.second.c_str();
+ break;
+ }
+ }
+
+ if (nullptr == new_role)
+ {
+ // role is new or fallback.
+ new_role = old_role;
+ }
+
+ HMI_DEBUG("old:%s -> new:%s", old_role, new_role);
+
+ return new_role;
+}
+
+int WindowManager::loadOldRolesConfigFile()
+{
+ // Get afm application installed dir
+ char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
+ HMI_DEBUG("afm_app_install_dir:%s", afm_app_install_dir);
+
+ string file_name;
+ if (!afm_app_install_dir)
+ {
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
+ }
+ else
+ {
+ file_name = string(afm_app_install_dir) + string(kPathOldRolesConfigFile);
+ }
+
+ // Load old_rolea config file
+ json_object* json_obj;
+ int ret = jh::inputJsonFilie(file_name.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_ERROR("Could not open %s, so use default old_roles information", kPathOldRolesConfigFile);
+ json_obj = json_tokener_parse(kDefaultOldRolesConfig);
+ }
+ 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("Parse Error!!");
+ return -1;
+ }
+
+ int len = json_object_array_length(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; i<len; i++)
+ {
+ json_object* json_tmp = json_object_array_get_idx(json_cfg, i);
+
+ const char* old_role = jh::getStringFromJson(json_tmp, "name");
+ if (nullptr == old_role)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ const char* new_role = jh::getStringFromJson(json_tmp, "new");
+ if (nullptr == new_role)
+ {
+ HMI_ERROR("Parse Error!!");
+ return -1;
+ }
+
+ this->roleold2new[old_role] = string(new_role);
+ }
+
+ // Check
+ for(auto itr = this->roleold2new.begin();
+ itr != this->roleold2new.end(); ++itr)
+ {
+ HMI_DEBUG(">>> role old:%s new:%s",
+ itr->first.c_str(), itr->second.c_str());
+ }
+
+ // Release json_object
+ json_object_put(json_obj);
+
+ return 0;
+}
+
+Task WindowManager::convertCanSignalToCarStateTask(const char *signal_name)
+{
+ wm::LowCanClient *lcc = &(this->lcc);
+ Task task = Task::TASK_INVALID;
+
+ // If car info is updated, set car state change event
+ if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoParkingBrake]))
+ {
+ HMI_DEBUG("Parking Brake state is changed");
+
+ if (lcc->getCurrentParkingBrakeState())
+ {
+ task = wm::Task::TASK_PARKING_BRAKE_ON;
+ }
+ else
+ {
+ task = wm::Task::TASK_PARKING_BRAKE_OFF;
+ }
+ }
+ else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoAccelPedalPos]))
+ {
+ // Update accel pedal position
+ this->crr_car_info.accel_pedal_pos = lcc->getCurrentAccelPedalPosition();
+
+ if (lcc->isChangedAccelPedalState())
+ {
+ HMI_DEBUG("Accelerator Pedal state is changed");
+
+ if (lcc->getCurrentAccelPedalState())
+ {
+ task = wm::Task::TASK_ACCEL_PEDAL_ON;
+ }
+ else
+ {
+ task = wm::Task::TASK_ACCEL_PEDAL_OFF;
+ }
+ }
+ }
+ else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoHeadlame]))
+ {
+ HMI_DEBUG("Headlamp state is changed");
+
+ if (lcc->getCurrentHeadlampState())
+ {
+ task = wm::Task::TASK_HEDLAMP_ON;
+ }
+ else
+ {
+ task = wm::Task::TASK_HEDLAMP_OFF;
+ }
+ }
+ else if (strstr(signal_name, lcc->kSignalName[lcc->SignalNoLightstatusBrake]))
+ {
+ HMI_DEBUG("Lightstatus Brake state is changed");
+
+ if (lcc->getCurrentLightstatusBrakeState())
+ {
+ task = wm::Task::TASK_LIGHTSTATUS_BRAKE_ON;
+ }
+ else
+ {
+ task = wm::Task::TASK_LIGHTSTATUS_BRAKE_OFF;
+ }
+ }
+ return task;
+}
+
+void WindowManager::inputCarStateTask(Task task)
+{
+ unsigned req_num = 0;
+ WMError ret = WMError::UNKNOWN;
+
+ ret = this->setRequest(task, &req_num);
+
+ if(ret != WMError::SUCCESS)
+ {
+ HMI_ERROR(errorDescription(ret));
+ return;
+ }
+
+ if (req_num != g_app_list.currentRequestNumber())
+ {
+ // Add request, then invoked after the previous task is finished
+ HMI_SEQ_DEBUG(req_num, "request is accepted");
+ return;
+ }
+
+ /*
+ * Do allocate tasks
+ */
+ ret = this->checkPolicy(req_num);
+
+ if (ret != WMError::SUCCESS)
+ {
+ //this->emit_error()
+ HMI_SEQ_ERROR(req_num, errorDescription(ret));
+ g_app_list.removeRequest(req_num);
+ this->processNextRequest();
+ }
+}
+
+const char *WindowManager::check_surface_exist(const char *drawing_name)
+{
+ auto const &surface_id = this->id_alloc.lookup(string(drawing_name));
+ if (!surface_id)
+ {
+ return "Surface does not exist";
+ }
+
+ /* if (!this->controller->surface_exists(*surface_id))
+ {
+ return "Surface does not exist in controller!";
+ } */
+
+ /* auto layer_id = this->layers.get_layer_id(*surface_id);
+
+ if (!layer_id)
+ {
+ return "Surface is not on any layer!";
+ } */
+
+ HMI_DEBUG("surface %d is detected", *surface_id);
+ return nullptr;
+}
+
+const char* WindowManager::kDefaultOldRolesConfig = "{ \
+ \"old_roles\": [ \
+ { \
+ \"name\": \"HomeScreen\", \
+ \"new\": \"homescreen\" \
+ }, \
+ { \
+ \"name\": \"Music\", \
+ \"new\": \"music\" \
+ }, \
+ { \
+ \"name\": \"MediaPlayer\", \
+ \"new\": \"music\" \
+ }, \
+ { \
+ \"name\": \"Video\", \
+ \"new\": \"video\" \
+ }, \
+ { \
+ \"name\": \"VideoPlayer\", \
+ \"new\": \"video\" \
+ }, \
+ { \
+ \"name\": \"WebBrowser\", \
+ \"new\": \"browser\" \
+ }, \
+ { \
+ \"name\": \"Radio\", \
+ \"new\": \"radio\" \
+ }, \
+ { \
+ \"name\": \"Phone\", \
+ \"new\": \"phone\" \
+ }, \
+ { \
+ \"name\": \"Navigation\", \
+ \"new\": \"map\" \
+ }, \
+ { \
+ \"name\": \"HVAC\", \
+ \"new\": \"hvac\" \
+ }, \
+ { \
+ \"name\": \"Settings\", \
+ \"new\": \"settings\" \
+ }, \
+ { \
+ \"name\": \"Dashboard\", \
+ \"new\": \"dashboard\" \
+ }, \
+ { \
+ \"name\": \"POI\", \
+ \"new\": \"poi\" \
+ }, \
+ { \
+ \"name\": \"Mixer\", \
+ \"new\": \"mixer\" \
+ }, \
+ { \
+ \"name\": \"Restriction\", \
+ \"new\": \"restriction\" \
+ }, \
+ { \
+ \"name\": \"^OnScreen.*\", \
+ \"new\": \"on_screen\" \
+ } \
+ ] \
+}";
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/window_manager.hpp b/demo3/common/agl-service-windowmanager/src/window_manager.hpp
new file mode 100644
index 0000000..c4ad0f5
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/window_manager.hpp
@@ -0,0 +1,346 @@
+/*
+ * 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 WINDOW_MANAGER_HPP
+#define WINDOW_MANAGER_HPP
+
+#include <atomic>
+#include <memory>
+#include <unordered_map>
+#include <experimental/optional>
+#include "result.hpp"
+#include "pm_wrapper.hpp"
+#include "util.hpp"
+#include "request.hpp"
+#include "wm_error.hpp"
+#include "wm_layer_control.hpp"
+#include "wm_connection.hpp"
+#include "low_can_client.hpp"
+extern "C"
+{
+#include <afb/afb-binding.h>
+}
+
+struct json_object;
+
+namespace wm
+{
+
+using std::experimental::optional;
+
+/* DrawingArea name used by "{layout}.{area}" */
+extern const char kNameLayoutNormal[];
+extern const char kNameLayoutSplit[];
+extern const char kNameAreaFull[];
+extern const char kNameAreaMain[];
+extern const char kNameAreaSub[];
+
+/* Key for json obejct */
+extern const char kKeyDrawingName[];
+extern const char kKeyDrawingArea[];
+extern const char kKeyDrawingRect[];
+extern const char kKeyX[];
+extern const char kKeyY[];
+extern const char kKeyWidth[];
+extern const char kKeyHeigh[];
+extern const char kKeyWidthPixel[];
+extern const char kKeyHeightPixel[];
+extern const char kKeyWidthMm[];
+extern const char kKeyHeightMm[];
+extern const char kKeyScale[];
+extern const char kKeyIds[];
+
+struct id_allocator
+{
+ unsigned next = 1;
+
+ // Surfaces that where requested but not yet created
+ std::unordered_map<unsigned, std::string> id2name;
+ std::unordered_map<std::string, unsigned> name2id;
+
+ id_allocator(id_allocator const &) = delete;
+ id_allocator(id_allocator &&) = delete;
+ id_allocator &operator=(id_allocator const &);
+ id_allocator &operator=(id_allocator &&) = delete;
+
+ // Insert and return a new ID
+ unsigned generate_id(std::string const &name)
+ {
+ unsigned sid = this->next++;
+ this->id2name[sid] = name;
+ this->name2id[name] = sid;
+ HMI_DEBUG("allocated new id %u with name %s", sid, name.c_str());
+ return sid;
+ }
+
+ // Insert a new ID which defined outside
+ void register_name_id(std::string const &name, unsigned sid)
+ {
+ this->id2name[sid] = name;
+ this->name2id[name] = sid;
+ HMI_DEBUG("register id %u with name %s", sid, name.c_str());
+ return;
+ }
+
+ // Lookup by ID or by name
+ optional<unsigned> lookup(std::string const &name) const
+ {
+ auto i = this->name2id.find(name);
+ return i == this->name2id.end() ? nullopt : optional<unsigned>(i->second);
+ }
+
+ optional<std::string> lookup(unsigned id) const
+ {
+ auto i = this->id2name.find(id);
+ return i == this->id2name.end() ? nullopt
+ : optional<std::string>(i->second);
+ }
+
+ // Remove a surface id and name
+ void remove_id(std::string const &name)
+ {
+ auto i = this->name2id.find(name);
+ if (i != this->name2id.end())
+ {
+ this->id2name.erase(i->second);
+ this->name2id.erase(i);
+ }
+ }
+
+ void remove_id(unsigned id)
+ {
+ auto i = this->id2name.find(id);
+ if (i != this->id2name.end())
+ {
+ this->name2id.erase(i->second);
+ this->id2name.erase(i);
+ }
+ }
+};
+
+struct TmpClient
+{
+ std::string appid;
+ unsigned pid;
+};
+
+struct TmpService
+{
+ std::string appid; // Used to search who create service surface
+ std::string dest; // Used to attach service to destination application
+ std::string service;// The name of service surface
+ std::string uuid; // uuid
+ TmpService(const std::string& app, const std::string& dst,
+ const std::string& svc, const std::string& uuid)
+ : appid(app), dest(dst), service(svc), uuid(uuid) {}
+};
+
+struct CarInfo
+{
+ CarInfo()
+ : parking_brake_stt(true),
+ accel_pedal_stt(false),
+ accel_pedal_pos(0.0),
+ running_stt(false),
+ headlamp_stt(false),
+ lightstatus_brake_stt(true)
+ {};
+
+ bool parking_brake_stt;
+ bool accel_pedal_stt;
+ double accel_pedal_pos;
+ bool running_stt;
+ bool headlamp_stt;
+ bool lightstatus_brake_stt;
+};
+
+class WindowManager
+{
+ public:
+ typedef std::unordered_map<uint32_t, struct rect> rect_map;
+ typedef std::function<void(const char *err_msg)> reply_func;
+
+ enum EventType
+ {
+ Event_Val_Min = 0,
+
+ Event_Active = Event_Val_Min,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+
+ Event_ScreenUpdated,
+
+ Event_HeadlampOff,
+ Event_HeadlampOn,
+
+ Event_ParkingBrakeOff,
+ Event_ParkingBrakeOn,
+
+ Event_LightstatusBrakeOff,
+ Event_LightstatusBrakeOn,
+
+ Event_CarStop,
+ Event_CarRun,
+
+ Event_Error,
+
+ Event_Val_Max = Event_Error,
+ };
+
+ explicit WindowManager();
+ ~WindowManager() = default;
+
+ WindowManager(WindowManager const &) = delete;
+ WindowManager &operator=(WindowManager const &) = delete;
+ WindowManager(WindowManager &&) = delete;
+ WindowManager &operator=(WindowManager &&) = delete;
+
+ int init();
+
+ result<int> api_request_surface(char const *appid, char const *role);
+ char const *api_request_surface(char const *appid, char const *role, char const *ivi_id);
+ bool api_set_role(char const *appid, char const *role);
+ void api_activate_surface(char const *appid, char const *role, char const *drawing_area, const reply_func &reply);
+ void api_activate_surface_for_slave(char const *appid, char const *drawing_name,
+ char const *drawing_area, const reply_func &reply);
+ void api_activate_surface_to_master(char const *appid, char const *drawing_name,
+ char const *drawing_area, const reply_func &reply);
+ void api_deactivate_surface(char const *appid, char const *role, const reply_func &reply);
+ void api_deactivate_surface_for_slave(char const *appid, char const *drawing_name,
+ const reply_func &reply);
+ void api_deactivate_surface_to_master(char const *appid, char const *drawing_name,
+ const reply_func &reply);
+ void api_enddraw(char const *appid, char const *role);
+ void api_enddraw_for_remote(char const *appid, char const *drawing_name);
+ bool api_client_set_render_order(const char *appid, const std::vector<std::string> &render_order);
+ std::string api_client_attach_service_surface(const char* appid, const char* dest, const char* service_surface);
+ result<json_object *> api_get_display_info();
+ result<json_object *> api_get_area_info(char const *role);
+ result<json_object *> api_get_car_info(char const *label);
+ void send_event(char const *evname);
+ void send_event(char const *evname, char const *label);
+ void send_event(char const *evname, char const *label, char const *area, int x, int y, int w, int h);
+
+ // Events from the compositor we are interested in
+ void surface_created(unsigned pid, unsigned surface_id);
+ void surface_removed(unsigned surface_id);
+
+ void removeClient(const std::string &appid);
+ void exceptionProcessForTransition();
+ const char* convertRoleOldToNew(char const *role);
+
+ void analyzeReceivedEvent(const char *event, struct json_object *object);
+
+ // Do not use this function
+ void timerHandler();
+ void startTransitionWrapper(std::vector<WMAction> &actions);
+ void processError(WMError error);
+ void processForRemoteRequest(json_object *data);
+ std::string searchApp(unsigned pid, unsigned ppid, unsigned surface, json_object* resp);
+ void storeSurface(const std::string& appid, unsigned ppid, unsigned surface);
+
+ const std::vector<const char *> kListEventName{
+ "active",
+ "inactive",
+ "visible",
+ "invisible",
+ "syncDraw",
+ "flushDraw",
+ "screenUpdated",
+ "headlampOff",
+ "headlampOn",
+ "parkingBrakeOff",
+ "parkingBrakeOn",
+ "lightstatusBrakeOff",
+ "lightstatusBrakeOn",
+ "carStop",
+ "carRun",
+ "error"};
+ std::map<const char *, struct afb_event> map_afb_event;
+
+ WMConnection wmcon;
+
+ private:
+ // WM Events to clients
+ void emit_activated(char const *label);
+ void emit_deactivated(char const *label);
+ void emit_syncdraw(char const *label, char const *area, int x, int y, int w, int h);
+ void emit_syncdraw(const std::string &role, const std::string &area);
+ void emit_flushdraw(char const *label);
+ void emit_visible(char const *label, bool is_visible);
+ void emit_invisible(char const *label);
+ void emit_visible(char const *label);
+ void emitHeadlampOff();
+ void emitHeadlampOn();
+ void emitParkingBrakeOff();
+ void emitParkingBrakeOn();
+ void emitLightstatusBrakeOff();
+ void emitLightstatusBrakeOn();
+ void emitCarStop();
+ void emitCarRun();
+
+ WMError setRequest(const std::string &appid, const std::string &role, const std::string &area,
+ Task task, unsigned *req_num);
+ WMError setRequest(Task task, unsigned* req_num);
+ WMError setRequestForSlave(const std::string& appid, const std::string &role,
+ const std::string &area, Task task, unsigned* req_num);
+ WMError checkPolicy(unsigned req_num);
+ WMError checkPolicyForSlave(unsigned req_num);
+ WMError startTransition(unsigned req_num);
+ void transitionCarState(TaskCarState task);
+
+ WMError doEndDraw(unsigned req_num);
+ void emitScreenUpdated(unsigned req_num);
+
+ void setTimer();
+ void stopTimer();
+ void processNextRequest();
+
+ int loadOldRolesConfigFile();
+
+ Task convertCanSignalToCarStateTask(const char *signal_name);
+ void inputCarStateTask(Task task);
+
+ const char *check_surface_exist(const char *role);
+
+ private:
+ std::unordered_map<std::string, std::string> roleold2new;
+ std::unordered_map<std::string, std::string> rolenew2old;
+ std::shared_ptr<LayerControl> lc;
+
+ LowCanClient lcc;
+ CarInfo crr_car_info;
+
+ PMWrapper pmw;
+
+ // ID allocation and proxy methods for lookup
+ struct id_allocator id_alloc;
+ // Surface are info (x, y, w, h)
+ rect_map area_info;
+ // FOR CES DEMO
+ std::unordered_map<unsigned, struct TmpClient> tmp_surface2app;
+ std::vector<struct TmpService> tmp_services;
+ static const char* kDefaultOldRolesConfig;
+};
+
+} // namespace wm
+
+#endif // WINDOW_MANAGER_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/wm_client.cpp b/demo3/common/agl-service-windowmanager/src/wm_client.cpp
new file mode 100644
index 0000000..f2ad7be
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_client.cpp
@@ -0,0 +1,271 @@
+/*
+ * 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 <json-c/json.h>
+#include "wm_client.hpp"
+#include "util.hpp"
+#include <ilm/ilm_control.h>
+#include <uuid/uuid.h>
+
+
+#define INVALID_SURFACE_ID 0
+
+using std::string;
+using std::vector;
+
+namespace wm
+{
+
+static const vector<string> kWMEvents = {
+ // Private event for applications
+ "syncDraw", "flushDraw", "visible", "invisible", "active", "inactive", "error"};
+static const vector<string> kErrorDescription = {
+ "unknown-error"};
+
+static const char kKeyDrawingName[] = "drawing_name";
+static const char kKeyrole[] = "role";
+static const char kKeyError[] = "error";
+static const char kKeyErrorDesc[] = "kErrorDescription";
+
+WMClient::WMClient(const string &appid, unsigned layer, unsigned surface, const string &role)
+ : id(appid), layer(layer),
+ role2surface(0)
+{
+ role2surface[role] = surface;
+ for (auto x : kWMEvents)
+ {
+#if GTEST_ENABLED
+ string ev = x;
+#else
+ afb_event ev = afb_daemon_make_event(x.c_str());
+#endif
+ evname2afb_event[x] = ev;
+ }
+}
+
+WMClient::WMClient(const string &appid, const string &role)
+ : id(appid),
+ layer(0),
+ role2surface(0),
+ evname2afb_event(0)
+{
+ role2surface[role] = INVALID_SURFACE_ID;
+ for (auto x : kWMEvents)
+ {
+#if GTEST_ENABLED
+ string ev = x;
+#else
+ afb_event ev = afb_daemon_make_event(x.c_str());
+#endif
+ evname2afb_event[x] = ev;
+ }
+}
+
+WMClient::WMClient(const string &appid, unsigned layer, const string &role)
+ : id(appid),
+ layer(layer),
+ main_role(role),
+ role2surface(0),
+ evname2afb_event(0)
+{
+ role2surface[role] = INVALID_SURFACE_ID;
+ for (auto x : kWMEvents)
+ {
+#if GTEST_ENABLED
+ string ev = x;
+#else
+ afb_event ev = afb_daemon_make_event(x.c_str());
+#endif
+ evname2afb_event[x] = ev;
+ }
+}
+
+string WMClient::appID() const
+{
+ return this->id;
+}
+
+string WMClient::role() const
+{
+ return this->main_role;
+}
+
+unsigned WMClient::layerID() const
+{
+ return this->layer;
+}
+
+unsigned WMClient::surfaceID() const
+{
+ return this->surface;
+}
+
+/**
+ * Add surface to the client
+ *
+ * This function add main surface to the client(ivi_layer).
+ *
+ * @param string[in] role
+ * @return WMError
+ */
+WMError WMClient::addSurface(unsigned surface)
+{
+ this->surface = surface;
+ ilmErrorTypes err = ilm_layerAddSurface(this->layer, surface);
+
+ if(err == ILM_SUCCESS)
+ {
+ err = ilm_commitChanges();
+ }
+ return (err == ILM_SUCCESS) ? WMError::SUCCESS : WMError::FAIL;
+}
+
+bool WMClient::removeSurfaceIfExist(unsigned surface)
+{
+ bool ret = false;
+ if(surface == this->surface)
+ {
+ this->surface = INVALID_SURFACE_ID;
+ ret = true;
+ }
+ else
+ {
+ for(auto &x : this->service2surfaces)
+ {
+ if(x.second = surface)
+ {
+ ret = true;
+ string key = x.first;
+ this->service2surfaces.erase(key);
+ this->service2supplier.erase(key);
+ }
+ }
+ }
+ return ret;
+}
+
+WMError WMClient::setRenderOrder(const vector<string> &order)
+{
+ WMError ret = WMError::SUCCESS;
+ this->surface_render_order.clear();
+ for(const auto& x : order)
+ {
+ unsigned s; // surface
+ if(x == this->role())
+ {
+ s = this->surfaceID();
+ }
+ else if(this->service2surfaces.count(x) != 0)
+ {
+ s = this->service2surfaces[x];
+ }
+ else
+ {
+ ret = WMError::NOT_REGISTERED;
+ break;
+ }
+ this->surface_render_order.push_back(s);
+ }
+ if(ret == WMError::SUCCESS)
+ {
+ int count = 0;
+ t_ilm_layer* id_array = new t_ilm_surface[this->surface_render_order.size()];
+ if(id_array == nullptr)
+ {
+ HMI_WARNING("short memory");
+ ret = WMError::FAIL;
+ }
+ else
+ {
+ for(const auto& i : this->surface_render_order)
+ {
+ id_array[count] = i;
+ ++count;
+ }
+ ilm_layerSetRenderOrder(this->layerID(),
+ id_array, this->surface_render_order.size());
+ delete id_array;
+ }
+ }
+ return ret;
+}
+
+string WMClient::attachTmpServiceSurface(const string& supplier, const string& service_surface)
+{
+ string uuid;
+ uuid_t u;
+ char out[37]; // uuid is 36 characters
+ uuid_generate_random(u);
+ uuid_unparse(u, out);
+ uuid = out;
+ this->service2supplier.emplace(service_surface, supplier);
+ return uuid;
+}
+
+WMError WMClient::attachServiceSurface(const string& service_surface, unsigned surface)
+{
+ WMError ret = WMError::NOT_REGISTERED;
+ if(this->service2supplier.count(service_surface) != 0)
+ {
+ this->service2surfaces.emplace(service_surface, surface);
+ ret = WMError::SUCCESS;
+ }
+ return ret;
+}
+
+#if GTEST_ENABLED
+bool WMClient::subscribe(afb_req req, const string &evname)
+{
+ if(evname != kKeyError){
+ HMI_DEBUG("error is only enabeled for now");
+ return false;
+ }
+ int ret = afb_req_subscribe(req, this->evname2afb_event[evname]);
+ if (ret)
+ {
+ HMI_DEBUG("Failed to subscribe %s", evname.c_str());
+ return false;
+ }
+ return true;
+}
+
+void WMClient::emitError(WM_CLIENT_ERROR_EVENT ev)
+{
+ if (!afb_event_is_valid(this->evname2afb_event[kKeyError])){
+ 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("error: %d, description:%s", ev, kErrorDescription[ev].c_str());
+
+ int ret = afb_event_push(this->evname2afb_event[kKeyError], j);
+ if (ret != 0)
+ {
+ HMI_DEBUG("afb_event_push failed: %m");
+ }
+}
+#endif
+
+void WMClient::dumpInfo()
+{
+ DUMP("APPID : %s", id.c_str());
+ DUMP(" LAYER : %d", layer);
+ DUMP(" ROLE : %s , SURFACE : %d", main_role.c_str(), surface);
+}
+
+} // namespace wm \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/src/wm_client.hpp b/demo3/common/agl-service-windowmanager/src/wm_client.hpp
new file mode 100644
index 0000000..fc171f4
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_client.hpp
@@ -0,0 +1,92 @@
+/*
+ * 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 WINDOWMANAGER_CLIENT_HPP
+#define WINDOWMANAGER_CLIENT_HPP
+
+#include <vector>
+#include <string>
+#include <unordered_map>
+#include "wm_error.hpp"
+
+extern "C"
+{
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+}
+
+namespace wm
+{
+
+enum WM_CLIENT_ERROR_EVENT
+{
+ UNKNOWN_ERROR
+};
+
+class WMClient
+{
+ public:
+ WMClient();
+ WMClient(const std::string &appid, unsigned layer,
+ unsigned surface, const std::string &role);
+ WMClient(const std::string &appid, const std::string &role);
+ WMClient(const std::string &appid, unsigned layer, const std::string &role);
+ WMClient(const std::string &appid, unsigned layer,
+ const std::string& layer_name, unsigned surface, const std::string &role);
+ ~WMClient() = default;
+
+ std::string appID() const;
+ std::string role() const;
+ unsigned layerID() const;
+ unsigned surfaceID() const;
+ // void setRole(const std::string& role);
+ // void appendRole(const std::string& role);
+ WMError addSurface(unsigned surface);
+ bool removeSurfaceIfExist(unsigned surface);
+ // bool removeRole(const std::string& role);
+ std::vector<unsigned> renderOrder() const;
+ WMError setRenderOrder(const std::vector<std::string>& order);
+ std::string attachTmpServiceSurface(const std::string& from, const std::string& service_surface);
+ WMError attachServiceSurface(const std::string& service_surface, unsigned surface);
+
+#if GTEST_ENABLED
+ bool subscribe(afb_req req, const std::string &event_name);
+ void emitError(WM_CLIENT_ERROR_EVENT ev);
+#endif
+
+ void dumpInfo();
+
+ private:
+ std::string id;
+ unsigned layer;
+ std::string main_role;
+ std::string area;
+ unsigned surface; // currently, main application has only one surface.
+ //std::vector<std::string> role_list;
+ std::vector<unsigned> surface_render_order;
+ std::unordered_map<std::string, unsigned> service2surfaces;
+ std::unordered_map<std::string, unsigned> role2surface;
+ std::unordered_map<std::string, std::string> service2supplier;
+#if GTEST_ENABLED
+ // This is for unit test. afb_make_event occurs sig11 if call not in afb-binding
+ std::unordered_map<std::string, std::string> evname2afb_event;
+#else
+ std::unordered_map<std::string, struct afb_event> evname2afb_event;
+#endif
+};
+} // namespace wm
+
+#endif \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/src/wm_connection.cpp b/demo3/common/agl-service-windowmanager/src/wm_connection.cpp
new file mode 100644
index 0000000..10ecc3b
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_connection.cpp
@@ -0,0 +1,457 @@
+/*
+ * 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 "wm_connection.hpp"
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include "json_helper.hpp"
+#include "util.hpp"
+
+extern "C"
+{
+#include <afb/afb-binding.h>
+#include <systemd/sd-event.h>
+}
+
+
+/**
+ * namespace wm
+ */
+namespace wm
+{
+
+
+namespace
+{
+
+static const char kPathConnectionConfigFile[] = "/etc/connection.json";
+static const char kDefaultIpAddr[] = "192.168.10.10";
+static const int kDefaultPort = 4000;
+
+static int onIoEventReceive(sd_event_source *src, int fd, uint32_t revents, void * data)
+{
+ WMConnection *p_wmcon = (WMConnection*)data;
+
+ json_object *j_out;
+ int ret = p_wmcon->receive(&j_out);
+ if (0 > ret)
+ {
+ return 0;
+ }
+
+ const char* rq = jh::getStringFromJson(j_out, "req");
+ const char* id = jh::getStringFromJson(j_out, "appid");
+ const char* dn = jh::getStringFromJson(j_out, "drawing_name");
+ const char* da = jh::getStringFromJson(j_out, "drawing_area");
+
+ HMI_DEBUG("req:%s appid:%s, drawing_name:%s, drawing_area:%s", rq, id, dn, da);
+
+ // Callback
+ p_wmcon->callOnReceivedHandler(j_out);
+
+ return 0;
+}
+
+static int onIoEventAccept(sd_event_source *src, int fd, uint32_t revents, void * data)
+{
+ struct sockaddr_in addr;
+
+ WMConnection *p_wmcon = (WMConnection*)data;
+
+ // Accept connection
+ socklen_t len = sizeof(addr);
+ int my_socket = p_wmcon->getMySocket();
+ int connected_socket = accept(my_socket, (struct sockaddr *)&addr, &len);
+ if (0 > connected_socket)
+ {
+ HMI_ERROR("Failed to accept connection (%s)", strerror(errno));
+ return -1;
+ }
+
+ // Store connected socket
+ p_wmcon->setConnectedSocket(connected_socket);
+
+ // Register callback to receive
+ int ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
+ connected_socket, EPOLLIN,
+ onIoEventReceive, p_wmcon);
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to add I/O event receive(%s)", strerror(-ret));
+ return -1;
+ }
+
+ return 0;
+}
+
+} // namespace
+
+WMConnection::WMConnection()
+{
+ // Load connection config file
+ this->loadConnectionConfigFile();
+
+ // TODO: ECU name should be decide by config file
+ this->ecu_name = this->mode;
+}
+
+int WMConnection::initialize()
+{
+ int ret;
+
+ // Initialize for Master/Slave
+ if (this->isMasterMode())
+ {
+ ret = this->initializeMaster();
+ }
+ else
+ {
+ ret = this->initializeSlave();
+ }
+
+ return ret;
+}
+
+void WMConnection::registerCallback(ReceivedHandler on_received)
+{
+ this->onReceived = on_received;
+}
+
+int WMConnection::sendRequest(char const *req, char const *appid,
+ char const *drawing_name, char const *drawing_area)
+{
+ int ret;
+ json_object *j_obj = json_object_new_object();
+ json_object_object_add(j_obj, "req", json_object_new_string(req));
+ json_object_object_add(j_obj, "appid", json_object_new_string(appid));
+ json_object_object_add(j_obj, "drawing_name", json_object_new_string(drawing_name));
+ json_object_object_add(j_obj, "drawing_area", json_object_new_string(drawing_area));
+
+ ret = this->send(j_obj);
+
+ json_object_put(j_obj);
+
+ return ret;
+}
+
+int WMConnection::send(struct json_object* j_in)
+{
+ // Convert json_object to string to send
+ const char *buf = json_object_to_json_string(j_in);
+ if (nullptr == buf)
+ {
+ HMI_ERROR("Failed to convert json_object to string");
+ return -1;
+ }
+
+ int len = strlen(buf);
+
+ HMI_DEBUG("Send data(len:%d): %s", len, buf);
+
+ int n = write(this->connected_socket, buf, len);
+ if(0 > n)
+ {
+ HMI_ERROR("Failed to send data (%s)", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+bool WMConnection::isMasterMode()
+{
+ if ("master" == this->mode)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool WMConnection::isMasterArea(const char* area)
+{
+ if (nullptr == area)
+ {
+ return false;
+ }
+
+ std::string str_area = std::string(area);
+ if ("" == str_area)
+ {
+ return false;
+ }
+
+ std::vector<std::string> elements;
+ elements = parseString(str_area, '.');
+
+ if ("master" == elements[0])
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool WMConnection::isConnecting()
+{
+ return (0 > this->connected_socket) ? false : true;
+}
+
+std::string WMConnection::parseMasterArea(const char* area)
+{
+ std::string ret_area = "";
+ std::vector<std::string> elements;
+ elements = parseString(std::string(area), '.');
+
+ if ("master" != elements[0])
+ {
+ return std::string(area);
+ }
+
+ for (auto itr = (elements.begin() + 1); itr != elements.end(); ++itr)
+ {
+ ret_area += *itr;
+
+ if ((elements.end() - 1) != itr)
+ {
+ ret_area += ".";
+ }
+ }
+ return ret_area;
+}
+
+bool WMConnection::isSyncDrawingForRemote(const char* appid)
+{
+ if (std::string(appid) == this->syndDrawingAppId)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void WMConnection::startSyncDrawForRemote(const char* appid)
+{
+ this->syndDrawingAppId = std::string(appid);
+}
+
+void WMConnection::finishSyncDrawForRemote(const char* appid)
+{
+ if (std::string(appid) == this->syndDrawingAppId)
+ {
+ this->syndDrawingAppId = "";
+ }
+}
+
+int WMConnection::getMySocket()
+{
+ return this->my_socket;
+}
+
+int WMConnection::getConnectedSocket()
+{
+ return this->connected_socket;
+}
+
+void WMConnection::setConnectedSocket(int connected_socket)
+{
+ this->connected_socket = connected_socket;
+}
+
+std::string WMConnection::getEcuName()
+{
+ return this->ecu_name;
+}
+
+void WMConnection::callOnReceivedHandler(json_object *j_out)
+{
+ this->onReceived(j_out);
+}
+
+int WMConnection::initializeMaster()
+{
+ int ret = 0;
+ struct sockaddr_in addr;
+
+ // Create socket
+ this->my_socket = socket(AF_INET, SOCK_STREAM, 0);
+ if (0 > this->my_socket)
+ {
+ HMI_ERROR("Failed to create socket (%s)", strerror(errno));
+ return -1;
+ }
+
+ // Bind socket
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(this->port);
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ ret = bind(this->my_socket, (struct sockaddr *)&addr, sizeof(addr));
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to bind socket (%s)", strerror(errno));
+ return -1;
+ }
+
+ // Listen connection
+ ret = listen(this->my_socket, 1);
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to listen connection (%s)", strerror(errno));
+ return -1;
+ }
+
+ // Register callback to accept connection
+ ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
+ this->my_socket, EPOLLIN,
+ onIoEventAccept, this);
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to add I/O event accept(%s)", strerror(-ret));
+ return -1;
+ }
+
+ return ret;
+}
+
+int WMConnection::initializeSlave()
+{
+ // Create socket
+ this->my_socket = socket(AF_INET, SOCK_STREAM, 0);
+ if (0 > this->my_socket)
+ {
+ HMI_ERROR("Failed to create socket (%s)", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int WMConnection::connectToMaster()
+{
+ int ret = 0;
+ struct sockaddr_in addr;
+
+ // Connect to master
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(this->port);
+ addr.sin_addr.s_addr = inet_addr(this->ip.c_str());
+
+ ret = connect(this->my_socket, (struct sockaddr *)&addr, sizeof(addr));
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to connect to master (%s)", strerror(errno));
+ return ret;
+ }
+
+ HMI_DEBUG("Connected to master");
+
+ // Store connected socket
+ this->connected_socket = this->my_socket;
+
+ // Register callback to receive
+ ret = sd_event_add_io(afb_daemon_get_event_loop(), nullptr,
+ this->connected_socket, EPOLLIN,
+ onIoEventReceive, this);
+ if (0 > ret)
+ {
+ HMI_ERROR("Failed to add I/O event receive(%s)", strerror(-ret));
+ return -1;
+ }
+
+ return ret;
+}
+
+int WMConnection::receive(struct json_object** j_out)
+{
+ char buf[1024];
+ int n;
+
+ n = read(this->connected_socket, buf, sizeof(buf));
+ if(0 > n)
+ {
+ HMI_ERROR("Failed to receive data (%s)", strerror(errno));
+ return -1;
+ }
+
+ HMI_DEBUG("Received data length: %d", n);
+ HMI_DEBUG("Received data: %s", buf);
+
+ // Parse received data
+ struct json_tokener *tokener = json_tokener_new();
+ *j_out = json_tokener_parse_ex(tokener, buf, n);
+ if (nullptr == *j_out)
+ {
+ HMI_DEBUG("Failed to parse received data");
+ return -1;
+ }
+
+ return 0;
+}
+
+int WMConnection::loadConnectionConfigFile()
+{
+ // Get afm application installed dir
+ char const *afm_app_install_dir = getenv("AFM_APP_INSTALL_DIR");
+ if (!afm_app_install_dir)
+ {
+ HMI_ERROR("AFM_APP_INSTALL_DIR is not defined");
+ }
+ std::string path = std::string(afm_app_install_dir) + std::string(kPathConnectionConfigFile);
+
+ // Load connection config file
+ json_object* json_obj;
+ int ret = jh::inputJsonFilie(path.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_ERROR("Could not open %s, so use default mode \"slave\"", kPathConnectionConfigFile);
+ this->mode = "slave";
+ this->ip = kDefaultIpAddr;
+ this->port = kDefaultPort;
+ return 0;
+ }
+ HMI_DEBUG("json_obj dump:%s", json_object_get_string(json_obj));
+
+ const char* mode = jh::getStringFromJson(json_obj, "mode");
+ this->mode = (nullptr != mode) ? mode : "slave";
+
+ const char* ip = jh::getStringFromJson(json_obj, "master_ip");
+ this->ip = (nullptr != ip) ? ip : kDefaultIpAddr;
+
+ int port = jh::getIntFromJson(json_obj, "master_port");
+ this->port = (0 != port) ? port : kDefaultPort;
+
+ // Check
+ HMI_DEBUG("mode:%s master_ip:%s master_port:%d", mode, ip, port);
+
+ // Release json_object
+ json_object_put(json_obj);
+
+ return 0;
+}
+
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/wm_connection.hpp b/demo3/common/agl-service-windowmanager/src/wm_connection.hpp
new file mode 100644
index 0000000..9d3180f
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_connection.hpp
@@ -0,0 +1,64 @@
+/*
+ * Insert Copyright if needed.
+ */
+
+#ifndef WM_CONNECTION_HPP
+#define WM_CONNECTION_HPP
+
+#include <functional>
+
+struct json_object;
+
+namespace wm
+{
+
+class WMConnection
+{
+ public:
+ WMConnection();
+ ~WMConnection() = default;
+
+ using ReceivedHandler = std::function<void(json_object* j_out)>;
+
+ int initialize();
+ void registerCallback(ReceivedHandler on_received);
+ int sendRequest(char const *req, char const *appid,
+ char const *drawing_name, char const *drawing_area);
+ bool isMasterMode();
+ bool isMasterArea(const char* area);
+ bool isConnecting();
+ std::string parseMasterArea(const char* area);
+ bool isSyncDrawingForRemote(const char* role);
+ void startSyncDrawForRemote(const char* role);
+ void finishSyncDrawForRemote(const char* role);
+ int getMySocket();
+ int getConnectedSocket();
+ void setConnectedSocket(int connected_socket);
+ std::string getEcuName();
+ void callOnReceivedHandler(json_object *j_out);
+ int connectToMaster();
+
+ int receive(json_object** j_out);
+
+ private:
+ std::string mode;
+ std::string ip;
+ int port;
+ int my_socket = -1;
+ int connected_socket = -1;
+ ReceivedHandler onReceived;
+ std::string syndDrawingAppId;
+
+ std::string ecu_name;
+
+ int initializeMaster();
+ int initializeSlave();
+ int loadConnectionConfigFile();
+
+ int send(json_object* j_in);
+};
+
+} // namespace wm
+
+#endif // WM_CONNECTION_HPP
+
diff --git a/demo3/common/agl-service-windowmanager/src/wm_error.cpp b/demo3/common/agl-service-windowmanager/src/wm_error.cpp
new file mode 100644
index 0000000..694a7d0
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_error.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "wm_error.hpp"
+
+namespace wm {
+
+const char *errorDescription(WMError enum_error_number)
+{
+ switch (enum_error_number){
+ case SUCCESS:
+ return "Success";
+ case FAIL:
+ return "Request failed";
+ case REQ_REJECTED:
+ return "Request is rejected, due to the policy rejection of the request.";
+ case REQ_DROPPED:
+ return "Request is dropped, because the high priority request is done";
+ case NOT_REGISTERED:
+ return "Not registered";
+ case TIMEOUT_EXPIRED:
+ return "Request is dropped, due to time out expiring";
+ case LAYOUT_CHANGE_FAIL:
+ return "Layout change fails, due to some reasons";
+ case NO_ENTRY:
+ return "No element";
+ case NO_LAYOUT_CHANGE:
+ return "No layout change(deactivate only)";
+ default:
+ return "Unknown error number. Window manager bug.";
+ }
+}
+
+} \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/src/wm_error.hpp b/demo3/common/agl-service-windowmanager/src/wm_error.hpp
new file mode 100644
index 0000000..c4c61b4
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_error.hpp
@@ -0,0 +1,41 @@
+/*
+ * 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 WINDOW_MANAGER_ERROR
+#define WINDOW_MANAGER_ERROR
+
+namespace wm {
+
+typedef enum WINDOWMANAGER_ERROR
+{
+ SUCCESS = 0,
+ FAIL,
+ REQ_REJECTED,
+ REQ_DROPPED,
+ TIMEOUT_EXPIRED,
+ NOT_REGISTERED,
+ LAYOUT_CHANGE_FAIL,
+ NO_ENTRY,
+ NO_LAYOUT_CHANGE,
+ UNKNOWN,
+ ERR_MAX = UNKNOWN
+}
+WMError;
+
+const char *errorDescription(WMError enum_error_number);
+
+}
+#endif // WINDOW_MANAGER_ERROR \ No newline at end of file
diff --git a/demo3/common/agl-service-windowmanager/src/wm_layer.cpp b/demo3/common/agl-service-windowmanager/src/wm_layer.cpp
new file mode 100644
index 0000000..d3e7073
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_layer.cpp
@@ -0,0 +1,271 @@
+/*
+ * 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 <regex>
+#include <ilm/ilm_control.h>
+#include <stdlib.h>
+#include "wm_client.hpp"
+#include "wm_layer.hpp"
+#include "json_helper.hpp"
+#include "util.hpp"
+
+using std::string;
+using std::vector;
+using std::unordered_map;
+
+#define BG_LAYER_NAME "BackGroundLayer"
+
+namespace wm
+{
+
+LayerState::LayerState()
+ : render_order(),
+ area2appid()
+{}
+
+
+void LayerState::attachIdToArea(const string& area, const WMClient& client)
+{
+ this->area2appid[area] = client.appID();
+ this->render_order.push_back(client.layerID());
+}
+
+const unordered_map<string, string> LayerState::popCurrentState()
+{
+ unordered_map<string, string> tmp = this->area2appid;
+ this->area2appid.clear();
+ this->render_order.clear();
+ return tmp;
+}
+
+const unordered_map<string, string> LayerState::getCurrentState()
+{
+ return this->area2appid;
+}
+
+const vector<unsigned> LayerState::getIviIdList()
+{
+ return this->render_order;
+}
+
+void LayerState::addLayer(unsigned layer)
+{
+ auto result = std::find(this->render_order.begin(), this->render_order.end(), layer);
+ if(result == this->render_order.end())
+ this->render_order.push_back(layer);
+}
+
+void LayerState::removeLayer(unsigned layer)
+{
+ auto fwd_itr = std::remove_if(
+ this->render_order.begin(), this->render_order.end(),
+ [layer](unsigned elm) {
+ if(elm == layer)
+ HMI_DEBUG("remove layer %d", elm);
+ return elm == layer;
+ }
+ );
+ this->render_order.erase(fwd_itr, this->render_order.end());
+}
+
+void LayerState::setArea(const string& app, const string& area)
+{
+ this->area2appid[area] = app;
+}
+
+void LayerState::dump()
+{
+ std::string ids, apps;
+ for(const auto& ro : this->render_order)
+ {
+ ids += std::to_string(ro);
+ ids += ",";
+ }
+ for(const auto& area : this->area2appid)
+ {
+ apps += area.first;
+ apps += ":";
+ apps += area.second;
+ apps += ",";
+ }
+ DUMP(" render order : %s", ids.c_str());
+ DUMP(" area, app : %s", apps.c_str());
+}
+
+WMLayer::WMLayer(json_object* j, unsigned uuid) : tmp_state(), state(), uuid(uuid)
+{
+ this->name = jh::getStringFromJson(j, "name");
+ this->role_list = jh::getStringFromJson(j, "role");
+ const char* type = jh::getStringFromJson(j, "type");
+ this->id_begin = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_begin"));
+ this->id_end = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_end"));
+
+ if (name.size() == 0 || !type)
+ {
+ HMI_ERROR("Parse Error!!");
+ exit(1);
+ }
+ if(this->id_begin > this->id_end)
+ {
+ HMI_ERROR("INVALID");
+ exit(1);
+ }
+ string str_type = type;
+ this->type = (str_type == "tile") ? MANAGEMENT_TYPE::TILE : MANAGEMENT_TYPE::STACK;
+}
+
+unsigned WMLayer::getNewLayerID(const string& role)
+{
+ unsigned ret = 0;
+ if(this->name == BG_LAYER_NAME)
+ return ret;
+
+ // generate new layer id;
+ if(this->hasRole(role))
+ {
+ if(this->id_list.size() == 0)
+ {
+ ret = this->idBegin();
+ this->id_list.push_back(ret);
+ }
+ else
+ {
+ ret = this->id_list.back() + 1;
+ }
+ HMI_INFO("Generate new id: %d", ret);
+ }
+ else
+ {
+ return ret;
+ }
+
+ size_t count = std::count(id_list.begin(), id_list.end(), ret);
+ if( (ret > this->idEnd()) || (count > 1))
+ {
+ HMI_NOTICE("id %d is not available then generate new id", ret);
+ ret = 0; // reset
+ for(unsigned i = this->idBegin(); i < this->idEnd(); i++)
+ {
+ auto ret_found = std::find(id_list.begin(), id_list.end(), i);
+ if(ret_found == id_list.cend())
+ {
+ HMI_INFO("set new id: %d", i);
+ ret = i;
+ break;
+ }
+ }
+ }
+
+ if(ret != 0)
+ {
+ id_list.push_back(ret);
+ }
+ else
+ {
+ HMI_ERROR("failed to get New ID");
+ }
+ return ret;
+}
+
+const string& WMLayer::layerName()
+{
+ return this->name;
+}
+
+WMError WMLayer::setLayerState(const LayerState& l)
+{
+ this->tmp_state = l;
+ return WMError::SUCCESS;
+}
+
+void WMLayer::addLayerToState(unsigned layer)
+{
+ this->tmp_state.addLayer(layer);
+}
+
+void WMLayer::removeLayerFromState(unsigned layer)
+{
+ this->tmp_state.removeLayer(layer);
+}
+
+void WMLayer::setAreaToState(const string& app, const string& area)
+{
+ this->tmp_state.setArea(app, area);
+}
+
+void WMLayer::appendArea(const string& area)
+{
+ this->area_list.push_back(area);
+}
+
+void WMLayer::terminateApp(unsigned id)
+{
+ auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
+ [id](unsigned elm) {
+ return elm == id;
+ });
+ this->id_list.erase(fwd_itr, this->id_list.end());
+ this->tmp_state.removeLayer(id);
+ this->state.removeLayer(id);
+ ilm_layerRemove(id);
+}
+
+bool WMLayer::hasLayerID(unsigned id)
+{
+ bool ret = (id >= this->idBegin() && id <= this->idEnd());
+ if(!ret)
+ return ret;
+ auto itr = std::find(this->id_list.begin(), this->id_list.end(), id);
+ return (itr != this->id_list.end()) ? true : false;
+}
+
+bool WMLayer::hasRole(const string& role)
+{
+ auto re = std::regex(this->role_list);
+ if (std::regex_match(role, re))
+ {
+ HMI_DEBUG("role %s matches layer %s", role.c_str(), this->name.c_str());
+ return true;
+ }
+ return false;
+}
+
+void WMLayer::update()
+{
+ this->state = this->tmp_state;
+}
+
+void WMLayer::undo()
+{
+ this->tmp_state = this->state;
+}
+
+void WMLayer::dump()
+{
+ DUMP("===== wm layer status =====");
+ DUMP("Layer :%s", this->name.c_str());
+ this->tmp_state.dump();
+ this->state.dump();
+ DUMP("===== wm layer status end =====");
+
+}
+
+/* void WMLayer::undo()
+{
+ this->tmp_state = this->state;
+}
+ */
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/wm_layer.hpp b/demo3/common/agl-service-windowmanager/src/wm_layer.hpp
new file mode 100644
index 0000000..a6a359e
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_layer.hpp
@@ -0,0 +1,104 @@
+/*
+ * 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 WM_LAYER_HPP
+#define WM_LAYER_HPP
+
+#include <string>
+#include <vector>
+#include <unordered_map>
+#include <memory>
+#include "wm_error.hpp"
+
+struct json_object;
+
+namespace wm
+{
+
+class WMClient;
+class LayerState
+{
+ public:
+ LayerState();
+ ~LayerState() = default;
+ void attachIdToArea(const std::string& area, const WMClient&);
+ const std::unordered_map<std::string, std::string> popCurrentState();
+ const std::unordered_map<std::string, std::string> getCurrentState();
+ const std::vector<unsigned> getIviIdList();
+ void addLayer(unsigned layer);
+ void removeLayer(unsigned layer);
+ void setArea(const std::string& app, const std::string& area);
+
+ // Debug
+ void dump();
+
+ private:
+ std::vector<unsigned> render_order;
+ std::unordered_map<std::string, std::string> area2appid;
+};
+
+class WMLayer
+{
+ public:
+ enum MANAGEMENT_TYPE
+ {
+ TILE,
+ STACK
+ };
+
+ explicit WMLayer(json_object* j, unsigned uuid);
+ ~WMLayer() = default;
+
+ // Status & Setting API
+ unsigned getNewLayerID(const std::string& role);
+ unsigned idBegin() { return this->id_begin; }
+ unsigned idEnd() { return this->id_end; }
+ unsigned getUuid() { return this->uuid; }
+ const std::string& layerName();
+ MANAGEMENT_TYPE layerType() { return this->type; }
+ void appendArea(const std::string& area);
+ LayerState& getLayerState() { return tmp_state; }
+ WMError setLayerState(const LayerState& l);
+ bool hasLayerID(unsigned id);
+ bool hasRole(const std::string& role);
+
+ // Manipulation
+ void addLayerToState(unsigned layer);
+ void removeLayerFromState(unsigned layer);
+ void setAreaToState(const std::string& app, const std::string& area);
+ void terminateApp(unsigned layer);
+ void update();
+ void undo();
+
+ // Debug
+ void dump();
+
+ private:
+ LayerState tmp_state;
+ LayerState state;
+ unsigned uuid;
+ std::string name = ""; // Layer name
+ MANAGEMENT_TYPE type;
+ std::string role_list;
+ std::vector<std::string> area_list;
+ std::vector<unsigned> id_list;
+ unsigned id_begin;
+ unsigned id_end;
+};
+
+} // namespace wm
+
+#endif // WM_LAYER_HPP
diff --git a/demo3/common/agl-service-windowmanager/src/wm_layer_control.cpp b/demo3/common/agl-service-windowmanager/src/wm_layer_control.cpp
new file mode 100644
index 0000000..80dc0c9
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_layer_control.cpp
@@ -0,0 +1,911 @@
+/*
+ * 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 <assert.h>
+#include <unistd.h>
+#include "wm_layer_control.hpp"
+#include "wm_layer.hpp"
+#include "wm_client.hpp"
+#include "request.hpp"
+#include "json_helper.hpp"
+
+#define LC_AREA_PATH "/etc/areas.json"
+#define LC_LAYER_SETTING_PATH "/etc/layers_setting.json"
+#define LC_DEFAULT_AREA "fullscreen"
+#define BACK_GROUND_LAYER "BackGroundLayer"
+
+using std::string;
+using std::vector;
+using std::shared_ptr;
+
+namespace wm {
+
+LayerControl* g_lc_ctxt;
+
+static void createCallback_static(ilmObjectType object,
+ t_ilm_uint id,
+ t_ilm_bool created,
+ void* data)
+{
+ static_cast<LayerControl*>(data)->dispatchCreateEvent(object, id, created);
+}
+
+static void surfaceCallback_static(t_ilm_surface surface,
+ struct ilmSurfaceProperties* surface_prop,
+ t_ilm_notification_mask mask)
+{
+ g_lc_ctxt->dispatchSurfacePropChangeEvent(surface, surface_prop, mask);
+}
+
+static void layerCallback_static(t_ilm_layer layer,
+ struct ilmLayerProperties* layer_prop,
+ t_ilm_notification_mask mask)
+{
+ g_lc_ctxt->dispatchLayerPropChangeEvent(layer, layer_prop, mask);
+}
+
+LayerControl::LayerControl(const std::string& root, const std::string& ecu_name)
+{
+ string area_path = root + LC_AREA_PATH;
+ string layer_path= root + LC_LAYER_SETTING_PATH;
+ // load layers.setting.json
+ WMError ret = this->loadLayerSetting(layer_path);
+ assert(ret == WMError::SUCCESS);
+ // load areas.json
+ ret = this->loadAreasConfigFile(area_path, ecu_name);
+ assert(ret == WMError::SUCCESS);
+}
+
+WMError LayerControl::init(const LayerControlCallbacks& cb)
+{
+ HMI_DEBUG("Initialize of ilm library and display");
+ t_ilm_uint num = 0;
+ t_ilm_uint *ids;
+ int cnt = 0;
+ ilmErrorTypes rc = ilm_init();
+
+ while (rc != ILM_SUCCESS)
+ {
+ cnt++;
+ if (20 <= cnt)
+ {
+ HMI_ERROR("Could not connect to compositor");
+ goto lc_init_error;
+ }
+ HMI_ERROR("Wait to start weston ...");
+ sleep(1);
+ rc = ilm_init();
+ }
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ // Get current screen setting
+ rc = ilm_getScreenIDs(&num, &ids);
+
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ for(unsigned i = 0; i < num; i++)
+ {
+ HMI_INFO("get screen: %d", ids[i]);
+ }
+ // Currently, 0 is only available
+ this->screenID = ids[0];
+
+ if (1 < num)
+ {
+ // TODO: set remote screen id
+ HMI_INFO("There is remote screen (id:%d)", ids[1]);
+ this->remoteScreenID = ids[1];
+ }
+ else
+ {
+ HMI_INFO("There is no remote screen");
+ this->remoteScreenID = -1;
+ }
+
+ rc = ilm_getPropertiesOfScreen(this->screenID, &this->screen_prop);
+
+ if(rc != ILM_SUCCESS) goto lc_init_error;
+
+ // Register Callback to Window Manager and from ILM
+ this->cb = cb;
+ ilm_registerNotification(createCallback_static, this);
+
+ return WMError::SUCCESS;
+
+lc_init_error:
+ HMI_ERROR("Failed to initialize. Terminate WM");
+
+ return WMError::FAIL;
+}
+
+void LayerControl::createNewLayer(unsigned id)
+{
+ HMI_INFO("create new ID :%d", id);
+ struct rect rct = this->area2size[LC_DEFAULT_AREA];
+ ilm_layerCreateWithDimension(&id, rct.w, rct.h);
+ //ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
+ ilm_layerSetDestinationRectangle(id, this->offset_x, this->offset_y, rct.w, rct.h);
+ ilm_layerSetOpacity(id, 1.0);
+ ilm_layerSetVisibility(id, ILM_FALSE);
+ ilm_commitChanges();
+ auto wm_layer = getWMLayer(id);
+ wm_layer->addLayerToState(id);
+ this->renderLayers();
+ this->renderLayersRemote();
+}
+
+void LayerControl::createNewRemoteLayer(unsigned id)
+{
+ HMI_INFO("create new ID :%d (For remote layer)", id);
+ struct rect rct = {640, 720, 0, 0};
+ ilm_layerCreateWithDimension(&id, rct.w, rct.h);
+ //ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);
+ ilm_layerSetDestinationRectangle(id, this->offset_x, this->offset_y, rct.w, rct.h);
+ ilm_layerSetOpacity(id, 1.0);
+ ilm_layerSetVisibility(id, ILM_FALSE);
+ ilm_commitChanges();
+ auto wm_layer = getWMLayer(id);
+ wm_layer->addLayerToState(id);
+ this->renderLayers();
+ this->renderLayersRemote();
+}
+
+unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)
+{
+ unsigned ret = 0;
+ for(const auto& l: this->wm_layers)
+ {
+ ret = l->getNewLayerID(role);
+ if(ret != 0)
+ {
+ *layer_name = l->layerName();
+ unsigned uid = l->getUuid();
+ this->lid2wmlid[ret] = uid;
+ break;
+ }
+ }
+ return ret;
+}
+
+shared_ptr<WMLayer> LayerControl::getWMLayer(unsigned layer)
+{
+ unsigned uuid = this->lid2wmlid[layer];
+ return this->wm_layers[uuid];
+}
+
+std::shared_ptr<WMLayer> LayerControl::getWMLayer(std::string layer_name)
+{
+ for(auto &l : this->wm_layers)
+ {
+ if(l->layerName() == layer_name)
+ {
+ return l;
+ }
+ }
+ return nullptr;
+}
+
+struct rect LayerControl::getAreaSize(const std::string& area)
+{
+ return area2size[area];
+}
+
+void LayerControl::setupArea(const rectangle& base_rct, double scaling)
+{
+ this->scaling = scaling;
+ this->offset_x = base_rct.left();
+ this->offset_y = base_rct.top();
+
+ for (auto &i : this->area2size)
+ {
+ i.second.x = static_cast<int>(scaling * i.second.x + 0.5);
+ i.second.y = static_cast<int>(scaling * i.second.y + 0.5);
+ i.second.w = static_cast<int>(scaling * i.second.w + 0.5);
+ i.second.h = static_cast<int>(scaling * i.second.h + 0.5);
+
+ 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);
+ }
+}
+
+Screen LayerControl::getScreenInfo()
+{
+ return Screen(this->screen_prop.screenWidth, this->screen_prop.screenHeight);
+}
+
+double LayerControl::scale()
+{
+ return this->scaling;
+}
+
+WMError LayerControl::updateLayer(LayerState& layer_state)
+{
+ return WMError::SUCCESS;
+}
+
+WMError LayerControl::renderLayers()
+{
+ HMI_INFO("Commit change");
+ WMError rc = WMError::SUCCESS;
+
+ // Check the number of layers
+ vector<unsigned> ivi_l_ids;
+ for(auto& l : this->wm_layers)
+ {
+ auto state = l->getLayerState();
+ HMI_DEBUG("layer %s", l->layerName().c_str());
+ for(const auto& id : state.getIviIdList())
+ {
+ HMI_DEBUG("Add %d", id);
+ ivi_l_ids.push_back(id);
+ }
+ }
+
+ // Create render order
+ t_ilm_layer* id_array = new t_ilm_layer[ivi_l_ids.size()];
+ if(id_array == nullptr)
+ {
+ HMI_WARNING("short memory");
+ this->undoUpdate();
+ return WMError::FAIL;
+ }
+ int count = 0;
+ for(const auto& i : ivi_l_ids)
+ {
+ id_array[count] = i;
+ ++count;
+ }
+
+ // Display
+ ilmErrorTypes ret = ilm_displaySetRenderOrder(this->screenID, id_array, ivi_l_ids.size());
+ if(ret != ILM_SUCCESS)
+ {
+ this->undoUpdate();
+ rc = WMError::FAIL;
+ }
+ else
+ {
+ for(auto& l : this->wm_layers)
+ {
+ l->update();
+ }
+ }
+ ilm_commitChanges();
+ delete id_array;
+ return rc;
+}
+
+WMError LayerControl::renderLayersRemote()
+{
+ HMI_INFO("Commit change");
+ WMError rc = WMError::SUCCESS;
+
+ if (0 > this->remoteScreenID)
+ {
+ return rc;
+ }
+
+ // Check the number of layers
+ vector<unsigned> ivi_l_ids;
+ for(auto& l : this->wm_remote_layers)
+ {
+ auto state = l->getLayerState();
+ HMI_DEBUG("layer %s", l->layerName().c_str());
+ for(const auto& id : state.getIviIdList())
+ {
+ HMI_DEBUG("Add %d", id);
+ ivi_l_ids.push_back(id);
+ }
+ }
+
+ if (0 == ivi_l_ids.size())
+ {
+ ilm_displaySetRenderOrder(this->remoteScreenID, nullptr, 0);
+ return rc;
+ }
+
+ // Create render order
+ t_ilm_layer* id_array = new t_ilm_layer[ivi_l_ids.size()];
+ if(id_array == nullptr)
+ {
+ HMI_WARNING("short memory");
+ this->undoUpdate();
+ return WMError::FAIL;
+ }
+ int count = 0;
+ for(const auto& i : ivi_l_ids)
+ {
+ id_array[count] = i;
+ ++count;
+ }
+
+ // Display
+ ilmErrorTypes ret = ilm_displaySetRenderOrder(this->remoteScreenID, id_array, ivi_l_ids.size());
+ if(ret != ILM_SUCCESS)
+ {
+ this->undoUpdate();
+ rc = WMError::FAIL;
+ }
+ else
+ {
+ for(auto& l : this->wm_remote_layers)
+ {
+ l->update();
+ }
+ }
+ ilm_commitChanges();
+ delete id_array;
+ return rc;
+}
+
+WMError LayerControl::setXDGSurfaceOriginSize(unsigned surface)
+{
+ WMError ret = WMError::NOT_REGISTERED;
+ ilmSurfaceProperties prop;
+ ilmErrorTypes rc = ilm_getPropertiesOfSurface(surface, &prop);
+ if(rc == ILM_SUCCESS)
+ {
+ HMI_INFO("xdg surface info %d, %d", prop.origSourceWidth, prop.origSourceHeight);
+ ilm_surfaceSetSourceRectangle(surface, 0, 0, prop.origSourceWidth, prop.origSourceHeight);
+ ret = WMError::SUCCESS;
+ }
+ return ret;
+}
+
+
+void LayerControl::undoUpdate()
+{
+ for(auto& l : this->wm_layers)
+ {
+ l->undo();
+ }
+}
+
+WMError LayerControl::loadLayerSetting(const string &path)
+{
+ HMI_DEBUG("loading WMLayer(Application Containers) Setting from %s", path);
+
+ json_object *json_obj, *json_cfg;
+ int ret = jh::inputJsonFilie(path.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_ERROR("Could not open %s", path.c_str());
+ return WMError::FAIL;
+ }
+ HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));
+
+ if (!json_object_object_get_ex(json_obj, "mappings", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ int len = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg len:%d", len);
+
+ for (int i = 0; i < len; i++)
+ {
+ json_object *json_tmp = json_object_array_get_idx(json_cfg, i);
+ HMI_DEBUG("> json_tmp dump:%s", json_object_get_string(json_tmp));
+
+ this->wm_layers.emplace_back(std::make_shared<WMLayer>(json_tmp, i));
+ }
+ json_object_put(json_obj);
+
+ return WMError::SUCCESS;
+}
+
+WMError LayerControl::loadAreasConfigFile(const std::string& path, const std::string& ecu_name)
+{
+ // Load areas config file
+ json_object *json_obj;
+ int ret = jh::inputJsonFilie(path.c_str(), &json_obj);
+ if (0 > ret)
+ {
+ HMI_ERROR("Could not open %s", path.c_str());
+ return WMError::FAIL;
+ }
+ HMI_INFO("json_obj dump:%s", json_object_get_string(json_obj));
+
+ // Parse ecus
+ json_object *json_cfg;
+ if (!json_object_object_get_ex(json_obj, "ecus", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ int num_ecu = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(ecus) len:%d", num_ecu);
+
+ const char* c_ecu_name;
+ json_object *json_ecu;
+ for (int i = 0; i < num_ecu; i++)
+ {
+ json_ecu= json_object_array_get_idx(json_cfg, i);
+
+ c_ecu_name = jh::getStringFromJson(json_ecu, "name");
+ if (nullptr == c_ecu_name)
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ if (ecu_name == string(c_ecu_name))
+ {
+ break;
+ }
+ else
+ {
+ json_ecu = nullptr;
+ }
+ }
+
+ if (!json_ecu)
+ {
+ HMI_ERROR("Areas for ecu:%s is NOT exist!!", ecu_name.c_str());
+ return WMError::FAIL;
+ }
+
+ // Parse screens
+ if (!json_object_object_get_ex(json_ecu, "screens", &json_cfg))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ int num_screen = json_object_array_length(json_cfg);
+ HMI_DEBUG("json_cfg(screens) len:%d", num_screen);
+
+ int screen_id;
+ json_object *json_screen;
+ for (int i = 0; i < num_screen; i++)
+ {
+ json_screen = json_object_array_get_idx(json_cfg, i);
+ HMI_INFO("json_cfg dump:%s", json_object_get_string(json_cfg));
+
+ // TODO: Currently only one display is connected to a ECU.
+
+ screen_id = jh::getIntFromJson(json_screen, "id");
+
+ // Parse areas
+ json_object *json_tmp;
+ if (!json_object_object_get_ex(json_screen, "areas", &json_tmp))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ int num_area = json_object_array_length(json_tmp);
+ HMI_DEBUG("json_tmp(areas) len:%d", num_area);
+
+ const char *area;
+ for (int j = 0; j < num_area; j++)
+ {
+ json_object *json_area = json_object_array_get_idx(json_tmp, j);
+
+ area = jh::getStringFromJson(json_area, "name");
+ if (nullptr == area)
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+ HMI_DEBUG("> area:%s", area);
+
+ json_object *json_rect;
+ if (!json_object_object_get_ex(json_area, "rect", &json_rect))
+ {
+ HMI_ERROR("Parse Error!!");
+ return WMError::FAIL;
+ }
+
+ struct rect area_size;
+ area_size.x = jh::getIntFromJson(json_rect, "x");
+ area_size.y = jh::getIntFromJson(json_rect, "y");
+ area_size.w = jh::getIntFromJson(json_rect, "w");
+ area_size.h = jh::getIntFromJson(json_rect, "h");
+
+ this->area2size[area] = area_size;
+ }
+
+ // Check
+ for (const auto& itr : this->area2size)
+ {
+ 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);
+ }
+ }
+
+ // Release json_object
+ json_object_put(json_obj);
+
+ return WMError::SUCCESS;
+}
+
+WMError LayerControl::layoutChange(const WMAction& action)
+{
+ if ((action.visible == TaskVisible::INVISIBLE) ||
+ (action.visible == TaskVisible::REQ_REMOTE_VISIBLE) ||
+ (action.visible == TaskVisible::REQ_REMOTE_INVISIBLE))
+ {
+ // Visibility is not change -> no redraw is required
+ return WMError::SUCCESS;
+ }
+ if(action.client == nullptr)
+ {
+ HMI_SEQ_ERROR(action.req_num, "client may vanish");
+ return WMError::NOT_REGISTERED;
+ }
+ unsigned layer = action.client->layerID();
+ unsigned surface = action.client->surfaceID();
+
+ auto rect = this->getAreaSize(action.area);
+ HMI_DEBUG("Set layout %d, %d, %d, %d",rect.x, rect.y, rect.w, rect.h);
+
+ // TO BE FIXED:
+ // Sometimes, ivi_wm_surface_size signal doesn't reach window manager,
+ // then, Window Manager can't set source size.
+ // This fixes it but it takes about 200ns(on R-Car M3) wastefully
+ ilmSurfaceProperties sp;
+ ilm_getPropertiesOfSurface(surface, &sp);
+ if(sp.origSourceHeight != sp.sourceHeight) {
+ HMI_SEQ_NOTICE(action.req_num, "WORK AROUND: set source size w:%d h%d", sp.origSourceWidth, sp.origSourceHeight);
+ ilm_surfaceSetSourceRectangle(surface, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
+ ilm_commitChanges();
+ }
+
+ ilm_surfaceSetDestinationRectangle(surface, rect.x, rect.y, rect.w, rect.h);
+ ilm_commitChanges();
+ for(auto &wm_layer: this->wm_layers)
+ {
+ // Store the state who is assigned to the area
+ if(wm_layer->hasLayerID(layer))
+ {
+ wm_layer->setAreaToState(action.client->appID(), action.area);
+ /* TODO: manipulate state directly
+ LayerState ls = wm_layer->getLayerState();
+ ls.setArea(action.client->appID(), action.area);
+ wm_layer->dump(); */
+ }
+ }
+
+ return WMError::SUCCESS;
+}
+
+WMError LayerControl::visibilityChange(const WMAction& action)
+{
+ WMError ret = WMError::FAIL;
+ if(action.client == nullptr)
+ {
+ HMI_SEQ_ERROR(action.req_num, "client may vanish");
+ return WMError::NOT_REGISTERED;
+ }
+
+ if (action.visible == TaskVisible::VISIBLE)
+ {
+ ret = this->makeVisible(action.client);
+ }
+ else if (action.visible == TaskVisible::INVISIBLE)
+ {
+ ret = this->makeInvisible(action.client);
+ }
+ else if (action.visible == TaskVisible::REMOTE_VISIBLE)
+ {
+ ret = this->makeRemoteVisible(action.client);
+ }
+ else if (action.visible == TaskVisible::REMOTE_INVISIBLE)
+ {
+ ret = this->makeRemoteInvisible(action.client);
+ }
+ else // TaskVisible::REQ_REMOTE_VISIBLE || TaskVisible::REQ_REMOTE_INVISIBLE
+ {
+ // Visibility is not change
+ ret = WMError::SUCCESS;
+ }
+
+ return ret;
+}
+
+void LayerControl::terminateApp(const shared_ptr<WMClient> client)
+{
+ for(auto& l : this->wm_layers)
+ {
+ l->terminateApp(client->layerID());
+ }
+}
+
+void LayerControl::dispatchCreateEvent(ilmObjectType object, unsigned id, bool created)
+{
+ if (ILM_SURFACE == object)
+ {
+ if (created)
+ {
+ ilmSurfaceProperties sp;
+ ilmErrorTypes rc;
+ rc = ilm_getPropertiesOfSurface(id, &sp);
+ if(rc != ILM_SUCCESS)
+ {
+ HMI_ERROR("Failed to get surface %d property due to %d", id, ilm_getError());
+ return;
+ }
+ this->cb.surfaceCreated(sp.creatorPid, id);
+ ilm_surfaceSetSourceRectangle(id, 0, 0, sp.origSourceWidth, sp.origSourceHeight);
+ ilm_surfaceAddNotification(id, surfaceCallback_static);
+ ilm_surfaceSetVisibility(id, ILM_TRUE);
+ ilm_surfaceSetType(id, ILM_SURFACETYPE_DESKTOP);
+ }
+ else
+ {
+ this->cb.surfaceDestroyed(id);
+ }
+ }
+ if (ILM_LAYER == object)
+ {
+ if(created)
+ {
+ ilm_layerAddNotification(id, layerCallback_static);
+ }
+ else
+ {
+ // Ignore here. Nothing to do currently.
+ // Process of application dead is handled by Window Manager
+ // from binder notification
+ }
+ }
+}
+
+void LayerControl::dispatchSurfacePropChangeEvent(unsigned id,
+ struct ilmSurfaceProperties* sprop,
+ t_ilm_notification_mask mask)
+{
+ /*
+ ILM_NOTIFICATION_CONTENT_AVAILABLE & ILM_NOTIFICATION_CONTENT_REMOVED
+ are not handled here, handled in create/destroy event
+ */
+ if (ILM_NOTIFICATION_VISIBILITY & mask)
+ {
+ HMI_DEBUG("surface %d turns visibility %d", id, sprop->visibility);
+ }
+ if (ILM_NOTIFICATION_OPACITY & mask)
+ {
+ HMI_DEBUG("surface %d turns opacity %f", id, sprop->opacity);
+ }
+ if (ILM_NOTIFICATION_SOURCE_RECT & mask)
+ {
+ HMI_DEBUG("surface %d source rect changes", id);
+ }
+ if (ILM_NOTIFICATION_DEST_RECT & mask)
+ {
+ HMI_DEBUG("surface %d dest rect changes", id);
+ }
+ if (ILM_NOTIFICATION_CONFIGURED & mask)
+ {
+ HMI_DEBUG("surface %d size %d, %d, %d, %d", id,
+ sprop->sourceX, sprop->sourceY, sprop->origSourceWidth, sprop->origSourceHeight);
+ ilm_surfaceSetSourceRectangle(id, 0, 0, sprop->origSourceWidth, sprop->origSourceHeight);
+ }
+}
+
+void LayerControl::dispatchLayerPropChangeEvent(unsigned id,
+ struct ilmLayerProperties* lprop,
+ t_ilm_notification_mask mask)
+{
+ if (ILM_NOTIFICATION_VISIBILITY & mask)
+ {
+ HMI_DEBUG("layer %d turns visibility %d", id, lprop->visibility);
+ }
+ if (ILM_NOTIFICATION_OPACITY & mask)
+ {
+ HMI_DEBUG("layer %d turns opacity %f", id, lprop->opacity);
+ }
+ if (ILM_NOTIFICATION_SOURCE_RECT & mask)
+ {
+ HMI_DEBUG("layer %d source rect changes", id);
+ }
+ if (ILM_NOTIFICATION_DEST_RECT & mask)
+ {
+ HMI_DEBUG("layer %d dest rect changes", id);
+ }
+}
+
+WMError LayerControl::makeVisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ // Don't check here the client is not nullptr
+ unsigned layer = client->layerID();
+
+ this->moveForeGround(client);
+
+ ilm_layerSetVisibility(layer, ILM_TRUE);
+
+ /* for(auto& wm_layer : this->wm_layers)
+ {
+ if(wm_layer->hasLayerID(layer))
+ {
+ LayerState ls = wm_layer->getLayerState();
+ ls.addLayer(layer);;
+ }
+ } */
+
+ // Move foreground from back ground layer
+ /* for(auto& wm_layer : this->wm_layers)
+ {
+ if(wm_layer->layerName() == "BackGroundLayer")
+ {
+ if(wm_layer->hasRole(client->role()))
+ {
+ LayerState ls = wm_layer->getLayerState();
+ ls.removeLayer(layer);
+ }
+ break;
+ }
+ } */
+
+ return ret;
+}
+
+WMError LayerControl::makeInvisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+ bool mv_ok = this->moveBackGround(client);
+
+ if(!mv_ok)
+ {
+ HMI_INFO("make invisible client %s", client->appID().c_str());
+ ilm_layerSetVisibility(layer, ILM_FALSE);
+ }
+
+ //ilm_layerSetDestinationRectangle(layer, 0, 0, 0, 0);
+
+ /* for(auto& wm_layer : this->wm_layers)
+ {
+ if(wm_layer->hasLayerID(layer))
+ {
+ LayerState ls = wm_layer->getLayerState();
+ ls.removeLayer(layer);;
+ }
+ } */
+
+
+
+ return ret;
+}
+
+WMError LayerControl::makeRemoteVisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+ if (0 > this->remoteScreenID)
+ {
+ return ret;
+ }
+
+ // TODO: Currently there is only one remote screen.
+ for (auto itr = this->wm_layers.begin(); itr != this->wm_layers.end(); ++itr)
+ {
+ if((*itr)->hasLayerID(layer))
+ {
+ HMI_DEBUG("Add layer:%d to remote screen:%d", layer, this->remoteScreenID);
+ this->wm_remote_layers.push_back(*itr);
+ this->wm_layers.erase(itr);
+ }
+
+ if (this->wm_layers.end() == itr)
+ {
+ HMI_DEBUG("iteretor indicates end of vector of wm_layers");
+ break;
+ }
+ }
+
+ ilm_layerSetVisibility(layer, ILM_TRUE);
+
+ return ret;
+}
+
+WMError LayerControl::makeRemoteInvisible(const shared_ptr<WMClient> client)
+{
+ WMError ret = WMError::SUCCESS;
+ unsigned layer = client->layerID(); // Don't check here the client is not nullptr
+
+ if (0 > this->remoteScreenID)
+ {
+ return ret;
+ }
+
+ // TODO: Currently there is only one remote screen.
+ for (auto itr = this->wm_remote_layers.begin();
+ itr != this->wm_remote_layers.end(); ++itr)
+ {
+ if((*itr)->hasLayerID(layer))
+ {
+ HMI_DEBUG("Remove layer:%d from remote screen:%d", layer, this->remoteScreenID);
+ this->wm_layers.push_back(*itr);
+ this->wm_remote_layers.erase(itr);
+ }
+
+ if (this->wm_remote_layers.end() == itr)
+ {
+ HMI_DEBUG("iteretor indicates end of vector of wm_remote_layers");
+ break;
+ }
+ }
+
+ ilm_layerSetVisibility(layer, ILM_FALSE);
+
+ return ret;
+}
+
+bool LayerControl::moveBackGround(const shared_ptr<WMClient> client)
+{
+ bool ret = false;
+
+ // Move background from foreground layer
+ auto bg = this->getWMLayer(BACK_GROUND_LAYER);
+ if(bg != nullptr)
+ {
+ HMI_DEBUG("client %s role %s", client->appID().c_str(), client->role().c_str());
+ unsigned layer = client->layerID();
+ if(bg->hasRole(client->role()))
+ {
+ HMI_INFO("%s go to background", client->appID().c_str());
+ bg->addLayerToState(layer);
+ auto wm_layer = this->getWMLayer(layer);
+ wm_layer->removeLayerFromState(layer);
+ /* TODO: manipulate state directly
+ LayerState bg_ls = bg->getLayerState();
+ bg_ls.addLayer(layer);
+ LayerState ls = wm_layer->getLayerState();
+ ls.removeLayer(layer); */
+ bg->dump();
+ wm_layer->dump();
+ ret = true;
+ }
+ }
+ return ret;
+}
+
+bool LayerControl::moveForeGround(const shared_ptr<WMClient> client)
+{
+ bool ret = false;
+
+ // Move foreground from foreground layer
+ auto bg = this->getWMLayer(BACK_GROUND_LAYER);
+ if(bg != nullptr)
+ {
+ if(bg->hasRole(client->role()))
+ {
+ unsigned layer = client->layerID();
+ HMI_INFO("%s go to foreground", client->appID().c_str());
+ bg->removeLayerFromState(layer);
+ auto wm_layer = this->getWMLayer(layer);
+ wm_layer->addLayerToState(layer);
+ /* TODO: manipulate state directly
+ LayerState bg_ls = bg->getLayerState();
+ bg_ls.removeLayer(layer);
+ LayerState ls = wm_layer->getLayerState();
+ ls.addLayer(layer); */
+ bg->dump();
+ wm_layer->dump();
+ ret = true;
+ }
+ }
+ return ret;
+}
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/src/wm_layer_control.hpp b/demo3/common/agl-service-windowmanager/src/wm_layer_control.hpp
new file mode 100644
index 0000000..fa7c7cb
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/src/wm_layer_control.hpp
@@ -0,0 +1,118 @@
+/*
+ * 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 <string>
+#include <memory>
+#include <vector>
+#include <unordered_map>
+#include <functional>
+#include <ilm/ilm_control.h>
+#include "wm_error.hpp"
+#include "util.hpp"
+
+namespace wm {
+
+class Screen {
+ public:
+ Screen(unsigned w, unsigned h) : _width(w), _height(h){}
+ unsigned width() { return _width; }
+ unsigned height() { return _height; }
+ private:
+ unsigned _width;
+ unsigned _height;
+ unsigned _pysical_width = 0;
+ unsigned _pysical_height = 0;
+};
+
+class LayerControlCallbacks {
+ public:
+ LayerControlCallbacks() {};
+ ~LayerControlCallbacks() = default;
+ LayerControlCallbacks(const LayerControlCallbacks &obj) = default;
+
+ // callback functions
+ std::function<void(unsigned, unsigned)> surfaceCreated;
+ std::function<void(unsigned)> surfaceDestroyed;
+ /* std::function<void(unsigned)> surfaceDestroyed;
+ std::function<void(unsigned)> layerCreated;
+ std::function<void(unsigned)> layerDestroyed; */
+};
+
+class WMLayer;
+class LayerState;
+class WMAction;
+class WMClient;
+
+class LayerControl
+{
+ public:
+ explicit LayerControl(const std::string& root, const std::string& ecu_name);
+ ~LayerControl() = default;
+ WMError init(const LayerControlCallbacks& cb);
+ void createNewLayer(unsigned id);
+ void createNewRemoteLayer(unsigned id);
+ unsigned getNewLayerID(const std::string& role, std::string* layer_name);
+ std::shared_ptr<WMLayer> getWMLayer(unsigned layer);
+ std::shared_ptr<WMLayer> getWMLayer(std::string layer_name);
+ struct rect getAreaSize(const std::string& area);
+ void setupArea(const rectangle& base_rct, double scaling);
+ Screen getScreenInfo();
+ double scale();
+ // void setRenderOrder(const std::vector<unsigned> layer_render_order);
+ // std::vector<unsigned> getAllRenderOrder();
+ // std::vector<std::shared_ptr<WMLayer>>& getAllLayers();
+ // std::vector<unsigned> getRenderOrder(const std::string& layer_name);
+ WMError updateLayer(LayerState& layer_state);
+ WMError renderLayers();
+ WMError renderLayersRemote();
+ WMError setXDGSurfaceOriginSize(unsigned surface);
+ // WMError renderWMLayers();
+ void undoUpdate();
+ WMError layoutChange(const WMAction& action);
+ WMError visibilityChange(const WMAction &action);
+ void terminateApp(const std::shared_ptr<WMClient> client);
+
+ // Don't use this function.
+ void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);
+ void dispatchSurfacePropChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);
+ void dispatchLayerPropChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);
+
+ private:
+ WMError makeVisible(const std::shared_ptr<WMClient> client);
+ WMError makeInvisible(const std::shared_ptr<WMClient> client);
+ bool moveForeGround(const std::shared_ptr<WMClient> client);
+ bool moveBackGround(const std::shared_ptr<WMClient> client);
+ WMError loadLayerSetting(const std::string& path);
+ WMError loadAreasConfigFile(const std::string& path, const std::string& ecu_name);
+
+ // For Remote
+ WMError makeRemoteVisible(const std::shared_ptr<WMClient> client);
+ WMError makeRemoteInvisible(const std::shared_ptr<WMClient> client);
+
+ std::vector<std::shared_ptr<WMLayer>> wm_layers;
+ std::vector<std::shared_ptr<WMLayer>> wm_remote_layers;
+ std::unordered_map<unsigned, unsigned> lid2wmlid;
+ std::unordered_map<std::string, struct rect> area2size;
+ unsigned screenID;
+ signed remoteScreenID;
+ struct ilmScreenProperties screen_prop;
+ double scaling;
+ int offset_x;
+ int offset_y;
+ LayerControlCallbacks cb;
+};
+
+} // namespace wm
diff --git a/demo3/common/agl-service-windowmanager/tests/wm-request b/demo3/common/agl-service-windowmanager/tests/wm-request
new file mode 100644
index 0000000..fade547
--- /dev/null
+++ b/demo3/common/agl-service-windowmanager/tests/wm-request
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+nopygments=0
+if [ "$1" = "-p" ]
+then
+ nopygments=1
+ shift
+fi
+
+if ! [ "$1" ]
+then
+ echo "Usage: $0 VERB [ARGS]" >&2
+ exit 1
+fi
+
+UUIDFILE=/tmp/wm-request-uuid
+if ! which uuidgen 2>/dev/null 1>&2
+then
+ echo "c7c638c5-d097-4eb4-9012-a1e4c25b9808" > $UUIDFILE
+else
+ if ! [ -f $UUIDFILE ]
+ then
+ uuidgen > $UUIDFILE
+ fi
+fi
+UUID="`cat $UUIDFILE`"
+
+for i in afb-client-demo
+do
+ which $i 2>/dev/null 1>&2 || { echo "Program $i is missing" >&2; exit 1; }
+done
+
+set -eu
+
+ if [ $nopygments = 0 ] && which pygmentize 2>/dev/null 1>&2
+ then
+ json_pretty() {
+ pygmentize -l json
+ }
+ else
+ json_pretty() {
+ cat
+ }
+fi
+
+verb=$1
+shift
+
+set +u
+if [ "$1" ]
+then
+ set -u
+ args='{"drawing_name":"'"$1"'"}'
+fi
+
+afb-client-demo -H ws://localhost:1700/api\?token=wm\&uuid=$UUID windowmanager $verb $args | json_pretty
+
+# vim:set ft=sh:
diff --git a/demo3/common/libqtwindowmanager/LICENSE b/demo3/common/libqtwindowmanager/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/demo3/common/libqtwindowmanager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/demo3/common/libqtwindowmanager/qlibwindowmanager.pro b/demo3/common/libqtwindowmanager/qlibwindowmanager.pro
new file mode 100644
index 0000000..e5e3fe9
--- /dev/null
+++ b/demo3/common/libqtwindowmanager/qlibwindowmanager.pro
@@ -0,0 +1,17 @@
+#
+# 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.
+
+TEMPLATE = subdirs
+SUBDIRS = src \ No newline at end of file
diff --git a/demo3/common/libqtwindowmanager/src/qlibwindowmanager.cpp b/demo3/common/libqtwindowmanager/src/qlibwindowmanager.cpp
new file mode 100644
index 0000000..fff99c4
--- /dev/null
+++ b/demo3/common/libqtwindowmanager/src/qlibwindowmanager.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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 "qlibwindowmanager.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string>
+
+using namespace std;
+
+int QLibWindowmanager::init(int port, const QString &token) {
+ string ctoken = token.toStdString();
+ int ret_init = this->wm->init(port, ctoken);
+
+ this->screen_info = new AGLScreenInfoPrivate;
+
+ if(ret_init == 0) {
+ struct Screen scrn = this->wm->getScreenInfo();
+ this->screen_info->set_width_dp(scrn.width_dp);
+ this->screen_info->set_height_dp(scrn.height_dp);
+ this->screen_info->set_width_mm(scrn.width_mm);
+ this->screen_info->set_height_mm(scrn.height_mm);
+ this->screen_info->set_scale_factor(scrn.scale);
+ }
+
+ return ret_init;
+}
+
+int QLibWindowmanager::requestSurface(const QString &role) {
+ this->graphic_role = role.toStdString();
+ int surface_id = this->wm->requestSurface(this->graphic_role.c_str());
+ if(surface_id < 0){
+ qDebug("failed to get surfaceID");
+ return -1;
+ }
+ else{
+ qDebug("surfaceID is set to %d", surface_id);
+ char buf[65]; // surface id is under 64bit(1.84E19,) so 65 is sufficient for buffer
+ snprintf(buf, 65, "%d", surface_id);
+ setenv("QT_IVI_SURFACE_ID", buf, 1);
+ return 0;
+ }
+}
+
+int QLibWindowmanager::activateWindow(const QString &role) {
+ string srole = role.toStdString();
+ // Request default drawing area "normal.full" in libwindowmanager
+ return this->wm->activateWindow(srole.c_str());
+}
+
+int QLibWindowmanager::activateWindow(const QString &role, const QString &area) {
+ string srole = role.toStdString();
+ string sarea = area.toStdString();
+ return this->wm->activateWindow(srole.c_str(), sarea.c_str());
+}
+
+int QLibWindowmanager::deactivateWindow(const QString &role) {
+ string srole = role.toStdString();
+ return this->wm->deactivateWindow(srole.c_str());
+}
+
+// This API is deprecated, please use new API
+int QLibWindowmanager::activateSurface(const QString &role) {
+ return this->activateWindow(role);
+}
+
+// This API is deprecated, please use new API
+int QLibWindowmanager::activateSurface(const QString &role, const QString &area) {
+ return this->activateWindow(role, area);
+}
+
+// This API is deprecated, please use new API
+int QLibWindowmanager::deactivateSurface(const QString &role) {
+ return this->deactivateWindow(role);
+}
+
+int QLibWindowmanager::endDraw(const QString &role) {
+ string srole = role.toStdString();
+ return this->wm->endDraw(srole.c_str());
+ }
+
+void QLibWindowmanager::set_event_handler(enum QEventType et,
+ handler_fun f) {
+ LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et;
+ return this->wm->set_event_handler(wet, std::move(f));
+}
+
+void QLibWindowmanager::slotActivateWindow(){
+ // This is needed for first rendering when the app is launched
+ if(!isActive){
+ qDebug("Let's show %s", qPrintable(this->graphic_role.c_str()));
+ isActive = true;
+ this->activateWindow(this->graphic_role.c_str());
+ }
+}
+
+// This API is deprecated, please use new API
+void QLibWindowmanager::slotActivateSurface(){
+ this->slotActivateWindow();
+}
+
+QLibWindowmanager::QLibWindowmanager(QObject *parent)
+ :QObject(parent), isActive(false), screen_info(nullptr)
+{
+ wm = new LibWindowmanager();
+}
+
+QLibWindowmanager::~QLibWindowmanager()
+{
+ delete wm;
+ delete screen_info;
+} \ No newline at end of file
diff --git a/demo3/common/libqtwindowmanager/src/qlibwindowmanager.h b/demo3/common/libqtwindowmanager/src/qlibwindowmanager.h
new file mode 100644
index 0000000..b736e07
--- /dev/null
+++ b/demo3/common/libqtwindowmanager/src/qlibwindowmanager.h
@@ -0,0 +1,131 @@
+/*
+ * 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 QLIBWINDOWMANAGER_H
+#define QLIBWINDOWMANAGER_H
+#include <libwindowmanager.h>
+#include <functional>
+#include <QObject>
+#include <string>
+
+class AGLScreenInfo : public QObject
+{
+ Q_OBJECT
+
+ public:
+ AGLScreenInfo(double scale = 1.0) { _scale_factor = scale; };
+
+ Q_INVOKABLE double scale_factor() const { return _scale_factor; };
+
+ private:
+ double _scale_factor;
+};
+
+class AGLScreenInfoPrivate
+{
+ public:
+ unsigned long width_dp(void) const { return _width_dp; };
+ unsigned long height_dp(void) const { return _height_dp; };
+ unsigned long width_mm(void) const { return _width_mm; };
+ unsigned long height_mm(void) const { return _height_mm; };
+ double scale_factor(void) const { return _scale; };
+
+ void set_width_dp(unsigned long w) { _width_dp = w; };
+ void set_height_dp(unsigned long h) { _height_dp = h; };
+ void set_width_mm(unsigned long w) { _width_mm = w; };
+ void set_height_mm(unsigned long h) { _height_mm = h; };
+ void set_scale_factor(double scale) { _scale = scale; };
+
+ private:
+ unsigned long _width_dp;
+ unsigned long _height_dp;
+ unsigned long _width_mm;
+ unsigned long _height_mm;
+ double _scale = 1.0;
+};
+
+class QLibWindowmanager : public QObject{
+Q_OBJECT
+public:
+ explicit QLibWindowmanager(QObject *parent = nullptr);
+ ~QLibWindowmanager();
+
+ QLibWindowmanager(const QLibWindowmanager &) = delete;
+ QLibWindowmanager &operator=(const QLibWindowmanager &) = delete;
+
+public:
+ using handler_fun = std::function<void(json_object *object)>;
+
+ enum QEventType {
+ Event_Active = LibWindowmanager::Event_Active,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+
+ Event_ScreenUpdated,
+
+ Event_HeadlampOff,
+ Event_HeadlampOn,
+
+ Event_ParkingBrakeOff,
+ Event_ParkingBrakeOn,
+
+ Event_LightstatusBrakeOff,
+ Event_LightstatusBrakeOn,
+
+ Event_CarStop,
+ Event_CarRun,
+
+ Event_Error,
+
+ Event_Val_Max = Event_Error
+ };
+
+ int init(int port, const QString &token);
+
+ // WM API
+ Q_INVOKABLE int requestSurface(const QString &role);
+ Q_INVOKABLE int activateWindow(const QString &role);
+ Q_INVOKABLE int activateWindow(const QString &role, const QString &drawing_area);
+ Q_INVOKABLE int deactivateWindow(const QString &role);
+ Q_INVOKABLE int endDraw(const QString &role);
+
+ void set_event_handler(enum QEventType et, handler_fun f);
+
+ double get_scale_factor() const { return screen_info->scale_factor(); };
+
+ // These APIs are deprecated, please use new API
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &role));
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int activateSurface(const QString &role, const QString &drawing_area));
+ THIS_FUNCTION_IS_DEPRECATED(Q_INVOKABLE int deactivateSurface(const QString &role));
+
+public slots:
+ void slotActivateWindow();
+
+ // This API is deprecated, please use new API
+ THIS_FUNCTION_IS_DEPRECATED(void slotActivateSurface());
+
+private:
+ LibWindowmanager* wm;
+ std::string graphic_role;
+ bool isActive;
+ AGLScreenInfoPrivate* screen_info;
+};
+#endif // LIBWINDOWMANAGER_H
diff --git a/demo3/common/libqtwindowmanager/src/src.pro b/demo3/common/libqtwindowmanager/src/src.pro
new file mode 100644
index 0000000..a1c0203
--- /dev/null
+++ b/demo3/common/libqtwindowmanager/src/src.pro
@@ -0,0 +1,41 @@
+#
+# 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.
+
+TEMPLATE = lib
+VERSION = 0.1.0
+TARGET = qtwindowmanager
+
+HEADERS = qlibwindowmanager.h
+SOURCES = qlibwindowmanager.cpp
+
+headers.path = /usr/include
+headers.files = qlibwindowmanager.h
+
+target.path = /usr/lib
+
+CONFIG += link_pkgconfig create_pc create_prl no_install_prl
+
+PKGCONFIG += libwindowmanager
+
+QMAKE_PKGCONFIG_NAME = qlibwindowmanager
+QMAKE_PKGCONFIG_FILE = $${QMAKE_PKGCONFIG_NAME}
+QMAKE_PKGCONFIG_VERSION = $${VERSION}
+QMAKE_PKGCONFIG_DESCRIPTION = A wrapper interface for libwindowmanager for Qt
+QMAKE_PKGCONFIG_LIBDIR = ${prefix}/lib
+QMAKE_PKGCONFIG_INCDIR = ${prefix}/include
+QMAKE_PKGCONFIG_REQUIRES = libwindowmanager
+QMAKE_PKGCONFIG_DESTDIR = pkgconfig
+
+INSTALLS += target headers
diff --git a/demo3/common/libwindowmanager/CMakeLists.txt b/demo3/common/libwindowmanager/CMakeLists.txt
new file mode 100644
index 0000000..ad24ccb
--- /dev/null
+++ b/demo3/common/libwindowmanager/CMakeLists.txt
@@ -0,0 +1,46 @@
+#
+# 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.
+#
+
+cmake_minimum_required(VERSION 2.8)
+
+project(WindowManagerTMC)
+
+set(PACKAGE_VERSION_MAJOR 0)
+set(PACKAGE_VERSION_MINOR 1)
+set(PACKAGE_VERSION_REVISION 0)
+set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_REVISION}")
+
+find_package(PkgConfig REQUIRED)
+include(GNUInstallDirs)
+
+# Should modernize the following somehow...
+set(ENABLE_SCOPE_TRACING OFF CACHE BOOL "Enable scope enter/leave messages for certain parts of the code.")
+if(ENABLE_SCOPE_TRACING)
+ add_definitions(-DSCOPE_TRACING)
+else()
+ remove_definitions(-DSCOPE_TRACING)
+endif()
+
+set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none")
+
+set(LINK_LIBCXX OFF CACHE BOOL "Link against LLVMs libc++")
+
+add_subdirectory(src)
+
+configure_file(libwindowmanager.pc.in libwindowmanager.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libwindowmanager.pc
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
diff --git a/demo3/common/libwindowmanager/LICENSE b/demo3/common/libwindowmanager/LICENSE
new file mode 100644
index 0000000..f433b1a
--- /dev/null
+++ b/demo3/common/libwindowmanager/LICENSE
@@ -0,0 +1,177 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/demo3/common/libwindowmanager/libwindowmanager.pc.in b/demo3/common/libwindowmanager/libwindowmanager.pc.in
new file mode 100644
index 0000000..2a70037
--- /dev/null
+++ b/demo3/common/libwindowmanager/libwindowmanager.pc.in
@@ -0,0 +1,11 @@
+includedir=@PROJECT_INCLUDEDIR@
+libdir=@PROJECT_LIBDIR@
+
+Name: @PROJECT_PRETTY_NAME@
+Description: @PROJECT_DESCRIPTION@
+Version: @PROJECT_VERSION@
+URL: @PROJECT_URL@
+
+Requires: json-c afb-daemon
+Cflags: -I${includedir}
+Libs: -L${libdir} -lwindowmanager
diff --git a/demo3/common/libwindowmanager/src/CMakeLists.txt b/demo3/common/libwindowmanager/src/CMakeLists.txt
new file mode 100644
index 0000000..9052d70
--- /dev/null
+++ b/demo3/common/libwindowmanager/src/CMakeLists.txt
@@ -0,0 +1,80 @@
+#
+# 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 libafbwsc)
+pkg_check_modules(SD REQUIRED libsystemd>=222)
+
+set(TARGET_LIBWM windowmanager)
+
+add_library(${TARGET_LIBWM} SHARED
+ libwindowmanager.cpp
+ libwindowmanager.h)
+
+target_include_directories(${TARGET_LIBWM}
+ PRIVATE
+ ${AFB_INCLUDE_DIRS}
+ ${SD_INCLUDE_DIRS})
+
+target_link_libraries(${TARGET_LIBWM}
+ PUBLIC
+ -lpthread
+ ${AFB_LIBRARIES}
+ ${SD_LIBRARIES})
+
+if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release")
+ target_compile_definitions(${TARGET_LIBWM}
+ PRIVATE
+ _GLIBCXX_DEBUG)
+endif()
+
+target_compile_options(${TARGET_LIBWM}
+ PRIVATE
+ -Wall -Wextra -Wno-unused-parameter -Wno-comment)
+
+set_target_properties(${TARGET_LIBWM}
+ PROPERTIES
+ # INTERPROCEDURAL_OPTIMIZATION ON
+ CXX_EXTENSIONS OFF
+ CXX_STANDARD 14
+ VERSION ${PACKAGE_VERSION}
+ CXX_STANDARD_REQUIRED ON)
+
+if (LINK_LIBCXX)
+ set_target_properties(${TARGET_LIBWM}
+ PROPERTIES
+ LINK_FLAGS "-lc++")
+endif()
+
+if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "")
+ target_compile_options(${TARGET_LIBWM}
+ PRIVATE
+ -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer)
+ set_target_properties(${TARGET_LIBWM}
+ PROPERTIES
+ LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g")
+endif()
+
+install(
+ TARGETS ${TARGET_LIBWM}
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ COMPONENT "runtime")
+
+install(
+ FILES libwindowmanager.h
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ COMPONENT "development")
diff --git a/demo3/common/libwindowmanager/src/hmi-debug.h b/demo3/common/libwindowmanager/src/hmi-debug.h
new file mode 100644
index 0000000..2a744ba
--- /dev/null
+++ b/demo3/common/libwindowmanager/src/hmi-debug.h
@@ -0,0 +1,70 @@
+/*
+ * 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 <time.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+
+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__)
+
+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);
+}
+
+#endif //__HMI_DEBUG_H__ \ No newline at end of file
diff --git a/demo3/common/libwindowmanager/src/libwindowmanager.cpp b/demo3/common/libwindowmanager/src/libwindowmanager.cpp
new file mode 100644
index 0000000..dfc0886
--- /dev/null
+++ b/demo3/common/libwindowmanager/src/libwindowmanager.cpp
@@ -0,0 +1,1218 @@
+/*
+ * 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 "libwindowmanager.h"
+#include "hmi-debug.h"
+
+#include <atomic>
+#include <map>
+#include <mutex>
+#include <set>
+#include <queue>
+#include <unistd.h>
+#include <pthread.h>
+
+extern "C" {
+#include <afb/afb-ws-client.h>
+#include <afb/afb-wsj1.h>
+#include <systemd/sd-event.h>
+}
+
+#define UNUSED(x) (void)(x)
+
+namespace {
+ /* Key for json obejct */
+ static const char g_kKeyDrawingName[] = "drawing_name";
+ static const char g_kKeyDrawingArea[] = "drawing_area";
+ static const char g_kKeyDrawingRect[] = "drawing_rect";
+ static const char g_kKeyResponse[] = "response";
+}
+
+/**
+ * @class LibWindowmanager::Impl
+ */
+class LibWindowmanager::Impl {
+ public:
+
+ Impl();
+ ~Impl();
+
+ // This is the LibWindowmanager interface impl
+ int init(int port, char const *token);
+
+ // WM API
+ int requestSurface(json_object *object);
+ int requestSurfaceXDG(json_object *object);
+ int activateWindow(json_object *object);
+ int deactivateWindow(json_object *object);
+ int endDraw(json_object *object);
+
+ int getDisplayInfo(json_object *object);
+ int getAreaInfo(json_object *in_obj, json_object *out_obj);
+ struct Screen getScreenInfo() {return this->_screen;};
+
+ void set_event_handler(enum EventType et, handler_fun func);
+ void setEventHandler(const WMHandler &wmh);
+
+ int api_call(const char *verb, json_object *object,
+ const std::function<void(bool, json_object *)> &onReply);
+ void event(char const *et, json_object *object);
+ void event(char const *et);
+private:
+ int runEventLoop();
+
+ struct afb_wsj1 *wsj1;
+ struct sd_event *loop;
+
+ std::set<std::string> labels;
+ std::map<EventType, handler_fun> handlers;
+ std::queue<std::pair<handler_fun, std::string>> handler_queue;
+
+ const std::vector<std::string> kListEventName{
+ std::string("active"),
+ std::string("inactive"),
+ std::string("visible"),
+ std::string("invisible"),
+ std::string("syncDraw"),
+ std::string("flushDraw"),
+ std::string("screenUpdated"),
+ std::string("headlampOff"),
+ std::string("headlampOn"),
+ std::string("parkingBrakeOff"),
+ std::string("parkingBrakeOn"),
+ std::string("lightstatusBrakeOff"),
+ std::string("lightstatusBrakeOn"),
+ std::string("carStop"),
+ std::string("carRun"),
+ std::string("error")
+ };
+
+ struct Screen _screen;
+ WMHandler _wmh;
+};
+
+namespace {
+
+constexpr const char *const wmAPI = "windowmanager";
+
+#define CONCAT_(X, Y) X##Y
+#define CONCAT(X, Y) CONCAT_(X, Y)
+
+#ifndef SCOPE_TRACING
+#define TRACE()
+#define TRACEN(N)
+#else
+#define TRACE() \
+ ScopeTrace __attribute__((unused)) CONCAT(trace_scope_, __LINE__)(__func__)
+#define TRACEN(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) : f(func) {
+ fprintf(stderr, "%*s%s -->\n", 2 * indent++, "", this->f);
+ }
+ ~ScopeTrace() { fprintf(stderr, "%*s%s <--\n", 2 * --indent, "", this->f); }
+};
+thread_local int ScopeTrace::indent = 0;
+#endif
+
+/* called when wsj1 receives a method invocation */
+void onCall(void *closure, const char *api, const char *verb,
+ struct afb_wsj1_msg *msg) {
+ TRACE();
+ UNUSED(closure);
+ UNUSED(verb);
+ UNUSED(api);
+ UNUSED(msg);
+}
+
+/* called when wsj1 receives an event */
+void onEvent(void *closure, const char *event, afb_wsj1_msg *msg) {
+ TRACE();
+ // check API name in event
+ if (0 != strncmp(wmAPI, event, strlen(wmAPI))) {
+ HMI_ERROR("libwm", "Unknown event: %s", event);
+ return;
+ }
+
+ json_object *j, *val;
+ j = afb_wsj1_msg_object_j(msg);
+ if (json_object_object_get_ex(j, "data", &val)) {
+ static_cast<LibWindowmanager::Impl *>(closure)->event(event, val);
+ }
+ else {
+ static_cast<LibWindowmanager::Impl *>(closure)->event(event);
+ }
+}
+
+/* called when wsj1 hangsup */
+void onHangup(void *closure, afb_wsj1 *wsj1) {
+ TRACE();
+ UNUSED(closure);
+ UNUSED(wsj1);
+ HMI_ERROR("libwm", "Hangup, the WindowManager vanished");
+}
+
+constexpr struct afb_wsj1_itf itf = {
+ onHangup, onCall, onEvent,
+};
+
+} // namespace
+
+/**
+ * @class LibWindowmanager::Impl::Impl
+ */
+LibWindowmanager::Impl::Impl()
+ : wsj1{}, loop{}, labels(), handlers(),
+ _screen{0,0,0,0,0.0},
+ _wmh()
+{}
+
+LibWindowmanager::Impl::~Impl() {
+ TRACE();
+ afb_wsj1_unref(wsj1);
+ sd_event_unref(loop);
+}
+
+int LibWindowmanager::Impl::init(int port, char const *token) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ char *uribuf = nullptr;
+ int rc = -1;
+
+ if (this->loop != nullptr && this->wsj1 != nullptr) {
+ HMI_ERROR("libwm", "LibWindowmanager instance is already initialized!");
+ rc = -EALREADY;
+ goto fail;
+ }
+
+ if (token == nullptr) {
+ HMI_ERROR("libwm", "Token is invalid");
+ rc = -EINVAL;
+ goto fail;
+ }
+
+ if (port < 1 || port > 0xffff) {
+ HMI_ERROR("libwm", "Port is invalid");
+ rc = -EINVAL;
+ goto fail;
+ }
+
+ /* get the default event loop */
+ rc = sd_event_default(&this->loop);
+ if (rc < 0) {
+ HMI_ERROR("libwm", "Connection to default event loop failed: %s",
+ strerror(-rc));
+ goto fail;
+ }
+
+ asprintf(&uribuf, "ws://localhost:%d/api?token=%s", port, token);
+
+ /* connect the websocket wsj1 to the uri given by the first argument */
+ this->wsj1 = afb_ws_client_connect_wsj1(
+ this->loop, uribuf, const_cast<struct afb_wsj1_itf *>(&itf), this);
+ if (this->wsj1 == nullptr) {
+ sd_event_unref(this->loop);
+ this->loop = nullptr;
+ HMI_ERROR("libwm", "Connection to %s failed: %m", uribuf);
+ rc = -errno;
+ goto fail;
+ }
+
+ this->runEventLoop();
+
+ return 0;
+
+fail:
+ return rc;
+}
+
+int LibWindowmanager::Impl::requestSurface(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ json_object *val;
+ const char *tmp_label;
+ if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) {
+ tmp_label = json_object_get_string(val);
+ }
+ else {
+ HMI_DEBUG("libwm", "Not found key \"%s\"", g_kKeyDrawingName);
+ return -EINVAL;
+ }
+
+ // DrawingName in "object" is overwrited in api_call("RequestSurface")
+ // So it is neccesary to copy it.
+ const char *label = std::string(tmp_label).c_str();
+
+ if (this->labels.find(label) != this->labels.end()) {
+ HMI_ERROR("libwm", "Surface label already known!");
+ return -EINVAL;
+ }
+
+ // Store application name first
+ // because it may not return from setenv
+ HMI_DEBUG("libwm", "Insert application name: %s\n", label);
+ this->labels.insert(this->labels.end(), label);
+
+ int rc = -1;
+ /* send the request */
+ int rc2 =
+ this->api_call("RequestSurface", object, [&rc](bool ok, json_object *j) {
+ if (ok) {
+ json_object *val;
+ if (json_object_object_get_ex(j, g_kKeyResponse, &val)) {
+ rc = json_object_get_int(val);
+ }
+ else {
+ HMI_ERROR("libwm", "Not found key \"response\"");
+ rc = -EINVAL;
+ return;
+ }
+ }
+ });
+
+ if (rc2 < 0) {
+ rc = rc2;
+ }
+
+ if (rc < 0) {
+ HMI_ERROR("libwm", "Erase application name: %s", label);
+ this->labels.erase(label);
+ }
+
+ return rc;
+}
+
+int LibWindowmanager::Impl::requestSurfaceXDG(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ json_object *val;
+ const char *tmp_label;
+ if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) {
+ tmp_label = json_object_get_string(val);
+ }
+ else {
+ HMI_DEBUG("libwm", "Not found key \"%s\"", g_kKeyDrawingName);
+ return -EINVAL;
+ }
+
+ // DrawingName in "object" is overwrited in api_call("RequestSurface")
+ // So it is neccesary to copy it.
+ const char *label = std::string(tmp_label).c_str();
+
+ if (this->labels.find(label) != this->labels.end()) {
+ HMI_ERROR("libwm", "Surface label already known!");
+ return -EINVAL;
+ }
+
+ // Store application name first
+ // because it may not return from setenv
+ HMI_DEBUG("libwm", "Insert application name: %s\n", label);
+ this->labels.insert(this->labels.end(), label);
+
+ /* send the request */
+ int rc = this->api_call("RequestSurfaceXDG", object, [](bool ok, json_object *j) {
+ if (!ok) {
+ HMI_ERROR("libwm", "Could not get surface ID from WM: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ }
+ });
+
+ if (rc != 0) {
+ HMI_ERROR("libwm", "Erase application name: %s", label);
+ this->labels.erase(label);
+ }
+
+ return rc;
+}
+
+int LibWindowmanager::Impl::activateWindow(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+ return this->api_call("ActivateWindow", object, [](bool ok, json_object *j) {
+ if (!ok) {
+ HMI_ERROR("libwm", "API Call activateWindow() failed: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ }
+ });
+}
+
+int LibWindowmanager::Impl::deactivateWindow(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+ return this->api_call("DeactivateWindow", object, [](bool ok, json_object *j) {
+ if (!ok) {
+ HMI_ERROR("libwm", "API Call deactivateWindow() failed: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ }
+ });
+}
+
+int LibWindowmanager::Impl::endDraw(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+ return this->api_call("EndDraw", object, [](bool ok, json_object *j) {
+ if (!ok) {
+ HMI_ERROR("libwm", "API Call endDraw() failed: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ }
+ });
+}
+
+int LibWindowmanager::Impl::getDisplayInfo(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ if (nullptr == object) {
+ HMI_ERROR("libwm", "Argment is NULL!");
+ return -EINVAL;
+ }
+
+ if ((nullptr == this->loop) || (nullptr == this->wsj1)) {
+ HMI_ERROR("libwm", "LibWindowmanager is not initialized!");
+ return -EPERM;
+ }
+
+ int w_px, h_px, w_mm, h_mm;
+ int rc = -1;
+ double scale;
+ /* send the request */
+ int rc2 =
+ this->api_call("GetDisplayInfo", nullptr,
+ [&rc, &w_px, &h_px, &w_mm, &h_mm, &scale](bool ok, json_object *j) {
+ if (ok) {
+ json_object *val;
+ if (json_object_object_get_ex(j, g_kKeyResponse, &val)) {
+ HMI_DEBUG("libwm", "responce:%s", json_object_get_string(val));
+
+ json_object *j_w_px = nullptr;
+ if (!json_object_object_get_ex(val, "width_pixel", &j_w_px)) {
+ HMI_DEBUG("libwm", "Not found key \"width_pixel\"");
+ rc = -EINVAL;
+ return;
+ }
+ w_px = json_object_get_int(j_w_px);
+
+ json_object *j_h_px = nullptr;
+ if (!json_object_object_get_ex(val, "height_pixel", &j_h_px)) {
+ HMI_DEBUG("libwm", "Not found key \"height_pixel\"");
+ rc = -EINVAL;
+ return;
+ }
+ h_px = json_object_get_int(j_h_px);
+
+ json_object *j_w_mm = nullptr;
+ if (!json_object_object_get_ex(val, "width_mm", &j_w_mm)) {
+ HMI_DEBUG("libwm", "Not found key \"width_mm\"");
+ rc = -EINVAL;
+ return;
+ }
+ w_mm = json_object_get_int(j_w_mm);
+
+ json_object *j_h_mm = nullptr;
+ if (!json_object_object_get_ex(val, "height_mm", &j_h_mm)) {
+ HMI_DEBUG("libwm", "Not found key \"height_mm\"");
+ rc = -EINVAL;
+ return;
+ }
+ h_mm = json_object_get_int(j_h_mm);
+
+ json_object *j_scale = nullptr;
+ if (!json_object_object_get_ex(val, "scale", &j_scale)) {
+ HMI_DEBUG("libwm:", "Not found key \"scale\"");
+ scale = 1.0; // for backward compatibility
+ } else {
+ scale = json_object_get_double(j_scale);
+ }
+ rc = 0;
+ }
+ else {
+ HMI_ERROR("libwm", "Not found key \"response\"");
+ rc = -EINVAL;
+ return;
+ }
+ } else {
+ HMI_ERROR("libwm", "Windowmanager-service is not initialized: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ rc = -EPERM;
+ }
+ });
+
+ if (0 > rc2) {
+ HMI_ERROR("libwm", "api_call() failed");
+ rc = rc2;
+ }
+
+ if (0 == rc) {
+ json_object_object_add(object, "width_pixel", json_object_new_int(w_px));
+ json_object_object_add(object, "height_pixel", json_object_new_int(h_px));
+ json_object_object_add(object, "width_mm", json_object_new_int(w_mm));
+ json_object_object_add(object, "height_mm", json_object_new_int(h_mm));
+ json_object_object_add(object, "scale", json_object_new_double(scale));
+ this->_screen = Screen{
+ static_cast<unsigned long>(w_px),
+ static_cast<unsigned long>(h_px),
+ static_cast<unsigned long>(w_mm),
+ static_cast<unsigned long>(h_mm),
+ scale};
+ }
+
+ return rc;
+}
+
+int LibWindowmanager::Impl::getAreaInfo(json_object *in_obj, json_object *out_obj) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ if (nullptr == in_obj) {
+ HMI_ERROR("libwm", "Argment is NULL!");
+ return -EINVAL;
+ }
+
+ if ((nullptr == this->loop) || (nullptr == this->wsj1)) {
+ HMI_ERROR("libwm", "LibWindowmanager is not initialized!");
+ return -EPERM;
+ }
+
+ int x, y, w, h;
+ int rc = -1;
+ /* send the request */
+ int rc2 =
+ this->api_call("GetAreaInfo", in_obj,
+ [&rc, &x, &y, &w, &h](bool ok, json_object *j) {
+ if (ok) {
+ json_object *val;
+ HMI_DEBUG("libwm", "j:%s", json_object_get_string(j));
+ if (json_object_object_get_ex(j, g_kKeyResponse, &val)) {
+ json_object *j_x = nullptr;
+ if (!json_object_object_get_ex(val, "x", &j_x)) {
+ HMI_DEBUG("libwm", "Not found key \"x\"");
+ rc = -EINVAL;
+ return;
+ }
+ x = json_object_get_int(j_x);
+
+ json_object *j_y = nullptr;
+ if (!json_object_object_get_ex(val, "y", &j_y)) {
+ HMI_DEBUG("libwm", "Not found key \"y\"");
+ rc = -EINVAL;
+ return;
+ }
+ y = json_object_get_int(j_y);
+
+ json_object *j_w = nullptr;
+ if (!json_object_object_get_ex(val, "width", &j_w)) {
+ HMI_DEBUG("libwm", "Not found key \"width\"");
+ rc = -EINVAL;
+ return;
+ }
+ w = json_object_get_int(j_w);
+
+ json_object *j_h = nullptr;
+ if (!json_object_object_get_ex(val, "height", &j_h)) {
+ HMI_DEBUG("libwm", "Not found key \"height\"");
+ rc = -EINVAL;
+ return;
+ }
+ h = json_object_get_int(j_h);
+ rc = 0;
+
+ HMI_DEBUG("libwm", "responce:%s", json_object_get_string(val));
+ }
+ else {
+ HMI_ERROR("libwm", "Not found key \"response\"");
+ rc = -EINVAL;
+ return;
+ }
+ } else {
+ HMI_ERROR("libwm", "Could not get area rect: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ rc = -EINVAL;
+ }
+ });
+
+ if (0 > rc2) {
+ HMI_ERROR("libwm", "api_call() failed");
+ rc = rc2;
+ }
+
+ if (0 == rc) {
+ json_object_object_add(out_obj, "x", json_object_new_int(x));
+ json_object_object_add(out_obj, "y", json_object_new_int(y));
+ json_object_object_add(out_obj, "width", json_object_new_int(w));
+ json_object_object_add(out_obj, "height", json_object_new_int(h));
+ }
+
+ return rc;
+}
+
+static void _on_reply_static(void *closure, struct afb_wsj1_msg *msg)
+{
+}
+
+void LibWindowmanager::Impl::set_event_handler(enum EventType et, handler_fun func) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+
+ // Subscribe event
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, "event", json_object_new_int(et));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event: %s", kListEventName[et].c_str());
+ }
+
+ // Set event handler
+ if (et >= Event_Active && et <= Event_Val_Max) {
+ this->handlers[et] = std::move(func);
+ }
+}
+
+namespace {
+std::pair<bool, LibWindowmanager::EventType> make_event_type(char const *et) {
+ // Event have the form "$API/$EVENT", just try to find the first / and
+ // get on with it.
+ char const *et2 = strchr(et, '/');
+ if (et2 != nullptr) {
+ et = et2 + 1;
+ }
+
+#define ET(N, A) \
+ do { \
+ if (strcasecmp(et, N) == 0) \
+ return std::pair<bool, LibWindowmanager::EventType>( \
+ true, CONCAT(LibWindowmanager::Event_, A)); \
+ } while (false)
+
+ ET("active", Active);
+ ET("inactive", Inactive);
+ ET("visible", Visible);
+ ET("invisible", Invisible);
+ ET("syncdraw", SyncDraw);
+ ET("flushdraw", FlushDraw);
+ ET("screenUpdated", ScreenUpdated);
+ ET("headlampOff", HeadlampOff);
+ ET("headlampOn", HeadlampOn);
+ ET("parkingBrakeOff", ParkingBrakeOff);
+ ET("parkingBrakeOn", ParkingBrakeOn);
+ ET("lightstatusBrakeOff", LightstatusBrakeOff);
+ ET("lightstatusBrakeOn", LightstatusBrakeOn);
+ ET("carStop", CarStop);
+ ET("carRun", CarRun);
+ ET("error", Error);
+#undef ET
+
+ return std::pair<bool, LibWindowmanager::EventType>(false,
+ LibWindowmanager::Event_Active);
+}
+} // namespace
+
+/// object will be json_object_put
+int LibWindowmanager::Impl::api_call(
+ const char *verb, json_object *object,
+ const std::function<void(bool, json_object *)> &onReply) {
+ TRACE();
+
+ int rc = 0;
+ if ((0 == strcmp("RequestSurface", verb)) ||
+ (0 == strcmp("GetDisplayInfo", verb)) ||
+ (0 == strcmp("GetAreaInfo", verb))) {
+ // We need to wrap the actual onReply call once in order to
+ // *look* like a normal functions pointer (std::functions<>
+ // with captures cannot convert to function pointers).
+ // Alternatively we could setup a local struct and use it as
+ // closure, but I think it is cleaner this way.
+ int call_rc = 0;
+ std::atomic<bool> returned{};
+ returned.store(false, std::memory_order_relaxed);
+ std::function<void(bool, json_object *)> wrappedOnReply =
+ [&returned, &call_rc, &onReply](bool ok, json_object *j) {
+ TRACEN(wrappedOnReply);
+ call_rc = ok ? 0 : -EINVAL;
+ // We know it failed, but there may be an explanation in the
+ // json object.
+ {
+ TRACEN(onReply);
+ onReply(ok, j);
+ }
+ returned.store(true, std::memory_order_release);
+ };
+
+ // make the actual call, use wrappedOnReply as closure
+ rc = afb_wsj1_call_j(
+ this->wsj1, wmAPI, verb, object,
+ [](void *closure, afb_wsj1_msg *msg) {
+ TRACEN(callClosure);
+ auto *onReply =
+ reinterpret_cast<std::function<void(bool, json_object *)> *>(
+ closure);
+ (*onReply)(!(afb_wsj1_msg_is_reply_ok(msg) == 0),
+ afb_wsj1_msg_object_j(msg));
+ },
+ &wrappedOnReply);
+
+ if (0 == rc) {
+ // We need to wait until "returned" got set, this is necessary
+ // if events get triggered by the call (and would be dispatched before
+ // the actual call-reply).
+ while (!returned.load(std::memory_order_consume)) {
+ sd_event_run(loop, 16);
+ }
+
+ // return the actual API call result
+ rc = call_rc;
+ }
+ }
+ else {
+ rc = afb_wsj1_call_j(this->wsj1, wmAPI, verb, object, _on_reply_static, this);
+ }
+
+ if (rc < 0) {
+ HMI_ERROR("libwm", "calling %s/%s failed: %m", wmAPI, verb);
+ }
+
+ return rc;
+}
+
+void LibWindowmanager::Impl::setEventHandler(const WMHandler &wmh)
+{
+ // Subscribe
+ const char* ev = "event";
+ if(wmh.on_visible != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_Visible));
+ struct json_object* j_i = json_object_new_object();
+ json_object_object_add(j_i, ev, json_object_new_int(Event_Invisible));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event visible");
+ }
+ ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j_i, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event");
+ }
+ }
+
+ if(wmh.on_active != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_Active));
+ struct json_object* j_i = json_object_new_object();
+ json_object_object_add(j_i, ev, json_object_new_int(Event_Inactive));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j_i, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event");
+ }
+ }
+
+ if(wmh.on_sync_draw != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_SyncDraw));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_flush_draw != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_FlushDraw));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_screen_updated != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_ScreenUpdated));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_headlamp_off != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_HeadlampOff));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_headlamp_on != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_HeadlampOn));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_parking_brake_off != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_ParkingBrakeOff));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_parking_brake_on != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_ParkingBrakeOn));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_lightstatus_brake_off != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_LightstatusBrakeOff));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_lightstatus_brake_on != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_LightstatusBrakeOn));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_car_stop != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_CarStop));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ if(wmh.on_car_run != nullptr) {
+ struct json_object* j = json_object_new_object();
+ json_object_object_add(j, ev, json_object_new_int(Event_CarRun));
+
+ int ret = afb_wsj1_call_j(this->wsj1, wmAPI, "wm_subscribe", j, _on_reply_static, this);
+ if (0 > ret) {
+ HMI_ERROR("libwm", "Failed to subscribe event active");
+ }
+ }
+
+ // Register
+ this->_wmh.on_visible = wmh.on_visible;
+ this->_wmh.on_active = wmh.on_active;
+ this->_wmh.on_sync_draw = wmh.on_sync_draw;
+ this->_wmh.on_flush_draw = wmh.on_flush_draw;
+ this->_wmh.on_screen_updated = wmh.on_screen_updated;
+ this->_wmh.on_headlamp_off = wmh.on_headlamp_off;
+ this->_wmh.on_headlamp_on = wmh.on_headlamp_on;
+ this->_wmh.on_parking_brake_off = wmh.on_parking_brake_off;
+ this->_wmh.on_parking_brake_on = wmh.on_parking_brake_on;
+ this->_wmh.on_lightstatus_brake_off = wmh.on_lightstatus_brake_off;
+ this->_wmh.on_lightstatus_brake_on = wmh.on_lightstatus_brake_on;
+ this->_wmh.on_car_stop = wmh.on_car_stop;
+ this->_wmh.on_car_run = wmh.on_car_run;
+}
+
+void LibWindowmanager::Impl::event(char const *et, json_object *object) {
+ TRACE();
+ auto oet = make_event_type(et);
+ if (!oet.first) {
+ HMI_ERROR("libwm", "Unknown event type string '%s'", et);
+ return;
+ }
+ json_object *j_val;
+ std::string role = "";
+ bool emit = false;
+ if(json_object_object_get_ex(object, g_kKeyDrawingName, &j_val)) {
+ role = json_object_get_string(j_val);
+ }
+ if (this->labels.find(role) != this->labels.end()){
+ emit = true;
+ }
+
+ switch(oet.second) {
+ case Event_Active :
+ case Event_Inactive : {
+ bool active = ((oet.second == Event_Active) ? true : false);
+ if(!emit) break;
+ if(this->_wmh.on_active) {
+ return this->_wmh.on_active(role.c_str(), active);
+ }
+ break;
+ }
+ case Event_Visible :
+ case Event_Invisible : {
+ bool visible = ((oet.second == Event_Visible) ? true : false);
+ if(!emit) break;
+ if(this->_wmh.on_visible) {
+ return this->_wmh.on_visible(role.c_str(), visible);
+ }
+ break;
+ }
+ case Event_SyncDraw :
+ if(this->_wmh.on_sync_draw && emit) {
+ json_object_object_get_ex(object, g_kKeyDrawingArea, &j_val);
+ const char* area = json_object_get_string(j_val);
+ json_object *j_rect;
+ json_object_object_get_ex(object, g_kKeyDrawingRect, &j_rect);
+ json_object_object_get_ex(j_rect, "x", &j_val);
+ int x = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "y", &j_val);
+ int y = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "width", &j_val);
+ int w = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "height", &j_val);
+ int h = json_object_get_int(j_val);
+ Rect rect(x, y, w, h);
+ return this->_wmh.on_sync_draw(role.c_str(), area, rect);
+ }
+ break;
+ case Event_FlushDraw :
+ if(this->_wmh.on_flush_draw && emit) {
+ return this->_wmh.on_flush_draw(role.c_str());
+ }
+ break;
+ case Event_ScreenUpdated :
+ if(this->_wmh.on_screen_updated) {
+ // emit this case
+ json_object_object_get_ex(object, "ids", &j_val);
+ int len = json_object_array_length(j_val);
+ std::vector<std::string> id_list;
+ for(int i = 0; i < len; i++)
+ {
+ std::string elem = json_object_get_string(json_object_array_get_idx(j_val, i));
+ id_list.push_back(elem);
+ }
+ return this->_wmh.on_screen_updated(id_list);
+ }
+ break;
+ default :
+ break;
+ }
+
+ auto i = this->handlers.find(oet.second);
+ if (i != this->handlers.end()) {
+ json_object *val;
+ const char *label;
+ if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) {
+ label = json_object_get_string(val);
+ }
+ else {
+ i->second(object);
+ return;
+ }
+
+ if (this->labels.find(label) != this->labels.end()) {
+ i->second(object);
+ }
+ }
+}
+
+void LibWindowmanager::Impl::event(char const *et) {
+ TRACE();
+ auto oet = make_event_type(et);
+ if (!oet.first) {
+ HMI_ERROR("libwm", "Unknown event type string '%s'", et);
+ return;
+ }
+
+ switch(oet.second) {
+ case Event_HeadlampOff:
+ if(this->_wmh.on_headlamp_off) {
+ return this->_wmh.on_headlamp_off(nullptr);
+ }
+ break;
+ case Event_HeadlampOn:
+ if(this->_wmh.on_headlamp_on) {
+ return this->_wmh.on_headlamp_on(nullptr);
+ }
+ break;
+ case Event_ParkingBrakeOff:
+ if(this->_wmh.on_parking_brake_off) {
+ return this->_wmh.on_parking_brake_off(nullptr);
+ }
+ break;
+ case Event_ParkingBrakeOn:
+ if(this->_wmh.on_parking_brake_on) {
+ return this->_wmh.on_parking_brake_on(nullptr);
+ }
+ break;
+ case Event_LightstatusBrakeOff:
+ if(this->_wmh.on_lightstatus_brake_off) {
+ return this->_wmh.on_lightstatus_brake_off(nullptr);
+ }
+ break;
+ case Event_LightstatusBrakeOn:
+ if(this->_wmh.on_lightstatus_brake_on) {
+ return this->_wmh.on_lightstatus_brake_on(nullptr);
+ }
+ break;
+ case Event_CarStop:
+ if(this->_wmh.on_car_stop) {
+ return this->_wmh.on_car_stop(nullptr);
+ }
+ break;
+ case Event_CarRun:
+ if(this->_wmh.on_car_run) {
+ return this->_wmh.on_car_run(nullptr);
+ }
+ break;
+ default :
+ break;
+ }
+
+ auto i = this->handlers.find(oet.second);
+ if (i != this->handlers.end()) {
+ i->second(nullptr);
+ }
+}
+
+static void *event_loop_run(void *args){
+ struct sd_event* loop = (struct sd_event*)(args);
+ for(;;)
+ sd_event_run(loop, 30000000);
+}
+
+int LibWindowmanager::Impl::runEventLoop() {
+ if(this->wsj1 && this->loop)
+ {
+ pthread_t thread_id;
+ int ret = pthread_create(&thread_id, NULL, event_loop_run, this->loop);
+ if(ret != 0)
+ {
+ HMI_ERROR("libwm", "Cannot run eventloop due to error:%d", errno);
+ return -1;
+ }
+ else
+ return thread_id;
+ }
+ else
+ {
+ HMI_ERROR("libwm", "Connecting is not established yet");
+ return -1;
+ }
+}
+
+/**
+ * @class LibWindowmanager
+ */
+int LibWindowmanager::init(int port, char const *token) {
+ int ret = this->d->init(port, token);
+ if(ret == 0) {
+ json_object* j = json_object_new_object();
+ ret = this->getDisplayInfo(j); // return 0 if success
+ json_object_put(j);
+ }
+ return ret;
+}
+
+int LibWindowmanager::init(int port, const std::string &token) {
+ int ret = this->d->init(port, token.c_str());
+ if(ret == 0) {
+ json_object* j = json_object_new_object();
+ ret = this->getDisplayInfo(j); // return 0 if success
+ json_object_put(j);
+ }
+ return ret;
+}
+
+int LibWindowmanager::requestSurface(json_object *object) {
+ return this->d->requestSurface(object);
+}
+
+int LibWindowmanager::requestSurface(const char *role) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ return this->d->requestSurface(object);
+}
+
+int LibWindowmanager::requestSurfaceXDG(json_object *object) {
+ return this->d->requestSurfaceXDG(object);
+}
+
+int LibWindowmanager::requestSurfaceXDG(const char* role, unsigned ivi_id) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ json_object_object_add(object, kKeyIviId, json_object_new_int(ivi_id));
+ return this->d->requestSurfaceXDG(object);
+}
+
+int LibWindowmanager::activateWindow(json_object *object) {
+ return this->d->activateWindow(object);
+}
+
+int LibWindowmanager::activateWindow(const char* role, const char* area) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ json_object_object_add(object, kKeyDrawingArea, json_object_new_string(area));
+ return this->d->activateWindow(object);
+}
+
+int LibWindowmanager::activateWindow(const char* role) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ json_object_object_add(object, kKeyDrawingArea, json_object_new_string(kDefaultArea.c_str()));
+ return this->d->activateWindow(object);
+}
+
+int LibWindowmanager::deactivateWindow(json_object *object) {
+ return this->d->deactivateWindow(object);
+}
+
+int LibWindowmanager::deactivateWindow(const char* role) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ return this->d->deactivateWindow(nullptr);
+}
+
+// This API is deprecated, please use new API
+int LibWindowmanager::activateSurface(json_object *object) {
+ return this->activateWindow(object);
+}
+
+// This API is deprecated, please use new API
+int LibWindowmanager::deactivateSurface(json_object *object) {
+ return this->deactivateWindow(object);
+}
+
+int LibWindowmanager::endDraw(json_object *object) {
+ return this->d->endDraw(object);
+}
+
+int LibWindowmanager::endDraw(const char* role) {
+ json_object* object = json_object_new_object();
+ json_object_object_add(object, kKeyDrawingName, json_object_new_string(role));
+ return this->d->endDraw(object);
+}
+
+int LibWindowmanager::getDisplayInfo(json_object *object) {
+ return this->d->getDisplayInfo(object);
+}
+
+int LibWindowmanager::getAreaInfo(json_object *in_obj, json_object *out_obj) {
+ return this->d->getAreaInfo(in_obj, out_obj);
+}
+
+int LibWindowmanager::getAreaInfo(const char *role, Rect *out_rect) {
+ json_object *object = json_object_new_object();
+ json_object *out = json_object_new_object();
+ json_object_object_add(object, this->kKeyDrawingName, json_object_new_string(role));
+ int ret = this->d->getAreaInfo(object, out);
+
+ out_rect->set_left(0);
+ out_rect->set_top(0);
+ out_rect->set_width(0);
+ out_rect->set_height(0);
+
+ if(!ret) {
+ json_object *j_val;
+ json_object *j_rect;
+ json_object_object_get_ex(out, kKeyDrawingRect, &j_rect);
+ if (json_object_object_get_ex(j_rect, "x", &j_val)) {
+ out_rect->set_left(json_object_get_int(j_val));
+ }
+ if (json_object_object_get_ex(j_rect, "y", &j_val)) {
+ out_rect->set_top(json_object_get_int(j_val));
+ }
+ if (json_object_object_get_ex(j_rect, "width", &j_val)) {
+ out_rect->set_width(json_object_get_int(j_val));
+ }
+ if (json_object_object_get_ex(j_rect, "height", &j_val)) {
+ out_rect->set_height(json_object_get_int(j_val));
+ }
+ }
+ return ret;
+}
+
+int LibWindowmanager::getAreaInfo(const char *label, json_object *out_obj) {
+ json_object *object = json_object_new_object();
+ json_object_object_add(object, this->kKeyDrawingName, json_object_new_string(label));
+ return this->d->getAreaInfo(object, out_obj);
+}
+
+void LibWindowmanager::set_event_handler(enum EventType et, handler_fun f) {
+ return this->d->set_event_handler(et, std::move(f));
+}
+
+struct Screen LibWindowmanager::getScreenInfo() {
+ return this->d->getScreenInfo();
+}
+
+void LibWindowmanager::setEventHandler(const WMHandler &wml)
+{
+ return this->d->setEventHandler(wml);
+}
+
+LibWindowmanager::LibWindowmanager() : d(new Impl) {}
+
+LibWindowmanager::~LibWindowmanager() { delete d; }
+
+WMHandler::WMHandler()
+ : on_visible(nullptr),
+ on_active(nullptr),
+ on_sync_draw(nullptr),
+ on_flush_draw(nullptr),
+ on_screen_updated(nullptr),
+ on_headlamp_off(nullptr),
+ on_headlamp_on(nullptr),
+ on_parking_brake_off(nullptr),
+ on_parking_brake_on(nullptr),
+ on_lightstatus_brake_off(nullptr),
+ on_lightstatus_brake_on(nullptr),
+ on_car_stop(nullptr),
+ on_car_run(nullptr)
+{}
diff --git a/demo3/common/libwindowmanager/src/libwindowmanager.h b/demo3/common/libwindowmanager/src/libwindowmanager.h
new file mode 100644
index 0000000..e963798
--- /dev/null
+++ b/demo3/common/libwindowmanager/src/libwindowmanager.h
@@ -0,0 +1,168 @@
+/*
+ * 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 LIBWINDOWMANAGER_H
+#define LIBWINDOWMANAGER_H
+
+#include <functional>
+#include <vector>
+#include <string>
+#include <json-c/json.h>
+
+class Rect {
+ public:
+ Rect() : _x(0), _y(0),_w(0), _h(0) {}
+ Rect(unsigned x, unsigned y, unsigned w, unsigned h)
+ : _x(x), _y(y),_w(w), _h(h) {}
+ ~Rect() = default;
+ unsigned left() const { return _x;}
+ unsigned top() const { return _y;}
+ unsigned width() const { return _w;}
+ unsigned height() const { return _h;}
+ void set_left (unsigned int x) { _x = x; }
+ void set_top (unsigned int y) { _y = y; }
+ void set_width (unsigned int w) { _w = w; }
+ void set_height(unsigned int h) { _h = h; }
+ private:
+ unsigned _x;
+ unsigned _y;
+ unsigned _w;
+ unsigned _h;
+};
+
+struct Screen
+{
+ unsigned long width_dp;
+ unsigned long height_dp;
+ unsigned long width_mm;
+ unsigned long height_mm;
+ double scale = 1.0;
+};
+
+class WMHandler {
+ public:
+ WMHandler();
+ ~WMHandler() = default;
+
+ using visible_handler = std::function<void(const char*, bool visible)>;
+ using active_handler = std::function<void(const char*, bool active)>;
+ using sync_draw_handler = std::function<void(const char*, const char*, Rect)>;
+ using flush_draw_handler= std::function<void(const char*)>;
+ using screen_updated_handler = std::function<void(const std::vector<std::string>&)>;
+ using car_event_handler= std::function<void(const char*)>;
+
+ visible_handler on_visible;
+ active_handler on_active;
+ sync_draw_handler on_sync_draw;
+ flush_draw_handler on_flush_draw;
+ screen_updated_handler on_screen_updated;
+ car_event_handler on_headlamp_off;
+ car_event_handler on_headlamp_on;
+ car_event_handler on_parking_brake_off;
+ car_event_handler on_parking_brake_on;
+ car_event_handler on_lightstatus_brake_off;
+ car_event_handler on_lightstatus_brake_on;
+ car_event_handler on_car_stop;
+ car_event_handler on_car_run;
+};
+
+class LibWindowmanager {
+public:
+ LibWindowmanager();
+ ~LibWindowmanager();
+
+ LibWindowmanager(const LibWindowmanager &) = delete;
+ LibWindowmanager &operator=(const LibWindowmanager &) = delete;
+
+ using handler_fun = std::function<void(json_object *)>;
+
+ /* DrawingArea name (usage: {layout}.{area}) */
+ const std::string kDefaultArea = "normal.full";
+ const std::string kStrLayoutNormal = "normal";
+ const std::string kStrLayoutSplit = "split";
+ const std::string kStrAreaFull = "full";
+ const std::string kStrAreaMain = "main";
+ const std::string kStrAreaSub = "sub";
+
+ /* Key for json obejct */
+ const char *kKeyDrawingName = "drawing_name";
+ const char *kKeyDrawingArea = "drawing_area";
+ const char *kKeyDrawingRect = "drawing_rect";
+ const char *kKeyIviId = "ivi_id";
+
+ enum EventType {
+ Event_Active = 0,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+
+ Event_ScreenUpdated,
+
+ Event_HeadlampOff,
+ Event_HeadlampOn,
+
+ Event_ParkingBrakeOff,
+ Event_ParkingBrakeOn,
+
+ Event_LightstatusBrakeOff,
+ Event_LightstatusBrakeOn,
+
+ Event_CarStop,
+ Event_CarRun,
+
+ Event_Error,
+
+ Event_Val_Max = Event_Error
+ };
+
+ int init(int port, char const *token);
+ int init(int port, const std::string &token);
+
+ // WM API
+ int requestSurface(const char* role);
+ int requestSurfaceXDG(const char* role, unsigned ivi_id);
+ int activateWindow(const char* role, const char* area);
+ int activateWindow(const char* role);
+ int deactivateWindow(const char* role);
+ int endDraw(const char* role);
+ struct Screen getScreenInfo();
+ int getAreaInfo(const char* role, Rect *out_rect);
+ void setEventHandler(const WMHandler& wmh);
+
+ // Backward Compatible API
+ int requestSurface(json_object *object);
+ int requestSurfaceXDG(json_object *object);
+ int activateWindow(json_object *object);
+ int deactivateWindow(json_object *object);
+ int endDraw(json_object *object);
+ int getDisplayInfo(json_object *object);
+ int getAreaInfo(json_object *in_obj, json_object *out_obj);
+ int getAreaInfo(const char *label, json_object *out_obj);
+ void set_event_handler(enum EventType et, handler_fun f);
+
+ // These APIs are deprecated, please use new API
+ THIS_FUNCTION_IS_DEPRECATED(int activateSurface(json_object *object));
+ THIS_FUNCTION_IS_DEPRECATED(int deactivateSurface(json_object *object));
+ class Impl;
+
+private:
+ Impl *const d;
+};
+#endif // LIBWINDOWMANAGER_H