mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-27 09:20:49 +00:00
add fileContextMenu
Signed-off-by: xsz233 <xushizhe@huawei.com>
This commit is contained in:
parent
5907b4120b
commit
f3adf1bb02
@ -365,6 +365,8 @@ enum {
|
||||
|
||||
// bms extension adapter
|
||||
ERR_BUNDLE_MANAGER_UNINSTALL_FROM_BMS_EXTENSION_FAILED = 8521478,
|
||||
|
||||
ERR_BUNDLE_MANAGER_QUERY_MENU_FAILED = 8521500,
|
||||
};
|
||||
|
||||
// Error code for Hidump
|
||||
|
@ -41,6 +41,8 @@ enum BundleFlag {
|
||||
GET_BUNDLE_WITH_EXTENSION_INFO = 0x00000020,
|
||||
// get bundle info include hash value
|
||||
GET_BUNDLE_WITH_HASH_VALUE = 0x00000030,
|
||||
// get bundle info inlcude menu, only for dump usage
|
||||
GET_BUNDLE_WITH_MENU = 0x00000040,
|
||||
};
|
||||
|
||||
enum class GetBundleInfoFlag {
|
||||
@ -53,6 +55,7 @@ enum class GetBundleInfoFlag {
|
||||
GET_BUNDLE_INFO_WITH_METADATA = 0x00000020,
|
||||
GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040,
|
||||
GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080,
|
||||
GET_BUNDLE_INFO_WITH_MENU = 0x00000100,
|
||||
};
|
||||
|
||||
struct RequestPermissionUsedScene : public Parcelable {
|
||||
|
@ -147,6 +147,7 @@ struct HapModuleInfo : public Parcelable {
|
||||
std::string buildHash;
|
||||
IsolationMode isolationMode = IsolationMode::NONISOLATION_FIRST;
|
||||
AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED;
|
||||
std::string fileContextMenu;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static HapModuleInfo *Unmarshalling(Parcel &parcel);
|
||||
|
@ -80,6 +80,7 @@ const std::string HAP_MODULE_INFO_ISOLATION_MODE = "isolationMode";
|
||||
const std::string HAP_MODULE_INFO_AOT_COMPILE_STATUS = "aotCompileStatus";
|
||||
const std::string HAP_MODULE_INFO_COMPRESS_NATIVE_LIBS = "compressNativeLibs";
|
||||
const std::string HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES = "nativeLibraryFileNames";
|
||||
const std::string HAP_MODULE_INFO_FILE_CONTEXT_MENU = "fileContextMenu";
|
||||
const size_t MODULE_CAPACITY = 10240; // 10K
|
||||
}
|
||||
|
||||
@ -445,6 +446,7 @@ bool HapModuleInfo::ReadFromParcel(Parcel &parcel)
|
||||
for (int32_t i = 0; i < nativeLibraryFileNamesSize; ++i) {
|
||||
nativeLibraryFileNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||
}
|
||||
fileContextMenu = Str16ToStr8(parcel.ReadString16());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -558,6 +560,7 @@ bool HapModuleInfo::Marshalling(Parcel &parcel) const
|
||||
for (auto &fileName : nativeLibraryFileNames) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(fileName));
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(fileContextMenu));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -614,7 +617,8 @@ void to_json(nlohmann::json &jsonObject, const HapModuleInfo &hapModuleInfo)
|
||||
{HAP_MODULE_INFO_ISOLATION_MODE, hapModuleInfo.isolationMode},
|
||||
{HAP_MODULE_INFO_AOT_COMPILE_STATUS, hapModuleInfo.aotCompileStatus},
|
||||
{HAP_MODULE_INFO_COMPRESS_NATIVE_LIBS, hapModuleInfo.compressNativeLibs},
|
||||
{HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES, hapModuleInfo.nativeLibraryFileNames}
|
||||
{HAP_MODULE_INFO_NATIVE_LIBRARY_FILE_NAMES, hapModuleInfo.nativeLibraryFileNames},
|
||||
{HAP_MODULE_INFO_FILE_CONTEXT_MENU, hapModuleInfo.fileContextMenu}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1030,6 +1034,14 @@ void from_json(const nlohmann::json &jsonObject, HapModuleInfo &hapModuleInfo)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::STRING);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
HAP_MODULE_INFO_FILE_CONTEXT_MENU,
|
||||
hapModuleInfo.fileContextMenu,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGW("HapModuleInfo from_json error, error code : %{public}d", parseResult);
|
||||
}
|
||||
|
@ -1397,6 +1397,12 @@ void CommonFunc::ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModu
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nPreloads, index, nPreload));
|
||||
}
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objHapModuleInfo, "preloads", nPreloads));
|
||||
if (!hapModuleInfo.fileContextMenu.empty()) {
|
||||
napi_value nMenu;
|
||||
NAPI_CALL_RETURN_VOID(
|
||||
env, napi_create_string_utf8(env, hapModuleInfo.fileContextMenu.c_str(), NAPI_AUTO_LENGTH, &nMenu));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objHapModuleInfo, "fileContextMenu", nMenu));
|
||||
}
|
||||
}
|
||||
|
||||
void CommonFunc::ConvertDependency(napi_env env, const Dependency &dependency, napi_value value)
|
||||
|
@ -978,6 +978,7 @@ private:
|
||||
const std::string &abilityName, AbilityInfo &abilityInfo) const;
|
||||
void RestoreSandboxUidAndGid(std::map<int32_t, std::string> &bundleIdMap);
|
||||
bool IsUpdateInnerBundleInfoSatisified(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
|
||||
ErrCode ProcessBundleMenu(BundleInfo& bundleInfo, int32_t flag, bool clearData) const;
|
||||
|
||||
private:
|
||||
mutable std::shared_mutex bundleInfoMutex_;
|
||||
|
@ -91,6 +91,9 @@ public:
|
||||
*/
|
||||
ErrCode ParseExtTypeConfig(
|
||||
const std::string &configFile, std::set<std::string> &extensionTypeList) const;
|
||||
|
||||
ErrCode GetHapProfileString(
|
||||
const std::string &hapPath, const std::string &profilePath, std::string &content) const;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -472,6 +472,9 @@ constexpr const char* BUNDLE_TYPE_SHARED = "shared";
|
||||
constexpr const char* COMPILE_SDK_VERSION = "compileSdkVersion";
|
||||
constexpr const char* COMPILE_SDK_TYPE = "compileSdkType";
|
||||
constexpr const char* COMPILE_SDK_TYPE_OPEN_HARMONY = "OpenHarmony";
|
||||
|
||||
// moduleMenu
|
||||
constexpr const char* MODULE_FILE_CONTEXT_MENU = "fileContextMenu";
|
||||
} // namespace Profile
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -124,6 +124,7 @@ struct InnerModuleInfo {
|
||||
bool compressNativeLibs = true;
|
||||
std::vector<std::string> nativeLibraryFileNames;
|
||||
AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED;
|
||||
std::string fileContextMenu;
|
||||
};
|
||||
|
||||
struct SkillUri {
|
||||
|
@ -63,6 +63,7 @@ namespace {
|
||||
constexpr int MAX_EVENT_CALL_BACK_SIZE = 100;
|
||||
constexpr int32_t DATA_GROUP_INDEX_START = 1;
|
||||
constexpr int32_t UUID_LENGTH = 36;
|
||||
constexpr int32_t PROFILE_PREFIX_LENGTH = 9;
|
||||
constexpr const char* GLOBAL_RESOURCE_BUNDLE_NAME = "ohos.global.systemres";
|
||||
// freeInstall action
|
||||
constexpr const char* FREE_INSTALL_ACTION = "ohos.want.action.hapFreeInstall";
|
||||
@ -71,6 +72,10 @@ constexpr const char* DATA_PROXY_URI_PREFIX = "datashareproxy://";
|
||||
constexpr int32_t DATA_PROXY_URI_PREFIX_LEN = 17;
|
||||
// profile path
|
||||
constexpr const char* INTENT_PROFILE_PATH = "resources/base/profile/insight_intent.json";
|
||||
constexpr const char* PROFILE_PATH = "resources/base/profile/";
|
||||
constexpr const char* PROFILE_PREFIX = "$profile:";
|
||||
constexpr const char* JSON_SUFFIX = ".json";
|
||||
|
||||
const std::map<ProfileType, std::string> PROFILE_TYPE_MAP = {
|
||||
{ ProfileType::INTENT_PROFILE, INTENT_PROFILE_PATH },
|
||||
};
|
||||
@ -1713,6 +1718,10 @@ bool BundleDataMgr::GetBundleInfo(
|
||||
|
||||
int32_t responseUserId = innerBundleInfo.GetResponseUserId(requestUserId);
|
||||
innerBundleInfo.GetBundleInfo(flags, bundleInfo, responseUserId);
|
||||
|
||||
if ((static_cast<uint32_t>(flags) & BundleFlag::GET_BUNDLE_WITH_MENU) == BundleFlag::GET_BUNDLE_WITH_MENU) {
|
||||
ProcessBundleMenu(bundleInfo, flags, false);
|
||||
}
|
||||
APP_LOGD("get bundleInfo(%{public}s) successfully in user(%{public}d)", bundleName.c_str(), userId);
|
||||
return true;
|
||||
}
|
||||
@ -1744,10 +1753,56 @@ ErrCode BundleDataMgr::GetBundleInfoV9(
|
||||
|
||||
int32_t responseUserId = innerBundleInfo.GetResponseUserId(requestUserId);
|
||||
innerBundleInfo.GetBundleInfoV9(flags, bundleInfo, responseUserId);
|
||||
|
||||
|
||||
if ((static_cast<uint32_t>(flags) & static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE))
|
||||
== static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE)) {
|
||||
ProcessBundleMenu(bundleInfo, flags, true);
|
||||
}
|
||||
APP_LOGD("get bundleInfo(%{public}s) successfully in user(%{public}d)", bundleName.c_str(), userId);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleDataMgr::ProcessBundleMenu(BundleInfo &bundleInfo, int32_t flags, bool clearData) const
|
||||
{
|
||||
if (clearData) {
|
||||
if ((static_cast<uint32_t>(flags) & static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU))
|
||||
!= static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU)) {
|
||||
APP_LOGD("no GET_BUNDLE_INFO_WITH_MENU flag, remove menu content");
|
||||
std::for_each(bundleInfo.hapModuleInfos.begin(), bundleInfo.hapModuleInfos.end(), [](auto &hapModuleInfo) {
|
||||
hapModuleInfo.fileContextMenu = Constants::EMPTY_STRING;
|
||||
});
|
||||
return ERR_OK;
|
||||
}
|
||||
std::vector<HapModuleInfo>& hapModuleInfos = bundleInfo.hapModuleInfos;
|
||||
hapModuleInfos.erase(std::remove_if(
|
||||
hapModuleInfos.begin(), hapModuleInfos.end(), [](const auto& hapModuleInfo) {
|
||||
return hapModuleInfo.fileContextMenu.empty();
|
||||
}), hapModuleInfos.end());
|
||||
if (hapModuleInfos.empty()) {
|
||||
APP_LOGW("getBundleInfo with menu flag, but no module has menu");
|
||||
BundleInfo emptyInfo;
|
||||
bundleInfo = emptyInfo;
|
||||
return ERR_BUNDLE_MANAGER_QUERY_MENU_FAILED;
|
||||
}
|
||||
}
|
||||
for (auto &hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
std::string menuProfile = hapModuleInfo.fileContextMenu;
|
||||
auto pos = menuProfile.find(PROFILE_PREFIX);
|
||||
if (pos == std::string::npos) {
|
||||
APP_LOGW("invalid menu profile");
|
||||
continue;
|
||||
}
|
||||
std::string menuFileName = menuProfile.substr(pos + PROFILE_PREFIX_LENGTH);
|
||||
std::string menuFilePath = PROFILE_PATH + menuFileName + JSON_SUFFIX;
|
||||
|
||||
std::string menuProfileContent;
|
||||
GetJsonProfileByExtractor(hapModuleInfo.hapPath, menuFilePath, menuProfileContent);
|
||||
hapModuleInfo.fileContextMenu = menuProfileContent;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleDataMgr::GetBaseSharedBundleInfos(const std::string &bundleName,
|
||||
std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos) const
|
||||
{
|
||||
@ -2043,8 +2098,13 @@ ErrCode BundleDataMgr::GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &
|
||||
if (innerBundleInfo.GetBundleInfoV9(flags, bundleInfo, responseUserId) != ERR_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
auto ret = ProcessBundleMenu(bundleInfo, flags, true);
|
||||
if (ret == ERR_OK) {
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
}
|
||||
}
|
||||
if (bundleInfos.empty()) {
|
||||
APP_LOGW("bundleInfos is empty");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -2069,7 +2129,13 @@ ErrCode BundleDataMgr::GetAllBundleInfosV9(int32_t flags, std::vector<BundleInfo
|
||||
}
|
||||
BundleInfo bundleInfo;
|
||||
info.GetBundleInfoV9(flags, bundleInfo, Constants::ALL_USERID);
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
auto ret = ProcessBundleMenu(bundleInfo, flags, true);
|
||||
if (ret == ERR_OK) {
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
}
|
||||
}
|
||||
if (bundleInfos.empty()) {
|
||||
APP_LOGW("bundleInfos is empty");
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -1397,7 +1397,8 @@ bool BundleMgrHostImpl::DumpBundleInfo(
|
||||
BundleFlag::GET_BUNDLE_WITH_ABILITIES |
|
||||
BundleFlag::GET_BUNDLE_WITH_REQUESTED_PERMISSION |
|
||||
BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO |
|
||||
BundleFlag::GET_BUNDLE_WITH_HASH_VALUE, bundleInfo, userId)) {
|
||||
BundleFlag::GET_BUNDLE_WITH_HASH_VALUE |
|
||||
BundleFlag::GET_BUNDLE_WITH_MENU, bundleInfo, userId)) {
|
||||
APP_LOGE("get bundleInfo(%{public}s) failed", bundleName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
@ -136,6 +136,7 @@ const std::string MODULE_COMPRESS_NATIVE_LIBS = "compressNativeLibs";
|
||||
const std::string MODULE_NATIVE_LIBRARY_FILE_NAMES = "nativeLibraryFileNames";
|
||||
const std::string MODULE_AOT_COMPILE_STATUS = "aotCompileStatus";
|
||||
const std::string DATA_GROUP_INFOS = "dataGroupInfos";
|
||||
const std::string MODULE_FILE_CONTEXT_MENU = "fileContextMenu";
|
||||
const int32_t SINGLE_HSP_VERSION = 1;
|
||||
const std::map<std::string, IsolationMode> ISOLATION_MODE_MAP = {
|
||||
{"isolationOnly", IsolationMode::ISOLATION_ONLY},
|
||||
@ -663,6 +664,7 @@ void to_json(nlohmann::json &jsonObject, const InnerModuleInfo &info)
|
||||
{MODULE_COMPRESS_NATIVE_LIBS, info.compressNativeLibs},
|
||||
{MODULE_NATIVE_LIBRARY_FILE_NAMES, info.nativeLibraryFileNames},
|
||||
{MODULE_AOT_COMPILE_STATUS, info.aotCompileStatus},
|
||||
{MODULE_FILE_CONTEXT_MENU, info.fileContextMenu}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1197,6 +1199,14 @@ void from_json(const nlohmann::json &jsonObject, InnerModuleInfo &info)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
MODULE_FILE_CONTEXT_MENU,
|
||||
info.fileContextMenu,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGE("read InnerModuleInfo from database error, error code : %{public}d", parseResult);
|
||||
}
|
||||
@ -1860,6 +1870,7 @@ std::optional<HapModuleInfo> InnerBundleInfo::FindHapModuleInfo(const std::strin
|
||||
hapInfo.compressNativeLibs = it->second.compressNativeLibs;
|
||||
hapInfo.nativeLibraryFileNames = it->second.nativeLibraryFileNames;
|
||||
hapInfo.aotCompileStatus = it->second.aotCompileStatus;
|
||||
hapInfo.fileContextMenu = it->second.fileContextMenu;
|
||||
return hapInfo;
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,7 @@ struct Module {
|
||||
std::string buildHash;
|
||||
std::string isolationMode;
|
||||
bool compressNativeLibs = true;
|
||||
std::string fileContextMenu;
|
||||
};
|
||||
|
||||
struct ModuleJson {
|
||||
@ -1379,6 +1380,14 @@ void from_json(const nlohmann::json &jsonObject, Module &module)
|
||||
g_parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
}
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
MODULE_FILE_CONTEXT_MENU,
|
||||
module.fileContextMenu,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
g_parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &jsonObject, ModuleJson &moduleJson)
|
||||
@ -2058,7 +2067,8 @@ bool ToInnerModuleInfo(
|
||||
innerModuleInfo.buildHash = moduleJson.module.buildHash;
|
||||
innerModuleInfo.isolationMode = moduleJson.module.isolationMode;
|
||||
innerModuleInfo.compressNativeLibs = moduleJson.module.compressNativeLibs;
|
||||
// abilities and extensionAbilities store in InnerBundleInfo
|
||||
innerModuleInfo.fileContextMenu = moduleJson.module.fileContextMenu;
|
||||
// abilities and fileContextMenu store in InnerBundleInfo
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ const std::string TEST_BUNDLE_NAME = "bundleName";
|
||||
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";
|
||||
const size_t NUMBER_ONE = 1;
|
||||
} // namespace
|
||||
|
||||
@ -5488,4 +5489,148 @@ HWTEST_F(BmsBundleManagerTest, GetJsonProfile_0006, Function | SmallTest | Level
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
UnInstallBundle(BUNDLE_PREVIEW_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoWithMenu_0001
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu successfully
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetBundleInfoWithMenu_0001, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_PREVIEW_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
BundleInfo info;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU);
|
||||
auto ret = dataMgr->GetBundleInfoV9(BUNDLE_PREVIEW_NAME, flag, info, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
auto pos = info.hapModuleInfos[0].fileContextMenu.find(MENU_VALUE);
|
||||
EXPECT_NE(pos, std::string::npos);
|
||||
|
||||
UnInstallBundle(BUNDLE_PREVIEW_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoWithMenu_0002
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu with menu, but no menu in bundleInfo
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetBundleInfoWithMenu_0002, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_BACKUP_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
BundleInfo info;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU);
|
||||
auto ret = dataMgr->GetBundleInfoV9(BUNDLE_BACKUP_NAME, flag, info, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_TRUE(info.hapModuleInfos.empty());
|
||||
|
||||
UnInstallBundle(BUNDLE_BACKUP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoWithMenu_0003
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu with menu, but no menu flag
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetBundleInfoWithMenu_0003, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_PREVIEW_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
BundleInfo info;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE);
|
||||
auto ret = dataMgr->GetBundleInfoV9(BUNDLE_PREVIEW_NAME, flag, info, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_TRUE(info.hapModuleInfos[0].fileContextMenu.empty());
|
||||
|
||||
UnInstallBundle(BUNDLE_PREVIEW_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllBundleInfoWithMenu_0001
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu successfully
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetAllBundleInfoWithMenu_0001, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_PREVIEW_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
std::vector<BundleInfo> infos;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU);
|
||||
auto ret = dataMgr->GetBundleInfosV9(flag, infos, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_EQ(infos.size(), NUMBER_ONE);
|
||||
auto pos = infos[0].hapModuleInfos[0].fileContextMenu.find(MENU_VALUE);
|
||||
EXPECT_NE(pos, std::string::npos);
|
||||
|
||||
UnInstallBundle(BUNDLE_PREVIEW_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllBundleInfoWithMenu_0001
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu with menu, but no menu in bundleInfo
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetAllBundleInfoWithMenu_0002, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_BACKUP_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
std::vector<BundleInfo> infos;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU);
|
||||
auto ret = dataMgr->GetBundleInfosV9(flag, infos, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_TRUE(infos.empty());
|
||||
UnInstallBundle(BUNDLE_BACKUP_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetAllBundleInfoWithMenu_0001
|
||||
* @tc.name: GetBundleInfoWithMenu
|
||||
* @tc.desc: 1. GetBundleMenu with menu, but no menu flag
|
||||
*/
|
||||
HWTEST_F(BmsBundleManagerTest, GetAllBundleInfoWithMenu_0003, Function | SmallTest | Level0)
|
||||
{
|
||||
std::string bundlePath = RESOURCE_ROOT_PATH + BUNDLE_PREVIEW_TEST;
|
||||
ErrCode installResult = InstallThirdPartyBundle(bundlePath);
|
||||
EXPECT_EQ(installResult, ERR_OK);
|
||||
|
||||
auto dataMgr = GetBundleDataMgr();
|
||||
EXPECT_NE(dataMgr, nullptr);
|
||||
|
||||
std::vector<BundleInfo> infos;
|
||||
int32_t flag = static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE);
|
||||
auto ret = dataMgr->GetBundleInfosV9(flag, infos, USERID);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
EXPECT_TRUE(infos[0].hapModuleInfos[0].fileContextMenu.empty());
|
||||
|
||||
UnInstallBundle(BUNDLE_PREVIEW_NAME);
|
||||
}
|
||||
} // OHOS
|
||||
|
@ -52,6 +52,7 @@
|
||||
"type": "preview"
|
||||
}
|
||||
],
|
||||
"fileContextMenu": "$profile:menu",
|
||||
"installationFree": false,
|
||||
"mainElement": "MainAbility",
|
||||
"name": "entry",
|
||||
|
@ -0,0 +1 @@
|
||||
{"key": "value"}
|
Loading…
Reference in New Issue
Block a user