1 /* 2 * Copyright (c) 2021-2022 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* PARAM_FORM_IDENTITY_KEY = "ohos.extra.param.key.form_identity"; 31 constexpr const char* PARAM_FORM_CALLING_IDENTITY_KEY = "ohos.extra.param.key.form_calling_identity"; 32 constexpr const char* PARAM_MODULE_NAME_KEY = "ohos.extra.param.key.module_name"; 33 constexpr const char* PARAM_BUNDLE_NAME_KEY = "ohos.extra.param.key.bundle_name"; 34 constexpr const char* PARAM_ABILITY_NAME_KEY = "ohos.extra.param.key.ability_name"; 35 constexpr const char* PARAM_FORM_NAME_KEY = "ohos.extra.param.key.form_name"; 36 constexpr const char* PARAM_FORM_DIMENSION_KEY = "ohos.extra.param.key.form_dimension"; 37 constexpr const char* PARAM_FORM_RENDERINGMODE_KEY = "ohos.extra.param.key.form_rendering_mode"; 38 constexpr const char* PARAM_MESSAGE_KEY = "ohos.extra.param.key.message"; 39 constexpr const char* PARAM_FORM_TEMPORARY_KEY = "ohos.extra.param.key.form_temporary"; 40 constexpr const char* PARAM_CALLER_BUNDLE_NAME_KEY = "ohos.extra.param.key.caller_bundle_name"; 41 constexpr const char* PARAM_FORM_TRANSPARENCY_KEY = "ohos.extra.param.key.form_background_transparency"; 42 constexpr const char* PARAM_FORM_WIDTH_KEY = "ohos.extra.param.key.form_width"; 43 constexpr const char* PARAM_FORM_HEIGHT_KEY = "ohos.extra.param.key.form_height"; 44 constexpr int32_t ONE_HOST_MAX_FORM_SIZE = 256; 45 constexpr const char* RECREATE_FORM_KEY = "ohos.extra.param.key.recreate"; 46 constexpr const char* PARAM_FORM_CUSTOMIZE_KEY = "ohos.extra.param.key.form_customize"; 47 constexpr const char* PARAM_FORM_ORIENTATION_KEY = "ohos.extra.param.key.form_orientation"; 48 constexpr int32_t ORIENTATION_PORTRAIT = 1; 49 constexpr int32_t ORIENTATION_LANDSCAPE = 2; 50 constexpr const char* PARAM_FORM_ABILITY_NAME_KEY = "abilityName"; 51 constexpr const char* PARAM_FORM_USER_ID = "ohos.extra.param.key.form_user_id"; 52 constexpr const char* KEY_IS_TIMER = "isCountTimerRefresh"; 53 constexpr const char* KEY_TIMER_REFRESH = "isTimerRefresh"; 54 constexpr const char* SYSTEM_PARAM_FORM_UPDATE_TIME = "persist.sys.fms.form.update.time"; 55 constexpr const char* SYSTEM_PARAM_FORM_REFRESH_MIN_TIME = "persist.sys.fms.form.refresh.min.time"; 56 constexpr const char* ACTION_UPDATEATTIMER = "form_update_at_timer"; 57 constexpr const char* KEY_WAKEUP_TIME = "wakeUpTime"; 58 constexpr const char* KEY_WAKEUP_TIME_LEFT = "wakeUpTimeLeft"; 59 constexpr const char* KEY_WAKEUP_TIME_RIGHT = "wakeUpTimeRight"; 60 constexpr const char* KEY_ACTION_TYPE = "form_update_action_type"; 61 constexpr const char* ABS_CODE_PATH = "/data/app/el1/bundle/public"; 62 constexpr const char* LOCAL_CODE_PATH = "/data/storage/el1/bundle"; 63 constexpr const char* LOCAL_BUNDLES = "/data/bundles"; 64 constexpr const char* FORM_PUBLISH_ACTION = "action.form.publish"; 65 constexpr const char* PARAM_DEVICE_ID_KEY = "ohos.extra.param.key.device_id"; 66 constexpr const char* PARAM_FORM_HOST_TOKEN = "ohos.extra.param.form.host.token"; 67 constexpr const char* PARAM_PUBLISH_FORM_HOST_BUNDLE_KEY = "ohos.extra.param.key.form_host_bundle_name"; 68 constexpr const char* PARAM_PUBLISH_FORM_HOST_MODULE_KEY = "ohos.extra.param.key.form_host_module_name"; 69 constexpr const char* PARAM_PUBLISH_FORM_HOST_ABILITY_KEY = "ohos.extra.param.key.form_host_ability_name"; 70 constexpr const char* FRS_BUNDLE_NAME = "com.ohos.formrenderservice"; 71 constexpr const char* FRS_APP_INDEX = "ohos.extra.param.key.frs_index"; 72 constexpr const char* PARAM_FORM_ID = "formID"; 73 constexpr const char* IS_FORM_AGENT = "isFormAgent"; 74 constexpr const char* PARAM_FORM_BORDER_WIDTH_KEY = "ohos.extra.param.key.form_border_width"; 75 constexpr int32_t TYPE_RESET_LIMIT = 1; 76 constexpr int32_t TYPE_STATIC_UPDATE = 2; 77 constexpr int32_t TYPE_DYNAMIC_UPDATE = 3; 78 const long ABS_REFRESH_MS = 2500; 79 80 constexpr int32_t UNKNOWN = 0; 81 // The form events type which means that the form becomes visible. 82 constexpr int32_t FORM_VISIBLE = 1; 83 // The form events type which means that the form becomes invisible. 84 constexpr int32_t FORM_INVISIBLE = 2; 85 86 // The default user id 87 constexpr int32_t DEFAULT_USER_ID = 0; 88 89 // The invalid user id 90 constexpr int32_t INVALID_USER_ID = -1; 91 92 // The default provider user id 93 constexpr int32_t DEFAULT_PROVIDER_USER_ID = -1; 94 95 // The max uid of system app. 96 constexpr int32_t MAX_SYSTEM_APP_UID = 10000; 97 98 constexpr int32_t MIN_TIME_SPEED = 1; 99 constexpr int32_t MAX_TIME_SPEED = 1000; 100 constexpr int32_t MAX_HOUR = 23; 101 constexpr int32_t MAX_MINUTE = 59; 102 constexpr int32_t MAX_SECOND = 60; 103 constexpr int32_t MIN_TIME = 0; 104 constexpr int32_t HOUR_PER_DAY = 24; 105 constexpr int32_t MIN_PER_HOUR = 60; 106 constexpr int32_t SEC_PER_MIN = 60; 107 constexpr int32_t MS_PER_DAY = 24 * 60 * 60 * 1000; 108 const long TIME_1000 = 1000; 109 const long TIME_1000000 = 1000000; 110 const long TIME_CONVERSION = 30 * 60 * TIME_1000; 111 constexpr int32_t MIN_CONFIG_DURATION = 1; // 1 means 30 min 112 constexpr int32_t MAX_CONFIG_DURATION = 2 * 24 * 7; // one week 113 const long MIN_PERIOD = MIN_CONFIG_DURATION * TIME_CONVERSION; // 30 min in ms unit 114 const long MAX_PERIOD = MAX_CONFIG_DURATION * TIME_CONVERSION; // 1 week in ms unit 115 const long ABS_TIME = 5 * TIME_1000; // 5s abs time 116 constexpr const char* TIME_DELIMETER = ":"; 117 constexpr int32_t UPDATE_AT_CONFIG_COUNT = 2; 118 119 constexpr int32_t LIMIT_COUNT = 50; 120 constexpr int32_t MIN_NEXT_TIME = 300; // seconds 121 122 // The max retry times of reconnection. 123 constexpr int32_t MAX_RETRY_TIME = 30; 124 // The time interval between reconnections(milliseconds). 125 constexpr int32_t SLEEP_TIME = 1000; 126 127 constexpr int64_t MS_PER_SECOND = 1000; 128 129 // form host bundlename 130 constexpr const char* PARAM_FORM_HOST_BUNDLENAME_KEY = "form_host_bundlename"; 131 132 // form manager service bundlename 133 constexpr const char* PARAM_FORM_MANAGER_SERVICE_BUNDLENAME_KEY = "form_manager_service_bundlename"; 134 135 // PROVIDER_FLAG false:ProviderFormInfo is null;true: ProviderFormInfo not null 136 constexpr const char* PROVIDER_FLAG = "provider_flag"; 137 constexpr const char* FORM_CONNECT_ID = "form_connect_id"; 138 constexpr const char* FORM_SUPPLY_INFO = "form_supply_info"; 139 constexpr const char* FORM_SHARE_REQUEST_CODE = "form_share_request_code"; 140 constexpr const char* FORM_ACQUIRE_DATA_REQUEST_CODE = "form_acquire_data_request_code"; 141 // the delimiter between bundleName and abilityName 142 constexpr const char* NAME_DELIMITER = "::"; 143 144 constexpr const char* PARAM_FORM_ADD_COUNT = "form.add.count"; 145 146 constexpr const char* FORM_SUPPLY_UID = "form_supply_uid"; 147 constexpr const char* FORM_RENDER_COMP_ID = "form_render_comp_id"; 148 constexpr const char* FORM_DELAY_TIME_OF_RECYCLE = "form_delay_time_of_recycle"; 149 constexpr const char* FORM_STATUS_DATA = "form_status_data"; 150 constexpr const char* FORM_IS_RECOVER_FORM_TO_HANDLE_CLICK_EVENT = "form_is_recover_form_to_handle_click_event"; 151 152 const size_t MAX_LAYOUT = 8; 153 constexpr int32_t MAX_FORMS = 512; 154 constexpr int32_t MAX_RECORD_PER_APP = 256; 155 constexpr int32_t MAX_TEMP_FORMS = 256; 156 constexpr int32_t MAX_FORM_DATA_SIZE = 1024; 157 constexpr int32_t DEFAULT_VISIBLE_NOTIFY_DELAY = 1000; 158 159 constexpr char MAX_NORMAL_FORM_SIZE [] = "maxNormalFormSize"; 160 constexpr char MAX_TEMP_FORM_SIZE [] = "maxTempFormSize"; 161 constexpr char HOST_MAX_FORM_SIZE [] = "hostMaxFormSize"; 162 constexpr char VISIBLE_NOTIFY_DELAY [] = "visibleNotifyDelayTime"; 163 164 constexpr int32_t NOT_IN_RECOVERY = 0; 165 constexpr int32_t RECOVER_FAIL = 1; 166 constexpr int32_t IN_RECOVERING = 2; 167 168 constexpr int32_t FLAG_HAS_OBJECT = 1; 169 constexpr int32_t FLAG_NO_OBJECT = 0; 170 171 constexpr int32_t DEATH_RECIPIENT_FLAG = 0; 172 constexpr int32_t MAX_VISIBLE_NOTIFY_LIST = 32; 173 174 constexpr const char* ACQUIRE_TYPE = "form_acquire_form"; 175 constexpr int32_t ACQUIRE_TYPE_CREATE_FORM = 1; 176 constexpr int32_t ACQUIRE_TYPE_RECREATE_FORM = 2; 177 178 constexpr int32_t DELETE_FORM = 3; 179 constexpr int32_t RELEASE_FORM = 8; 180 constexpr int32_t RELEASE_CACHED_FORM = 9; 181 182 constexpr int64_t INVALID_UDID_HASH = 0L; 183 184 enum class Dimension : int8_t { 185 DIMENSION_MIN = 1, 186 DIMENSION_1_2 = DIMENSION_MIN, 187 DIMENSION_2_2, 188 DIMENSION_2_4, 189 DIMENSION_4_4, 190 DIMENSION_2_1, 191 DIMENSION_1_1, 192 DIMENSION_MAX = DIMENSION_1_1 193 }; 194 195 const std::map<Dimension, std::string> DIMENSION_MAP = { 196 {Dimension::DIMENSION_1_2, "1*2"}, 197 {Dimension::DIMENSION_2_2, "2*2"}, 198 {Dimension::DIMENSION_2_4, "2*4"}, 199 {Dimension::DIMENSION_4_4, "4*4"}, 200 {Dimension::DIMENSION_2_1, "2*1"}, 201 {Dimension::DIMENSION_1_1, "1*1"} 202 }; 203 204 enum class RenderingMode : int8_t { 205 FULL_COLOR = 0, 206 SINGLE_COLOR 207 }; 208 209 // rdb 210 constexpr const char* FORM_RDB_NAME = "/formdb.db"; 211 constexpr const char* FORM_RDB_TABLE_NAME = "form_table"; 212 constexpr const char* FORM_MANAGER_SERVICE_PATH = "/data/service/el1/public/database/form_storage"; 213 constexpr const char* FORM_JOURNAL_MODE = "WAL"; 214 constexpr const char* FORM_SYNC_MODE = "FULL"; 215 constexpr int32_t FORM_RDB_VERSION = 1; 216 constexpr const char* FORM_RDB_FILE_TYPE = ""; 217 constexpr const char* FORM_RENDER_TYPE_KEY = "form_render_type"; 218 constexpr int32_t RENDER_FORM = 0; // default value 219 constexpr int32_t UPDATE_RENDERING_FORM = 1; 220 constexpr const char* FORM_COMPILE_MODE_KEY = "form_compile_mode"; 221 constexpr const char* FORM_COMPATIBLE_VERSION_KEY = "form_compatible_version"; 222 223 //ArkTs card 224 constexpr const char* FORM_COMP_ID = "ohos.extra.param.key.form_comp_id"; 225 constexpr const char* FORM_DENSITY = "ohos.extra.param.key.form_density"; 226 constexpr const char* FORM_PROCESS_ON_ADD_SURFACE = "ohos.extra.param.key.process_on_add_surface"; 227 constexpr const char* FORM_ALLOW_UPDATE = "allowUpdate"; 228 229 // The state of whether the ArkTs card can be rendered 230 constexpr const char FORM_RENDER_STATE[] = "ohos.extra.param.key.form_render_state"; 231 232 //CallEvent 233 constexpr const char* FORM_CALL_EVENT_PARAMS = "params"; 234 constexpr const char* PARAM_FORM_CALL_EVENT_METHOD_KEY = "method"; 235 constexpr int32_t EVENT_CALL_NOTIFY = 1; 236 //arquireFormData 237 constexpr const char* LAUNCH_REASON_KEY = "ohos.extra.param.key.form_launch_reason"; 238 // The form launch reason which means that the form is default. 239 constexpr int32_t FORM_DEFAULT = 1; 240 // The form launch reason which means that the form is share. 241 constexpr int32_t FORM_SHARE = 2; 242 // Specify the form Id 243 constexpr const char* PARAM_FORM_MIGRATE_FORM_KEY = "ohos.extra.param.key.migrate_form"; 244 // For click message event 245 constexpr const char* KEY_DIRECT_CALL_INAPP = "directCallInApp"; 246 } // namespace Constants 247 } // namespace AppExecFwk 248 } // namespace OHOS 249 #endif // OHOS_FORM_FWK_FORM_CONSTANTS_H 250