330e10d97d467ba409269303b5dae66491d9f629
[apps/agl-service-windowmanager.git] / policy_manager / stm / stm.h
1 /*
2  * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
3  * Copyright (c) 2019 Konsulko Group
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef TMCAGLWM_STM_HPP
19 #define TMCAGLWM_STM_HPP
20
21 #define STM_TRUE 1
22 #define STM_FALSE 0
23
24 #define STM_CREATE_EVENT_ID(evt, ctg, area) \
25     ((evt) | ((ctg) << 8) | ((area) << 16))
26
27 #define STM_GET_EVENT_FROM_ID(id) \
28     ((id) & 0xFF)
29
30 #define STM_GET_CATEGORY_FROM_ID(id) \
31     (((id) >> 8) & 0xFF)
32
33 #define STM_GET_AREA_FROM_ID(id) \
34     (((id) >> 16) & 0xFF)
35
36 // Event number
37 enum StmEvtNo {
38     StmEvtNoNone = 0,
39     StmEvtNoActivate,
40     StmEvtNoDeactivate,
41     StmEvtNoRestrictionModeOff,
42     StmEvtNoRestrictionMode1On,
43     StmEvtNoRestrictionMode2On,
44     StmEvtNoUndo,
45
46     StmEvtNoNum,
47
48     StmEvtNoMin = StmEvtNoNone,
49     StmEvtNoMax = StmEvtNoNum - 1,
50 };
51
52 // Category number
53 enum StmCtgNo {
54     StmCtgNoNone = 0,
55     StmCtgNoHomescreen,
56     StmCtgNoMap,
57     StmCtgNoGeneral,
58     StmCtgNoSplitable,
59     StmCtgNoPopUp,
60     StmCtgNoSystemAlert,
61     StmCtgNoRestriction,
62     StmCtgNoSystem,
63     StmCtgNoSoftwareKeyboard,
64     StmCtgNoDebug,
65     StmCtgNoRemote,
66
67     StmCtgNoNum,
68
69     StmCtgNoMin = StmCtgNoNone,
70     StmCtgNoMax = StmCtgNoNum - 1,
71 };
72
73 // Area number
74 enum StmAreaNo {
75     StmAreaNoNone = 0,
76     StmAreaNoFullscreen,
77     StmAreaNoNormal,
78     StmAreaNoSplitMain,
79     StmAreaNoSplitSub,
80     StmAreaNoOnScreen,
81     StmAreaNoRestrictionNormal,
82     StmAreaNoRestrictionSplitMain,
83     StmAreaNoRestrictionSplitSub,
84     StmAreaNoSoftwareKyeboard,
85     StmAreaNoRemoteFullscreen,
86
87     StmAreaNoNum,
88
89     StmAreaNoMin = StmAreaNoNone,
90     StmAreaNoMax = StmAreaNoNum - 1,
91 };
92
93 // Layer number
94 enum StmLayerNo {
95     StmLayerNoHomescreen = 0,
96     StmLayerNoApps,
97     StmLayerNoNearHomescreen,
98     StmLayerNoRestriction,
99     StmLayerNoOnScreen,
100     StmLayerNoRemoteApps,
101
102     StmLayerNoNum,
103
104     StmLayerNoMin = StmLayerNoHomescreen,
105     StmLayerNoMax = StmLayerNoNum - 1,
106 };
107
108 // Layout kind number
109 enum StmLayoutNo {
110     StmLayoutNoNone = 0,
111     StmLayoutNoPopUp,
112     StmLayoutNoSysAlt,
113     StmLayoutNoMapNml,
114     StmLayoutNoMapSpl,
115     StmLayoutNoMapFll,
116     StmLayoutNoSplNml,
117     StmLayoutNoSplSpl,
118     StmLayoutNoGenNml,
119     StmLayoutNoHms,
120     StmLayoutNoRstNml,
121     StmLayoutNoRstSplMain,
122     StmLayoutNoRstSplSub,
123     StmLayoutNoSysNml,
124     StmLayoutNoSftKbd,
125     StmLayoutNoDbgNml,
126     StmLayoutNoDbgSplMain,
127     StmLayoutNoDbgSplSub,
128     StmLayoutNoDbgFll,
129     StmLayoutNoRmtFll,
130
131     StmLayoutNoNum,
132
133     StmLayoutNoMin = StmLayoutNoNone,
134     StmLayoutNoMax = StmLayoutNoNum - 1,
135 };
136
137 // Mode kind number
138 enum StmModeNo {
139     StmModeNoRestrictionMode = 0,
140
141     StmModeNoNum,
142
143     StmModeNoMin = StmModeNoRestrictionMode,
144     StmModeNoMax = StmModeNoNum - 1,
145 };
146
147 // Enum for mode state
148 enum StmRestrictionModeSttNo {
149     StmRestrictionModeSttNoOff = 0,
150     StmRestrictionModeSttNo1On,
151     StmRestrictionModeSttNo2On,
152 };
153
154 // String for state
155 extern const char* kStmEventName[];
156 extern const char* kStmCategoryName[];
157 extern const char* kStmAreaName[];
158 extern const char* kStmLayoutName[];
159 extern const char* kStmLayerName[];
160 extern const char* kStmModeName[];
161 extern const char** kStmModeStateNameList[];
162
163 // Struct for state
164 typedef struct StmBaseState {
165     int changed;
166     int state;
167 } StmBaseState;
168
169 typedef struct StmState {
170     StmBaseState mode[StmModeNoNum];
171     StmBaseState layer[StmLayerNoNum];
172 } StmState;
173
174 // API
175 void stmInitialize();
176 int stmTransitionState(int event_no, StmState* state);
177 void stmUndoState();
178
179
180 #endif  // TMCAGLWM_STM_HPP