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