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