1 /* 2 * Copyright (c) 2020-2023 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_BUNDLE_COMMON_H 17 #define OHOS_BUNDLE_COMMON_H 18 19 #include "pms.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 #ifdef __cplusplus 25 } 26 #endif 27 28 #include "ability_info.h" 29 #include "module_info.h" 30 #include "stdint.h" 31 32 namespace OHOS { 33 const char PROFILE_NAME[] = "config.json"; 34 const char SERVICE_NAME[] = "ohos.nfc.cardemulation.action.HOST_APDU_SERVICE"; 35 const char JSON_SUFFIX[] = ".json"; 36 const char PATH_SEPARATOR[] = "/"; 37 const char FILE_DELIMITER[] = "_"; 38 const char MODULE_ENTRY[] = "entry"; 39 const char MODULE_FEATURE[] = "feature"; 40 const uint16_t PATH_LENGTH = 256; 41 const uint8_t ICON_NUM = 2; 42 const uint16_t MAX_METADATA_NAME = 255; 43 const uint16_t MAX_METADATA_VALUE = 255; 44 const uint16_t MAX_NAME_LEN = 255; 45 const uint16_t MAX_DECRIPTION_LEN = 255; 46 const uint16_t MAX_VENDOR_LEN = 255; 47 const uint8_t MAX_MODULENAME_LEN = 31; 48 const uint8_t MAX_ABILITY_NAME_LEN = 255; 49 const int8_t PROFILE_INVALID = -1; 50 const int8_t BUNDLENAME_INVALID = -2; 51 const int8_t VERSION_CODE_INVALID = -3; 52 const uint8_t MAX_SINGLE_DIGIT_VALUE = 10; 53 const uint8_t ZERO_ASCII_NUM = 48; 54 // bundle type 55 const uint8_t SYSTEM_APP_FLAG = 0; 56 const uint8_t THIRD_SYSTEM_APP_FLAG = 1; 57 const uint8_t THIRD_APP_FLAG = 2; 58 59 const uint8_t MIN_BUNDLE_NAME_LEN = 7; 60 const uint8_t MAX_BUNDLE_NAME_LEN = 127; 61 62 const char LABEL_ID[] = "labelId"; 63 const char ICON_ID[] = "iconId"; 64 const char MODULE_DES_ID[] = "descriptionId"; 65 const char ABILITY_DES_ID[] = "descriptionId"; 66 const char RESOURCES_INDEX[] = "/resources.index"; 67 const char DEFAULT_LABEL_SETTING[] = "$string:"; 68 const char DEFAULT_DESC_SETTING[] = "$string:"; 69 const char DEFAULT_ICON_SETTING_BEGIN[] = "$media:"; 70 // app config 71 const char PROFILE_KEY_APP[] = "app"; 72 const char PROFILE_KEY_VENDOR[] = "vendor"; 73 const char PROFILE_KEY_BUNDLENAME[] = "bundleName"; 74 const char PROFILE_KEY_VERSION[] = "version"; 75 const char PROFILE_KEY_VERSION_CODE[] = "code"; 76 const char PROFILE_KEY_VERSION_NAME[] = "name"; 77 const char PROFILE_KEY_APIVERSION[] = "apiVersion"; 78 const char PROFILE_KEY_APIVERSION_COMPATIBLE[] = "compatible"; 79 const char PROFILE_KEY_APIVERSION_TARGET[] = "target"; 80 const char PROFILE_KEY_SKILLS[] = "skills"; 81 const char PROFILE_KEY_SKILLS_ENTITIES[] = "entities"; 82 const char PROFILE_KEY_SKILLS_ACTIONS[] = "actions"; 83 // deviceConfig 84 const char PROFILE_KEY_DEVICECONFIG[] = "deviceConfig"; 85 const char PROFILE_KEY_DEVICECONFIG_DEFAULT[] = "default"; 86 const char PROFILE_KEY_KEEPALIVE[] = "keepAlive"; 87 // module config 88 const char PROFILE_KEY_MODULE[] = "module"; 89 const char PROFILE_KEY_MODULE_NAME[] = "name"; 90 const char PROFILE_KEY_MODULE_DESCRIPTION[] = "description"; 91 const char PROFILE_KEY_MODULE_DEVICETYPE[] = "deviceType"; 92 const char PROFILE_KEY_MODULE_DISTRO[] = "distro"; 93 const char PROFILE_KEY_MODULE_DISTRO_DELIVERY[] = "deliveryWithInstall"; 94 const char PROFILE_KEY_MODULE_DISTRO_MODULENAME[] = "moduleName"; 95 const char PROFILE_KEY_MODULE_DISTRO_MODULETYPE[] = "moduleType"; 96 const char PROFILE_KEY_MODULE_METADATA[] = "metaData"; 97 const char PROFILE_KEY_MODULE_METADATA_CUSTOMIZEDATA[] = "customizeData"; 98 const char PROFILE_KEY_MODULE_METADATA_NAME[] = "name"; 99 const char PROFILE_KEY_MODULE_METADATA_VALUE[] = "value"; 100 const char PROFILE_KEY_MODULE_METADATA_EXTRA[] = "extra"; 101 const char PROFILE_KEY_MODULE_ABILITIES[] = "abilities"; 102 const char PROFILE_KEY_MODULE_ABILITY_NAME[] = "name"; 103 const char PROFILE_KEY_MODULE_ABLLITY_DESCRIPTION[] = "description"; 104 const char PROFILE_KEY_MODULE_ABILITY_LABEL[] = "label"; 105 const char PROFILE_KEY_MODULE_ABILITY_ICON[] = "icon"; 106 const char PROFILE_KEY_MODULE_ABILITY_TYPE[] = "type"; 107 const char PROFILE_KEY_MODULE_ABILITY_LAUNCHTYPE[] = "launchType"; 108 const char PROFILE_KEY_MODULE_ABILITY_VISIBLE[] = "visible"; 109 const char PROFILE_KEY_MODULE_ABILITY_DEVICE_CAP[] = "deviceCapability"; 110 const char PROFILE_KEY_MODULE_ABILITY_SRC_PATH[] = "srcPath"; 111 // js config 112 const char PROFILE_KEY_JS[] = "js"; 113 114 const char PROFILE_KEY_REQPERMISSIONS[] = "reqPermissions"; 115 const char PROFILE_KEY_REQPERMISSIONS_NAME[] = "name"; 116 const char PROFILE_KEY_REQPERMISSIONS_REASON[] = "reason"; 117 const char PROFILE_KEY_REQPERMISSIONS_USEDSCENE[] = "usedScene"; 118 const char PROFILE_KEY_REQPERMISSIONS_WHEN[] = "when"; 119 120 const char ASSETS[] = "/assets/"; 121 122 const char GRANTTIME_INUSE[] = "inuse"; 123 const char GRANTTIME_ALWAYS[] = "always"; 124 // shared lib path 125 const char SHARED_LIB_NAME[] = "shared_libs"; 126 const char SHARED_LIB_PATH[] = "/storage/app/libs"; 127 128 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 129 const char DEFAULT_DEVICE_TYPE[] = "smartVision"; 130 const char INSTALL_PATH[] = "/storage/app/run"; 131 const char DATA_PATH[] = "/storage/app/data"; 132 const char JSON_PATH[] = "/storage/app/etc/bundles/"; 133 const char EXTEANAL_INSTALL_PATH[] = "/sdcard/app/run"; 134 const char EXTEANAL_DATA_PATH[] = "/sdcard/app/data"; 135 const char SYSTEM_BUNDLE_PATH[] = "/system/internal"; 136 const char THIRD_SYSTEM_BUNDLE_PATH[] = "/system/external"; 137 const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/uninstalled_delbundle.json"; 138 const char THIRD_SYSTEM_BUNDLE_JSON[] = "/storage/app/etc/third_system_bundle.json"; 139 const char UID_GID_MAP[] = "uid_gid_map"; 140 const char INSTALL_FILE_SUFFIX[] = ".hap"; 141 // uid and gid 142 const int8_t INVALID_UID = -1; 143 const int8_t INVALID_GID = -1; 144 const uint32_t BASE_SYS_UID = 100; 145 const uint32_t BASE_SYS_VEN_UID = 1000; 146 const uint32_t MAX_SYS_VEN_UID = 9999; 147 const uint32_t BASE_APP_UID = 10000; 148 const char PROFILE_KEY_UID_SIZE[] = "size"; 149 const char PROFILE_KEY_UID_AND_GID[] = "uid_and_gid"; 150 151 const uint8_t MAX_VERSION_NAME_LEN = 127; 152 const uint16_t MAX_LABLE_LEN = 255; 153 #else 154 const char DEFAULT_DEVICE_TYPE[] = "fitnessWatch"; 155 const char INSTALL_PATH[] = "user/ace/run"; 156 const char DATA_PATH[] = "user/ace/data"; 157 const char SYSTEM_BUNDLE_PATH[] = "system/ace/sys"; 158 const char THIRD_SYSTEM_BUNDLE_PATH[] = "system/ace/vendor"; 159 const char UNINSTALL_THIRD_SYSTEM_BUNDLE_JSON[] = "user/ace/etc/uninstalled_delbundle.json"; 160 const char THIRD_SYSTEM_BUNDLE_JSON[] = "user/ace/etc/third_system_bundle.json"; 161 const char JSON_PATH[] = "user/ace/etc/bundles/"; 162 const char JSON_PATH_NO_SLASH_END[] = "user/ace/etc/bundles"; 163 // store bundle permissions for IAM 164 const char PERMISSIONS_PATH[] = "user/ace/etc/permissions"; 165 const char ASSET_JS_PATH[] = "/assets/js/default"; 166 const char NEW_ASSET_JS_PATH[] = "/assets/js/MainAbility"; 167 const char ASSET_PATH[] = "/assets/js/"; 168 const char ICON_NAME[] = "/icon.bin"; 169 const char SMALL_ICON_NAME[] = "/icon_small.bin"; 170 const char ICON_PNG_NAME[] = "/icon.png.bin"; 171 const char SMALL_ICON_PNG_NAME[] = "/icon_small.png.bin"; 172 const char DEFAULT_ICON_SETTING[] = "$media:icon"; 173 const char INSTALL_FILE_SUFFIX[] = ".bin"; 174 const char TMP_RESOURCE_DIR[] = "user/ace/run/tmpResource"; 175 const char RESOURCES_RAW_FILE[] = "/resources/rawfile"; 176 const char RAW_FILE[] = "/rawfile"; 177 const uint16_t READ_SIZE = 1024 * 4; 178 const uint8_t MAGIC_NUMBER_LEN = 1; 179 const uint8_t INT_LENGTH = 4; 180 const uint8_t LONG_LENGTH = 8; 181 const uint16_t MAX_INT = 256; 182 const uint8_t MAX_VERSION_NAME_LEN = 20; 183 const uint8_t MAX_LABLE_LEN = 30; 184 const uint8_t MAX_THIRD_BUNDLE_NUMBER = 45; 185 186 struct SignatureInfo { 187 char *bundleName; 188 char *appId; 189 char **restricPermission; 190 uint32_t restricNum; 191 }; 192 #endif 193 // InstallRecord key 194 const char JSON_MAIN_KEY[] = "packages"; 195 const char JSON_SUB_KEY_PACKAGE[] = "bundleName"; 196 const char JSON_SUB_KEY_CODEPATH[] = "codePath"; 197 const char JSON_SUB_KEY_APPID[] = "appID"; 198 const char JSON_SUB_KEY_VERSIONCODE[] = "versionCode"; 199 const char JSON_SUB_KEY_JSENGINE_VERSION[] = "JsEngineVersion"; 200 const char JSON_SUB_KEY_TRANSFORM_RESULT[] = "transformResult"; 201 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 202 const char JSON_SUB_KEY_UID[] = "uid"; 203 const char JSON_SUB_KEY_GID[] = "gid"; 204 #endif 205 206 struct ProfileVersion { 207 #ifdef __LITEOS_M__ 208 int32_t versionCode; 209 #else 210 uint32_t versionCode; 211 #endif 212 char *versionName; 213 }; 214 215 struct ProfileApiVersion { 216 int32_t minApiVersion; 217 int32_t maxApiVersion; 218 }; 219 220 struct AbilityRes { 221 uint32_t iconId; 222 uint32_t labelId; 223 uint32_t descriptionId; 224 uint32_t index; 225 }; 226 227 struct BundleRes { 228 char *bundleName; 229 uint32_t moduleDescriptionId; 230 AbilityRes *abilityRes; 231 uint32_t totalNumOfAbilityRes; 232 }; 233 234 struct BundleProfile { 235 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 236 bool isKeepAlive; 237 bool isNativeApp; 238 #endif 239 char *bundleName; 240 char *vendor; 241 char *label; 242 char *iconPath; 243 char *srcPath = nullptr; 244 ProfileVersion profileVersion; 245 ProfileApiVersion profileApiVersion; 246 ModuleInfo moduleInfo; 247 AbilityInfo *abilityInfos; 248 uint32_t numOfAbility; 249 }; 250 251 struct Permissions { 252 int32_t permNum; 253 PermissionTrans *permissionTrans; 254 }; 255 256 struct InstallRecord { 257 char *bundleName; 258 char *codePath; 259 char *appId; // it contains bundleName and cert publicKey 260 #ifndef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 261 #ifndef __LINUX__ 262 #ifdef BC_TRANS_ENABLE 263 char *jsEngineVersion; 264 int32_t transformResult; // 0: success, -1: fail 265 #endif 266 #endif 267 #endif 268 int32_t versionCode; 269 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 270 int32_t uid; 271 int32_t gid; 272 #endif 273 }; 274 } // namespace OHOS 275 #endif // OHOS_BUNDLE_COMMON_H 276