常量整改

Signed-off-by: 张欣宇 <zhangxinyu74@huawei.com>
Change-Id: Ibcb1dd9f67ac98562c66c2f349a5a52f7660119e
This commit is contained in:
张欣宇 2024-05-07 09:28:11 +00:00
parent 4a01a9ec87
commit 28cbdb5b7b
41 changed files with 251 additions and 261 deletions

View File

@ -23,8 +23,7 @@
namespace OHOS {
namespace AppExecFwk {
namespace Constants {
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
const std::string EMPTY_STRING = "";
constexpr const char* EMPTY_STRING = "";
constexpr const char* INSTALL_FILE_SUFFIX = ".hap";
constexpr const char* HSP_FILE_SUFFIX = ".hsp";
constexpr const char* QUICK_FIX_FILE_SUFFIX = ".hqf";
@ -33,13 +32,8 @@ constexpr const char* FILE_UNDERLINE = "_";
const char FILE_SEPARATOR_CHAR = '/';
constexpr const char* CURRENT_DEVICE_ID = "PHONE-001";
constexpr const char* HAP_COPY_PATH = "/data/service/el1/public/bms/bundle_manager_service";
constexpr const char* BUNDLE_RESOURCE = "/data/service/el1/public/bms/bundle_resources";
constexpr const char* CACHE_DIR = "cache";
constexpr const char* TMP_SUFFIX = "_tmp";
constexpr const char* ASSETS_DIR = "assets";
constexpr const char* RESOURCES_INDEX = "resources.index";
constexpr const char* BUNDLE_CODE_DIR = "/data/app/el1/bundle/public";
constexpr const char* BUNDLE_BASE_CODE_DIR = "/data/app/el1/bundle";
constexpr const char* BUNDLE_APP_DATA_BASE_DIR = "/data/app/";
constexpr const char* BASE = "/base/";
constexpr const char* DATABASE = "/database/";
@ -49,7 +43,6 @@ constexpr const char* BUNDLE_MANAGER_SERVICE_PATH = "/data/service/el1/public/bm
constexpr const char* SANDBOX_DATA_PATH = "/data/storage/el2/base";
constexpr const char* REAL_DATA_PATH = "/data/app/el2";
constexpr const char* DATA_GROUP_PATH = "/group/";
constexpr const char* DATA_EXTENSION_PATH = "/extension/";
constexpr const char* STREAM_INSTALL_PATH = "stream_install";
constexpr const char* SECURITY_STREAM_INSTALL_PATH = "security_stream_install";
constexpr const char* QUICK_FIX_PATH = "quick_fix";
@ -68,20 +61,14 @@ constexpr int ALL_USERID = -3;
constexpr int ANY_USERID = -4;
constexpr int NOT_EXIST_USERID = -5;
constexpr int PATH_MAX_SIZE = 256;
constexpr int SIGNATURE_MATCHED = 0;
constexpr int SIGNATURE_NOT_MATCHED = 1;
constexpr int SIGNATURE_UNKNOWN_BUNDLE = 2;
constexpr int PERMISSION_GRANTED = 0;
constexpr int PERMISSION_NOT_GRANTED = -1;
constexpr int DEFAULT_STREAM_FD = -1;
constexpr int DUMP_INDENT = 4;
constexpr unsigned int INSTALLD_UMASK = 0000;
constexpr int32_t INVALID_API_VERSION = -1;
constexpr int32_t API_VERSION_EIGHT = 8;
constexpr int32_t API_VERSION_NINE = 9;
constexpr int32_t ALL_VERSIONCODE = -1;
constexpr int32_t INVALID_UDID = -1;
constexpr int32_t DEFAULT_INSTALLERID = -1;
constexpr int32_t BACKUP_DEFAULT_APP_KEY = -2;
// native so
@ -91,55 +78,33 @@ constexpr const char* MODULE_NAME_SEPARATOR = ",";
constexpr const char* ARM_EABI = "armeabi";
constexpr const char* ARM_EABI_V7A = "armeabi-v7a";
constexpr const char* ARM64_V8A = "arm64-v8a";
constexpr const char* X86 = "x86";
constexpr const char* X86_64 = "x86_64";
constexpr const char* ARM64 = "arm64";
extern const std::string LIBS;
extern const std::string AN;
extern const std::string AP;
constexpr const char* LIBS_ARM_EABI_V7A = "libs/armeabi-v7a/";
constexpr const char* ARM = "arm";
extern const std::map<std::string, std::string> ABI_MAP;
constexpr const char* DOT = ".";
constexpr const char* SO_SUFFIX = ".so";
constexpr const char* AN_SUFFIX = ".an";
constexpr const char* AI_SUFFIX = ".ai";
constexpr const char* AP_SUFFIX = ".ap";
constexpr const char* SYSTEM_LIB64 = "/system/lib64";
constexpr const char* DIFF_SUFFIX = ".diff";
constexpr const char* PATCH_PATH = "patch_";
constexpr const char* HOT_RELOAD_PATH = "hotreload_";
extern const std::string RES_FILE_PATH;
// uid and gid
constexpr int32_t INVALID_UID = -1;
constexpr int32_t INVALID_GID = -1;
constexpr int32_t INVALID_BUNDLEID = -1;
constexpr int32_t INVALID_ACCESS_TOKEN_ID = -1;
constexpr int32_t ROOT_UID = 0;
constexpr int32_t BMS_UID = 1000;
constexpr int32_t SHELL_UID = 2000;
constexpr int32_t BACKU_HOME_GID = 1089;
constexpr int32_t ACCOUNT_UID = 3058;
constexpr int32_t FOUNDATION_UID = 5523;
constexpr int32_t DMS_UID = 5522;
constexpr int32_t STORAGE_SERVICE_UID = 1090;
constexpr int32_t BMS_GID = 1000;
constexpr int32_t BASE_SYS_UID = 2100;
constexpr int32_t MAX_SYS_UID = 2899;
constexpr int32_t BASE_SYS_VEN_UID = 5000;
constexpr int32_t MAX_SYS_VEN_UID = 5999;
constexpr int32_t BASE_APP_UID = 10000;
constexpr int32_t BASE_USER_RANGE = 200000;
constexpr int32_t DATA_GROUP_UID_OFFSET = 100000;
constexpr int32_t MAX_APP_UID = 65535;
constexpr int32_t U_VALUE = 100000;
constexpr int32_t DATABASE_DIR_GID = 3012;
constexpr int32_t DFS_GID = 1009;
constexpr int32_t LOG_DIR_GID = 1007;
constexpr const char* PROFILE_KEY_UID_SIZE = "size";
constexpr const char* PROFILE_KEY_UID_AND_GID = "uid_and_gid";
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
// for render process
constexpr int32_t START_UID_FOR_RENDER_PROCESS = 1000000;
constexpr int32_t END_UID_FOR_RENDER_PROCESS = 1099999;
@ -169,8 +134,6 @@ constexpr const char* PERMISSION_INSTALL_QUICK_FIX_BUNDLE = "ohos.permission.INS
constexpr const char* PERMISSION_UNINSTALL_QUICK_FIX_BUNDLE = "ohos.permission.UNINSTALL_QUICK_FIX_BUNDLE";
constexpr const char* PERMISSION_CHANGE_BUNDLE_UNINSTALL_STATE = "ohos.permission.CHANGE_BUNDLE_UNINSTALL_STATE";
constexpr const char* PERMISSION_START_SHORTCUT = "ohos.permission.START_SHORTCUT";
// install list permissions file
constexpr const char* INSTALL_LIST_PERMISSIONS_FILE_PATH = "/system/etc/app/install_list_permissions.json";
enum class AppType {
SYSTEM_APP = 0,
@ -178,80 +141,42 @@ enum class AppType {
THIRD_PARTY_APP,
};
constexpr const char* ACTION_VIEW_DATA = "ohos.want.action.viewData";
constexpr const char* ACTION_HOME = "action.system.home";
constexpr const char* WANT_ACTION_HOME = "ohos.want.action.home";
constexpr const char* ENTITY_HOME = "entity.system.home";
constexpr const char* FLAG_HOME_INTENT_FROM_SYSTEM = "flag.home.intent.from.system";
// the ability file folder name.
constexpr const char* LIB_FOLDER_NAME = "libs";
constexpr const char* RES_FOLDER_NAME = "resources";
constexpr uint8_t MAX_LABLE_LEN = 30;
constexpr uint8_t MAX_BUNDLE_NAME = 128;
constexpr uint8_t MIN_BUNDLE_NAME = 7;
constexpr uint8_t MAX_VENDOR = 255;
constexpr uint8_t EQUAL_ZERO = 0;
constexpr uint8_t MAX_MODULE_PACKAGE = 127;
constexpr uint8_t MAX_MODULE_NAME = 31;
constexpr uint8_t MAX_MODULE_ABILITIES_READPERMISSION = 255;
constexpr uint8_t MAX_MODULE_ABILITIES_WRITEPERMISSION = 255;
constexpr uint8_t MAX_MODULE_SHORTCUTID = 63;
constexpr uint8_t MAX_MODULE_LABEL = 63;
constexpr uint8_t MAX_JSON_ELEMENT_LENGTH = 255;
constexpr uint16_t MAX_JSON_ARRAY_LENGTH = 512;
constexpr uint16_t MAX_JSON_STRING_LENGTH = 4096;
// max number of haps under one direction
constexpr uint8_t MAX_HAP_NUMBER = 128;
// single max hap size
constexpr int64_t ONE_GB = 1024 * 1024 * 1024;
constexpr int64_t MAX_HAP_SIZE = ONE_GB * 4; // 4GB
constexpr const char* UID = "uid";
constexpr const char* USER_ID = "userId";
constexpr const char* BUNDLE_NAME = "bundleName";
constexpr const char* MODULE_NAME = "moduleName";
constexpr const char* ABILITY_NAME = "abilityName";
constexpr const char* HAP_PATH = "hapPath";
constexpr const char* APP_ID = "appId";
constexpr int32_t MAX_LIMIT_SIZE = 4;
constexpr const char* DATA_ABILITY_URI_PREFIX = "dataability://";
const char DATA_ABILITY_URI_SEPARATOR = '/';
constexpr const char* PARAM_URI_SEPARATOR = ":///";
constexpr uint32_t PARAM_URI_SEPARATOR_LEN = 4;
constexpr const char* URI_SEPARATOR = "://";
constexpr const char* SEPARATOR = "/";
constexpr int MAX_DIMENSION_SIZE = 10;
constexpr int MAX_DEVICETYPE_SIZE = 50;
// appFeature
constexpr const char* HOS_NORMAL_APP = "hos_normal_app";
constexpr const char* HOS_SYSTEM_APP = "hos_system_app";
// rdb
constexpr const char* BUNDLE_RDB_NAME = "/bmsdb.db";
constexpr const char* BUNDLE_RDB_TABLE_NAME = "installed_bundle";
constexpr const char* PRE_BUNDLE_RDB_TABLE_NAME = "preinstalled_bundle";
constexpr const char* DEFAULT_APP_RDB_TABLE_NAME = "default_app";
constexpr const char* QUICK_FIX_RDB_TABLE_NAME = "quick_fix";
constexpr const char* SAND_BOX_RDB_TABLE_NAME = "sandbox";
const int32_t BUNDLE_RDB_VERSION = 1;
// ipc
constexpr int32_t ASHMEM_THRESHOLD = 200 * 1024; // 200K
constexpr int32_t PREINSTALL_PARCEL_CAPACITY = 400 * 1024; // 400K
constexpr int32_t CAPACITY_SIZE = 1 * 1024 * 1000; // 1M
constexpr int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M
constexpr int32_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
// file size
constexpr int32_t INVALID_FILE_SIZE = -1;
// permission
constexpr const char* LISTEN_BUNDLE_CHANGE = "ohos.permission.LISTEN_BUNDLE_CHANGE";
@ -286,14 +211,11 @@ constexpr const char* APP_DETAIL_ABILITY = "AppDetailAbility";
constexpr int32_t DEFAULT_OVERLAY_ENABLE_STATUS = 1;
constexpr int32_t DEFAULT_OVERLAY_DISABLE_STATUS = 0;
constexpr int32_t OVERLAY_MINIMUM_PRIORITY = 1;
constexpr int32_t OVERLAY_MAXIMUM_PRIORITY = 100;
constexpr const char* OVERLAY_STATE = "overlayState";
constexpr const char* PERMISSION_CHANGE_OVERLAY_ENABLED_STATE = "ohos.permission.CHANGE_OVERLAY_ENABLED_STATE";
// ark compile mode
constexpr const char* COMPILE_NONE = "none";
constexpr const char* COMPILE_PARTIAL = "partial";
constexpr const char* COMPILE_FULL = "full";
constexpr const char* ARK_CACHE_PATH = "/data/local/ark-cache/";
constexpr const char* ARK_PROFILE_PATH = "/data/local/ark-profile/";
@ -306,23 +228,15 @@ constexpr const char* SECURITY_SIGNATURE_FILE_PATH = "security_signature_files";
//pgo file
constexpr const char* PGO_FILE_SUFFIX = ".ap";
constexpr const char* PGO_FILE_PATH = "pgo_files";
//abc file
constexpr const char* ABC_FILE_SUFFIX = ".abc";
constexpr const char* ABC_FILE_PATH = "abc_files";
// system param
extern const std::string ALLOW_ENTERPRISE_BUNDLE;
extern const std::string IS_ENTERPRISE_DEVICE;
extern const std::string DEVELOPERMODE_STATE;
constexpr const char* ALLOW_ENTERPRISE_BUNDLE = "const.bms.allowenterprisebundle";
constexpr const char* IS_ENTERPRISE_DEVICE = "const.edm.is_enterprise_device";
constexpr const char* DEVELOPERMODE_STATE = "const.security.developermode.state";
//extResource
constexpr const char* EXT_RESOURCE_FILE_SUFFIX = ".hsp";
constexpr const char* EXT_RESOURCE_FILE_PATH = "ext_resource";
// sa id
constexpr int32_t DOWNLOAD_SERVICE_SA_ID = 3706;
// hmdfs and sharefs config
constexpr const char* HMDFS_CONFIG_PATH = "/config/hmdfs/";
constexpr const char* SHAREFS_CONFIG_PATH = "/config/sharefs/";
@ -332,10 +246,6 @@ constexpr const char* SYSTEM_UI_BUNDLE_NAME = "com.ohos.systemui";
constexpr const char* LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
// clone application
constexpr int32_t CLONE_APP_INDEX_MIN = 1;
constexpr int32_t CLONE_APP_INDEX_MAX = 5;
constexpr const char* SHADER_CACHE_PATH = "/data/local/shader_cache/local/";
extern const std::string CLONE_BUNDLE_PREFIX;
} // namespace Constants

View File

@ -24,6 +24,9 @@
namespace OHOS {
namespace AppExecFwk {
namespace JsonConstant {
constexpr uint16_t MAX_JSON_STRING_LENGTH = 4096;
}
enum class JsonType {
NULLABLE,
BOOLEAN,
@ -145,7 +148,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
}
data = jsonObject.at(key).get<T>();
if (jsonObject.at(key).get<std::string>().length() > Constants::MAX_JSON_STRING_LENGTH) {
if (jsonObject.at(key).get<std::string>().length() > JsonConstant::MAX_JSON_STRING_LENGTH) {
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_SIZE_CHECK_ERROR;
}
break;

View File

@ -21,12 +21,10 @@ namespace Constants {
const std::string PATH_SEPARATOR = "/";
const std::string LIBS = "libs/";
const std::string AN = "an/";
const std::string AP = "ap/";
const std::string RES_FILE_PATH = "resources/resfile/";
const std::string ALLOW_ENTERPRISE_BUNDLE = "const.bms.allowenterprisebundle";
const std::string IS_ENTERPRISE_DEVICE = "const.edm.is_enterprise_device";
const std::string DEVELOPERMODE_STATE = "const.security.developermode.state";
const std::vector<std::string> BUNDLE_EL = {DIR_EL1, DIR_EL2, DIR_EL3, DIR_EL4};
constexpr const char* X86 = "x86";
constexpr const char* X86_64 = "x86_64";
const std::map<std::string, std::string> ABI_MAP = {
{ARM_EABI, "arm"},
{ARM_EABI_V7A, "arm"},

View File

@ -25,6 +25,9 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr int MAX_DEVICETYPE_SIZE = 50;
}
using namespace Constants;
bool CompatibleAbilityInfo::ReadFromParcel(Parcel& parcel)
{
@ -79,7 +82,7 @@ bool CompatibleAbilityInfo::ReadFromParcel(Parcel& parcel)
int32_t deviceTypeSize;
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, deviceTypeSize);
if (deviceTypeSize > Constants::MAX_DEVICETYPE_SIZE) {
if (deviceTypeSize > MAX_DEVICETYPE_SIZE) {
APP_LOGE("device type size is overflow");
return false;
}

View File

@ -25,30 +25,30 @@
namespace OHOS {
namespace AppExecFwk {
const std::string JSON_KEY_TYPE = "type";
const std::string JSON_KEY_PERMISSIONS = "permissions";
const std::string JSON_KEY_ACTIONS = "actions";
const std::string JSON_KEY_ENTITIES = "entities";
const std::string JSON_KEY_URIS = "uris";
const std::string JSON_KEY_SKILLS = "skills";
const std::string JSON_KEY_SCHEME = "scheme";
const std::string JSON_KEY_HOST = "host";
const std::string JSON_KEY_PORT = "port";
const std::string JSON_KEY_PATH = "path";
const std::string JSON_KEY_PATHSTARTWITH = "pathStartWith";
const std::string JSON_KEY_PATHREGEX = "pathRegex";
const std::string JSON_KEY_UTD = "utd";
const std::string JSON_KEY_MAXFILESUPPORTED = "maxFileSupported";
const std::string JSON_KEY_LINKFEATURE = "linkFeature";
const std::string JSON_KEY_DOMAINVERIFY = "domainVerify";
const std::string BUNDLE_MODULE_PROFILE_KEY_PATHREGX = "pathRegx";
namespace {
const std::string PARAM_SEPARATOR = "?";
const std::string PORT_SEPARATOR = ":";
const std::string SCHEME_SEPARATOR = "://";
const std::string PATH_SEPARATOR = "/";
const std::string TYPE_WILDCARD = "*/*";
constexpr const char* JSON_KEY_TYPE = "type";
constexpr const char* JSON_KEY_PERMISSIONS = "permissions";
constexpr const char* JSON_KEY_ACTIONS = "actions";
constexpr const char* JSON_KEY_ENTITIES = "entities";
constexpr const char* JSON_KEY_URIS = "uris";
constexpr const char* JSON_KEY_SCHEME = "scheme";
constexpr const char* JSON_KEY_HOST = "host";
constexpr const char* JSON_KEY_PORT = "port";
constexpr const char* JSON_KEY_PATH = "path";
constexpr const char* JSON_KEY_PATHSTARTWITH = "pathStartWith";
constexpr const char* JSON_KEY_PATHREGEX = "pathRegex";
constexpr const char* JSON_KEY_UTD = "utd";
constexpr const char* JSON_KEY_MAXFILESUPPORTED = "maxFileSupported";
constexpr const char* JSON_KEY_LINKFEATURE = "linkFeature";
constexpr const char* JSON_KEY_DOMAINVERIFY = "domainVerify";
constexpr const char* BUNDLE_MODULE_PROFILE_KEY_PATHREGX = "pathRegx";
constexpr const char* PARAM_SEPARATOR = "?";
constexpr const char* PORT_SEPARATOR = ":";
constexpr const char* SCHEME_SEPARATOR = "://";
constexpr const char* PATH_SEPARATOR = "/";
constexpr const char* TYPE_WILDCARD = "*/*";
const char WILDCARD = '*';
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
}; // namespace
bool Skill::Match(const OHOS::AAFwk::Want &want) const
@ -366,7 +366,7 @@ bool Skill::MatchType(const std::string &type, const std::string &skillUriType)
return false;
}
// only match */*
if (type == Constants::TYPE_ONLY_MATCH_WILDCARD) {
if (type == TYPE_ONLY_MATCH_WILDCARD) {
return skillUriType == TYPE_WILDCARD;
}
if (type == TYPE_WILDCARD || skillUriType == TYPE_WILDCARD) {

View File

@ -21,6 +21,9 @@
namespace OHOS {
namespace AppExecFwk {
namespace StreamConstant {
constexpr int32_t DEFAULT_INSTALLERID = -1;
}
class IBundleStreamInstaller : public IRemoteBroker {
public:
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleStreamInstaller");
@ -47,7 +50,7 @@ public:
}
virtual uint32_t GetInstallerId() const
{
return Constants::DEFAULT_INSTALLERID;
return StreamConstant::DEFAULT_INSTALLERID;
}
virtual void SetInstallerId(uint32_t installerId) {};
virtual void UnInit() {};

View File

@ -37,6 +37,9 @@ const int32_t LIMIT_PARCEL_SIZE = 1024;
const int32_t ASHMEM_LEN = 16;
constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
const int32_t MAX_STATUS_VECTOR_NUM = 1000;
constexpr int32_t ASHMEM_THRESHOLD = 200 * 1024; // 200K
constexpr int32_t PREINSTALL_PARCEL_CAPACITY = 400 * 1024; // 400K
constexpr int32_t MAX_CAPACITY_BUNDLES = 5 * 1024 * 1000; // 5M
void SplitString(const std::string &source, std::vector<std::string> &strings)
{
@ -704,7 +707,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfos(MessageParcel &data, MessageParcel &
int userId = data.ReadInt32();
std::vector<BundleInfo> infos;
reply.SetDataCapacity(Constants::MAX_CAPACITY_BUNDLES);
reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
bool ret = GetBundleInfos(flag, infos, userId);
if (!reply.WriteBool(ret)) {
APP_LOGE("write failed");
@ -726,7 +729,7 @@ ErrCode BundleMgrHost::HandleGetBundleInfosWithIntFlags(MessageParcel &data, Mes
int userId = data.ReadInt32();
std::vector<BundleInfo> infos;
reply.SetDataCapacity(Constants::MAX_CAPACITY_BUNDLES);
reply.SetDataCapacity(MAX_CAPACITY_BUNDLES);
bool ret = GetBundleInfos(flags, infos, userId);
if (!reply.WriteBool(ret)) {
APP_LOGE("write failed");
@ -3255,7 +3258,7 @@ ErrCode BundleMgrHost::WriteBigParcelable(T &parcelable, const char *ashmemName,
{
auto size = sizeof(reply);
APP_LOGD("reply size is %{public}lu", static_cast<unsigned long>(size));
bool useAshMem = size > Constants::ASHMEM_THRESHOLD;
bool useAshMem = size > ASHMEM_THRESHOLD;
if (!reply.WriteBool(useAshMem)) {
APP_LOGE("write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -3365,7 +3368,7 @@ ErrCode BundleMgrHost::HandleGetAllPreinstalledApplicationInfos(MessageParcel &d
constexpr int32_t VECTOR_SIZE_UNDER_DEFAULT_DATA = 500;
if (vectorSize > VECTOR_SIZE_UNDER_DEFAULT_DATA &&
!reply.SetDataCapacity(Constants::PREINSTALL_PARCEL_CAPACITY)) {
!reply.SetDataCapacity(PREINSTALL_PARCEL_CAPACITY)) {
APP_LOGE("SetDataCapacity failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}

View File

@ -32,6 +32,12 @@
namespace OHOS {
namespace AppExecFwk {
namespace InnerConstant {
constexpr const char* ASSETS_DIR = "assets";
constexpr const char* RESOURCES_INDEX = "resources.index";
constexpr int32_t INVALID_GID = -1;
const std::string EMPTY_STRING = "";
}
struct ExtendResourceInfo {
std::string moduleName;
int32_t iconId;
@ -359,11 +365,11 @@ public:
{
InnerBundleUserInfo innerBundleUserInfo;
if (!GetInnerBundleUserInfo(userId, innerBundleUserInfo)) {
return Constants::INVALID_GID;
return InnerConstant::INVALID_GID;
}
if (innerBundleUserInfo.gids.empty()) {
return Constants::INVALID_GID;
return InnerConstant::INVALID_GID;
}
return innerBundleUserInfo.gids[0];
@ -397,11 +403,11 @@ public:
if (innerModuleInfos_.count(currentPackage_) == 1) {
std::string moduleResPath;
if (isNewVersion_) {
moduleResPath = moduleSrcDir + Constants::PATH_SEPARATOR + Constants::RESOURCES_INDEX;
moduleResPath = moduleSrcDir + Constants::PATH_SEPARATOR + InnerConstant::RESOURCES_INDEX;
} else {
moduleResPath = moduleSrcDir + Constants::PATH_SEPARATOR + Constants::ASSETS_DIR +
moduleResPath = moduleSrcDir + Constants::PATH_SEPARATOR + InnerConstant::ASSETS_DIR +
Constants::PATH_SEPARATOR +innerModuleInfos_.at(currentPackage_).distro.moduleName +
Constants::PATH_SEPARATOR + Constants::RESOURCES_INDEX;
Constants::PATH_SEPARATOR + InnerConstant::RESOURCES_INDEX;
}
innerModuleInfos_.at(currentPackage_).moduleResPath = moduleResPath;
@ -421,7 +427,7 @@ public:
return innerModuleInfos_.at(modulePackage).hapPath;
}
return Constants::EMPTY_STRING;
return InnerConstant::EMPTY_STRING;
}
const std::string &GetModuleName(const std::string &modulePackage) const
@ -430,7 +436,7 @@ public:
return innerModuleInfos_.at(modulePackage).moduleName;
}
return Constants::EMPTY_STRING;
return InnerConstant::EMPTY_STRING;
}
const std::string &GetCurModuleName() const;
@ -481,7 +487,7 @@ public:
if (innerModuleInfos_.find(modulePackage) != innerModuleInfos_.end()) {
return innerModuleInfos_.at(modulePackage).modulePath;
}
return Constants::EMPTY_STRING;
return InnerConstant::EMPTY_STRING;
}
std::string GetModuleDataDir(std::string modulePackage) const
@ -489,7 +495,7 @@ public:
if (innerModuleInfos_.find(modulePackage) != innerModuleInfos_.end()) {
return innerModuleInfos_.at(modulePackage).moduleDataDir;
}
return Constants::EMPTY_STRING;
return InnerConstant::EMPTY_STRING;
}
bool IsDisabled() const
@ -724,7 +730,7 @@ public:
baseBundleInfo_->entryInstallationFree = installationFree;
if (installationFree) {
baseApplicationInfo_->needAppDetail = false;
baseApplicationInfo_->appDetailAbilityLibraryPath = Constants::EMPTY_STRING;
baseApplicationInfo_->appDetailAbilityLibraryPath = InnerConstant::EMPTY_STRING;
}
}
@ -765,7 +771,7 @@ public:
baseApplicationInfo_->hideDesktopIcon = hideDesktopIcon;
if (hideDesktopIcon) {
baseApplicationInfo_->needAppDetail = false;
baseApplicationInfo_->appDetailAbilityLibraryPath = Constants::EMPTY_STRING;
baseApplicationInfo_->appDetailAbilityLibraryPath = InnerConstant::EMPTY_STRING;
}
}

View File

@ -29,7 +29,7 @@ struct BmsRdbConfig {
std::string tableName;
std::string createTableSql;
std::vector<std::string> insertColumnSql;
int32_t version { Constants::BUNDLE_RDB_VERSION };
int32_t version { 1 };
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -81,6 +81,7 @@ const std::string FAILURE_REASON_COMPILE_FAILED = "compile failed";
constexpr const char* PGO_MERGED_AP_PREFIX = "merged_";
constexpr const char* PGO_RT_AP_PREFIX = "rt_";
constexpr const char* COPY_AP_DEST_PATH = "/data/local/pgo/";
constexpr const char* COMPILE_NONE = "none";
}
AOTHandler::AOTHandler()
@ -234,9 +235,9 @@ void AOTHandler::HandleInstall(const std::unordered_map<std::string, InnerBundle
APP_LOGD("current device doesn't support arm64, no need to AOT");
return;
}
std::string compileMode = system::GetParameter(INSTALL_COMPILE_MODE, Constants::COMPILE_NONE);
std::string compileMode = system::GetParameter(INSTALL_COMPILE_MODE, COMPILE_NONE);
APP_LOGD("%{public}s = %{public}s", INSTALL_COMPILE_MODE, compileMode.c_str());
if (compileMode == Constants::COMPILE_NONE) {
if (compileMode == COMPILE_NONE) {
APP_LOGD("%{public}s = none, no need to AOT", INSTALL_COMPILE_MODE);
return;
}
@ -477,9 +478,9 @@ void AOTHandler::OTACompileInternal() const
return;
}
std::string compileMode = system::GetParameter(OTA_COMPILE_MODE, Constants::COMPILE_NONE);
std::string compileMode = system::GetParameter(OTA_COMPILE_MODE, COMPILE_NONE);
APP_LOGI("%{public}s = %{public}s", OTA_COMPILE_MODE, compileMode.c_str());
if (compileMode == Constants::COMPILE_NONE) {
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", OTA_COMPILE_MODE);
return;
}
@ -664,7 +665,7 @@ void AOTHandler::HandleIdle() const
}
std::string compileMode = system::GetParameter(IDLE_COMPILE_MODE, Constants::COMPILE_PARTIAL);
APP_LOGI("%{public}s = %{public}s", IDLE_COMPILE_MODE, compileMode.c_str());
if (compileMode == Constants::COMPILE_NONE) {
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", IDLE_COMPILE_MODE);
return;
}
@ -710,7 +711,7 @@ void AOTHandler::HandleCompile(const std::string &bundleName, const std::string
APP_LOGI("current device doesn't support arm64, no need to AOT");
return;
}
if (compileMode == Constants::COMPILE_NONE) {
if (compileMode == COMPILE_NONE) {
APP_LOGI("%{public}s = none, no need to AOT", IDLE_COMPILE_MODE);
return;
}

View File

@ -73,15 +73,15 @@ namespace OHOS {
namespace AppExecFwk {
using namespace OHOS::Security;
namespace {
const std::string ARK_CACHE_PATH = "/data/local/ark-cache/";
const std::string ARK_PROFILE_PATH = "/data/local/ark-profile/";
const std::string COMPILE_SDK_TYPE_OPEN_HARMONY = "OpenHarmony";
const std::string LOG = "log";
const std::string HSP_VERSION_PREFIX = "v";
const std::string PRE_INSTALL_HSP_PATH = "/shared_bundles/";
const std::string APP_INSTALL_PATH = "/data/app/el1/bundle";
const std::string DEBUG_APP_IDENTIFIER = "DEBUG_LIB_ID";
const std::string SKILL_URI_SCHEME_HTTPS = "https";
constexpr const char* ARK_CACHE_PATH = "/data/local/ark-cache/";
constexpr const char* ARK_PROFILE_PATH = "/data/local/ark-profile/";
constexpr const char* COMPILE_SDK_TYPE_OPEN_HARMONY = "OpenHarmony";
constexpr const char* LOG = "log";
constexpr const char* HSP_VERSION_PREFIX = "v";
constexpr const char* PRE_INSTALL_HSP_PATH = "/shared_bundles/";
constexpr const char* APP_INSTALL_PATH = "/data/app/el1/bundle";
constexpr const char* DEBUG_APP_IDENTIFIER = "DEBUG_LIB_ID";
constexpr const char* SKILL_URI_SCHEME_HTTPS = "https";
constexpr int32_t DATA_GROUP_DIR_MODE = 02770;
#ifdef STORAGE_SERVICE_ENABLE
@ -101,6 +101,7 @@ const std::set<std::string> SINGLETON_WHITE_LIST = {
"com.ohos.mms",
"com.ohos.FusionSearch"
};
constexpr const char* DATA_EXTENSION_PATH = "/extension/";
std::string GetHapPath(const InnerBundleInfo &info, const std::string &moduleName)
{
@ -3097,7 +3098,7 @@ void BaseBundleInstaller::UpdateExtensionSandboxInfo(std::unordered_map<std::str
continue;
}
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH
+ DATA_EXTENSION_PATH
+ iter->second.bundleName + Constants::PATH_SEPARATOR
+ iter->second.moduleName + Constants::PATH_SEPARATOR
+ iter->second.name;
@ -3173,7 +3174,7 @@ void BaseBundleInstaller::GetRemoveExtensionDirs(
for (const std::string &oldModuleName : oldModuleNames) {
if (newModules.find(oldModuleName) == newModules.end()) {
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH
+ DATA_EXTENSION_PATH
+ oldInfo.GetBundleName() + Constants::PATH_SEPARATOR
+ oldModuleName;
APP_LOGI("dir %{public}s need to be removed", dir.c_str());
@ -3251,7 +3252,7 @@ void BaseBundleInstaller::CheckRemoveExtensionBundleDir(
return;
}
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH + oldInfo.GetBundleName();
+ DATA_EXTENSION_PATH + oldInfo.GetBundleName();
if (isFeatureNeedUninstall_) {
if (!oldInfo.GetAllExtensionDirs(userId_).empty()) {
removeExtensionDirs_.clear();
@ -3300,7 +3301,7 @@ void BaseBundleInstaller::CheckRemoveExtensionModuleDir(
// current module need not to create extension dir
if (!oldInfo.GetAllExtensionDirsInSpecifiedModule(curModuleName, userId_).empty()) {
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH + oldInfo.GetBundleName()
+ DATA_EXTENSION_PATH + oldInfo.GetBundleName()
+ curModuleName;
APP_LOGI("need to remove extension dir for module, dir is %{public}s", dir.c_str());
removeExtensionDirs_.emplace_back(dir);
@ -3326,7 +3327,7 @@ void BaseBundleInstaller::CheckRemoveExtensionModuleDirWhenUpgrade(const std::ve
}
for (const std::string &moduleName : oldModules) {
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH + oldInfo.GetBundleName()
+ DATA_EXTENSION_PATH + oldInfo.GetBundleName()
+ moduleName;
if (oldInfo.GetAllExtensionDirsInSpecifiedModule(moduleName, userId_).empty()) {
APP_LOGI("dir %{public}s not existed", dir.c_str());
@ -3363,7 +3364,7 @@ void BaseBundleInstaller::RemoveBundleExtensionDir(const std::string &bundleName
return;
}
std::string dir = Constants::REAL_DATA_PATH + Constants::PATH_SEPARATOR + std::to_string(userId_)
+ Constants::DATA_EXTENSION_PATH + bundleName;
+ DATA_EXTENSION_PATH + bundleName;
auto result = InstalldClient::GetInstance()->RemoveDir(dir);
if (result != ERR_OK) {
APP_LOGW("remove extension dir %{public}s failed", dir.c_str());

View File

@ -37,6 +37,8 @@ constexpr const char* APP_IDENTIFIER = "appIdentifier";
constexpr const char* APP_DISTRIBUTION_TYPE = "appDistributionType";
constexpr const char* APP_INDEX = "appIndex";
const std::string BUNDLE_RESOURCES_CHANGED = "usual.event.BUNDLE_RESOURCES_CHANGED";
constexpr const char* UID = "uid";
constexpr const char* SANDBOX_APP_INDEX = "sandbox_app_index";
}
BundleCommonEventMgr::BundleCommonEventMgr()
@ -80,7 +82,7 @@ void BundleCommonEventMgr::NotifyBundleStatus(const NotifyBundleEvents &installR
element.SetModuleName(installResult.modulePackage);
element.SetAbilityName(installResult.abilityName);
want.SetElement(element);
want.SetParam(Constants::UID, installResult.uid);
want.SetParam(UID, installResult.uid);
int32_t bundleUserId = BundleUtil::GetUserIdByUid(installResult.uid);
want.SetParam(Constants::USER_ID, bundleUserId);
want.SetParam(Constants::ABILITY_NAME, installResult.abilityName);
@ -140,10 +142,10 @@ ErrCode BundleCommonEventMgr::NotifySandboxAppStatus(const InnerBundleInfo &info
element.SetBundleName(info.GetBundleName());
element.SetAbilityName(info.GetMainAbility());
want.SetElement(element);
want.SetParam(Constants::UID, uid);
want.SetParam(UID, uid);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(Constants::ABILITY_NAME, info.GetMainAbility());
want.SetParam(Constants::SANDBOX_APP_INDEX, info.GetAppIndex());
want.SetParam(SANDBOX_APP_INDEX, info.GetAppIndex());
want.SetParam(ACCESS_TOKEN_ID, static_cast<int32_t>(info.GetAccessTokenId(userId)));
want.SetParam(APP_ID, info.GetAppId());
EventFwk::CommonEventData commonData { want };
@ -163,7 +165,7 @@ void BundleCommonEventMgr::NotifyOverlayModuleStateStatus(const std::string &bun
element.SetBundleName(bundleName);
element.SetModuleName(moduleName);
want.SetElement(element);
want.SetParam(Constants::UID, uid);
want.SetParam(UID, uid);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(Constants::OVERLAY_STATE, isEnabled);
EventFwk::CommonEventData commonData { want };
@ -190,7 +192,7 @@ void BundleCommonEventMgr::NotifySetDiposedRule(
want.SetAction(DISPOSED_RULE_ADDED);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(Constants::APP_ID, appId);
want.SetParam(APP_ID, appId);
EventFwk::CommonEventData commonData { want };
commonData.SetData(data);
EventFwk::CommonEventPublishInfo publishInfo;
@ -204,7 +206,7 @@ void BundleCommonEventMgr::NotifyDeleteDiposedRule(const std::string &appId, int
OHOS::AAFwk::Want want;
want.SetAction(DISPOSED_RULE_DELETED);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(Constants::APP_ID, appId);
want.SetParam(APP_ID, appId);
EventFwk::CommonEventData commonData { want };
EventFwk::CommonEventPublishInfo publishInfo;
std::vector<std::string> permissionVec { Constants::PERMISSION_MANAGE_DISPOSED_APP_STATUS };

View File

@ -108,6 +108,12 @@ const std::map<ProfileType, const char*> PROFILE_TYPE_MAP = {
{ ProfileType::PKG_CONTEXT_PROFILE, PKG_CONTEXT_PROFILE_PATH }
};
const std::string SCHEME_END = "://";
constexpr const char* PARAM_URI_SEPARATOR = ":///";
constexpr const char* URI_SEPARATOR = "://";
constexpr uint32_t PARAM_URI_SEPARATOR_LEN = 4;
constexpr int32_t INVALID_BUNDLEID = -1;
constexpr int32_t DATA_GROUP_UID_OFFSET = 100000;
constexpr int32_t MAX_APP_UID = 65535;
}
BundleDataMgr::BundleDataMgr()
@ -118,7 +124,7 @@ BundleDataMgr::BundleDataMgr()
sandboxAppHelper_ = DelayedSingleton<BundleSandboxAppHelper>::GetInstance();
bundleStateStorage_ = std::make_shared<BundleStateStorage>();
baseAppUid_ = system::GetIntParameter<int32_t>("const.product.baseappid", Constants::BASE_APP_UID);
if (baseAppUid_ < Constants::BASE_APP_UID || baseAppUid_ >= Constants::MAX_APP_UID) {
if (baseAppUid_ < Constants::BASE_APP_UID || baseAppUid_ >= MAX_APP_UID) {
baseAppUid_ = Constants::BASE_APP_UID;
}
APP_LOGI("BundleDataMgr instance is created");
@ -1876,11 +1882,11 @@ bool BundleDataMgr::QueryAbilityInfoByUri(
return false;
}
std::string noPpefixUri = abilityUri.substr(strlen(Constants::DATA_ABILITY_URI_PREFIX));
auto posFirstSeparator = noPpefixUri.find(Constants::DATA_ABILITY_URI_SEPARATOR);
auto posFirstSeparator = noPpefixUri.find(Constants::FILE_SEPARATOR_CHAR);
if (posFirstSeparator == std::string::npos) {
return false;
}
auto posSecondSeparator = noPpefixUri.find(Constants::DATA_ABILITY_URI_SEPARATOR, posFirstSeparator + 1);
auto posSecondSeparator = noPpefixUri.find(Constants::FILE_SEPARATOR_CHAR, posFirstSeparator + 1);
std::string uri;
if (posSecondSeparator == std::string::npos) {
uri = noPpefixUri.substr(posFirstSeparator + 1, noPpefixUri.size() - posFirstSeparator - 1);
@ -1930,11 +1936,11 @@ bool BundleDataMgr::QueryAbilityInfosByUri(const std::string &abilityUri, std::v
return false;
}
std::string noPpefixUri = abilityUri.substr(strlen(Constants::DATA_ABILITY_URI_PREFIX));
auto posFirstSeparator = noPpefixUri.find(Constants::DATA_ABILITY_URI_SEPARATOR);
auto posFirstSeparator = noPpefixUri.find(Constants::FILE_SEPARATOR_CHAR);
if (posFirstSeparator == std::string::npos) {
return false;
}
auto posSecondSeparator = noPpefixUri.find(Constants::DATA_ABILITY_URI_SEPARATOR, posFirstSeparator + 1);
auto posSecondSeparator = noPpefixUri.find(Constants::FILE_SEPARATOR_CHAR, posFirstSeparator + 1);
std::string uri;
if (posSecondSeparator == std::string::npos) {
uri = noPpefixUri.substr(posFirstSeparator + 1, noPpefixUri.size() - posFirstSeparator - 1);
@ -3751,7 +3757,7 @@ bool BundleDataMgr::GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo)
return false;
}
int32_t bundleId = Constants::INVALID_BUNDLEID;
int32_t bundleId = INVALID_BUNDLEID;
if (!GenerateBundleId(innerBundleUserInfo.bundleName, bundleId)) {
APP_LOGW("Generate bundleId failed, bundleName: %{public}s", innerBundleUserInfo.bundleName.c_str());
return false;
@ -3791,7 +3797,7 @@ bool BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bun
}
}
if (bundleIdMap_.rbegin()->first == Constants::MAX_APP_UID) {
if (bundleIdMap_.rbegin()->first == MAX_APP_UID) {
APP_LOGW("the bundleId exceeding the maximum value, bundleName:%{public}s", bundleName.c_str());
return false;
}
@ -5020,15 +5026,15 @@ bool BundleDataMgr::QueryExtensionAbilityInfoByUri(const std::string &uri, int32
std::string convertUri = uri;
// example of valid param uri : fileShare:///com.example.FileShare/person/10
// example of convertUri : fileShare://com.example.FileShare
size_t schemePos = uri.find(Constants::PARAM_URI_SEPARATOR);
size_t schemePos = uri.find(PARAM_URI_SEPARATOR);
if (schemePos != uri.npos) {
// 1. cut string
size_t cutPos = uri.find(Constants::SEPARATOR, schemePos + Constants::PARAM_URI_SEPARATOR_LEN);
size_t cutPos = uri.find(Constants::PATH_SEPARATOR, schemePos + PARAM_URI_SEPARATOR_LEN);
if (cutPos != uri.npos) {
convertUri = uri.substr(0, cutPos);
}
// 2. replace :/// with ://
convertUri.replace(schemePos, Constants::PARAM_URI_SEPARATOR_LEN, Constants::URI_SEPARATOR);
convertUri.replace(schemePos, PARAM_URI_SEPARATOR_LEN, URI_SEPARATOR);
} else {
if (convertUri.compare(0, DATA_PROXY_URI_PREFIX_LEN, DATA_PROXY_URI_PREFIX) != 0) {
LOG_W(BMS_TAG_QUERY_EXTENSION, "invalid uri : %{private}s", uri.c_str());
@ -6254,14 +6260,14 @@ void BundleDataMgr::GenerateDataGroupUuidAndUid(DataGroupInfo &dataGroupInfo, in
indexList.emplace(iter->second.first);
}
int32_t index = DATA_GROUP_INDEX_START;
for (int32_t i = DATA_GROUP_INDEX_START; i < Constants::DATA_GROUP_UID_OFFSET; i++) {
for (int32_t i = DATA_GROUP_INDEX_START; i < DATA_GROUP_UID_OFFSET; i++) {
if (indexList.find(i) == indexList.end()) {
index = i;
break;
}
}
int32_t uid = userId * Constants::BASE_USER_RANGE + index + Constants::DATA_GROUP_UID_OFFSET;
int32_t uid = userId * Constants::BASE_USER_RANGE + index + DATA_GROUP_UID_OFFSET;
dataGroupInfo.uid = uid;
dataGroupInfo.gid = uid;
@ -6288,7 +6294,7 @@ void BundleDataMgr::GenerateDataGroupInfos(InnerBundleInfo &innerBundleInfo,
auto iter = dataGroupIndexMap.find(groupId);
if (iter != dataGroupIndexMap.end()) {
dataGroupInfo.uuid = iter->second.second;
int32_t uid = iter->second.first + userId * Constants::BASE_USER_RANGE + Constants::DATA_GROUP_UID_OFFSET;
int32_t uid = iter->second.first + userId * Constants::BASE_USER_RANGE + DATA_GROUP_UID_OFFSET;
dataGroupInfo.uid = uid;
dataGroupInfo.gid = uid;
innerBundleInfo.AddDataGroupInfo(groupId, dataGroupInfo);
@ -6306,7 +6312,7 @@ void BundleDataMgr::GetDataGroupIndexMap(
for (const auto &infoItem : bundleInfo.second.GetDataGroupInfos()) {
for_each(std::begin(infoItem.second), std::end(infoItem.second), [&](const DataGroupInfo &dataGroupInfo) {
int32_t index = dataGroupInfo.uid - dataGroupInfo.userId * Constants::BASE_USER_RANGE
- Constants::DATA_GROUP_UID_OFFSET;
- DATA_GROUP_UID_OFFSET;
dataGroupIndexMap[dataGroupInfo.dataGroupId] =
std::pair<int32_t, std::string>(index, dataGroupInfo.uuid);
});

View File

@ -20,12 +20,15 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr const char* BUNDLE_RDB_TABLE_NAME = "installed_bundle";
}
BundleDataStorageRdb::BundleDataStorageRdb()
{
APP_LOGI("BundleDataStorageRdb instance is created");
BmsRdbConfig bmsRdbConfig;
bmsRdbConfig.dbName = Constants::BUNDLE_RDB_NAME;
bmsRdbConfig.tableName = Constants::BUNDLE_RDB_TABLE_NAME;
bmsRdbConfig.tableName = BUNDLE_RDB_TABLE_NAME;
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
}

View File

@ -29,6 +29,8 @@ namespace {
// pre bundle profile
constexpr const char* INSTALL_LIST_PERMISSIONS_CONFIG = "/etc/app/install_list_permissions.json";
constexpr const char* SCENEBOARD_BUNDLE_NAME = "com.ohos.sceneboard";
// install list permissions file
constexpr const char* INSTALL_LIST_PERMISSIONS_FILE_PATH = "/system/etc/app/install_list_permissions.json";
const int32_t BASE_API_VERSION = 1000;
}
@ -49,7 +51,7 @@ bool BundlePermissionMgr::Init()
permissionFileList.push_back(item + INSTALL_LIST_PERMISSIONS_CONFIG);
}
#else
permissionFileList.emplace_back(Constants::INSTALL_LIST_PERMISSIONS_FILE_PATH);
permissionFileList.emplace_back(INSTALL_LIST_PERMISSIONS_FILE_PATH);
#endif
BundleParser bundleParser;
std::set<DefaultPermission> permissions;
@ -273,7 +275,8 @@ bool BundlePermissionMgr::GetRequestPermissionStates(
}
} else {
APP_LOGE("request permission name : %{public}s is not exit in AccessTokenMgr", req.c_str());
bundleInfo.reqPermissionStates.emplace_back(Constants::PERMISSION_NOT_GRANTED);
bundleInfo.reqPermissionStates.emplace_back(
static_cast<int32_t>(AccessToken::PermissionState::PERMISSION_DENIED));
}
}
return true;

View File

@ -126,10 +126,10 @@ bool BundleResourceRdb::DeleteResourceInfo(const std::string &key)
* 1. bundleName
* 2. bundleName/moduleName/abilityName
*/
if (key.find(Constants::SEPARATOR) == std::string::npos) {
if (key.find(Constants::PATH_SEPARATOR) == std::string::npos) {
NativeRdb::AbsRdbPredicates absRdbPredicates(BundleResourceConstants::BUNDLE_RESOURCE_RDB_TABLE_NAME);
// need delete both bundle resource and launcher ability resource
absRdbPredicates.BeginsWith(BundleResourceConstants::NAME, key + Constants::SEPARATOR);
absRdbPredicates.BeginsWith(BundleResourceConstants::NAME, key + Constants::PATH_SEPARATOR);
if (!rdbDataManager_->DeleteData(absRdbPredicates)) {
APP_LOGW("delete key:%{public}s failed", key.c_str());
}

View File

@ -53,6 +53,11 @@ static std::string g_deviceUdid;
static std::mutex g_mutex;
// hmdfs and sharefs config
constexpr const char* BUNDLE_ID_FILE = "appid";
// single max hap size
constexpr int64_t ONE_GB = 1024 * 1024 * 1024;
constexpr int64_t MAX_HAP_SIZE = ONE_GB * 4; // 4GB
constexpr const char* ABC_FILE_PATH = "abc_files";
constexpr const char* PGO_FILE_PATH = "pgo_files";
}
std::mutex BundleUtil::g_mutex;
@ -78,8 +83,8 @@ ErrCode BundleUtil::CheckFilePath(const std::string &bundlePath, std::string &re
APP_LOGE("can not access the bundle file path: %{public}s, errno:%{public}d", realPath.c_str(), errno);
return ERR_APPEXECFWK_INSTALL_INVALID_BUNDLE_FILE;
}
if (!CheckFileSize(realPath, Constants::MAX_HAP_SIZE)) {
APP_LOGE("file size is larger than max hap size Max size is: %{public}" PRId64, Constants::MAX_HAP_SIZE);
if (!CheckFileSize(realPath, MAX_HAP_SIZE)) {
APP_LOGE("file size is larger than max hap size Max size is: %{public}" PRId64, MAX_HAP_SIZE);
return ERR_APPEXECFWK_INSTALL_INVALID_HAP_SIZE;
}
return ERR_OK;
@ -374,9 +379,9 @@ std::string BundleUtil::CreateInstallTempDir(uint32_t installerId, const DirType
} else if (type == DirType::SIG_FILE_DIR) {
tempDir += Constants::PATH_SEPARATOR + Constants::SIGNATURE_FILE_PATH;
} else if (type == DirType::PGO_FILE_DIR) {
tempDir += Constants::PATH_SEPARATOR + Constants::PGO_FILE_PATH;
tempDir += Constants::PATH_SEPARATOR + PGO_FILE_PATH;
} else if (type == DirType::ABC_FILE_DIR) {
tempDir += Constants::PATH_SEPARATOR + Constants::ABC_FILE_PATH;
tempDir += Constants::PATH_SEPARATOR + ABC_FILE_PATH;
} else if (type == DirType::EXT_RESOURCE_FILE_DIR) {
tempDir += Constants::PATH_SEPARATOR + Constants::EXT_RESOURCE_FILE_PATH;
} else {

View File

@ -51,6 +51,7 @@ const std::string WORD = "WORD";
const std::string EXCEL = "EXCEL";
const std::string PPT = "PPT";
const std::string EMAIL = "EMAIL";
constexpr const char* ACTION_VIEW_DATA = "ohos.want.action.viewData";
const std::map<std::string, std::set<std::string>> APP_TYPES = {
{IMAGE, {"image/*"}},
{AUDIO, {"audio/*"}},
@ -308,7 +309,7 @@ void DefaultAppMgr::HandleRemoveUser(int32_t userId) const
bool DefaultAppMgr::IsBrowserWant(const Want& want) const
{
bool matchAction = want.GetAction() == Constants::ACTION_VIEW_DATA;
bool matchAction = want.GetAction() == ACTION_VIEW_DATA;
if (!matchAction) {
LOG_D(BMS_TAG_DEFAULT_APP, "Action does not match, not browser want");
return false;
@ -348,7 +349,7 @@ std::string DefaultAppMgr::GetType(const Want& want) const
if (IsEmailWant(want)) {
return EMAIL;
}
if (want.GetAction() == Constants::ACTION_VIEW_DATA) {
if (want.GetAction() == ACTION_VIEW_DATA) {
std::string type = want.GetType();
if (!type.empty()) {
return type;
@ -559,7 +560,7 @@ bool DefaultAppMgr::MatchAppType(const std::string& type, const std::vector<Skil
return false;
}
for (const std::string& mimeType : item->second) {
if (MatchActionAndType(Constants::ACTION_VIEW_DATA, mimeType, skills)) {
if (MatchActionAndType(ACTION_VIEW_DATA, mimeType, skills)) {
return true;
}
}
@ -570,12 +571,12 @@ bool DefaultAppMgr::IsBrowserSkillsValid(const std::vector<Skill>& skills) const
{
LOG_D(BMS_TAG_DEFAULT_APP, "begin to verify browser skills.");
Want httpWant;
httpWant.SetAction(Constants::ACTION_VIEW_DATA);
httpWant.SetAction(ACTION_VIEW_DATA);
httpWant.AddEntity(ENTITY_BROWSER);
httpWant.SetUri(HTTP);
Want httpsWant;
httpsWant.SetAction(Constants::ACTION_VIEW_DATA);
httpsWant.SetAction(ACTION_VIEW_DATA);
httpsWant.AddEntity(ENTITY_BROWSER);
httpsWant.SetUri(HTTPS);
for (const Skill& skill : skills) {
@ -608,7 +609,7 @@ bool DefaultAppMgr::IsEmailSkillsValid(const std::vector<Skill>& skills) const
bool DefaultAppMgr::MatchFileType(const std::string& type, const std::vector<Skill>& skills) const
{
LOG_D(BMS_TAG_DEFAULT_APP, "type : %{public}s", type.c_str());
if (MatchActionAndType(Constants::ACTION_VIEW_DATA, type, skills)) {
if (MatchActionAndType(ACTION_VIEW_DATA, type, skills)) {
return true;
}
LOG_E(BMS_TAG_DEFAULT_APP, "MatchFileType failed");

View File

@ -27,13 +27,14 @@ namespace {
constexpr int32_t INITIAL_USER_ID = -1;
const std::string DEFAULT_APP_JSON_PATH = "/etc/app/default_app.json";
const std::string BACK_UP_DEFAULT_APP_JSON_PATH = "/etc/app/backup_default_app.json";
constexpr const char* DEFAULT_APP_RDB_TABLE_NAME = "default_app";
}
DefaultAppRdb::DefaultAppRdb()
{
LOG_D(BMS_TAG_DEFAULT_APP, "create DefaultAppRdb.");
BmsRdbConfig bmsRdbConfig;
bmsRdbConfig.dbName = Constants::BUNDLE_RDB_NAME;
bmsRdbConfig.tableName = Constants::DEFAULT_APP_RDB_TABLE_NAME;
bmsRdbConfig.tableName = DEFAULT_APP_RDB_TABLE_NAME;
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
LoadDefaultApplicationConfig();

View File

@ -38,6 +38,7 @@ namespace OHOS {
namespace AppExecFwk {
namespace {
const std::string SEPARATOR = "/";
constexpr const char* EXT_RESOURCE_FILE_SUFFIX = ".hsp";
bool IsFileNameValid(const std::string &fileName)
{
@ -85,7 +86,7 @@ void ConvertToExtendResourceInfo(
extendResourceInfo.moduleName = innerBundleInfo.GetCurModuleName();
extendResourceInfo.iconId = innerBundleInfo.GetIconId();
std::string path = BuildResourcePath(bundleName);
path.append(extendResourceInfo.moduleName).append(Constants::EXT_RESOURCE_FILE_SUFFIX);
path.append(extendResourceInfo.moduleName).append(EXT_RESOURCE_FILE_SUFFIX);
extendResourceInfo.filePath = path;
}
}
@ -149,7 +150,7 @@ bool ExtendResourceManagerHostImpl::CheckFileParam(const std::string &filePath)
APP_LOGE("CheckFile filePath(%{public}s) failed due to invalid path", filePath.c_str());
return false;
}
if (!BundleUtil::CheckFileType(filePath, Constants::EXT_RESOURCE_FILE_SUFFIX)) {
if (!BundleUtil::CheckFileType(filePath, EXT_RESOURCE_FILE_SUFFIX)) {
APP_LOGE("CheckFile filePath(%{public}s) failed due to suffix error.", filePath.c_str());
return false;
}
@ -653,7 +654,7 @@ ErrCode ExtendResourceManagerHostImpl::CreateFd(
APP_LOGE("verify permission failed");
return ERR_APPEXECFWK_PERMISSION_DENIED;
}
if (!BundleUtil::CheckFileType(fileName, Constants::EXT_RESOURCE_FILE_SUFFIX)) {
if (!BundleUtil::CheckFileType(fileName, EXT_RESOURCE_FILE_SUFFIX)) {
APP_LOGE("not hsp file.");
return ERR_EXT_RESOURCE_MANAGER_CREATE_FD_FAILED;
}

View File

@ -71,6 +71,9 @@ constexpr uint32_t TYPE_HARMONEY_APP = 1;
constexpr uint32_t TYPE_HARMONEY_SERVICE = 2;
constexpr uint32_t DEFAULT_VALUE = -1;
constexpr uint32_t DEFAULT_EMBEDDED_VALUE = 0;
constexpr int32_t DMS_UID = 5522;
// sa id
constexpr int32_t DOWNLOAD_SERVICE_SA_ID = 3706;
// replace want int ecological rule
constexpr const char* PARAM_REPLACE_WANT = "ohos.extra.param.key.replace_want";
@ -410,10 +413,10 @@ void BundleConnectAbilityMgr::LoadDownloadService() const
LOG_E(BMS_TAG_FREE_INSTALL, "Create load callback failed");
return;
}
auto ret = systemAbilityMgr->LoadSystemAbility(Constants::DOWNLOAD_SERVICE_SA_ID, loadCallback);
auto ret = systemAbilityMgr->LoadSystemAbility(DOWNLOAD_SERVICE_SA_ID, loadCallback);
if (ret != 0) {
LOG_E(BMS_TAG_FREE_INSTALL, "Load system ability %{public}d failed with %{public}d.",
Constants::DOWNLOAD_SERVICE_SA_ID, ret);
DOWNLOAD_SERVICE_SA_ID, ret);
return;
}
LOG_I(BMS_TAG_FREE_INSTALL, "LoadDownloadService end");
@ -861,7 +864,7 @@ void BundleConnectAbilityMgr::GetTargetAbilityInfo(const Want &want, int32_t use
targetAbilityInfo->targetInfo.type = want.GetType();
targetAbilityInfo->targetInfo.callingUid = callingUid;
targetAbilityInfo->targetInfo.callingAppType = CALLING_TYPE_HARMONY;
if (callingUid == Constants::DMS_UID) {
if (callingUid == DMS_UID) {
callingAppids.push_back(want.GetStringParam(PARAM_FREEINSTALL_APPID));
callingBundleNames = want.GetStringArrayParam(PARAM_FREEINSTALL_BUNDLENAMES);
} else {

View File

@ -82,6 +82,9 @@ const std::string EXT_RESOURCE_MODULE_NAME = "moduleName";
const std::string EXT_RESOURCE_ICON_ID = "iconId";
const std::string EXT_RESOURCE_FILE_PATH = "filePath";
const int32_t SINGLE_HSP_VERSION = 1;
// clone application
constexpr int32_t CLONE_APP_INDEX_MIN = 1;
constexpr int32_t CLONE_APP_INDEX_MAX = 5;
const std::map<std::string, IsolationMode> ISOLATION_MODE_MAP = {
{"isolationOnly", IsolationMode::ISOLATION_ONLY},
{"nonisolationOnly", IsolationMode::NONISOLATION_ONLY},
@ -3419,7 +3422,7 @@ ErrCode InnerBundleInfo::AddCloneBundle(const InnerBundleCloneInfo &attr)
InnerBundleUserInfo &userInfo = innerBundleUserInfos_.find(key)->second;
std::map<std::string, InnerBundleCloneInfo> &cloneInfos = userInfo.cloneInfos;
if (appIndex < Constants::CLONE_APP_INDEX_MIN || appIndex > Constants::CLONE_APP_INDEX_MAX) {
if (appIndex < CLONE_APP_INDEX_MIN || appIndex > CLONE_APP_INDEX_MAX) {
APP_LOGE("Add Clone Bundle Fail, appIndex: %{public}d not in valid range", appIndex);
return ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX;
}
@ -3462,7 +3465,7 @@ ErrCode InnerBundleInfo::RemoveCloneBundle(const int32_t userId, const int32_t a
InnerBundleUserInfo &userInfo = innerBundleUserInfos_.find(key)->second;
std::map<std::string, InnerBundleCloneInfo> &cloneInfos = userInfo.cloneInfos;
if (appIndex < Constants::CLONE_APP_INDEX_MIN || appIndex > Constants::CLONE_APP_INDEX_MAX) {
if (appIndex < CLONE_APP_INDEX_MIN || appIndex > CLONE_APP_INDEX_MAX) {
APP_LOGE("Remove Clone Bundle Fail, appIndex: %{public}d not in valid range", appIndex);
return ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX;
}

View File

@ -53,12 +53,17 @@ namespace {
static const char LIB_DIFF_PATCH_SHARED_SO_PATH[] = "system/lib/libdiff_patch_shared.z.so";
static const char LIB64_DIFF_PATCH_SHARED_SO_PATH[] = "system/lib64/libdiff_patch_shared.z.so";
static const char APPLY_PATCH_FUNCTION_NAME[] = "ApplyPatch";
static std::string PREFIX_RESOURCE_PATH = "/resources/rawfile/";
static std::string PREFIX_TARGET_PATH = "/print_service/";
constexpr const char* PREFIX_RESOURCE_PATH = "/resources/rawfile/";
constexpr const char* PREFIX_TARGET_PATH = "/print_service/";
static constexpr int32_t INSTALLS_UID = 3060;
static constexpr int32_t MODE_BASE = 07777;
static const std::string PROC_MOUNTS_PATH = "/proc/mounts";
static const std::string QUOTA_DEVICE_DATA_PATH = "/data";
constexpr const char* PROC_MOUNTS_PATH = "/proc/mounts";
constexpr const char* QUOTA_DEVICE_DATA_PATH = "/data";
constexpr const char* CACHE_DIR = "cache";
constexpr const char* BUNDLE_BASE_CODE_DIR = "/data/app/el1/bundle";
constexpr const char* AP_PATH = "ap/";
constexpr const char* AI_SUFFIX = ".ai";
constexpr const char* DIFF_SUFFIX = ".diff";
#if defined(CODE_SIGNATURE_ENABLE)
using namespace OHOS::Security::CodeSign;
#endif
@ -218,7 +223,7 @@ bool InstalldOperator::ExtractFiles(const ExtractParam &extractParam)
}
if ((extractParam.extractFileType == ExtractFileType::AP) &&
!extractor.IsDirExist(Constants::AP)) {
!extractor.IsDirExist(AP_PATH)) {
APP_LOGD("hap has no ap files and does not need to be extracted.");
return true;
}
@ -314,7 +319,7 @@ bool InstalldOperator::IsDiffFiles(const std::string &entryName,
APP_LOGD("entryName not start with %{public}s", prefix.c_str());
return false;
}
if (!EndsWith(entryName, Constants::DIFF_SUFFIX)) {
if (!EndsWith(entryName, DIFF_SUFFIX)) {
APP_LOGD("file name not diff format.");
return false;
}
@ -386,7 +391,7 @@ bool InstalldOperator::DeterminePrefix(const ExtractFileType &extractFileType, c
break;
}
case ExtractFileType::AP: {
prefix = Constants::AP;
prefix = AP_PATH;
break;
}
case ExtractFileType::RES_FILE: {
@ -408,7 +413,7 @@ bool InstalldOperator::DetermineSuffix(const ExtractFileType &extractFileType, s
}
case ExtractFileType::AN: {
suffixes.emplace_back(Constants::AN_SUFFIX);
suffixes.emplace_back(Constants::AI_SUFFIX);
suffixes.emplace_back(AI_SUFFIX);
break;
}
case ExtractFileType::AP: {
@ -614,7 +619,7 @@ bool InstalldOperator::IsValidCodePath(const std::string &codePath)
if (codePath.empty()) {
return false;
}
return IsValidPath(Constants::BUNDLE_BASE_CODE_DIR + Constants::PATH_SEPARATOR, codePath);
return IsValidPath(BUNDLE_BASE_CODE_DIR + Constants::PATH_SEPARATOR, codePath);
}
bool InstalldOperator::DeleteFiles(const std::string &dataPath)
@ -804,7 +809,7 @@ void InstalldOperator::TraverseCacheDirectory(const std::string &currentPath, st
if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0) {
continue;
}
if (ptr->d_type == DT_DIR && strcmp(ptr->d_name, Constants::CACHE_DIR) == 0) {
if (ptr->d_type == DT_DIR && strcmp(ptr->d_name, CACHE_DIR) == 0) {
std::string currentDir = filePath + std::string(ptr->d_name);
cacheDirs.emplace_back(currentDir);
continue;
@ -1154,7 +1159,7 @@ bool InstalldOperator::ApplyDiffPatch(const std::string &oldSoPath, const std::s
}
std::vector<std::string> newSoList;
for (const auto &diffFileName : diffFileNames) {
std::string soFileName = diffFileName.substr(0, diffFileName.rfind(Constants::DIFF_SUFFIX));
std::string soFileName = diffFileName.substr(0, diffFileName.rfind(DIFF_SUFFIX));
APP_LOGD("ApplyDiffPatch soName: %{public}s, diffName: %{public}s", soFileName.c_str(), diffFileName.c_str());
if (find(oldSoFileNames.begin(), oldSoFileNames.end(), soFileName) != oldSoFileNames.end()) {
int32_t ret = applyPatch(realDiffFilePath + Constants::PATH_SEPARATOR + diffFileName,
@ -1581,7 +1586,7 @@ bool InstalldOperator::ExtractResourceFiles(const ExtractParam &extractParam, co
for (const auto &entryName : entryNames) {
if (StartsWith(entryName, Constants::LIBS)
|| StartsWith(entryName, Constants::AN)
|| StartsWith(entryName, Constants::AP)) {
|| StartsWith(entryName, AP_PATH)) {
continue;
}
const std::string relativeDir = GetPathDir(entryName);

View File

@ -32,6 +32,9 @@ using namespace std::chrono_literals;
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr unsigned int INSTALLD_UMASK = 0000;
}
REGISTER_SYSTEM_ABILITY_BY_ID(InstalldService, INSTALLD_SERVICE_ID, true);
InstalldService::InstalldService(int32_t saId, bool runOnCreate) : SystemAbility(saId, runOnCreate)
@ -72,7 +75,7 @@ bool InstalldService::Init()
return false;
}
// installd service need mask 000
umask(Constants::INSTALLD_UMASK);
umask(INSTALLD_UMASK);
hostImpl_ = new (std::nothrow) InstalldHostImpl();
if (hostImpl_ == nullptr) {
APP_LOGE("InstalldHostImpl Init failed");

View File

@ -33,6 +33,7 @@ namespace AppExecFwk {
namespace {
const std::string COMPRESS_NATIVE_LIBS = "persist.bms.supportCompressNativeLibs";
const int32_t THRESHOLD_VAL_LEN = 40;
constexpr uint8_t MAX_MODULE_NAME = 31;
bool IsSupportCompressNativeLibs()
{
char compressNativeLibs[THRESHOLD_VAL_LEN] = {0};
@ -1636,7 +1637,7 @@ bool CheckModuleNameIsValid(const std::string &moduleName)
if (moduleName.empty()) {
return false;
}
if (moduleName.size() > Constants::MAX_MODULE_NAME) {
if (moduleName.size() > MAX_MODULE_NAME) {
return false;
}
if (moduleName.find(Constants::RELATIVE_PATH) != std::string::npos) {

View File

@ -22,6 +22,7 @@ namespace OHOS {
namespace AppExecFwk {
namespace {
const std::string SHARED_TYPE = "shared";
constexpr int32_t OVERLAY_MAXIMUM_PRIORITY = 100;
} // namespace
ErrCode BundleOverlayInstallChecker::CheckOverlayInstallation(
@ -192,7 +193,7 @@ ErrCode BundleOverlayInstallChecker::CheckBundleType(const InnerBundleInfo &info
ErrCode BundleOverlayInstallChecker::CheckTargetPriority(int32_t priority) const
{
APP_LOGD("start");
if ((priority < Constants::OVERLAY_MINIMUM_PRIORITY) || (priority > Constants::OVERLAY_MAXIMUM_PRIORITY)) {
if ((priority < Constants::OVERLAY_MINIMUM_PRIORITY) || (priority > OVERLAY_MAXIMUM_PRIORITY)) {
APP_LOGE("overlay hap has invalid module priority %{public}d", priority);
return ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_INVALID_PRIORITY;
}

View File

@ -19,12 +19,15 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr const char* PRE_BUNDLE_RDB_TABLE_NAME = "preinstalled_bundle";
}
PreInstallDataStorageRdb::PreInstallDataStorageRdb()
{
APP_LOGI("PreInstallDataStorageRdb instance is created");
BmsRdbConfig bmsRdbConfig;
bmsRdbConfig.dbName = Constants::BUNDLE_RDB_NAME;
bmsRdbConfig.tableName = Constants::PRE_BUNDLE_RDB_TABLE_NAME;
bmsRdbConfig.tableName = PRE_BUNDLE_RDB_TABLE_NAME;
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
}

View File

@ -22,12 +22,15 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr const char* QUICK_FIX_RDB_TABLE_NAME = "quick_fix";
}
QuickFixManagerRdb::QuickFixManagerRdb()
{
LOG_I(BMS_TAG_QUICK_FIX, "create QuickFixManagerRdb.");
BmsRdbConfig bmsRdbConfig;
bmsRdbConfig.dbName = Constants::BUNDLE_RDB_NAME;
bmsRdbConfig.tableName = Constants::QUICK_FIX_RDB_TABLE_NAME;
bmsRdbConfig.tableName = QUICK_FIX_RDB_TABLE_NAME;
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
}

View File

@ -21,12 +21,15 @@
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr const char* SAND_BOX_RDB_TABLE_NAME = "sandbox";
}
SandboxManagerRdb::SandboxManagerRdb()
{
APP_LOGI("create SandboxManagerRdb.");
BmsRdbConfig bmsRdbConfig;
bmsRdbConfig.dbName = Constants::BUNDLE_RDB_NAME;
bmsRdbConfig.tableName = Constants::SAND_BOX_RDB_TABLE_NAME;
bmsRdbConfig.tableName = SAND_BOX_RDB_TABLE_NAME;
rdbDataManager_ = std::make_shared<RdbDataManager>(bmsRdbConfig);
rdbDataManager_->CreateTable();
}

View File

@ -42,6 +42,7 @@ const std::string DATA_STORAGE_EL3_BASE = "/data/storage/el3/base/";
const std::string DATA_STORAGE_EL3_DATABASE = "/data/storage/el3/database/";
const std::string DATA_STORAGE_EL4_BASE = "/data/storage/el4/base/";
const std::string DATA_STORAGE_EL4_DATABASE = "/data/storage/el4/database/";
constexpr const char* ABC_FILE_SUFFIX = ".abc";
bool IsValidPath(const std::string &path)
{
@ -298,7 +299,7 @@ bool VerifyManagerHostImpl::CheckFileParam(const std::vector<std::string> &abcPa
APP_LOGE("CheckFile abcPath(%{public}s) failed due to invalid path", abcPath.c_str());
return false;
}
if (!BundleUtil::CheckFileType(abcPath, Constants::ABC_FILE_SUFFIX)) {
if (!BundleUtil::CheckFileType(abcPath, ABC_FILE_SUFFIX)) {
APP_LOGE("CheckFile abcPath(%{public}s) failed due to not abc suffix.", abcPath.c_str());
return false;
}
@ -465,7 +466,7 @@ ErrCode VerifyManagerHostImpl::DeleteAbc(const std::string &path)
APP_LOGE("DeleteAbc failed due to invalid path");
return ERR_BUNDLE_MANAGER_DELETE_ABC_PARAM_ERROR;
}
if (!BundleUtil::CheckFileType(path, Constants::ABC_FILE_SUFFIX)) {
if (!BundleUtil::CheckFileType(path, ABC_FILE_SUFFIX)) {
APP_LOGE("DeleteAbc failed due to not abc file.");
return ERR_BUNDLE_MANAGER_DELETE_ABC_PARAM_ERROR;
}

View File

@ -31,6 +31,9 @@ using namespace std::chrono_literals;
namespace OHOS {
namespace AppExecFwk {
namespace {
constexpr unsigned int INSTALLD_UMASK = 0000;
}
InstalldService::InstalldService() : SystemAbility(INSTALLD_SERVICE_ID, true)
{
APP_LOGI("installd service instance is created");
@ -63,7 +66,7 @@ bool InstalldService::Init()
return false;
}
// installd service need mask 000
umask(Constants::INSTALLD_UMASK);
umask(INSTALLD_UMASK);
hostImpl_ = new (std::nothrow) InstalldHostImpl();
if (hostImpl_ == nullptr) {
APP_LOGE("InstalldHostImpl Init failed");

View File

@ -58,6 +58,7 @@ const int32_t USERID = 100;
const uint32_t ZERO = 0;
const uint32_t INVALID_ACCESSTOKENID = 0;
const int32_t WAIT_TIME = 5; // init mocked bms
const int32_t BUNDLE_RDB_VERSION = 1;
// test hap with so
const std::string BUNDLE_NAME_WITH_LIBS = "com.example.nativelibs";
const std::string HAP_COMPRESS_NATIVE_LIBS_FALSE_01 =
@ -572,13 +573,13 @@ HWTEST_F(BmsBundleAccessTokenIdTest, DbmsServicesKitTest_0003, Function | SmallT
HWTEST_F(BmsBundleAccessTokenIdTest, DbmsServicesKitTest_0004, Function | SmallTest | Level0)
{
DistributedBundleInfo distributedBundleInfo;
distributedBundleInfo.version = Constants::BUNDLE_RDB_VERSION;
distributedBundleInfo.version = BUNDLE_RDB_VERSION;
distributedBundleInfo.bundleName = "bundleName";
distributedBundleInfo.versionCode = Constants::BUNDLE_RDB_VERSION;
distributedBundleInfo.versionCode = BUNDLE_RDB_VERSION;
distributedBundleInfo.versionName = "versionName";
distributedBundleInfo.minCompatibleVersion = Constants::BUNDLE_RDB_VERSION;
distributedBundleInfo.targetVersionCode = Constants::BUNDLE_RDB_VERSION;
distributedBundleInfo.compatibleVersionCode = Constants::BUNDLE_RDB_VERSION;
distributedBundleInfo.minCompatibleVersion = BUNDLE_RDB_VERSION;
distributedBundleInfo.targetVersionCode = BUNDLE_RDB_VERSION;
distributedBundleInfo.compatibleVersionCode = BUNDLE_RDB_VERSION;
distributedBundleInfo.appId = "appId";
distributedBundleInfo.enabled = false;
@ -586,13 +587,13 @@ HWTEST_F(BmsBundleAccessTokenIdTest, DbmsServicesKitTest_0004, Function | SmallT
bool ret = distributedBundleInfo.Marshalling(parcel);
EXPECT_TRUE(ret);
auto unmarshalledResult = DistributedBundleInfo::Unmarshalling(parcel);
EXPECT_EQ(unmarshalledResult->version, Constants::BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->version, BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->bundleName, "bundleName");
EXPECT_EQ(unmarshalledResult->versionCode, Constants::BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->versionCode, BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->versionName, "versionName");
EXPECT_EQ(unmarshalledResult->minCompatibleVersion, Constants::BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->targetVersionCode, Constants::BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->compatibleVersionCode, Constants::BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->minCompatibleVersion, BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->targetVersionCode, BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->compatibleVersionCode, BUNDLE_RDB_VERSION);
EXPECT_EQ(unmarshalledResult->appId, "appId");
EXPECT_EQ(unmarshalledResult->enabled, false);
}

View File

@ -57,6 +57,8 @@ constexpr uint32_t VIRTUAL_CHILD_PID = 12345678;
constexpr const char* OTA_COMPILE_TIME = "persist.bms.optimizing_apps.timing";
constexpr const char* OTA_COMPILE_SWITCH = "const.bms.optimizing_apps.switch";
constexpr const char* UPDATE_TYPE = "persist.dupdate_engine.update_type";
constexpr const char* COMPILE_NONE = "none";
constexpr const char* COMPILE_FULL = "full";
} // namespace
class BmsAOTMgrTest : public testing::Test {
@ -227,7 +229,7 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0600, Function | SmallTest | Level0)
{
AOTArgs aotArgs;
ErrCode ret;
aotArgs.compileMode = Constants::COMPILE_FULL;
aotArgs.compileMode = COMPILE_FULL;
aotArgs.hapPath = NOHAP_PATH;
aotArgs.outputPath = OUT_PUT_PATH;
aotArgs.arkProfilePath = OUT_PUT_PATH;
@ -245,7 +247,7 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0700, Function | SmallTest | Level0)
{
AOTArgs aotArgs;
ErrCode ret;
aotArgs.compileMode = Constants::COMPILE_FULL;
aotArgs.compileMode = COMPILE_FULL;
aotArgs.hapPath = HAP_PATH;
aotArgs.outputPath = OUT_PUT_PATH;
aotArgs.arkProfilePath = OUT_PUT_PATH;
@ -264,7 +266,7 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0800, Function | SmallTest | Level0)
{
AOTArgs aotArgs;
ErrCode ret;
aotArgs.compileMode = Constants::COMPILE_FULL;
aotArgs.compileMode = COMPILE_FULL;
aotArgs.hapPath = HAP_PATH;
aotArgs.outputPath = OUT_PUT_PATH;
aotArgs.arkProfilePath = OUT_PUT_PATH;
@ -572,7 +574,7 @@ HWTEST_F(BmsAOTMgrTest, AOTHandler_1200, Function | SmallTest | Level0)
{
std::string bundleName = "";
ClearDataMgr();
AOTHandler::GetInstance().HandleCompile(bundleName, Constants::COMPILE_NONE, true);
AOTHandler::GetInstance().HandleCompile(bundleName, COMPILE_NONE, true);
EXPECT_EQ(bundleName, "");
ResetDataMgr();

View File

@ -52,6 +52,7 @@ constexpr int32_t TEST_GROUP_INDEX_TWO = 2;
constexpr int32_t TEST_GROUP_INDEX_THREE = 3;
constexpr int32_t TEST_GROUP_INDEX_FORE = 4;
const int32_t WAIT_TIME = 5;
constexpr int32_t DATA_GROUP_UID_OFFSET = 100000;
} // namespace
class BmsBundleDataGroupTest : public testing::Test {
@ -530,7 +531,7 @@ HWTEST_F(BmsBundleDataGroupTest, GenerateDataGroupUuidAndUid_0010, Function | Sm
dataGroupIndexMap.emplace(DATA_GROUP_ID_TEST_ONE, std::make_pair(TEST_GROUP_INDEX_ONE, DATA_GROUP_UUID_ONE));
dataGroupIndexMap.emplace(DATA_GROUP_ID_TEST_TWO, std::make_pair(TEST_GROUP_INDEX_TWO, DATA_GROUP_UUID_TWO));
int32_t uid = USERID * Constants::BASE_USER_RANGE + TEST_GROUP_INDEX_THREE + Constants::DATA_GROUP_UID_OFFSET;
int32_t uid = USERID * Constants::BASE_USER_RANGE + TEST_GROUP_INDEX_THREE + DATA_GROUP_UID_OFFSET;
dataMgr->GenerateDataGroupUuidAndUid(dataGroupInfo, USERID, dataGroupIndexMap);
EXPECT_EQ(dataGroupInfo.uid, uid);
EXPECT_EQ(dataGroupInfo.gid, uid);

View File

@ -86,6 +86,7 @@ const std::string INVALID_TYPE5 = "abc/*";
const std::string INVALID_TYPE6 = "*/*";
const std::string EMAIL_ACTION = "ohos.want.action.sendToData";
const std::string EMAIL_SCHEME = "mailto";
constexpr const char* ACTION_VIEW_DATA = "ohos.want.action.viewData";
const nlohmann::json DEFAULT_CONFIG = R"(
[{
"bundleName": "bundleName",
@ -1137,7 +1138,7 @@ HWTEST_F(BmsBundleDefaultAppTest, BmsBundleDefaultApp_5100, Function | SmallTest
EXPECT_NE(dataMgr, nullptr);
Want want;
want.SetAction(Constants::ACTION_VIEW_DATA);
want.SetAction(ACTION_VIEW_DATA);
want.SetType(DEFAULT_FILE_TYPE_VIDEO_MP4);
int32_t flags = 0;
std::vector<AbilityInfo> abilityInfos;
@ -1251,7 +1252,7 @@ HWTEST_F(BmsBundleDefaultAppTest, BmsBundleDefaultApp_5600, Function | SmallTest
AAFwk::Want want;
AAFwk::Want want1;
want1.ClearWant(&want);
want.SetAction(Constants::ACTION_VIEW_DATA);
want.SetAction(ACTION_VIEW_DATA);
want.SetType(DEFAULT_APP_VIDEO);
auto defaultAppProxy = GetDefaultAppProxy();
@ -1521,7 +1522,7 @@ HWTEST_F(BmsBundleDefaultAppTest, MatchFileType_0200, Function | SmallTest | Lev
{
std::vector<Skill> skills;
Skill skill;
skill.actions.push_back(Constants::ACTION_VIEW_DATA);
skill.actions.push_back(ACTION_VIEW_DATA);
SkillUri uris;
uris.type = "application/msword";

View File

@ -211,9 +211,11 @@ const int32_t ICON_ID = 16777258;
const int32_t LABEL_ID = 16777257;
const int32_t SPACE_SIZE = 0;
const int32_t GET_ABILITY_INFO_WITH_APP_LINKING = 0x00000040;
constexpr int32_t MAX_APP_UID = 65535;
const std::vector<std::string> &DISALLOWLIST = {"com.example.actsregisterjserrorrely"};
const std::string ENTRY = "entry";
const std::string FEATURE = "feature";
constexpr const char* OVERLAY_STATE = "overlayState";
} // namespace
struct Param {
@ -1052,7 +1054,7 @@ HWTEST_F(BmsBundleDataMgrTest, QueryAbilityInfoByUri_0200, Function | SmallTest
innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::DISABLED);
GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo);
bool res = GetBundleDataMgr()->QueryAbilityInfoByUri(
Constants::DATA_ABILITY_URI_PREFIX + Constants::DATA_ABILITY_URI_SEPARATOR, Constants::ALL_USERID, abilityInfo);
Constants::DATA_ABILITY_URI_PREFIX + Constants::FILE_SEPARATOR_CHAR, Constants::ALL_USERID, abilityInfo);
EXPECT_EQ(res, false);
}
@ -1069,7 +1071,7 @@ HWTEST_F(BmsBundleDataMgrTest, QueryAbilityInfoByUri_0300, Function | SmallTest
innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::DISABLED);
GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo);
bool res = bundleMgrHostImpl_->QueryAbilityInfoByUri(
Constants::DATA_ABILITY_URI_PREFIX + Constants::DATA_ABILITY_URI_SEPARATOR, Constants::ALL_USERID, abilityInfo);
Constants::DATA_ABILITY_URI_PREFIX + Constants::FILE_SEPARATOR_CHAR, Constants::ALL_USERID, abilityInfo);
EXPECT_EQ(res, false);
}
/**
@ -1098,7 +1100,7 @@ HWTEST_F(BmsBundleDataMgrTest, QueryAbilityInfosByUri_0200, Function | SmallTest
innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::DISABLED);
GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_TEST1, innerBundleInfo);
bool res = GetBundleDataMgr()->QueryAbilityInfosByUri(
Constants::DATA_ABILITY_URI_PREFIX + Constants::DATA_ABILITY_URI_SEPARATOR, abilityInfo);
Constants::DATA_ABILITY_URI_PREFIX + Constants::FILE_SEPARATOR_CHAR, abilityInfo);
EXPECT_EQ(res, false);
}
@ -1753,7 +1755,7 @@ HWTEST_F(BmsBundleDataMgrTest, GenerateUidAndGid_0100, Function | SmallTest | Le
ApplicationInfo applicationInfo;
applicationInfo.bundleName = BUNDLE_NAME_TEST;
innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
GetBundleDataMgr()->bundleIdMap_.emplace(Constants::MAX_APP_UID, BUNDLE_TEST1);
GetBundleDataMgr()->bundleIdMap_.emplace(MAX_APP_UID, BUNDLE_TEST1);
GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo);
bool res = GetBundleDataMgr()->GenerateUidAndGid(innerBundleUserInfo);
EXPECT_EQ(res, false);
@ -2703,7 +2705,7 @@ HWTEST_F(BmsBundleDataMgrTest, TestFindAbilityInfos_0500, Function | MediumTest
InnerBundleInfo info;
InnerBundleUserInfo userInfo;
AbilityInfo abilityInfo;
abilityInfo.name = Constants::OVERLAY_STATE;
abilityInfo.name = OVERLAY_STATE;
userInfo.bundleName = MODULE_NAME1;
info.innerBundleUserInfos_.try_emplace(MODULE_NAME1, userInfo);
info.baseAbilityInfos_.try_emplace(MODULE_NAME1, abilityInfo);

View File

@ -245,6 +245,7 @@ const std::string URI_UTD = "utd";
const std::string URI_LINK_FEATURE = "login";
const std::string SKILL_PERMISSION = "permission1";
const int32_t MAX_FILE_SUPPORTED = 1;
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
} // namespace
class BmsBundleKitServiceTest : public testing::Test {
@ -5904,7 +5905,7 @@ HWTEST_F(BmsBundleKitServiceTest, SkillMatch_TYPE_WILDCARD_001, Function | Small
skill.uris.emplace_back(skillUri);
// success testCase
Want want;
want.SetType(Constants::TYPE_ONLY_MATCH_WILDCARD);
want.SetType(TYPE_ONLY_MATCH_WILDCARD);
bool ret = skill.Match(want);
EXPECT_EQ(true, ret);
// failed testCase

View File

@ -80,6 +80,7 @@ const std::string OVER_MAX_SIZE(300, 'x');
const std::string ABILITY_NAME = "com.example.l3jsdemo.entry.EntryAbility";
const std::string EMPTY_STRING = "";
const std::string MENU_VALUE = "value";
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
const size_t NUMBER_ONE = 1;
const uint32_t BUNDLE_BACKUP_VERSION = 1000000;
const uint32_t BUNDLE_BACKUP_LABEL_ID = 16777216;
@ -1906,7 +1907,7 @@ HWTEST_F(BmsBundleManagerTest, SkillFalse_0004, Function | SmallTest | Level1)
{
struct Skill skill;
skill.actions.emplace_back("action001");
bool ret = skill.MatchType(Constants::TYPE_ONLY_MATCH_WILDCARD, "*/*");
bool ret = skill.MatchType(TYPE_ONLY_MATCH_WILDCARD, "*/*");
EXPECT_EQ(ret, true);
}

View File

@ -58,6 +58,7 @@ const int32_t NOT_EXIST_USERID = -5;
const int32_t FOUR = 4;
const int32_t DEFAULT_OVERLAY_BUNDLE_INFO = 0;
const int32_t WAIT_TIME = 5; // init mocked bms
constexpr int32_t OVERLAY_MAXIMUM_PRIORITY = 100;
} // namespace
class BmsBundleOverlayCheckerTest : public testing::Test {
@ -707,7 +708,7 @@ HWTEST_F(BmsBundleOverlayCheckerTest, CheckExternalBundle_0100, Function | Small
code = checker.CheckExternalBundle(innerBundleInfo, userId);
EXPECT_EQ(code, ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_INVALID_PRIORITY);
applicationInfo.targetPriority = Constants::OVERLAY_MAXIMUM_PRIORITY + 1;
applicationInfo.targetPriority = OVERLAY_MAXIMUM_PRIORITY + 1;
innerBundleInfo.SetBaseApplicationInfo(applicationInfo);
code = checker.CheckExternalBundle(innerBundleInfo, userId);
EXPECT_EQ(code, ERR_BUNDLEMANAGER_OVERLAY_INSTALLATION_FAILED_INVALID_PRIORITY);

View File

@ -53,6 +53,7 @@ const int32_t USERID = 100;
const int32_t FLAGS = 0;
const int32_t UID = 0;
const int32_t WAIT_TIME = 5; // init mocked bms
constexpr int PERMISSION_NOT_GRANTED = -1;
} // namespace
class BmsBundlePermissionFalseTest : public testing::Test {
@ -1236,7 +1237,7 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_8300, Functi
int32_t installedUid = 100;
BundleStreamInstallerHostImpl impl(installerId, installedUid);
int ret = impl.CreateStream(BUNDLE_NAME);
EXPECT_EQ(ret, Constants::PERMISSION_NOT_GRANTED);
EXPECT_EQ(ret, PERMISSION_NOT_GRANTED);
}
/**
@ -1251,7 +1252,7 @@ HWTEST_F(BmsBundlePermissionFalseTest, BmsBundlePermissionFalseTest_8400, Functi
int32_t installedUid = 100;
BundleStreamInstallerHostImpl impl(installerId, installedUid);
int ret = impl.CreateSharedBundleStream(BUNDLE_NAME, UID);
EXPECT_EQ(ret, Constants::PERMISSION_NOT_GRANTED);
EXPECT_EQ(ret, PERMISSION_NOT_GRANTED);
}
/**

View File

@ -2583,7 +2583,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetAppType_0300, Function | MediumTest | Level2)
std::string uninstallResult = commonTool.VectorToStr(resvec);
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
if (std::strcmp(appType.c_str(), (Constants::EMPTY_STRING).c_str()) != 0) {
if (std::strcmp(appType.c_str(), Constants::EMPTY_STRING) != 0) {
APP_LOGI("GetAppType_0300 failed - cycle count: %{public}d", i);
break;
}
@ -2639,7 +2639,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetAppType_0500, Function | MediumTest | Level2)
std::string appType = bundleMgrProxy->GetAppType(appName);
EXPECT_EQ(appType, Constants::EMPTY_STRING);
if (std::strcmp(appType.c_str(), (Constants::EMPTY_STRING).c_str()) != 0) {
if (std::strcmp(appType.c_str(), Constants::EMPTY_STRING) != 0) {
APP_LOGI("GetAppType_0500 failed - cycle count: %{public}d", i);
break;
}
@ -2736,7 +2736,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0300, Function | MediumTest | Lev
std::string uninstallResult = commonTool.VectorToStr(resvec);
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
if (std::strcmp(abilityLabel.c_str(), (Constants::EMPTY_STRING).c_str()) != 0) {
if (std::strcmp(abilityLabel.c_str(), Constants::EMPTY_STRING) != 0) {
APP_LOGI("GetAbilityLabel_0300 failed - cycle count: %{public}d", i);
break;
}
@ -2781,7 +2781,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0400, Function | MediumTest | Lev
std::string uninstallResult = commonTool.VectorToStr(resvec);
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
if (std::strcmp(abilityLabel.c_str(), (Constants::EMPTY_STRING).c_str()) != 0) {
if (std::strcmp(abilityLabel.c_str(), Constants::EMPTY_STRING) != 0) {
APP_LOGI("GetAbilityLabel_0400 failed - cycle count: %{public}d", i);
break;
}
@ -2838,7 +2838,7 @@ HWTEST_F(ActsBmsKitSystemTest, GetAbilityLabel_0600, Function | MediumTest | Lev
std::string abilityLabel = bundleMgrProxy->GetAbilityLabel(appName, abilityName);
EXPECT_EQ(abilityLabel, Constants::EMPTY_STRING);
if (std::strcmp(abilityLabel.c_str(), (Constants::EMPTY_STRING).c_str()) != 0) {
if (std::strcmp(abilityLabel.c_str(), Constants::EMPTY_STRING) != 0) {
APP_LOGI("GetAbilityLabel_0600 failed - cycle count: %{public}d", i);
break;
}