1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_FORM_FWK_FORM_CONSTANTS_H
17 #define OHOS_FORM_FWK_FORM_CONSTANTS_H
18 
19 #include <map>
20 #include <string>
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 namespace Constants {
25     constexpr const char* PERMISSION_INTERACT_ACROSS_LOCAL_ACCOUNTS = "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS";
26     constexpr const char* PERMISSION_REQUIRE_FORM = "ohos.permission.REQUIRE_FORM";
27     constexpr const char* PERMISSION_AGENT_REQUIRE_FORM = "ohos.permission.AGENT_REQUIRE_FORM";
28     constexpr const char* PERMISSION_KEEP_BACKGROUND_RUNNING = "ohos.permission.KEEP_BACKGROUND_RUNNING";
29     constexpr const char* PERMISSION_OBSERVE_FORM_RUNNING = "ohos.permission.OBSERVE_FORM_RUNNING";
30     constexpr const char* PERMISSION_START_ABILITIES_FROM_BACKGROUND =
31         "ohos.permission.START_ABILITIES_FROM_BACKGROUND";
32     constexpr const char* PARAM_FORM_IDENTITY_KEY = "ohos.extra.param.key.form_identity";
33     constexpr const char* PARAM_FORM_CALLING_IDENTITY_KEY = "ohos.extra.param.key.form_calling_identity";
34     constexpr const char* PARAM_MODULE_NAME_KEY = "ohos.extra.param.key.module_name";
35     constexpr const char* PARAM_BUNDLE_NAME_KEY = "ohos.extra.param.key.bundle_name";
36     constexpr const char* PARAM_ABILITY_NAME_KEY = "ohos.extra.param.key.ability_name";
37     constexpr const char* PARAM_FORM_NAME_KEY = "ohos.extra.param.key.form_name";
38     constexpr const char* PARAM_FORM_DIMENSION_KEY = "ohos.extra.param.key.form_dimension";
39     constexpr const char* PARAM_FORM_RENDERINGMODE_KEY = "ohos.extra.param.key.form_rendering_mode";
40     constexpr const char* PARAM_FORM_OBSCURED_KEY = "ohos.extra.param.key.form_obscured_mode";
41     constexpr const char* PARAM_MESSAGE_KEY = "ohos.extra.param.key.message";
42     constexpr const char* PARAM_FORM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary";
43     constexpr const char* PARAM_CALLER_BUNDLE_NAME_KEY = "ohos.extra.param.key.caller_bundle_name";
44     constexpr const char* PARAM_FORM_TRANSPARENCY_KEY = "ohos.extra.param.key.form_background_transparency";
45     constexpr const char* PARAM_FORM_WIDTH_KEY = "ohos.extra.param.key.form_width";
46     constexpr const char* PARAM_FORM_HEIGHT_KEY = "ohos.extra.param.key.form_height";
47     constexpr int32_t ONE_HOST_MAX_FORM_SIZE = 256;
48     constexpr const char* RECREATE_FORM_KEY = "ohos.extra.param.key.recreate";
49     constexpr const char* PARAM_FORM_CUSTOMIZE_KEY = "ohos.extra.param.key.form_customize";
50     constexpr const char* PARAM_FORM_ORIENTATION_KEY = "ohos.extra.param.key.form_orientation";
51     constexpr int32_t ORIENTATION_PORTRAIT = 1;
52     constexpr int32_t ORIENTATION_LANDSCAPE = 2;
53     constexpr const char* PARAM_FORM_ABILITY_NAME_KEY = "abilityName";
54     constexpr const char* PARAM_FORM_USER_ID = "ohos.extra.param.key.form_user_id";
55     constexpr const char* KEY_IS_TIMER = "isCountTimerRefresh";
56     constexpr const char* KEY_TIMER_REFRESH = "isTimerRefresh";
57     constexpr const char* SYSTEM_PARAM_FORM_UPDATE_TIME = "persist.sys.fms.form.update.time";
58     constexpr const char* SYSTEM_PARAM_FORM_REFRESH_MIN_TIME = "persist.sys.fms.form.refresh.min.time";
59     constexpr const char* ACTION_UPDATEATTIMER = "form_update_at_timer";
60     constexpr const char* KEY_WAKEUP_TIME = "wakeUpTime";
61     constexpr const char* KEY_WAKEUP_TIME_LEFT = "wakeUpTimeLeft";
62     constexpr const char* KEY_WAKEUP_TIME_RIGHT = "wakeUpTimeRight";
63     constexpr const char* KEY_ACTION_TYPE = "form_update_action_type";
64     constexpr const char* ABS_CODE_PATH = "/data/app/el1/bundle/public";
65     constexpr const char* LOCAL_CODE_PATH = "/data/storage/el1/bundle";
66     constexpr const char* LOCAL_BUNDLES = "/data/bundles";
67     constexpr const char* FORM_PUBLISH_ACTION = "action.form.publish";
68     constexpr const char* PARAM_DEVICE_ID_KEY = "ohos.extra.param.key.device_id";
69     constexpr const char* PARAM_FORM_HOST_TOKEN = "ohos.extra.param.form.host.token";
70     constexpr const char* PARAM_PUBLISH_FORM_HOST_BUNDLE_KEY = "ohos.extra.param.key.form_host_bundle_name";
71     constexpr const char* PARAM_PUBLISH_FORM_HOST_MODULE_KEY = "ohos.extra.param.key.form_host_module_name";
72     constexpr const char* PARAM_PUBLISH_FORM_HOST_ABILITY_KEY = "ohos.extra.param.key.form_host_ability_name";
73     constexpr const char* FRS_BUNDLE_NAME = "com.ohos.formrenderservice";
74     constexpr const char* FRS_APP_INDEX = "ohos.extra.param.key.frs_index";
75     constexpr const char* PARAM_FORM_ID = "formID";
76     constexpr const char* IS_FORM_AGENT = "isFormAgent";
77     constexpr const char* PARAM_FORM_BORDER_WIDTH_KEY = "ohos.extra.param.key.form_border_width";
78     constexpr const char* FORM_LOCATION_KEY = "ohos.extra.param.key.form_location";
79     constexpr const char* FORM_DISABLE_GESTURE_KEY = "ohos.extra.param.key.form_disable_gesture";
80     constexpr int32_t TYPE_RESET_LIMIT = 1;
81     constexpr int32_t TYPE_STATIC_UPDATE = 2;
82     constexpr int32_t TYPE_DYNAMIC_UPDATE = 3;
83     const long ABS_REFRESH_MS = 2500;
84     constexpr const char* PARAM_HOST_BG_INVERSE_COLOR_KEY = "ohos.extra.param.key.host_bg_inverse_color";
85     constexpr const char* PARAM_FONT_FOLLOW_SYSTEM_KEY = "ohos.inner.key.font_follow_system";
86     constexpr const char* PARAM_THEME_KEY  = "ohos.extra.param.key.form_is_theme";
87     constexpr const char* PARAM_THEME_THEME_FORM_ID  = "themeFormId";
88     constexpr const char* PARAM_THEME_THEME_ID  = "themeId";
89     constexpr const char* PARAM_PUBLISH_FORM_HOST_SNAPSHOT_KEY = "ohos.extra.param.key.add_form_to_host_snapshot";
90     constexpr const char* PARAM_PUBLISH_FORM_HOST_WIDTH_KEY = "ohos.extra.param.key.add_form_to_host_width";
91     constexpr const char* PARAM_PUBLISH_FORM_HOST_HEIGHT_KEY = "ohos.extra.param.key.add_form_to_host_height";
92     constexpr const char* PARAM_PUBLISH_FORM_HOST_SCREENX_KEY = "ohos.extra.param.key.add_form_to_host_screenx";
93     constexpr const char* PARAM_PUBLISH_FORM_HOST_SCREENY_KEY = "ohos.extra.param.key.add_form_to_host_screeny";
94     constexpr const char* CPU_SCENE_ID_CONFIG_UPDATE  = "1";
95     constexpr const char* PARAM_DYNAMIC_NAME_KEY = "isDynamic";
96     constexpr const char* RECYCLE_FORMS_USER_ID = "ohos.extra.param.key.recycle_forms_user_id";
97     constexpr const char* PARAM_APP_CLONE_INDEX_KEY = "ohos.extra.param.key.appCloneIndex";
98 
99     constexpr int32_t UNKNOWN = 0;
100     // The form events type which means that the form becomes visible.
101     constexpr int32_t FORM_VISIBLE = 1;
102     // The form events type which means that the form becomes invisible.
103     constexpr int32_t FORM_INVISIBLE = 2;
104 
105     // The default user id
106     constexpr int32_t DEFAULT_USER_ID = 0;
107 
108     constexpr int32_t DEFAULT_SANDBOX_FRS_APP_INDEX = 1001;
109 
110     // The invalid user id
111     constexpr int32_t INVALID_USER_ID = -1;
112 
113     // The default provider user id
114     constexpr int32_t DEFAULT_PROVIDER_USER_ID = -1;
115 
116     // The max uid of system app.
117     constexpr int32_t MAX_SYSTEM_APP_UID = 10000;
118 
119     constexpr int32_t CALLING_UID_TRANSFORM_DIVISOR = 200000;
120 
121     constexpr int32_t MIN_TIME_SPEED = 1;
122     constexpr int32_t MAX_TIME_SPEED = 1000;
123     constexpr int32_t MAX_HOUR = 23;
124     constexpr int32_t MAX_MINUTE = 59;
125     constexpr int32_t MAX_SECOND = 60;
126     constexpr int32_t MIN_TIME = 0;
127     constexpr int32_t HOUR_PER_DAY = 24;
128     constexpr int32_t MIN_PER_HOUR = 60;
129     constexpr int32_t SEC_PER_MIN = 60;
130     constexpr int32_t MS_PER_DAY = 24 * 60 * 60 * 1000;
131     const long TIME_1000 = 1000;
132     const long TIME_1000000 = 1000000;
133     const long TIME_CONVERSION = 30 * 60 * TIME_1000;
134     constexpr int32_t MIN_CONFIG_DURATION = 1; // 1 means 30 min
135     constexpr int32_t MAX_CONFIG_DURATION = 2 * 24 * 7; // one week
136     const long MIN_PERIOD = MIN_CONFIG_DURATION * TIME_CONVERSION; // 30 min in ms unit
137     const long MAX_PERIOD = MAX_CONFIG_DURATION * TIME_CONVERSION; // 1 week in ms unit
138     const long ABS_TIME = 30 * TIME_1000; // 30s abs time
139     constexpr const char* TIME_DELIMETER = ":";
140     constexpr int32_t UPDATE_AT_CONFIG_COUNT = 2;
141 
142     constexpr int32_t LIMIT_COUNT = 50;
143     constexpr int32_t MIN_NEXT_TIME = 300; // seconds
144 
145     // The max retry times of reconnection.
146     constexpr int32_t MAX_RETRY_TIME = 30;
147     // The time interval between reconnections(milliseconds).
148     constexpr int32_t SLEEP_TIME = 1000;
149 
150     constexpr int64_t MS_PER_SECOND = 1000;
151 
152     // form host bundlename
153     constexpr const char* PARAM_FORM_HOST_BUNDLENAME_KEY = "form_host_bundlename";
154 
155     // form manager service bundlename
156     constexpr const char* PARAM_FORM_MANAGER_SERVICE_BUNDLENAME_KEY = "form_manager_service_bundlename";
157 
158     // PROVIDER_FLAG false:ProviderFormInfo is null;true: ProviderFormInfo not null
159     constexpr const char* PROVIDER_FLAG = "provider_flag";
160     constexpr const char* FORM_CONNECT_ID = "form_connect_id";
161     constexpr const char* FORM_SUPPLY_INFO = "form_supply_info";
162     constexpr const char* FORM_SHARE_REQUEST_CODE = "form_share_request_code";
163     constexpr const char* FORM_ACQUIRE_DATA_REQUEST_CODE = "form_acquire_data_request_code";
164     // the delimiter between bundleName and abilityName
165     constexpr const char* NAME_DELIMITER = "::";
166 
167     constexpr const char* PARAM_FORM_ADD_COUNT = "form.add.count";
168 
169     constexpr const char* FORM_SUPPLY_UID = "form_supply_uid";
170     constexpr const char* FORM_RENDER_COMP_ID = "form_render_comp_id";
171     constexpr const char* FORM_DELAY_TIME_OF_RECYCLE = "form_delay_time_of_recycle";
172     constexpr const char* FORM_STATUS_DATA = "form_status_data";
173     constexpr const char* FORM_IS_DYNAMIC = "form_is_dynamic";
174     constexpr const char* FORM_IS_RECOVER_FORM = "form_is_recover_form";
175     constexpr const char* FORM_IS_RECOVER_FORM_TO_HANDLE_CLICK_EVENT = "form_is_recover_form_to_handle_click_event";
176 
177     const size_t MAX_LAYOUT = 8;
178     constexpr int32_t MAX_FORMS = 512;
179     constexpr int32_t MAX_RECORD_PER_APP = 256;
180     constexpr int32_t MAX_TEMP_FORMS = 256;
181     constexpr int32_t MAX_FORM_DATA_SIZE = 1024;
182     constexpr int32_t DEFAULT_VISIBLE_NOTIFY_DELAY = 1000;
183 
184     constexpr char MAX_NORMAL_FORM_SIZE [] = "maxNormalFormSize";
185     constexpr char MAX_TEMP_FORM_SIZE [] = "maxTempFormSize";
186     constexpr char HOST_MAX_FORM_SIZE [] = "hostMaxFormSize";
187     constexpr char VISIBLE_NOTIFY_DELAY [] = "visibleNotifyDelayTime";
188 
189     constexpr int32_t NOT_IN_RECOVERY = 0;
190     constexpr int32_t RECOVER_FAIL = 1;
191     constexpr int32_t IN_RECOVERING = 2;
192 
193     constexpr int32_t FLAG_HAS_OBJECT = 1;
194     constexpr int32_t FLAG_NO_OBJECT = 0;
195 
196     constexpr int32_t DEATH_RECIPIENT_FLAG = 0;
197     constexpr int32_t MAX_VISIBLE_NOTIFY_LIST = 32;
198 
199     constexpr const char* ACQUIRE_TYPE = "form_acquire_form";
200     constexpr int32_t ACQUIRE_TYPE_CREATE_FORM = 1;
201     constexpr int32_t ACQUIRE_TYPE_RECREATE_FORM = 2;
202 
203     constexpr int32_t DELETE_FORM = 3;
204     constexpr int32_t RELEASE_FORM = 8;
205     constexpr int32_t RELEASE_CACHED_FORM = 9;
206 
207     constexpr int64_t INVALID_UDID_HASH = 0L;
208 
209     constexpr int32_t REFRESH_ALL_FORM = 0;
210     constexpr int32_t REFRESH_APP_FORM = 1;
211     constexpr int32_t REFRESH_ATOMIC_FORM = 2;
212     constexpr int32_t REFRESH_SYSTEMAPP_FORM = 3;
213 
214     enum class Dimension : int8_t {
215         DIMENSION_MIN = 1,
216         DIMENSION_1_2 = DIMENSION_MIN,
217         DIMENSION_2_2,
218         DIMENSION_2_4,
219         DIMENSION_4_4,
220         DIMENSION_2_1,
221         DIMENSION_1_1,
222         DIMENSION_6_4,
223         DIMENSION_MAX = DIMENSION_6_4
224     };
225 
226     enum class Shape : int8_t {
227         RECT = 1,
228         CIRCLE
229     };
230 
231     const std::map<Dimension, std::string> DIMENSION_MAP = {
232         {Dimension::DIMENSION_1_2, "1*2"},
233         {Dimension::DIMENSION_2_2, "2*2"},
234         {Dimension::DIMENSION_2_4, "2*4"},
235         {Dimension::DIMENSION_4_4, "4*4"},
236         {Dimension::DIMENSION_2_1, "2*1"},
237         {Dimension::DIMENSION_1_1, "1*1"},
238         {Dimension::DIMENSION_6_4, "6*4"}
239     };
240 
241     enum class RenderingMode : int8_t {
242         FULL_COLOR = 0,
243         SINGLE_COLOR
244     };
245 
246     enum class FormLocation : int8_t {
247         OTHER = -1,
248         DESKTOP = 0,
249         FORM_CENTER = 1,
250         FORM_MANAGER = 2,
251         NEGATIVE_SCREEN = 3,
252         FORM_CENTER_NEGATIVE_SCREEN = 4,
253         FORM_MANAGER_NEGATIVE_SCREEN = 5,
254         SCREEN_LOCK = 6,
255         AI_SUGGESTION = 7,
256     };
257 
258     enum class PublishFormErrorCode : int8_t {
259         SUCCESS,
260         NO_SPACE,
261         PARAM_ERROR,
262         INTERNAL_ERROR,
263     };
264 
265     struct PublishFormResult {
266         PublishFormErrorCode code;
267         std::string message;
268     };
269 
270     // rdb
271     const std::string FORM_MANAGER_SERVICE_PATH = "/data/service/el1/public/database/form_storage";
272     const std::string FORM_RDB_NAME = "/formdb.db";
273     constexpr const char* FORM_RDB_TABLE_NAME = "form_table";
274     constexpr const char* FORM_JOURNAL_MODE = "WAL";
275     constexpr const char* FORM_SYNC_MODE = "FULL";
276     constexpr int32_t FORM_RDB_VERSION = 1;
277     constexpr const char* FORM_RDB_FILE_TYPE = "";
278     constexpr const char* FORM_RENDER_TYPE_KEY = "form_render_type";
279     constexpr int32_t RENDER_FORM = 0; // default value
280     constexpr int32_t UPDATE_RENDERING_FORM = 1;
281     constexpr const char* FORM_COMPILE_MODE_KEY = "form_compile_mode";
282     constexpr const char* FORM_COMPATIBLE_VERSION_KEY = "form_compatible_version";
283     constexpr const char* FORM_TARGET_VERSION_KEY = "form_target_version";
284 
285     //ArkTs card
286     constexpr const char* FORM_COMP_ID = "ohos.extra.param.key.form_comp_id";
287     constexpr const char* FORM_DENSITY = "ohos.extra.param.key.form_density";
288     constexpr const char* FORM_PROCESS_ON_ADD_SURFACE = "ohos.extra.param.key.process_on_add_surface";
289     constexpr const char* FORM_ALLOW_UPDATE = "allowUpdate";
290 
291     // The state of whether the ArkTs card can be rendered
292     constexpr const char FORM_RENDER_STATE[] = "ohos.extra.param.key.form_render_state";
293 
294     //CallEvent
295     constexpr const char* FORM_CALL_EVENT_PARAMS = "params";
296     constexpr const char* PARAM_FORM_CALL_EVENT_METHOD_KEY = "method";
297     constexpr int32_t EVENT_CALL_NOTIFY = 1;
298     //arquireFormData
299     constexpr const char* LAUNCH_REASON_KEY = "ohos.extra.param.key.form_launch_reason";
300     // The form launch reason which means that the form is default.
301     constexpr int32_t FORM_DEFAULT = 1;
302     // The form launch reason which means that the form is share.
303     constexpr int32_t FORM_SHARE = 2;
304     // Specify the form Id
305     constexpr const char* PARAM_FORM_MIGRATE_FORM_KEY = "ohos.extra.param.key.migrate_form";
306     // For click message event
307     constexpr const char* KEY_DIRECT_CALL_INAPP = "directCallInApp";
308     // Is the user granted
309     constexpr const char* FORM_PERMISSION_GRANTED_KEY = "ohos.extra.param.key.permission_granted";
310     // User permission name
311     constexpr const char* FORM_PERMISSION_NAME_KEY = "ohos.extra.param.key.permission_name";
312 
313     constexpr const char* MODULE_PKG_NAME_KEY = "pkg_name";
314     constexpr const char* MODULE_HAP_PATH_KEY = "hap_path";
315     // Form enable skeleton key
316     constexpr const char* FORM_ENABLE_SKELETON_KEY = "ohos.extra.param.key.enable_skeleton";
317     // Allow form update and refresh
318     constexpr const char* FORM_ENABLE_UPDATE_REFRESH_KEY = "enableFormUpdateRefresh";
319 }  // namespace Constants
320 }  // namespace AppExecFwk
321 }  // namespace OHOS
322 #endif  // OHOS_FORM_FWK_FORM_CONSTANTS_H
323