Merge branch 'master' of gitee.com:openharmony/bundlemanager_bundle_framework into 0608

Signed-off-by: sunjiakun <sunjiakun5@huawei.com>
This commit is contained in:
sunjiakun 2024-06-09 12:10:58 +00:00 committed by Gitee
commit 45793304cd
80 changed files with 1398 additions and 93 deletions

View File

@ -109,6 +109,11 @@ ohos_shared_library("appexecfwk_base") {
"ipc:ipc_single",
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:utd_client" ]
}
public_external_deps = [ "json:nlohmann_json_static" ]
subsystem_name = "bundlemanager"

View File

@ -69,6 +69,9 @@ private:
bool MatchMimeType(const std::string &uriString, size_t &matchUriIndex) const;
bool MatchLinkFeature(const std::string &linkFeature, const OHOS::AAFwk::Want &want, size_t &matchUriIndex) const;
std::string GetOptParamUri(const std::string &uriString) const;
bool MatchUtd(const std::string &paramType, const std::string &skillUriType, bool &containsUtd) const;
bool IsUtdMatch(const std::string &paramUtd, const std::string &skillUtd) const;
bool IsUtd(const std::string &param) const;
};
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -22,6 +22,10 @@
#include "json_util.h"
#include <fcntl.h>
#include "nlohmann/json.hpp"
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
#include "type_descriptor.h"
#include "utd_client.h"
#endif
namespace OHOS {
namespace AppExecFwk {
@ -416,6 +420,13 @@ bool Skill::MatchType(const std::string &type, const std::string &skillUriType)
if (type.empty() || skillUriType.empty()) {
return false;
}
bool containsUtd = false;
bool matchUtdRet = MatchUtd(type, skillUriType, containsUtd);
if (containsUtd) {
return matchUtdRet;
}
// only match */*
if (type == TYPE_ONLY_MATCH_WILDCARD) {
return skillUriType == TYPE_WILDCARD;
@ -440,6 +451,73 @@ bool Skill::MatchType(const std::string &type, const std::string &skillUriType)
}
}
bool Skill::MatchUtd(const std::string &paramType, const std::string &skillUriType, bool &containsUtd) const
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
bool isParamUtd = IsUtd(paramType);
bool isSkillUtd = IsUtd(skillUriType);
containsUtd = isParamUtd || isSkillUtd;
if (!isParamUtd && !isSkillUtd) {
// 1.param : mimeType, skill : mimeType
return false;
} else if (isParamUtd && isSkillUtd) {
// 2.param : utd, skill : utd
return IsUtdMatch(paramType, skillUriType);
} else if (!isParamUtd && isSkillUtd) {
// 3.param : mimeType, skill : utd
std::string paramUtd;
auto ret = UDMF::UtdClient::GetInstance().GetUniformDataTypeByMIMEType(paramType, paramUtd);
if (ret != ERR_OK) {
return false;
}
return IsUtdMatch(paramUtd, skillUriType);
} else {
// 4.param : utd, skill : mimeType
std::string skillUtd;
auto ret = UDMF::UtdClient::GetInstance().GetUniformDataTypeByMIMEType(skillUriType, skillUtd);
if (ret != ERR_OK) {
return false;
}
return IsUtdMatch(paramType, skillUtd);
}
#else
containsUtd = false;
return false;
#endif
}
bool Skill::IsUtdMatch(const std::string &paramUtd, const std::string &skillUtd) const
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
std::shared_ptr<UDMF::TypeDescriptor> paramTypeDescriptor;
auto ret = UDMF::UtdClient::GetInstance().GetTypeDescriptor(paramUtd, paramTypeDescriptor);
if (ret != ERR_OK || paramTypeDescriptor == nullptr) {
return false;
}
bool isMatch = false;
ret = paramTypeDescriptor->BelongsTo(skillUtd, isMatch);
if (ret != ERR_OK) {
return false;
}
return isMatch;
#else
return false;
#endif
}
bool Skill::IsUtd(const std::string &param) const
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
bool isUtd = false;
auto ret = UDMF::UtdClient::GetInstance().IsUtd(param, isUtd);
return ret == ERR_OK && isUtd;
#else
return false;
#endif
}
bool Skill::MatchMimeType(const std::string & uriString) const
{
std::vector<std::string> mimeTypes;

View File

@ -420,7 +420,7 @@ ohos_shared_library("libbms") {
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -100,7 +100,7 @@ private:
std::shared_ptr<BundleCommonEventMgr> commonEventMgr_;
std::mutex appRunningControlMutex_;
std::unordered_map<std::string, std::vector<DisposedRule>> abilityRunningControlRuleCache_;
std::mutex abilityRunningControlRuleMutex_;
std::shared_mutex abilityRunningControlRuleMutex_;
};
} // AppExecFwk
} // OHOS

View File

@ -161,6 +161,7 @@ public:
* @return Returns result.
*/
static bool DeleteDir(const std::string &path);
static bool IsUtd(const std::string &param);
static std::string GetBoolStrVal(bool val);
static void MakeFsConfig(const std::string &bundleName, int32_t bundleId, const std::string &configPath);
static void RemoveFsConfig(const std::string &bundleName, const std::string &configPath);

View File

@ -67,6 +67,16 @@ private:
std::string GetType(const AAFwk::Want& want) const;
bool MatchActionAndType(const std::string& action, const std::string& type, const std::vector<Skill>& skills) const;
bool GetBrokerBundleInfo(const Element& element, BundleInfo& bundleInfo) const;
bool IsSameDefaultApp(const std::vector<BundleInfo>& bundleInfos) const;
bool IsSameAbilityInfo(const std::vector<BundleInfo>& bundleInfos) const;
bool IsSameExtensionInfo(const std::vector<BundleInfo>& bundleInfos) const;
std::vector<std::string> GetMimeTypes(const std::string& utd) const;
ErrCode IsDefaultApplicationInternal(int32_t userId, const std::string& type, bool& isDefaultApp) const;
ErrCode GetDefaultApplicationInternal(
int32_t userId, const std::string& type, BundleInfo& bundleInfo, bool backup = false) const;
ErrCode SetDefaultApplicationInternal(int32_t userId, const std::string& type, const Element& element) const;
ErrCode ResetDefaultApplicationInternal(int32_t userId, const std::string& type) const;
std::shared_ptr<IDefaultAppDb> defaultAppDb_;
mutable std::mutex mutex_;

View File

@ -345,7 +345,7 @@ ErrCode AppControlManager::SetDisposedRule(const std::string &callerName, const
}
std::string key = appId + std::string("_") + std::to_string(userId) + std::string("_") + std::to_string(appIndex);
{
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
std::unique_lock<std::shared_mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
if (iter != abilityRunningControlRuleCache_.end()) {
abilityRunningControlRuleCache_.erase(iter);
@ -376,7 +376,7 @@ ErrCode AppControlManager::DeleteDisposedRule(
}
std::string key = appId + std::string("_") + std::to_string(userId) + std::string("_") + std::to_string(appIndex);
{
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
std::unique_lock<std::shared_mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
if (iter != abilityRunningControlRuleCache_.end()) {
abilityRunningControlRuleCache_.erase(iter);
@ -431,7 +431,7 @@ void AppControlManager::DeleteAppRunningRuleCache(std::string &key)
void AppControlManager::DeleteAbilityRunningRuleCache(std::string &key)
{
std::lock_guard<std::mutex> cacheLock(abilityRunningControlRuleMutex_);
std::unique_lock<std::shared_mutex> lock(abilityRunningControlRuleMutex_);
auto cacheIter = abilityRunningControlRuleCache_.find(key);
if (cacheIter != abilityRunningControlRuleCache_.end()) {
abilityRunningControlRuleCache_.erase(cacheIter);
@ -465,7 +465,7 @@ ErrCode AppControlManager::GetAbilityRunningControlRule(
}
std::string key = bundleInfo.appId + std::string("_") + std::to_string(userId) + std::string("_")
+ std::to_string(appIndex);
std::lock_guard<std::mutex> lock(abilityRunningControlRuleMutex_);
std::shared_lock<std::shared_mutex> lock(abilityRunningControlRuleMutex_);
auto iter = abilityRunningControlRuleCache_.find(key);
if (iter != abilityRunningControlRuleCache_.end()) {
disposedRules = iter->second;

View File

@ -269,7 +269,7 @@ ErrCode BaseBundleInstaller::InstallBundleByBundleName(
InstallScene::CREATE_USER,
result);
PerfProfile::GetInstance().SetBundleInstallEndTime(GetTickCount());
APP_LOGD("finish to process %{public}s bundle install", bundleName.c_str());
APP_LOGI("finish to process %{public}s bundle install, resultCode: %{public}d", bundleName.c_str(), result);
return result;
}
@ -280,6 +280,9 @@ ErrCode BaseBundleInstaller::Recover(
PerfProfile::GetInstance().SetBundleInstallStartTime(GetTickCount());
int32_t uid = Constants::INVALID_UID;
ErrCode result = ProcessRecover(bundleName, installParam, uid);
APP_LOGI("recover result: %{public}d, needSendEvent: %{public}d, dataMgr: %{public}d, bundle: %{public}d"
", modulePackage: %{public}d", result, installParam.needSendEvent, (dataMgr_ == nullptr), bundleName_.empty(),
modulePackage_.empty());
if (installParam.needSendEvent && dataMgr_ && !bundleName_.empty() && !modulePackage_.empty()) {
NotifyBundleEvents installRes = {
.bundleName = bundleName,
@ -3586,12 +3589,8 @@ void BaseBundleInstaller::RemoveCreatedExtensionDirsForException() const
APP_LOGI("no need to remove extension sandbox dir");
return;
}
for (const std::string &dir : createExtensionDirs_) {
auto result = InstalldClient::GetInstance()->RemoveDir(dir);
if (result != ERR_OK) {
APP_LOGW("remove created extension sandbox dir %{public}s failed.", dir.c_str());
continue;
}
if (InstalldClient::GetInstance()->RemoveExtensionDir(userId_, createExtensionDirs_) != ERR_OK) {
APP_LOGW("remove created extension sandbox dir failed.");
}
}

View File

@ -105,11 +105,14 @@ void BundleCommonEventMgr::NotifyBundleStatus(const NotifyBundleEvents &installR
}
if (installResult.resultCode != ERR_OK || installResult.isBmsExtensionUninstalled) {
APP_LOGI("install ret: %{public}d, extension: %{public}d",
installResult.resultCode, installResult.isBmsExtensionUninstalled);
return;
}
int32_t bundleUserId = BundleUtil::GetUserIdByUid(installResult.uid);
int32_t publishUserId = (bundleUserId == Constants::DEFAULT_USERID) ?
AccountHelper::GetCurrentActiveUserId() : bundleUserId;
APP_LOGI("%{public}s publish event", installResult.bundleName.c_str());
EventFwk::CommonEventManager::PublishCommonEventAsUser(commonData, publishUserId);
}

View File

@ -193,7 +193,7 @@ ErrCode BundleInstallChecker::CheckMultipleHapsSignInfo(
auto verifyRes = BundleVerifyMgr::HapVerify(bundlePath, hapVerifyResult);
#ifndef X86_EMULATOR_MODE
if (verifyRes != ERR_OK) {
APP_LOGE("hap file verify failed");
APP_LOGE("hap file verify failed, bundlePath: %{public}s", bundlePath.c_str());
return verifyRes;
}
#endif

View File

@ -39,6 +39,10 @@
#include "ipc_skeleton.h"
#include "parameter.h"
#include "string_ex.h"
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
#include "type_descriptor.h"
#include "utd_client.h"
#endif
namespace OHOS {
namespace AppExecFwk {
@ -534,6 +538,17 @@ bool BundleUtil::DeleteDir(const std::string &path)
return true;
}
bool BundleUtil::IsUtd(const std::string &param)
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
bool isUtd = false;
auto ret = UDMF::UtdClient::GetInstance().IsUtd(param, isUtd);
return ret == ERR_OK && isUtd;
#else
return false;
#endif
}
std::string BundleUtil::GetBoolStrVal(bool val)
{
return val ? "true" : "false";

View File

@ -24,6 +24,10 @@
#include "ipc_skeleton.h"
#include "mime_type_mgr.h"
#include "string_ex.h"
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
#include "type_descriptor.h"
#include "utd_client.h"
#endif
namespace OHOS {
namespace AppExecFwk {
@ -97,6 +101,29 @@ void DefaultAppMgr::Init()
}
ErrCode DefaultAppMgr::IsDefaultApplication(int32_t userId, const std::string& type, bool& isDefaultApp) const
{
LOG_I(BMS_TAG_DEFAULT_APP,
"IsDefaultApplication begin, userId : %{public}d, type : %{public}s", userId, type.c_str());
if (!BundleUtil::IsUtd(type)) {
return IsDefaultApplicationInternal(userId, type, isDefaultApp);
}
std::vector<std::string> mimeTypes = GetMimeTypes(type);
if (mimeTypes.empty()) {
LOG_E(BMS_TAG_DEFAULT_APP, "get mimeTypes by utd failed");
isDefaultApp = false;
return ERR_OK;
}
LOG_I(BMS_TAG_DEFAULT_APP, "mimeTypes : %{public}s", BundleUtil::ToString(mimeTypes).c_str());
for (const auto& mimeType : mimeTypes) {
(void)IsDefaultApplicationInternal(userId, mimeType, isDefaultApp);
if (!isDefaultApp) {
break;
}
}
return ERR_OK;
}
ErrCode DefaultAppMgr::IsDefaultApplicationInternal(int32_t userId, const std::string& type, bool& isDefaultApp) const
{
std::lock_guard<std::mutex> lock(mutex_);
std::string mimeType = type;
@ -123,12 +150,14 @@ ErrCode DefaultAppMgr::IsDefaultApplication(int32_t userId, const std::string& t
std::shared_ptr<BundleDataMgr> dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
LOG_W(BMS_TAG_DEFAULT_APP, "get BundleDataMgr failed.");
isDefaultApp = false;
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
std::string callingBundleName;
ret = dataMgr->GetBundleNameForUid(IPCSkeleton::GetCallingUid(), callingBundleName);
if (!ret) {
LOG_W(BMS_TAG_DEFAULT_APP, "GetBundleNameForUid failed.");
isDefaultApp = false;
return ERR_BUNDLE_MANAGER_INTERNAL_ERROR;
}
LOG_D(BMS_TAG_DEFAULT_APP, "callingBundleName : %{public}s", callingBundleName.c_str());
@ -138,6 +167,36 @@ ErrCode DefaultAppMgr::IsDefaultApplication(int32_t userId, const std::string& t
ErrCode DefaultAppMgr::GetDefaultApplication(
int32_t userId, const std::string& type, BundleInfo& bundleInfo, bool backup) const
{
LOG_I(BMS_TAG_DEFAULT_APP, "GetDefaultApplication begin, userId : %{public}d, \
type : %{public}s, backup : %{public}d", userId, type.c_str(), backup);
if (!BundleUtil::IsUtd(type)) {
return GetDefaultApplicationInternal(userId, type, bundleInfo, backup);
}
std::vector<std::string> mimeTypes = GetMimeTypes(type);
if (mimeTypes.empty()) {
LOG_E(BMS_TAG_DEFAULT_APP, "get mimeTypes by utd failed");
return ERR_BUNDLE_MANAGER_INVALID_TYPE;
}
LOG_I(BMS_TAG_DEFAULT_APP, "mimeTypes : %{public}s", BundleUtil::ToString(mimeTypes).c_str());
std::vector<BundleInfo> bundleInfos;
for (const auto& mimeType : mimeTypes) {
BundleInfo info;
ErrCode ret = GetDefaultApplicationInternal(userId, mimeType, info, backup);
if (ret != ERR_OK) {
return ret;
}
bundleInfos.emplace_back(info);
}
if (bundleInfos.empty() || !IsSameDefaultApp(bundleInfos)) {
return ERR_BUNDLE_MANAGER_DEFAULT_APP_NOT_EXIST;
}
bundleInfo = bundleInfos[0];
return ERR_OK;
}
ErrCode DefaultAppMgr::GetDefaultApplicationInternal(
int32_t userId, const std::string& type, BundleInfo& bundleInfo, bool backup) const
{
LOG_D(BMS_TAG_DEFAULT_APP, "begin, backup(bool) : %{public}d", backup);
std::lock_guard<std::mutex> lock(mutex_);
@ -169,7 +228,31 @@ ErrCode DefaultAppMgr::GetDefaultApplication(
}
}
ErrCode DefaultAppMgr::SetDefaultApplication(int32_t userId, const std::string& type, const Element& element) const
ErrCode DefaultAppMgr::SetDefaultApplication(
int32_t userId, const std::string& type, const Element& element) const
{
LOG_I(BMS_TAG_DEFAULT_APP,
"SetDefaultApplication begin, userId : %{public}d, type : %{public}s", userId, type.c_str());
if (!BundleUtil::IsUtd(type)) {
return SetDefaultApplicationInternal(userId, type, element);
}
std::vector<std::string> mimeTypes = GetMimeTypes(type);
if (mimeTypes.empty()) {
LOG_E(BMS_TAG_DEFAULT_APP, "get mimeTypes by utd failed");
return ERR_BUNDLE_MANAGER_INVALID_TYPE;
}
LOG_I(BMS_TAG_DEFAULT_APP, "mimeTypes : %{public}s", BundleUtil::ToString(mimeTypes).c_str());
for (const auto& mimeType : mimeTypes) {
ErrCode ret = SetDefaultApplicationInternal(userId, mimeType, element);
if (ret != ERR_OK) {
return ret;
}
}
return ERR_OK;
}
ErrCode DefaultAppMgr::SetDefaultApplicationInternal(
int32_t userId, const std::string& type, const Element& element) const
{
std::lock_guard<std::mutex> lock(mutex_);
std::string mimeType = type;
@ -217,6 +300,28 @@ ErrCode DefaultAppMgr::SetDefaultApplication(int32_t userId, const std::string&
}
ErrCode DefaultAppMgr::ResetDefaultApplication(int32_t userId, const std::string& type) const
{
LOG_I(BMS_TAG_DEFAULT_APP,
"ResetDefaultApplication begin, userId : %{public}d, type : %{public}s", userId, type.c_str());
if (!BundleUtil::IsUtd(type)) {
return ResetDefaultApplicationInternal(userId, type);
}
std::vector<std::string> mimeTypes = GetMimeTypes(type);
if (mimeTypes.empty()) {
LOG_E(BMS_TAG_DEFAULT_APP, "get mimeTypes by utd failed");
return ERR_BUNDLE_MANAGER_INVALID_TYPE;
}
LOG_I(BMS_TAG_DEFAULT_APP, "mimeTypes : %{public}s", BundleUtil::ToString(mimeTypes).c_str());
for (const auto& mimeType : mimeTypes) {
ErrCode ret = ResetDefaultApplicationInternal(userId, mimeType);
if (ret != ERR_OK) {
return ret;
}
}
return ERR_OK;
}
ErrCode DefaultAppMgr::ResetDefaultApplicationInternal(int32_t userId, const std::string& type) const
{
std::lock_guard<std::mutex> lock(mutex_);
std::string mimeType = type;
@ -779,5 +884,102 @@ bool DefaultAppMgr::GetBrokerBundleInfo(const Element& element, BundleInfo& bund
LOG_I(BMS_TAG_DEFAULT_APP, "get broker bundleInfo success");
return true;
}
bool DefaultAppMgr::IsSameDefaultApp(const std::vector<BundleInfo>& bundleInfos) const
{
size_t size = bundleInfos.size();
if (size == 0) {
LOG_W(BMS_TAG_DEFAULT_APP, "size empty");
return false;
}
if (size == 1) {
return true;
}
return IsSameAbilityInfo(bundleInfos) || IsSameExtensionInfo(bundleInfos);
}
bool DefaultAppMgr::IsSameAbilityInfo(const std::vector<BundleInfo>& bundleInfos) const
{
const BundleInfo& firstBundleInfo = bundleInfos[0];
if (firstBundleInfo.name.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "bundleName empty");
return false;
}
if (firstBundleInfo.abilityInfos.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "abilityInfos empty");
return false;
}
std::string bundleName = firstBundleInfo.name;
std::string moduleName = firstBundleInfo.abilityInfos[0].moduleName;
std::string abilityName = firstBundleInfo.abilityInfos[0].name;
for (size_t i = 1; i < bundleInfos.size(); ++i) {
if (bundleInfos[i].name != bundleName) {
LOG_W(BMS_TAG_DEFAULT_APP, "bundleName not equal");
return false;
}
if (bundleInfos[i].abilityInfos.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "abilityInfos empty");
return false;
}
if (bundleInfos[i].abilityInfos[0].moduleName != moduleName) {
LOG_W(BMS_TAG_DEFAULT_APP, "moduleName not equal");
return false;
}
if (bundleInfos[i].abilityInfos[0].name != abilityName) {
LOG_W(BMS_TAG_DEFAULT_APP, "abilityName not equal");
return false;
}
}
return true;
}
bool DefaultAppMgr::IsSameExtensionInfo(const std::vector<BundleInfo>& bundleInfos) const
{
const BundleInfo& firstBundleInfo = bundleInfos[0];
if (firstBundleInfo.name.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "bundleName empty");
return false;
}
if (firstBundleInfo.extensionInfos.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "extensionInfos empty");
return false;
}
std::string bundleName = firstBundleInfo.name;
std::string moduleName = firstBundleInfo.extensionInfos[0].moduleName;
std::string extensionName = firstBundleInfo.extensionInfos[0].name;
for (size_t i = 1; i < bundleInfos.size(); ++i) {
if (bundleInfos[i].name != bundleName) {
LOG_W(BMS_TAG_DEFAULT_APP, "bundleName not equal");
return false;
}
if (bundleInfos[i].extensionInfos.empty()) {
LOG_W(BMS_TAG_DEFAULT_APP, "extensionInfos empty");
return false;
}
if (bundleInfos[i].extensionInfos[0].moduleName != moduleName) {
LOG_W(BMS_TAG_DEFAULT_APP, "moduleName not equal");
return false;
}
if (bundleInfos[i].extensionInfos[0].name != extensionName) {
LOG_W(BMS_TAG_DEFAULT_APP, "extensionName not equal");
return false;
}
}
return true;
}
std::vector<std::string> DefaultAppMgr::GetMimeTypes(const std::string& utd) const
{
#ifdef BUNDLE_FRAMEWORK_UDMF_ENABLED
std::shared_ptr<UDMF::TypeDescriptor> typeDescriptor;
auto ret = UDMF::UtdClient::GetInstance().GetTypeDescriptor(utd, typeDescriptor);
if (ret != ERR_OK || typeDescriptor == nullptr) {
return {};
}
return typeDescriptor->GetMimeTypes();
#else
return {};
#endif
}
}
}

View File

@ -144,7 +144,7 @@ ohos_unittest("BmsAbilityManagerHelperTest") {
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -171,7 +171,7 @@ ohos_unittest("BmsBundleAccessTokenIdTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -163,7 +163,7 @@ ohos_unittest("BmsAOTMgrTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -160,7 +160,7 @@ ohos_unittest("BmsBundleAppControlTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -317,7 +317,7 @@ ohos_unittest("BmsBundleMockAppControlTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -164,7 +164,7 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -154,7 +154,7 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -226,7 +226,7 @@ ohos_unittest("BmsBundleCloneAppDataStructTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
}
@ -372,7 +372,7 @@ ohos_unittest("BmsBundleCloneAppIpcTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -160,7 +160,7 @@ ohos_unittest("BmsBundleCommonTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -155,7 +155,7 @@ ohos_unittest("BmsBundleCrowdtestingTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -147,7 +147,7 @@ ohos_unittest("BmsBundleDataGroupTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -83,7 +83,7 @@ ohos_unittest("BmsBundleDataStorageDatabaseTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
}

View File

@ -164,7 +164,7 @@ ohos_unittest("BmsBundleDefaultAppTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -75,6 +75,10 @@ const std::string ABILITY_EXCEL = "EXCEL";
const std::string ABILITY_EXCEL_ERROR = "EXCEL-ERROR";
const std::string ABILITY_PPT = "PPT";
const std::string ABILITY_PPT_ERROR = "PPT-ERROR";
const std::string ABILITY_GENERAL_VIDEO = "GeneralVideo";
const std::string ABILITY_GENERAL_AVI = "GeneralAvi";
const std::string ABILITY_VIDEO_MS_VIDEO = "VideoMsVideo";
const std::string UTD_GENERAL_AVI = "general.avi";
const std::string LABEL = "$string:MainAbility_label";
const std::string ICON = "$media:icon";
const std::string DESCRIPTION = "$string:MainAbility_desc";
@ -260,6 +264,81 @@ ErrCode BmsBundleDefaultAppTest::SetDefaultApplicationWrap(sptr<IDefaultApp> def
return defaultAppProxy->SetDefaultApplication(USER_ID, type, want);
}
/**
* @tc.number: UTD_0100
* @tc.name: test SetDefaultApplication and GetDefaultApplication, param is general.avi, config is general.avi
* @tc.desc: 1. call SetDefaultApplication, return true
* 2. call GetDefaultApplication, return true and the ability is same with SetDefaultApplication's ability
*/
HWTEST_F(BmsBundleDefaultAppTest, UTD_0100, Function | SmallTest | Level1)
{
auto defaultAppProxy = GetDefaultAppProxy();
EXPECT_NE(defaultAppProxy, nullptr);
ErrCode result = SetDefaultApplicationWrap(defaultAppProxy, UTD_GENERAL_AVI, ABILITY_GENERAL_AVI);
EXPECT_EQ(result, ERR_OK);
BundleInfo bundleInfo;
result = defaultAppProxy->GetDefaultApplication(USER_ID, UTD_GENERAL_AVI, bundleInfo);
EXPECT_EQ(result, ERR_OK);
EXPECT_EQ(bundleInfo.abilityInfos.size(), 1);
if (bundleInfo.abilityInfos.size() == 1) {
auto abilityInfo = bundleInfo.abilityInfos[0];
EXPECT_EQ(abilityInfo.name, ABILITY_GENERAL_AVI);
}
result = defaultAppProxy->ResetDefaultApplication(USER_ID, UTD_GENERAL_AVI);
EXPECT_EQ(result, ERR_OK);
result = defaultAppProxy->GetDefaultApplication(USER_ID, UTD_GENERAL_AVI, bundleInfo);
EXPECT_NE(result, ERR_OK);
}
/**
* @tc.number: UTD_0200
* @tc.name: test SetDefaultApplication and GetDefaultApplication, param is general.avi, config is general.video
* @tc.desc: 1. call SetDefaultApplication, return true
* 2. call GetDefaultApplication, return true and the ability is same with SetDefaultApplication's ability
*/
HWTEST_F(BmsBundleDefaultAppTest, UTD_0200, Function | SmallTest | Level1)
{
auto defaultAppProxy = GetDefaultAppProxy();
EXPECT_NE(defaultAppProxy, nullptr);
ErrCode result = SetDefaultApplicationWrap(defaultAppProxy, UTD_GENERAL_AVI, ABILITY_GENERAL_VIDEO);
EXPECT_EQ(result, ERR_OK);
BundleInfo bundleInfo;
result = defaultAppProxy->GetDefaultApplication(USER_ID, UTD_GENERAL_AVI, bundleInfo);
EXPECT_EQ(result, ERR_OK);
EXPECT_EQ(bundleInfo.abilityInfos.size(), 1);
if (bundleInfo.abilityInfos.size() == 1) {
auto abilityInfo = bundleInfo.abilityInfos[0];
EXPECT_EQ(abilityInfo.name, ABILITY_GENERAL_VIDEO);
}
result = defaultAppProxy->ResetDefaultApplication(USER_ID, UTD_GENERAL_AVI);
EXPECT_EQ(result, ERR_OK);
result = defaultAppProxy->GetDefaultApplication(USER_ID, UTD_GENERAL_AVI, bundleInfo);
EXPECT_NE(result, ERR_OK);
}
/**
* @tc.number: UTD_0300
* @tc.name: test SetDefaultApplication, param is general.avi, config is video/x-msvideo
* @tc.desc: 1. call SetDefaultApplication, return error
* 2. call GetDefaultApplication, return error
*/
HWTEST_F(BmsBundleDefaultAppTest, UTD_0300, Function | SmallTest | Level1)
{
auto defaultAppProxy = GetDefaultAppProxy();
EXPECT_NE(defaultAppProxy, nullptr);
ErrCode result = SetDefaultApplicationWrap(defaultAppProxy, UTD_GENERAL_AVI, ABILITY_VIDEO_MS_VIDEO);
EXPECT_NE(result, ERR_OK);
BundleInfo bundleInfo;
result = defaultAppProxy->GetDefaultApplication(USER_ID, UTD_GENERAL_AVI, bundleInfo);
EXPECT_NE(result, ERR_OK);
}
/**
* @tc.number: BmsBundleDefaultApp_0100
* @tc.name: test IsDefaultApplication
@ -1433,6 +1512,21 @@ HWTEST_F(BmsBundleDefaultAppTest, BmsBundleDefaultApp_6600, Function | SmallTest
EXPECT_NE(result, ERR_OK);
}
/**
* @tc.number: BmsBundleDefaultApp_6700
* @tc.name: test IsDefaultApplication
* @tc.desc: 1. call IsDefaultApplication, return false
*/
HWTEST_F(BmsBundleDefaultAppTest, BmsBundleDefaultApp_6700, Function | SmallTest | Level1)
{
auto defaultAppProxy = GetDefaultAppProxy();
EXPECT_NE(defaultAppProxy, nullptr);
bool isDefaultApp = false;
ErrCode result = defaultAppProxy->IsDefaultApplication("general.video", isDefaultApp);
EXPECT_EQ(result, ERR_OK);
EXPECT_FALSE(isDefaultApp);
}
/**
* @tc.number: AOT_EXECUTOR_0100
* @tc.name: test AOTExecutor

View File

@ -156,7 +156,7 @@ ohos_unittest("BmsBundleDependenciesTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -169,7 +169,7 @@ ohos_unittest("BmsBundleFreeInstallBaseTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -338,7 +338,7 @@ ohos_unittest("BmsBundleFreeInstallTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -157,7 +157,7 @@ ohos_unittest("BmsBundleHapVerifyTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -158,7 +158,7 @@ ohos_unittest("BmsBundleHspTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -319,7 +319,7 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -475,7 +475,7 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -163,7 +163,7 @@ ohos_unittest("BmsBundleInstallerManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -187,7 +187,7 @@ ohos_unittest("BmsBundleInstallerTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -374,7 +374,7 @@ ohos_unittest("BmsBundleOtaUpdateTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -562,7 +562,7 @@ ohos_unittest("BmsMultipleBundleInstallerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -722,7 +722,7 @@ ohos_unittest("BmsBundleInstallIpcTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -863,7 +863,7 @@ ohos_unittest("BmsBundleInstallCheckerTest") {
defines += [ "GET_BOOL_PARAMETER_TRUE" ]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1004,7 +1004,7 @@ ohos_unittest("BmsBundleInstallDeviceTypeTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1149,7 +1149,7 @@ ohos_unittest("BmsSystemBundleInstallerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1338,7 +1338,7 @@ ohos_unittest("BmsBundleInstallDriverTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1510,7 +1510,7 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -163,7 +163,7 @@ ohos_unittest("BmsBundleInstallersTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -159,7 +159,7 @@ ohos_unittest("BmsBundleKitServiceBaseTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -164,7 +164,7 @@ ohos_unittest("BmsBundleDataMgrTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -338,7 +338,7 @@ ohos_unittest("BmsBundleKitServiceTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -500,7 +500,7 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -249,6 +249,10 @@ const std::string ERROR_LINK_FEATURE = "ERROR_LINK";
const std::string FILE_URI = "test.jpg";
const std::string URI_MIME_IMAGE = "image/jpeg";
constexpr const char* TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
const std::string TYPE_VIDEO_AVI = "video/avi";
const std::string TYPE_VIDEO_MS_VIDEO = "video/x-msvideo";
const std::string UTD_GENERAL_AVI = "general.avi";
const std::string UTD_GENERAL_VIDEO = "general.video";
} // namespace
class BmsBundleKitServiceTest : public testing::Test {
@ -5984,6 +5988,61 @@ HWTEST_F(BmsBundleKitServiceTest, SkillMatch_HOME_ACTION_001, Function | SmallTe
EXPECT_EQ(true, ret);
}
/**
* @tc.number: skill match rules
* @tc.name: utd match test
* @tc.desc: param : utd, skill : utd
*/
HWTEST_F(BmsBundleKitServiceTest, SkillMatch_UTD_001, Function | SmallTest | Level1)
{
struct Skill skill;
// success testCase
bool ret = skill.MatchType(UTD_GENERAL_AVI, UTD_GENERAL_AVI);
EXPECT_TRUE(ret);
ret = skill.MatchType(UTD_GENERAL_AVI, UTD_GENERAL_VIDEO);
EXPECT_TRUE(ret);
// failed testCase
ret = skill.MatchType(UTD_GENERAL_VIDEO, UTD_GENERAL_AVI);
EXPECT_FALSE(ret);
}
/**
* @tc.number: skill match rules
* @tc.name: utd match test
* @tc.desc: param : mimeType, skill : utd
*/
HWTEST_F(BmsBundleKitServiceTest, SkillMatch_UTD_002, Function | SmallTest | Level1)
{
struct Skill skill;
// success testCase
bool ret = skill.MatchType(TYPE_VIDEO_AVI, UTD_GENERAL_AVI);
EXPECT_TRUE(ret);
ret = skill.MatchType(TYPE_VIDEO_MS_VIDEO, UTD_GENERAL_AVI);
EXPECT_TRUE(ret);
ret = skill.MatchType(TYPE_VIDEO_AVI, UTD_GENERAL_VIDEO);
EXPECT_TRUE(ret);
}
/**
* @tc.number: skill match rules
* @tc.name: utd match test
* @tc.desc: param : utd, skill : mimeType
*/
HWTEST_F(BmsBundleKitServiceTest, SkillMatch_UTD_003, Function | SmallTest | Level1)
{
struct Skill skill;
// success testCase
bool ret = skill.MatchType(UTD_GENERAL_AVI, TYPE_VIDEO_AVI);
EXPECT_TRUE(ret);
ret = skill.MatchType(UTD_GENERAL_AVI, TYPE_VIDEO_MS_VIDEO);
EXPECT_TRUE(ret);
// failed testCase
ret = skill.MatchType(UTD_GENERAL_VIDEO, TYPE_VIDEO_AVI);
EXPECT_FALSE(ret);
ret = skill.MatchType(UTD_GENERAL_VIDEO, TYPE_VIDEO_MS_VIDEO);
EXPECT_FALSE(ret);
}
/**
* @tc.number: skill match rules
* @tc.name: uri and type match test: want uri empty, type not empty, linkFeature not empty; skill uri empty,

View File

@ -161,7 +161,7 @@ ohos_unittest("BmsBundleManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -160,7 +160,7 @@ ohos_unittest("BmsBundleNavigationTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -140,7 +140,7 @@ ohos_unittest("BmsBundleOverlayCheckerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
@ -346,7 +346,7 @@ ohos_unittest("BmsBundleOverlayIpcTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
@ -476,7 +476,7 @@ ohos_unittest("BmsBundleManagerOverlayIpcTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
@ -608,7 +608,7 @@ ohos_unittest("BmsBundleSetOverlayEnabledTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
@ -740,7 +740,7 @@ ohos_unittest("BmsBundleGetOverlayModuleInfoTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -171,7 +171,7 @@ ohos_unittest("BmsBundlePermissionDefListTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -517,7 +517,7 @@ ohos_unittest("BmsBundlePermissionFalseTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -692,7 +692,7 @@ ohos_unittest("BmsBundlePermissionStartFullTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -868,7 +868,7 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1039,7 +1039,7 @@ ohos_unittest("BmsBundlePermissionTokenTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -1207,7 +1207,7 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -162,7 +162,7 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -164,7 +164,7 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -163,7 +163,7 @@ ohos_unittest("BmsBundleQuickFixManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -171,7 +171,7 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -143,7 +143,7 @@ ohos_unittest("BmsBundleQuickFixQueryTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -165,7 +165,7 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -166,7 +166,7 @@ ohos_unittest("BmsBundleQuickFixTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -163,7 +163,7 @@ ohos_unittest("BmsBundleResourceManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -187,7 +187,7 @@ ohos_unittest("BmsBundleResourceTest") {
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -164,7 +164,7 @@ ohos_unittest("BmsSandboxAppTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -328,7 +328,7 @@ ohos_unittest("BmsSandboxRdbTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -173,7 +173,7 @@ ohos_unittest("BmsBundleUninstallerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -176,7 +176,7 @@ ohos_unittest("BmsBundleUpdaterTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -157,7 +157,7 @@ ohos_unittest("BmsBundleVerifyManagerTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -133,7 +133,7 @@ ohos_unittest("BmsDataMgrTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -270,7 +270,7 @@ ohos_unittest("BmsExtensionDataMgrTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -114,7 +114,7 @@ ohos_unittest("BmsEventHandlerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {
@ -223,7 +223,7 @@ ohos_unittest("BmsEventHandlerUnLockedTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -166,7 +166,7 @@ ohos_unittest("BmsExtendResourceManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -88,7 +88,7 @@ ohos_unittest("BmsInstallDaemonTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
}
@ -167,7 +167,7 @@ ohos_unittest("BmsInstallDaemonIpcTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]
@ -254,7 +254,7 @@ ohos_unittest("BmsInstallDaemonHostImplTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -155,7 +155,7 @@ ohos_unittest("BmsInstalldHostTest") {
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -147,7 +147,7 @@ ohos_unittest("BmsRdbDataManagerTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -129,7 +129,7 @@ ohos_unittest("BmsServiceBundleScanTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -126,7 +126,7 @@ ohos_unittest("BmsServiceStartupTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -153,7 +153,7 @@ ohos_unittest("BmsSyscapToolTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (bms_device_info_manager_part_enabled) {

View File

@ -81,6 +81,7 @@ group("fuzztest") {
"fuzztest_others/appservicefwkinstallercheckandparsefiles_fuzzer:AppServiceFwkInstallerCheckAndParseFilesFuzzTest",
"fuzztest_others/appservicefwkinstallercheckapplabelinfo_fuzzer:AppServiceFwkInstallerCheckAppLabelInfoFuzzTest",
"fuzztest_others/appservicefwkinstallerinnerprocessinstall_fuzzer:AppServiceFwkInstallerInnerProcessInstallFuzzTest",
"fuzztest_others/appservicefwkinstallerinstall_fuzzer:AppServiceFwkInstallerInstallFuzzTest",
"fuzztest_others/appservicefwkinstallerprocessinstall_fuzzer:AppServiceFwkInstallerProcessInstallFuzzTest",
"fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest",
"fuzztest_others/bundlecloneinstaller_fuzzer:BundlecloneinstallerFuzzTest",
@ -91,6 +92,7 @@ group("fuzztest") {
"fuzztest_others/deployquickfix_fuzzer:DeployQuickFixFuzzTest",
"fuzztest_others/driverinstaller_fuzzer:DriverInstallerFuzzTest",
"fuzztest_others/elementname_fuzzer:ElementNameFuzzTest",
"fuzztest_others/filenamevalid_fuzzer:FileNameValidFuzzTest",
"fuzztest_others/installparamunmarshalling_fuzzer:InstallParamUnmarshallingFuzzTest",
"fuzztest_others/launcherservice_fuzzer:LauncherServiceFuzzTest",
"fuzztest_others/moduleinfo_fuzzer:ModuleInfoFuzzTest",
@ -117,6 +119,7 @@ group("fuzztest") {
if (bundle_framework_app_control) {
deps += [
"fuzztest_application/addappInstallcontrolrule_fuzzer:AddAppInstallControlRuleFuzzTest",
"fuzztest_application/addappjumpcontrolrule_fuzzer:AddAppJumpControlRuleFuzzTest",
"fuzztest_application/addapprunningcontrolrule_fuzzer:AddAppRunningControlRuleFuzzTest",
"fuzztest_application/apprunningcontrolrule_fuzzer:AppRunningControlRuleFuzzTest",
"fuzztest_application/apprunningcontrolruleresult_fuzzer:AppRunningControlRuleResultFuzzTest",

View File

@ -0,0 +1,44 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("../../../../appexecfwk.gni")
module_output_path = fuzz_test_path
##############################fuzztest##########################################
ohos_fuzztest("AddAppJumpControlRuleFuzzTest") {
module_out_path = module_output_path
fuzz_config_file =
"../../../fuzztest/fuzztest_application/addappjumpcontrolrule_fuzzer"
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "addappjumpcontrolrule_fuzzer.cpp" ]
deps = [
"${base_path}:appexecfwk_base",
"${common_path}:libappexecfwk_common",
"${core_path}:appexecfwk_core",
]
external_deps = [
"c_utils:utils",
"ipc:ipc_core",
]
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cstddef>
#include <cstdint>
#include "app_control_proxy.h"
#include "addappjumpcontrolrule_fuzzer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
sptr<IRemoteObject> object;
AppControlProxy appControl(object);
std::vector<AppJumpControlRule> controlRule;
appControl.AddAppJumpControlRule(controlRule, reinterpret_cast<uintptr_t>(data));
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_FUZZTEST_ADDAPPJUMPCONTROLRULE_FUZZER_H
#define TEST_FUZZTEST_ADDAPPJUMPCONTROLRULE_FUZZER_H
#define FUZZ_PROJECT_NAME "addappjumpcontrolrule_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -133,7 +133,7 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -133,7 +133,7 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") {
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
external_deps += [ "udmf:utd_client" ]
}
if (code_signature_enable && pend_sign_screenlock_mgr_enable) {
defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ]

View File

@ -0,0 +1,190 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = fuzz_test_path
ohos_fuzztest("AppServiceFwkInstallerInstallFuzzTest") {
fuzz_config_file =
"../../../fuzztest/fuzztest_others/appservicefwkinstallerinstall_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [ "//third_party/jsoncpp/include" ]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_host_impl.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_service.cpp",
]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [ "appservicefwkinstallerinstall_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library1:appService_v1_library1",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library2:appService_v1_library2",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version2_library1:appService_v2_library1",
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version2_library2:appService_v2_library2",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/rightTest:rightTest",
"${core_path}:appexecfwk_core",
]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
defines = []
if (code_signature_enable) {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (current_cpu == "arm64") {
defines += [ "USE_BUNDLE_EXTENSION" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (bundle_framework_quick_fix) {
include_dirs += [ "${services_path}/bundlemgr/src/include/quick_fix" ]
sources += quick_fix
defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
external_deps += [ "kv_store:distributeddata_inner" ]
configs += [ "${services_path}/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp",
]
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
if (bms_device_info_manager_part_enabled) {
external_deps += [
"device_info_manager:distributed_device_profile_common",
"device_info_manager:distributed_device_profile_sdk",
]
defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ]
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <cstddef>
#include <cstdint>
#include "app_service_fwk/app_service_fwk_installer.h"
#include "appservicefwkinstallerinstall_fuzzer.h"
#include "securec.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
constexpr size_t FOO_MAX_LEN = 1024;
constexpr size_t U32_AT_SIZE = 4;
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
InstallParam installParam;
installParam.isPreInstallApp = true;
installParam.removable = false;
AppServiceFwkInstaller appServicefwk;
std::vector<std::string> hspPaths;
appServicefwk.Install(hspPaths, installParam);
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
return 0;
}
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
/* Validate the length of size */
if (size > OHOS::FOO_MAX_LEN) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_FUZZTEST_APPSERVICEFWKINSTALLERINSTALL_FUZZER_H
#define TEST_FUZZTEST_APPSERVICEFWKINSTALLERINSTALL_FUZZER_H
#define FUZZ_PROJECT_NAME "appservicefwkinstallerinstall_fuzzer"
#endif

View File

@ -0,0 +1,14 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,175 @@
# Copyright (c) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/test.gni")
import("../../../../appexecfwk.gni")
import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni")
module_output_path = "bundle_framework/bundle_framework"
ohos_fuzztest("FileNameValidFuzzTest") {
fuzz_config_file = "../../../fuzztest/fuzztest_others/filenamevalid_fuzzer"
use_exceptions = true
module_out_path = module_output_path
include_dirs = [
"//third_party/jsoncpp/include",
"//third_party/json/include",
"${services_path}/bundlemgr/include/extend_resource",
]
sources = bundle_mgr_source
sources -= [ "${services_path}/bundlemgr/src/bms_param.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/bms_param.cpp" ]
sources -= [ "${services_path}/bundlemgr/src/system_ability_helper.cpp" ]
sources += [
"${services_path}/bundlemgr/src/aot/aot_executor.cpp",
"${services_path}/bundlemgr/src/installd/installd_operator.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_service.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_installd_host_impl.cpp",
]
sources += [
"${services_path}/bundlemgr/test/mock/src/accesstoken_kit.cpp",
"${services_path}/bundlemgr/test/mock/src/installd_permission_mgr.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_bundle_status.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_clean_cache.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_status_receiver.cpp",
"${services_path}/bundlemgr/test/mock/src/system_ability_helper.cpp",
]
sources += bundle_install_sources
sources -= [ "${services_path}/bundlemgr/src/installd_client.cpp" ]
sources += [ "${services_path}/bundlemgr/test/mock/src/installd_client.cpp" ]
sources += [ "filenamevalid_fuzzer.cpp" ]
configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
deps = [
"${bundle_framework_path}/test/sceneProject/unittest/bundle_app_service/app_service_version1_library1:appService_v1_library1",
"${bundle_framework_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/defaultAppTest:defaultAppTest",
"${bundle_framework_path}/test/sceneProject/unittest/test_bundle/resourceManagerTest:resourceManagerTest",
"${core_path}:appexecfwk_core",
]
deps += bundle_install_deps
external_deps = [
"ability_base:want",
"ability_runtime:app_manager",
"access_token:el5_filekey_manager_sdk",
"access_token:libprivacy_sdk",
"access_token:libtokenid_sdk",
"appspawn:hnpapi",
"appverify:libhapverify",
"bounds_checking_function:libsec_shared",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"hilog:libhilog",
"hitrace:hitrace_meter",
"init:libbegetutil",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
external_deps += bundle_install_external_deps
defines = []
if (code_signature_enable) {
sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ]
include_dirs += [ "${services_path}/bundlemgr/include" ]
external_deps += [
"bounds_checking_function:libsec_shared",
"code_signature:libcode_sign_utils",
"ets_runtime:libcompiler_service",
]
defines += [ "CODE_SIGNATURE_ENABLE" ]
}
if (configpolicy_enable) {
external_deps += [ "config_policy:configpolicy_util" ]
defines += [ "CONFIG_POLOCY_ENABLE" ]
}
if (build_selinux) {
external_deps += [ "selinux_adapter:libhap_restorecon" ]
}
if (account_enable) {
external_deps += [ "os_account:os_account_innerkits" ]
defines += [ "ACCOUNT_ENABLE" ]
}
if (bundle_framework_free_install) {
sources += aging
sources += free_install
sources += distributed_manager
external_deps += [
"ability_runtime:ability_manager",
"ability_runtime:app_manager",
"battery_manager:batterysrv_client",
"device_info_manager:distributed_device_profile_client",
"device_usage_statistics:usagestatsinner",
"display_manager:displaymgr",
"power_manager:powermgr_client",
"syscap_codec:syscap_interface_shared",
]
defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ]
}
if (global_resmgr_enable) {
defines += [ "GLOBAL_RESMGR_ENABLE" ]
external_deps += [ "resource_management:global_resmgr" ]
}
if (hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (hisysevent_enable) {
sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
defines += [ "HISYSEVENT_ENABLE" ]
}
if (bundle_framework_default_app) {
sources += default_app
defines += [ "BUNDLE_FRAMEWORK_DEFAULT_APP" ]
}
if (storage_service_enable) {
external_deps += [ "storage_service:storage_manager_sa_proxy" ]
defines += [ "STORAGE_SERVICE_ENABLE" ]
}
configs += [ "../../../../services/bundlemgr:rdb_config" ]
external_deps += [ "relational_store:native_rdb" ]
sources += [
"${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp",
"${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp",
"${services_path}/bundlemgr/test/mock/src/bundle_data_storage_rdb.cpp",
"${services_path}/bundlemgr/test/mock/src/mock_rdb_data_manager.cpp",
]
if (bundle_framework_app_control) {
defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ]
sources += [
"${services_path}/bundlemgr/src/app_control/app_control_manager.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp",
"${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp",
"${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp",
]
include_dirs += [ "${services_path}/bundlemgr/include/app_control" ]
external_deps += [ "c_utils:utils" ]
}
if (udmf_enabled) {
defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ]
external_deps += [ "udmf:udmf_client" ]
}
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FUZZ

View File

@ -0,0 +1,40 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "extend_resource_manager_host_impl.h"
#include "filenamevalid_fuzzer.h"
using namespace OHOS::AppExecFwk;
namespace OHOS {
bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size)
{
ExtendResourceManagerHostImpl impl;
std::vector<std::string> filePaths;
std::string emptyBundleName;
auto ret = impl.AddExtResource(emptyBundleName, filePaths);
if (ret == ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST) {
return false;
}
return true;
}
}
// Fuzzer entry point.
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
OHOS::DoSomethingInterestingWithMyAPI(data, size);
return 0;
}

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_FUZZTEST_FILENAMEVALID_FUZZER_H
#define TEST_FUZZTEST_FILENAMEVALID_FUZZER_H
#define FUZZ_PROJECT_NAME "filenamevalid_fuzzer"
#endif

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -409,6 +409,66 @@
}
]
},
{
"name": "GeneralVideo",
"srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"exported": true,
"skills": [
{
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"type": "general.video"
}
]
}
]
},
{
"name": "GeneralAvi",
"srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"exported": true,
"skills": [
{
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"type": "general.avi"
}
]
}
]
},
{
"name": "VideoMsVideo",
"srcEntry": "./ets/MainAbility/MainAbility.ts",
"description": "$string:MainAbility_desc",
"icon": "$media:icon",
"label": "$string:MainAbility_label",
"exported": true,
"skills": [
{
"actions": [
"ohos.want.action.viewData"
],
"uris": [
{
"type": "video/x-msvideo"
}
]
}
]
},
{
"name": "MainAbility",
"srcEntry": "./ets/MainAbility/MainAbility.ts",