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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H 18 19 #include<map> 20 #include <string> 21 #include <vector> 22 23 namespace OHOS { 24 namespace AppExecFwk { 25 namespace Constants { 26 const std::string EMPTY_STRING = ""; 27 const std::string BUNDLE_PROFILE_NAME = "config.json"; 28 const std::string MODULE_PROFILE_NAME = "module.json"; 29 const std::string SYSCAP_NAME = "rpcid.sc"; 30 const std::string INSTALL_FILE_SUFFIX = ".hap"; 31 const std::string PROFILE_FILE_SUFFIX = ".json"; 32 const std::string PROFILE_FILE_COLON = ":"; 33 const std::string PATH_SEPARATOR = "/"; 34 const std::string FILE_UNDERLINE = "_"; 35 const std::string ILLEGAL_PATH_FIELD = "../"; 36 const char DOT_SUFFIX = '.'; 37 const char FILE_SEPARATOR_CHAR = '/'; 38 const std::string CURRENT_DEVICE_ID = "PHONE-001"; 39 const std::string PRE_INSTALL_DEVICE_ID = "PRE-" + CURRENT_DEVICE_ID; 40 const std::string BUNDLE_DATA_BASE_DIR = "/data/bundlemgr"; 41 const std::string BUNDLE_DATA_BASE_FILE = BUNDLE_DATA_BASE_DIR + "/bmsdb.json"; 42 const std::string SYSTEM_APP_SCAN_PATH = "/system/app"; 43 const std::string SYSTEM_RESOURCES_APP_PATH = "/system/app/SystemResources.hap"; 44 const std::string SYSTEM_APP_INSTALL_PATH = "/data/accounts"; 45 const std::string THIRD_SYSTEM_APP_SCAN_PATH = "/system/vendor"; 46 const std::string THIRD_SYSTEM_APP_INSTALL_PATH = "/data/accounts"; 47 const std::string THIRD_PARTY_APP_INSTALL_PATH = "/data/accounts"; 48 const std::string EXTRACT_TMP_PATH = "/data/sadata/install_tmp/bundle_haps"; 49 const std::string HAP_COPY_PATH = "/data/sadata/install_tmp/Tmp_"; 50 const std::string USER_ACCOUNT_DIR = "account"; 51 const std::string APP_CODE_DIR = "applications"; 52 const std::string APP_DATA_DIR = "appdata"; 53 const std::string DATA_BASE_DIR = "database"; 54 const std::string DATA_DIR = "files"; 55 const std::string CACHE_DIR = "cache"; 56 const std::string CACHES_DIR = "caches"; 57 const std::string SHARED_DIR = "shared"; 58 const std::string SHARED_PREFERENCE_DIR = "sharedPreference"; 59 const std::string TMP_SUFFIX = "_tmp"; 60 const std::string ASSETS_DIR = "assets"; 61 const std::string RESOURCES_INDEX = "resources.index"; 62 const std::string BUNDLE_CODE_DIR = "/data/app/el1/bundle/public"; 63 const std::string BUNDLE_BASE_CODE_DIR = "/data/app/el1/bundle"; 64 const std::string BUNDLE_APP_DATA_BASE_DIR = "/data/app/"; 65 const std::string BASE = "/base/"; 66 const std::string DATABASE = "/database/"; 67 const std::string HAPS = "/haps/"; 68 const std::string DISTRIBUTED_FILE = "/data/service/el2/%/hmdfs/account/data/"; 69 const std::string DISTRIBUTED_FILE_NON_ACCOUNT = "/data/service/el2/%/hmdfs/non_account/data/"; 70 const std::string DISTRIBUTED_FILE_PROPERTY = "const.distributed_file_property.enabled"; 71 const std::vector<std::string> BUNDLE_EL = {"el1", "el2"}; 72 const std::vector<std::string> BUNDLE_DATA_DIR = { 73 "/cache", 74 "/files", 75 "/temp", 76 "/preferences", 77 "/haps", 78 "/el3/base", 79 "/el4/base" 80 }; 81 82 const std::string BMS_SERVICE_NAME = "BundleMgrService"; 83 const std::string INSTALLD_SERVICE_NAME = "installd"; 84 const std::string SYSTEM_APP = "system"; 85 const std::string THIRD_PARTY_APP = "third-party"; 86 constexpr int START_USERID = 100; 87 constexpr int DEFAULT_USERID = 0; 88 constexpr int INVALID_USERID = -1; 89 constexpr int UNSPECIFIED_USERID = -2; 90 constexpr int ALL_USERID = -3; 91 constexpr int ANY_USERID = -4; 92 constexpr int NOT_EXIST_USERID = -5; 93 constexpr int PATH_MAX_SIZE = 256; 94 constexpr int SIGNATURE_MATCHED = 0; 95 constexpr int SIGNATURE_NOT_MATCHED = 1; 96 constexpr int SIGNATURE_UNKNOWN_BUNDLE = 2; 97 constexpr int PERMISSION_GRANTED = 0; 98 constexpr int PERMISSION_NOT_GRANTED = -1; 99 constexpr int DUMP_INDENT = 4; 100 constexpr unsigned int INSTALLD_UMASK = 0000; 101 constexpr unsigned int PERMISSION_COMPATIBLE_API_VERSION = 7; 102 103 // native so 104 const std::string ABI_DEFAULT = "default"; 105 const std::string ABI_SEPARATOR = ","; 106 const std::string ARM_EABI = "armeabi"; 107 const std::string ARM_EABI_V7A = "armeabi-v7a"; 108 const std::string ARM64_V8A = "arm64-v8a"; 109 const std::string X86 = "x86"; 110 const std::string X86_64 = "x86_64"; 111 const std::string LIBS = "libs/"; 112 const std::string LIBS_ARM_EABI_V7A = "libs/armeabi-v7a/"; 113 const std::string ARM = "arm"; 114 const std::map<std::string, std::string> ABI_MAP = { 115 {ARM_EABI, "arm"}, 116 {ARM_EABI_V7A, "arm"}, 117 {ARM64_V8A, "arm64"}, 118 {X86, "x86"}, 119 {X86_64, "x86_64"}, 120 }; 121 const std::string SO_SUFFIX = ".so"; 122 constexpr unsigned int SO_SUFFIX_LEN = 3; 123 124 // uid and gid 125 constexpr int32_t INVALID_UID = -1; 126 constexpr int32_t INVALID_GID = -1; 127 constexpr int32_t INVALID_BUNDLEID = -1; 128 constexpr int32_t INVALID_ACCESS_TOKEN_ID = -1; 129 constexpr int32_t ROOT_UID = 0; 130 constexpr int32_t C_UESRID = 200; // clone bundle userId. 131 constexpr int32_t BMS_UID = 1000; 132 constexpr int32_t BMS_GID = 1000; 133 constexpr int32_t BASE_SYS_UID = 2100; 134 constexpr int32_t MAX_SYS_UID = 2899; 135 constexpr int32_t BASE_SYS_VEN_UID = 5000; 136 constexpr int32_t MAX_SYS_VEN_UID = 5999; 137 constexpr int32_t BASE_APP_UID = 10000; 138 constexpr int32_t BASE_USER_RANGE = 200000; 139 constexpr int32_t MAX_APP_UID = 65535; 140 constexpr int32_t U_VALUE = 100000; 141 constexpr int32_t DATABASE_DIR_GID = 3012; 142 constexpr int32_t DFS_GID = 1009; 143 const std::string PROFILE_KEY_UID_SIZE = "size"; 144 const std::string PROFILE_KEY_UID_AND_GID = "uid_and_gid"; 145 146 // permissions 147 const std::string PERMISSION_INSTALL_BUNDLE = "ohos.permission.INSTALL_BUNDLE"; 148 const std::string PERMISSION_GET_BUNDLE_INFO = "ohos.permission.GET_BUNDLE_INFO"; 149 const std::string PERMISSION_GET_BUNDLE_INFO_PRIVILEGED = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"; 150 const std::string PERMISSION_CHANGE_ABILITY_ENABLED_STATE = "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"; 151 const std::string PERNISSION_REMOVECACHEFILE = "ohos.permission.REMOVE_CACHE_FILES"; 152 153 enum class AppType { 154 SYSTEM_APP = 0, 155 THIRD_SYSTEM_APP, 156 THIRD_PARTY_APP, 157 }; 158 159 const std::string INTENT_ACTION_HOME = "action.system.home"; 160 const std::string INTENT_ENTITY_HOME = "entity.system.home"; 161 const std::string FLAG_HOME_INTENT_FROM_SYSTEM = "flag.home.intent.from.system"; 162 163 // the ability file folder name. 164 const std::string LIB_FOLDER_NAME = "libs"; 165 const std::string RES_FOLDER_NAME = "resources"; 166 167 constexpr uint8_t MAX_LABLE_LEN = 30; 168 constexpr uint8_t MAX_BUNDLE_NAME = 255; 169 constexpr uint8_t MIN_BUNDLE_NAME = 7; 170 constexpr uint8_t MAX_VENDOR = 255; 171 constexpr uint8_t EQUAL_ZERO = 0; 172 constexpr uint8_t MAX_MODULE_PACKAGE = 127; 173 constexpr uint8_t MAX_MODULE_NAME = 255; 174 constexpr uint8_t MAX_MODULE_ABILITIES_READPERMISSION = 255; 175 constexpr uint8_t MAX_MODULE_ABILITIES_WRITEPERMISSION = 255; 176 constexpr uint8_t MAX_MODULE_SHORTCUTID = 63; 177 constexpr uint8_t MAX_MODULE_LABEL = 63; 178 constexpr uint8_t MAX_JSON_ELEMENT_LENGTH = 255; 179 constexpr uint16_t MAX_JSON_ARRAY_LENGTH = 512; 180 // max number of haps under one direction 181 constexpr uint8_t MAX_HAP_NUMBER = 128; 182 183 // distributed database 184 const std::string APP_ID = "bundle_manager_service"; 185 const std::string STORE_ID = "installed_bundle_datas"; 186 const std::string ABILITY_USAGE_STORE_ID = "ability_usage_datas"; 187 const std::string PRE_INSTALL_DATA_STORE_ID = "preinstall_usage_datas"; 188 const std::string DISTRIBUTE_DATA_STORE_ID = "distribute_bundle_datas"; 189 190 // single max hap size 191 constexpr int64_t ONE_GB = 1024 * 1024 * 1024; 192 constexpr int64_t MAX_HAP_SIZE = ONE_GB * 4; // 4GB 193 194 const std::string UID = "uid"; 195 const std::string USER_ID = "userId"; 196 const std::string BUNDLE_NAME = "bundleName"; 197 const int32_t MAX_LIMIT_SIZE = 4; 198 199 const std::string DATA_ABILITY_URI_PREFIX = "dataability://"; 200 const char DATA_ABILITY_URI_SEPARATOR = '/'; 201 202 const std::string PARAM_URI_SEPARATOR = ":///"; 203 const uint32_t PARAM_URI_SEPARATOR_LEN = 4; 204 const std::string URI_SEPARATOR = "://"; 205 const uint32_t URI_SEPARATOR_LEN = 3; 206 const std::string SEPARATOR = "/"; 207 208 const int MAX_DIMENSION_SIZE = 10; 209 const int MAX_DEVICETYPE_SIZE = 50; 210 211 // appFeature 212 const std::string HOS_NORMAL_APP = "hos_normal_app"; 213 const std::string HOS_SYSTEM_APP = "hos_system_app"; 214 const std::string OHOS_SYSTEM_APP = "ohos_system_app"; 215 216 // ipc 217 const int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M 218 219 // file size 220 const int32_t INVALID_FILE_SIZE = -1; 221 222 // permission 223 const std::string LISTEN_BUNDLE_CHANGE = "ohos.permission.LISTEN_BUNDLE_CHANGE"; 224 225 // hmdfs config 226 constexpr std::string_view ABILTY_NAME = "abilityName"; 227 const std::string HMDFS_CONFIG_PATH {"/config/hmdfs/"}; 228 const std::string BUNDLE_ID_FILE = { "bid" }; 229 const std::string PATH_SEPERATE {"/"}; 230 } // namespace Constants 231 } // namespace AppExecFwk 232 } // namespace OHOS 233 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_BUNDLE_CONSTANTS_H 234