5f672b19ab60affa1057fd9baa210b533c9b6da7
[apps/agl-service-windowmanager-2017.git] / src / policy_manager / stm / stub / src / include / 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_STUB_STM_HPP
18 #define TMCAGLWM_STUB_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
64     StmCtgNoNum,
65
66     StmCtgNoMin = StmCtgNoNone,
67     StmCtgNoMax = StmCtgNoNum - 1,
68 };
69
70 // Area number
71 enum StmAreaNo {
72     StmAreaNoNone = 0,
73     StmAreaNoFullscreen,
74     StmAreaNoNormal,
75     StmAreaNoSplitMain,
76     StmAreaNoSplitSub,
77     StmAreaNoOnScreen,
78     StmAreaNoRestrictionNormal,
79     StmAreaNoRestrictionSplitMain,
80     StmAreaNoRestrictionSplitSub,
81     StmAreaNoSoftwareKyeboard,
82
83     StmAreaNoNum,
84
85     StmAreaNoMin = StmAreaNoNone,
86     StmAreaNoMax = StmAreaNoNum - 1,
87 };
88
89 // Layer number
90 enum StmLayerNo {
91     StmLayerNoHomescreen = 0,
92     StmLayerNoApps,
93     StmLayerNoNearHomescreen,
94     StmLayerNoRestriction,
95     StmLayerNoOnScreen,
96
97     StmLayerNoNum,
98
99     StmLayerNoMin = StmLayerNoHomescreen,
100     StmLayerNoMax = StmLayerNoNum - 1,
101 };
102
103 // Layout kind number
104 enum StmLayoutNo {
105     StmLayoutNoNone = 0,
106     StmLayoutNoPopUp,
107     StmLayoutNoSysAlt,
108     StmLayoutNoMapNml,
109     StmLayoutNoMapSpl,
110     StmLayoutNoMapFll,
111     StmLayoutNoSplNml,
112     StmLayoutNoSplSpl,
113     StmLayoutNoGenNml,
114     StmLayoutNoHms,
115     StmLayoutNoRstNml,
116     StmLayoutNoRstSplMain,
117     StmLayoutNoRstSplSub,
118     StmLayoutNoSysNml,
119     StmLayoutNoSftKbd,
120
121     StmLayoutNoNum,
122
123     StmLayoutNoMin = StmLayoutNoNone,
124     StmLayoutNoMax = StmLayoutNoNum - 1,
125 };
126
127 // Mode kind number
128 enum StmModeNo {
129     StmModeNoRestrictionMode = 0,
130
131     StmModeNoNum,
132
133     StmModeNoMin = StmModeNoRestrictionMode,
134     StmModeNoMax = StmModeNoNum - 1,
135 };
136
137 // Enum for mode state
138 enum StmRestrictionModeSttNo {
139     StmRestrictionModeSttNoOff = 0,
140     StmRestrictionModeSttNo1On,
141     StmRestrictionModeSttNo2On,
142 };
143
144 // String for state
145 extern const char* kStmEventName[];
146 extern const char* kStmCategoryName[];
147 extern const char* kStmAreaName[];
148 extern const char* kStmLayoutName[];
149 extern const char* kStmLayerName[];
150 extern const char* kStmModeName[];
151 extern const char** kStmModeStateNameList[];
152
153 // Struct for state
154 typedef struct StmBaseState {
155     int changed;
156     int state;
157 } StmBaseState;
158
159 typedef struct StmState {
160     StmBaseState mode[StmModeNoNum];
161     StmBaseState layer[StmLayerNoNum];
162 } StmState;
163
164 // API
165 void stmInitialize();
166 int stmTransitionState(int event_no, StmState* state);
167 void stmUndoState();
168
169
170 #endif  // TMCAGLWM_STUB_STM_HPP