mirror of
https://gitee.com/openharmony/bundlemanager_bundle_framework
synced 2024-11-27 09:20:49 +00:00
add router for navagation
Signed-off-by: zhaogan <zhaogan2@huawei.com>
This commit is contained in:
parent
94b560eff5
commit
6e4bd76026
@ -43,6 +43,8 @@ enum BundleFlag {
|
||||
GET_BUNDLE_WITH_HASH_VALUE = 0x00000030,
|
||||
// get bundle info inlcude menu, only for dump usage
|
||||
GET_BUNDLE_WITH_MENU = 0x00000040,
|
||||
// get bundle info inlcude router map, only for dump usage
|
||||
GET_BUNDLE_WITH_ROUTER_MAP = 0x00000080,
|
||||
};
|
||||
|
||||
enum class GetBundleInfoFlag {
|
||||
@ -56,6 +58,7 @@ enum class GetBundleInfoFlag {
|
||||
GET_BUNDLE_INFO_WITH_DISABLE = 0x00000040,
|
||||
GET_BUNDLE_INFO_WITH_SIGNATURE_INFO = 0x00000080,
|
||||
GET_BUNDLE_INFO_WITH_MENU = 0x00000100,
|
||||
GET_BUNDLE_INFO_WITH_ROUTER_MAP = 0x00000200,
|
||||
};
|
||||
|
||||
struct RequestPermissionUsedScene : public Parcelable {
|
||||
|
@ -88,6 +88,18 @@ struct ProxyData : public Parcelable {
|
||||
static ProxyData *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
struct RouterItem : public Parcelable {
|
||||
std::string url;
|
||||
std::string moduleName;
|
||||
std::string path;
|
||||
std::string buildFunction;
|
||||
std::map<std::string, std::string> data;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static RouterItem *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
// configuration information about an module
|
||||
struct HapModuleInfo : public Parcelable {
|
||||
std::string name; // module.name in config.json
|
||||
@ -148,6 +160,8 @@ struct HapModuleInfo : public Parcelable {
|
||||
IsolationMode isolationMode = IsolationMode::NONISOLATION_FIRST;
|
||||
AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED;
|
||||
std::string fileContextMenu;
|
||||
std::string routerMap;
|
||||
std::vector<RouterItem> routerArray;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static HapModuleInfo *Unmarshalling(Parcel &parcel);
|
||||
|
@ -144,6 +144,8 @@ void to_json(nlohmann::json &jsonObject, const ProxyData &proxyData);
|
||||
void from_json(const nlohmann::json &jsonObject, ProxyData &proxyData);
|
||||
void to_json(nlohmann::json &jsonObject, const DataGroupInfo &dataGroupInfo);
|
||||
void from_json(const nlohmann::json &jsonObject, DataGroupInfo &dataGroupInfo);
|
||||
void to_json(nlohmann::json &jsonObject, const RouterItem &routerItem);
|
||||
void from_json(const nlohmann::json &jsonObject, RouterItem &routerItem);
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_JSON_SERIALIZER_H
|
||||
|
@ -81,6 +81,13 @@ 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 std::string HAP_MODULE_INFO_ROUTER_MAP = "routerMap";
|
||||
const std::string HAP_MODULE_INFO_ROUTER_ARRAY = "routerArray";
|
||||
const std::string ROUTER_ITEM_KEY_URL = "url";
|
||||
const std::string ROUTER_JSON_KEY_MODULE = "module";
|
||||
const std::string ROUTER_ITEM_KEY_PATH = "path";
|
||||
const std::string ROUTER_ITEM_KEY_BUILD_FUNCTION = "buildFunction";
|
||||
const std::string ROUTER_ITEM_KEY_DATA = "data";
|
||||
const size_t MODULE_CAPACITY = 10240; // 10K
|
||||
}
|
||||
|
||||
@ -285,6 +292,110 @@ void from_json(const nlohmann::json &jsonObject, ProxyData &proxyData)
|
||||
}
|
||||
}
|
||||
|
||||
bool RouterItem::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
url = Str16ToStr8(parcel.ReadString16());
|
||||
moduleName = Str16ToStr8(parcel.ReadString16());
|
||||
path = Str16ToStr8(parcel.ReadString16());
|
||||
buildFunction = Str16ToStr8(parcel.ReadString16());
|
||||
|
||||
int32_t dataSize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, dataSize);
|
||||
CONTAINER_SECURITY_VERIFY(parcel, dataSize, &data);
|
||||
for (int32_t i = 0; i < dataSize; ++i) {
|
||||
std::string key = Str16ToStr8(parcel.ReadString16());
|
||||
std::string value = Str16ToStr8(parcel.ReadString16());
|
||||
data.emplace(key, value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
RouterItem *RouterItem::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
RouterItem *info = new (std::nothrow) RouterItem();
|
||||
if (info && !info->ReadFromParcel(parcel)) {
|
||||
APP_LOGW("read from parcel failed");
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
bool RouterItem::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(url));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(moduleName));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(path));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(buildFunction));
|
||||
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(data.size()));
|
||||
for (const auto &dataItem : data) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataItem.first));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(dataItem.second));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void to_json(nlohmann::json &jsonObject, const RouterItem &routerItem)
|
||||
{
|
||||
jsonObject = nlohmann::json {
|
||||
{ROUTER_ITEM_KEY_URL, routerItem.url},
|
||||
{ROUTER_JSON_KEY_MODULE, routerItem.moduleName},
|
||||
{ROUTER_ITEM_KEY_PATH, routerItem.path},
|
||||
{ROUTER_ITEM_KEY_BUILD_FUNCTION, routerItem.buildFunction},
|
||||
{ROUTER_ITEM_KEY_DATA, routerItem.data}
|
||||
};
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &jsonObject, RouterItem &routerItem)
|
||||
{
|
||||
const auto &jsonObjectEnd = jsonObject.end();
|
||||
int32_t parseResult = ERR_OK;
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ROUTER_ITEM_KEY_URL,
|
||||
routerItem.url,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ROUTER_JSON_KEY_MODULE,
|
||||
routerItem.moduleName,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ROUTER_ITEM_KEY_PATH,
|
||||
routerItem.path,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ROUTER_ITEM_KEY_BUILD_FUNCTION,
|
||||
routerItem.buildFunction,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::map<std::string, std::string>>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
ROUTER_ITEM_KEY_DATA,
|
||||
routerItem.data,
|
||||
JsonType::OBJECT,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGE("read module RouterItem from jsonObject error, error code : %{public}d", parseResult);
|
||||
}
|
||||
}
|
||||
|
||||
bool HapModuleInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
int32_t abilityInfosSize;
|
||||
@ -447,6 +558,19 @@ bool HapModuleInfo::ReadFromParcel(Parcel &parcel)
|
||||
nativeLibraryFileNames.emplace_back(Str16ToStr8(parcel.ReadString16()));
|
||||
}
|
||||
fileContextMenu = Str16ToStr8(parcel.ReadString16());
|
||||
routerMap = Str16ToStr8(parcel.ReadString16());
|
||||
|
||||
int32_t routerArraySize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, routerArraySize);
|
||||
CONTAINER_SECURITY_VERIFY(parcel, routerArraySize, &routerArray);
|
||||
for (int32_t i = 0; i < routerArraySize; ++i) {
|
||||
std::unique_ptr<RouterItem> routerItem(parcel.ReadParcelable<RouterItem>());
|
||||
if (!routerItem) {
|
||||
APP_LOGE("ReadParcelable<RouterItem> failed");
|
||||
return false;
|
||||
}
|
||||
routerArray.emplace_back(*routerItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -561,6 +685,11 @@ bool HapModuleInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(fileName));
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(fileContextMenu));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(routerMap));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, routerArray.size());
|
||||
for (auto &router : routerArray) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Parcelable, parcel, &router);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -618,7 +747,9 @@ void to_json(nlohmann::json &jsonObject, const HapModuleInfo &hapModuleInfo)
|
||||
{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_FILE_CONTEXT_MENU, hapModuleInfo.fileContextMenu}
|
||||
{HAP_MODULE_INFO_FILE_CONTEXT_MENU, hapModuleInfo.fileContextMenu},
|
||||
{HAP_MODULE_INFO_ROUTER_MAP, hapModuleInfo.routerMap},
|
||||
{HAP_MODULE_INFO_ROUTER_ARRAY, hapModuleInfo.routerArray}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1042,6 +1173,22 @@ void from_json(const nlohmann::json &jsonObject, HapModuleInfo &hapModuleInfo)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
HAP_MODULE_INFO_ROUTER_MAP,
|
||||
hapModuleInfo.routerMap,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::vector<RouterItem>>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
HAP_MODULE_INFO_ROUTER_ARRAY,
|
||||
hapModuleInfo.routerArray,
|
||||
JsonType::ARRAY,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::OBJECT);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGW("HapModuleInfo from_json error, error code : %{public}d", parseResult);
|
||||
}
|
||||
|
@ -2756,11 +2756,18 @@ void CreateBundleFlagObject(napi_env env, napi_value value)
|
||||
GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO), &nGetBundleInfoWithSignatureInfo));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "GET_BUNDLE_INFO_WITH_SIGNATURE_INFO",
|
||||
nGetBundleInfoWithSignatureInfo));
|
||||
|
||||
napi_value nGetBundleInfoWithMenu;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, static_cast<int32_t>(
|
||||
GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_MENU), &nGetBundleInfoWithMenu));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "GET_BUNDLE_INFO_WITH_MENU",
|
||||
nGetBundleInfoWithMenu));
|
||||
|
||||
napi_value nGetBundleInfoWithRouterMap;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, static_cast<int32_t>(
|
||||
GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP), &nGetBundleInfoWithRouterMap));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "GET_BUNDLE_INFO_WITH_ROUTER_MAP",
|
||||
nGetBundleInfoWithRouterMap));
|
||||
}
|
||||
|
||||
static ErrCode InnerGetBundleInfo(const std::string &bundleName, int32_t flags,
|
||||
|
@ -35,9 +35,11 @@ constexpr int32_t NAPI_RETURN_ZERO = 0;
|
||||
constexpr int32_t NAPI_RETURN_ONE = 1;
|
||||
constexpr const char* BUNDLE_NAME = "bundleName";
|
||||
constexpr const char* MODULE_NAME = "moduleName";
|
||||
constexpr const char* MODULE = "module";
|
||||
constexpr const char* ABILITY_NAME = "abilityName";
|
||||
constexpr const char* TARGET_MODULE_NAME = "targetModuleName";
|
||||
constexpr const char* URI = "uri";
|
||||
constexpr const char* URL = "url";
|
||||
constexpr const char* TYPE = "type";
|
||||
constexpr const char* ACTION = "action";
|
||||
constexpr const char* ENTITIES = "entities";
|
||||
@ -62,6 +64,12 @@ constexpr const char* PRIORITY = "priority";
|
||||
constexpr const char* STATE = "state";
|
||||
constexpr const char* DEBUG = "debug";
|
||||
constexpr const char* EXTENSION_ABILITY_TYPE_NAME = "extensionAbilityTypeName";
|
||||
constexpr const char* ROUTER_ARRAY = "routerArray";
|
||||
constexpr const char* PATH = "path";
|
||||
constexpr const char* BUILD_FUNCTION = "buildFunction";
|
||||
constexpr const char* DATA = "data";
|
||||
constexpr const char* KEY = "key";
|
||||
constexpr const char* VALUE = "value";
|
||||
|
||||
static std::unordered_map<int32_t, int32_t> ERR_MAP = {
|
||||
{ ERR_OK, SUCCESS },
|
||||
@ -1354,7 +1362,8 @@ void CommonFunc::ConvertSignatureInfo(napi_env env, const SignatureInfo &signatu
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, "appIdentifier", nAppIdentifier));
|
||||
}
|
||||
|
||||
void CommonFunc::ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModuleInfo, napi_value objHapModuleInfo)
|
||||
void CommonFunc::ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModuleInfo,
|
||||
napi_value objHapModuleInfo, int32_t flags)
|
||||
{
|
||||
napi_value nName;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, hapModuleInfo.name.c_str(), NAPI_AUTO_LENGTH, &nName));
|
||||
@ -1474,6 +1483,69 @@ void CommonFunc::ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModu
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objHapModuleInfo, "fileContextMenu", nMenu));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objHapModuleInfo, "fileContextMenuConfig", nMenu));
|
||||
}
|
||||
|
||||
napi_value nRouterArray;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nRouterArray));
|
||||
if ((static_cast<uint32_t>(flags) & static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP))
|
||||
== static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP)) {
|
||||
for (size_t idx = 0; idx < hapModuleInfo.routerArray.size(); idx++) {
|
||||
napi_value nRouterItem;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &nRouterItem));
|
||||
ConvertRouterItem(env, hapModuleInfo.routerArray[idx], nRouterItem);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nRouterArray, idx, nRouterItem));
|
||||
}
|
||||
}
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objHapModuleInfo, ROUTER_ARRAY, nRouterArray));
|
||||
}
|
||||
|
||||
void CommonFunc::ConvertRouterItem(napi_env env, const RouterItem &routerItem, napi_value value)
|
||||
{
|
||||
napi_value nUrl;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, routerItem.url.c_str(), NAPI_AUTO_LENGTH, &nUrl));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, URL, nUrl));
|
||||
|
||||
napi_value nModuleName;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, routerItem.moduleName.c_str(), NAPI_AUTO_LENGTH, &nModuleName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, MODULE, nModuleName));
|
||||
|
||||
napi_value nPath;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, routerItem.path.c_str(), NAPI_AUTO_LENGTH, &nPath));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, PATH, nPath));
|
||||
|
||||
napi_value nBuildFunction;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, routerItem.buildFunction.c_str(), NAPI_AUTO_LENGTH, &nBuildFunction));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, BUILD_FUNCTION, nBuildFunction));
|
||||
|
||||
napi_value nDataArray;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &nDataArray));
|
||||
ConvertRouterDataInfos(env, routerItem.data, nDataArray);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, value, DATA, nDataArray));
|
||||
}
|
||||
|
||||
void CommonFunc::ConvertRouterDataInfos(napi_env env,
|
||||
const std::map<std::string, std::string> &data, napi_value objInfos)
|
||||
{
|
||||
size_t index = 0;
|
||||
for (const auto &item : data) {
|
||||
napi_value objInfo = nullptr;
|
||||
napi_create_object(env, &objInfo);
|
||||
|
||||
napi_value nKey;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, item.first.c_str(), NAPI_AUTO_LENGTH, &nKey));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objInfo, KEY, nKey));
|
||||
|
||||
napi_value nValue;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(
|
||||
env, item.second.c_str(), NAPI_AUTO_LENGTH, &nValue));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objInfo, VALUE, nValue));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, objInfos, index++, objInfo));
|
||||
}
|
||||
}
|
||||
|
||||
void CommonFunc::ConvertDependency(napi_env env, const Dependency &dependency, napi_value value)
|
||||
@ -1537,7 +1609,7 @@ void CommonFunc::ConvertBundleInfo(napi_env env, const BundleInfo &bundleInfo, n
|
||||
for (size_t idx = 0; idx < bundleInfo.hapModuleInfos.size(); idx++) {
|
||||
napi_value objHapModuleInfo;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &objHapModuleInfo));
|
||||
ConvertHapModuleInfo(env, bundleInfo.hapModuleInfos[idx], objHapModuleInfo);
|
||||
ConvertHapModuleInfo(env, bundleInfo.hapModuleInfos[idx], objHapModuleInfo, flags);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_element(env, nHapModuleInfos, idx, objHapModuleInfo));
|
||||
}
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objBundleInfo, "hapModulesInfo", nHapModuleInfos));
|
||||
|
@ -120,7 +120,8 @@ static void ConvertRequestPermissionUsedScene(napi_env env,
|
||||
|
||||
static void ConvertSignatureInfo(napi_env env, const SignatureInfo &signatureInfo, napi_value value);
|
||||
|
||||
static void ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModuleInfo, napi_value objHapModuleInfo);
|
||||
static void ConvertHapModuleInfo(napi_env env, const HapModuleInfo &hapModuleInfo,
|
||||
napi_value objHapModuleInfo, int32_t flags = 0);
|
||||
|
||||
static void ConvertDependency(napi_env env, const Dependency &dependency, napi_value value);
|
||||
|
||||
@ -161,6 +162,10 @@ static void ConvertRecoverableApplicationInfo(
|
||||
static void ConvertRecoverableApplicationInfos(napi_env env, napi_value value,
|
||||
const std::vector<RecoverableApplicationInfo> &recoverableApplications);
|
||||
|
||||
static void ConvertRouterItem(napi_env env, const RouterItem &routerItem, napi_value value);
|
||||
|
||||
static void ConvertRouterDataInfos(napi_env env, const std::map<std::string, std::string> &data, napi_value objInfos);
|
||||
|
||||
class BundleMgrCommonDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
void OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject>& remote) override;
|
||||
};
|
||||
|
@ -1001,6 +1001,7 @@ private:
|
||||
void AddAppHspBundleName(const BundleType type, const std::string &bundleName);
|
||||
void ConvertServiceHspToSharedBundleInfo(const InnerBundleInfo &innerBundleInfo,
|
||||
std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos) const;
|
||||
void ProcessBundleRouterMap(BundleInfo& bundleInfo, int32_t flag) const;
|
||||
|
||||
private:
|
||||
mutable std::shared_mutex bundleInfoMutex_;
|
||||
|
@ -91,6 +91,15 @@ public:
|
||||
*/
|
||||
ErrCode ParseExtTypeConfig(
|
||||
const std::string &configFile, std::set<std::string> &extensionTypeList) const;
|
||||
|
||||
/**
|
||||
* @brief Parse router map json file, then return router map info if necessary.
|
||||
* @param configFile Indicates the path of configFile.
|
||||
* @param routerArray Indicates the obtained router item list.
|
||||
* @return Returns ERR_OK if the router info successfully parsed; returns ErrCode otherwise.
|
||||
*/
|
||||
ErrCode ParseRouterArray(
|
||||
const std::string &configFile, std::vector<RouterItem> &routerArray) const;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -485,6 +485,9 @@ constexpr const char* COMPILE_SDK_TYPE_OPEN_HARMONY = "OpenHarmony";
|
||||
|
||||
// moduleMenu
|
||||
constexpr const char* MODULE_FILE_CONTEXT_MENU = "fileContextMenu";
|
||||
|
||||
// module router
|
||||
constexpr const char* MODULE_ROUTER_MAP = "routerMap";
|
||||
} // namespace Profile
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -120,6 +120,7 @@ struct InnerModuleInfo {
|
||||
AOTCompileStatus aotCompileStatus = AOTCompileStatus::NOT_COMPILED;
|
||||
std::string fileContextMenu;
|
||||
bool isEncrypted = false;
|
||||
std::string routerMap;
|
||||
};
|
||||
|
||||
struct SkillUri {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "preinstall_data_storage_rdb.h"
|
||||
#include "bundle_event_callback_death_recipient.h"
|
||||
#include "bundle_mgr_service.h"
|
||||
#include "bundle_parser.h"
|
||||
#include "bundle_permission_mgr.h"
|
||||
#include "bundle_status_callback_death_recipient.h"
|
||||
#include "bundle_util.h"
|
||||
@ -1807,6 +1808,11 @@ bool BundleDataMgr::GetBundleInfo(
|
||||
if ((static_cast<uint32_t>(flags) & BundleFlag::GET_BUNDLE_WITH_MENU) == BundleFlag::GET_BUNDLE_WITH_MENU) {
|
||||
ProcessBundleMenu(bundleInfo, flags, false);
|
||||
}
|
||||
if ((static_cast<uint32_t>(flags) & BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP) ==
|
||||
BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP) {
|
||||
ProcessBundleRouterMap(bundleInfo, static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP));
|
||||
}
|
||||
APP_LOGD("get bundleInfo(%{public}s) successfully in user(%{public}d)", bundleName.c_str(), userId);
|
||||
return true;
|
||||
}
|
||||
@ -1840,6 +1846,7 @@ ErrCode BundleDataMgr::GetBundleInfoV9(
|
||||
innerBundleInfo.GetBundleInfoV9(flags, bundleInfo, responseUserId);
|
||||
|
||||
ProcessBundleMenu(bundleInfo, flags, true);
|
||||
ProcessBundleRouterMap(bundleInfo, flags);
|
||||
APP_LOGD("get bundleInfo(%{public}s) successfully in user(%{public}d)", bundleName.c_str(), userId);
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -1877,6 +1884,40 @@ ErrCode BundleDataMgr::ProcessBundleMenu(BundleInfo &bundleInfo, int32_t flags,
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void BundleDataMgr::ProcessBundleRouterMap(BundleInfo& bundleInfo, int32_t flag) const
|
||||
{
|
||||
APP_LOGI("ProcessBundleRouterMap with flags: %{public}d", flag);
|
||||
if ((static_cast<uint32_t>(flag) & static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE))
|
||||
!= static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE)) {
|
||||
return;
|
||||
}
|
||||
if ((static_cast<uint32_t>(flag) & static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP))
|
||||
!= static_cast<uint32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP)) {
|
||||
return;
|
||||
}
|
||||
for (auto &hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
std::string routerPath = hapModuleInfo.routerMap;
|
||||
auto pos = routerPath.find(PROFILE_PREFIX);
|
||||
if (pos == std::string::npos) {
|
||||
APP_LOGW("invalid router profile");
|
||||
continue;
|
||||
}
|
||||
std::string routerJsonName = routerPath.substr(pos + PROFILE_PREFIX_LENGTH);
|
||||
std::string routerJsonPath = PROFILE_PATH + routerJsonName + JSON_SUFFIX;
|
||||
|
||||
std::string routerMapString;
|
||||
if (GetJsonProfileByExtractor(hapModuleInfo.hapPath, routerJsonPath, routerMapString) != ERR_OK) {
|
||||
APP_LOGW("get json string from %{public}s failed", routerJsonPath.c_str());
|
||||
}
|
||||
|
||||
BundleParser bundleParser;
|
||||
if (bundleParser.ParseRouterArray(routerMapString, hapModuleInfo.routerArray) != ERR_OK) {
|
||||
APP_LOGE("parse router array from json file %{public}s failed", routerJsonPath.c_str());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ErrCode BundleDataMgr::GetBaseSharedBundleInfos(const std::string &bundleName,
|
||||
std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos, GetDependentBundleInfoFlag flag) const
|
||||
{
|
||||
@ -2193,10 +2234,9 @@ ErrCode BundleDataMgr::GetBundleInfosV9(int32_t flags, std::vector<BundleInfo> &
|
||||
if (innerBundleInfo.GetBundleInfoV9(flags, bundleInfo, responseUserId) != ERR_OK) {
|
||||
continue;
|
||||
}
|
||||
auto ret = ProcessBundleMenu(bundleInfo, flags, true);
|
||||
if (ret == ERR_OK) {
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
}
|
||||
ProcessBundleMenu(bundleInfo, flags, true);
|
||||
ProcessBundleRouterMap(bundleInfo, flags);
|
||||
bundleInfos.emplace_back(bundleInfo);
|
||||
}
|
||||
if (bundleInfos.empty()) {
|
||||
APP_LOGW("bundleInfos is empty");
|
||||
@ -5620,7 +5660,8 @@ ErrCode BundleDataMgr::GetJsonProfile(ProfileType profileType, const std::string
|
||||
ErrCode __attribute__((no_sanitize("cfi"))) BundleDataMgr::GetJsonProfileByExtractor(const std::string &hapPath,
|
||||
const std::string &profilePath, std::string &profile) const
|
||||
{
|
||||
APP_LOGD("GetJsonProfileByExtractor called");
|
||||
APP_LOGD("GetJsonProfileByExtractor with hapPath %{private}s and profilePath %{private}s",
|
||||
hapPath.c_str(), profilePath.c_str());
|
||||
BundleExtractor bundleExtractor(hapPath);
|
||||
if (!bundleExtractor.Init()) {
|
||||
APP_LOGE("bundle extractor init failed");
|
||||
|
@ -1530,7 +1530,8 @@ bool BundleMgrHostImpl::DumpBundleInfo(
|
||||
BundleFlag::GET_BUNDLE_WITH_REQUESTED_PERMISSION |
|
||||
BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO |
|
||||
BundleFlag::GET_BUNDLE_WITH_HASH_VALUE |
|
||||
BundleFlag::GET_BUNDLE_WITH_MENU, bundleInfo, userId)) {
|
||||
BundleFlag::GET_BUNDLE_WITH_MENU |
|
||||
BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP, bundleInfo, userId)) {
|
||||
APP_LOGE("get bundleInfo(%{public}s) failed", bundleName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ namespace {
|
||||
const std::string INSTALL_ABILITY_CONFIGS = "install_ability_configs";
|
||||
constexpr const char* BUNDLE_PACKFILE_NAME = "pack.info";
|
||||
constexpr const char* SYSCAP_NAME = "rpcid.sc";
|
||||
static const std::string ROUTER_MAP = "routerMap";
|
||||
|
||||
bool ParseStr(const char *buf, const int itemLen, int totalLen, std::vector<std::string> &sysCaps)
|
||||
{
|
||||
@ -64,7 +65,7 @@ bool ParseStr(const char *buf, const int itemLen, int totalLen, std::vector<std:
|
||||
bool BundleParser::ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf)
|
||||
{
|
||||
if (access(filePath.c_str(), F_OK) != 0) {
|
||||
APP_LOGD("%{public}s, not existed", filePath.c_str());
|
||||
APP_LOGD("access file %{public}s failed, error: %{public}s", filePath.c_str(), strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,5 +286,36 @@ ErrCode BundleParser::ParseExtTypeConfig(
|
||||
PreBundleProfile preBundleProfile;
|
||||
return preBundleProfile.TransformJsonToExtensionTypeList(jsonBuf, extensionTypeList);
|
||||
}
|
||||
|
||||
ErrCode BundleParser::ParseRouterArray(
|
||||
const std::string &jsonString, std::vector<RouterItem> &routerArray) const
|
||||
{
|
||||
APP_LOGD("Parse RouterItem from %{private}s", jsonString.c_str());
|
||||
nlohmann::json jsonBuf = nlohmann::json::parse(jsonString);
|
||||
|
||||
if (jsonBuf.is_discarded()) {
|
||||
APP_LOGE("json file %{private}s is discarded", jsonString.c_str());
|
||||
return ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
|
||||
}
|
||||
if (jsonBuf.find(ROUTER_MAP) == jsonBuf.end()) {
|
||||
APP_LOGE("routerMap no exist");
|
||||
return ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
|
||||
}
|
||||
nlohmann::json routerJson = jsonBuf.at(ROUTER_MAP);
|
||||
if (!routerJson.is_array()) {
|
||||
APP_LOGE("json under routerMap is not a json array");
|
||||
return ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
|
||||
}
|
||||
|
||||
for (const auto &object : routerJson) {
|
||||
if (!object.is_object()) {
|
||||
return ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
|
||||
}
|
||||
RouterItem routerItem;
|
||||
from_json(object, routerItem);
|
||||
routerArray.emplace_back(routerItem);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -573,6 +573,7 @@ std::optional<HapModuleInfo> InnerBundleInfo::FindHapModuleInfo(const std::strin
|
||||
hapInfo.nativeLibraryFileNames = it->second.nativeLibraryFileNames;
|
||||
hapInfo.aotCompileStatus = it->second.aotCompileStatus;
|
||||
hapInfo.fileContextMenu = it->second.fileContextMenu;
|
||||
hapInfo.routerMap = it->second.routerMap;
|
||||
return hapInfo;
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ const std::string MODULE_NATIVE_LIBRARY_FILE_NAMES = "nativeLibraryFileNames";
|
||||
const std::string MODULE_AOT_COMPILE_STATUS = "aotCompileStatus";
|
||||
const std::string MODULE_FILE_CONTEXT_MENU = "fileContextMenu";
|
||||
const std::string MODULE_IS_ENCRYPTED = "isEncrypted";
|
||||
const std::string MODULE_ROUTER_MAP = "routerMap";
|
||||
const std::string STR_PHONE = "phone";
|
||||
const std::string STR_DEFAULT = "default";
|
||||
} // namespace
|
||||
@ -490,6 +491,7 @@ void to_json(nlohmann::json &jsonObject, const InnerModuleInfo &info)
|
||||
{MODULE_AOT_COMPILE_STATUS, info.aotCompileStatus},
|
||||
{MODULE_FILE_CONTEXT_MENU, info.fileContextMenu},
|
||||
{MODULE_IS_ENCRYPTED, info.isEncrypted},
|
||||
{MODULE_ROUTER_MAP, info.routerMap},
|
||||
};
|
||||
}
|
||||
|
||||
@ -1011,6 +1013,14 @@ void from_json(const nlohmann::json &jsonObject, InnerModuleInfo &info)
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
MODULE_ROUTER_MAP,
|
||||
info.routerMap,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
if (parseResult != ERR_OK) {
|
||||
APP_LOGE("read InnerModuleInfo from database error, error code : %{public}d", parseResult);
|
||||
}
|
||||
|
@ -255,6 +255,7 @@ struct Module {
|
||||
std::string isolationMode;
|
||||
bool compressNativeLibs = true;
|
||||
std::string fileContextMenu;
|
||||
std::string routerMap;
|
||||
};
|
||||
|
||||
struct ModuleJson {
|
||||
@ -1416,6 +1417,14 @@ void from_json(const nlohmann::json &jsonObject, Module &module)
|
||||
false,
|
||||
g_parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
GetValueIfFindKey<std::string>(jsonObject,
|
||||
jsonObjectEnd,
|
||||
MODULE_ROUTER_MAP,
|
||||
module.routerMap,
|
||||
JsonType::STRING,
|
||||
false,
|
||||
g_parseResult,
|
||||
ArrayType::NOT_ARRAY);
|
||||
}
|
||||
|
||||
void from_json(const nlohmann::json &jsonObject, ModuleJson &moduleJson)
|
||||
@ -2110,6 +2119,7 @@ bool ToInnerModuleInfo(
|
||||
innerModuleInfo.isolationMode = moduleJson.module.isolationMode;
|
||||
innerModuleInfo.compressNativeLibs = moduleJson.module.compressNativeLibs;
|
||||
innerModuleInfo.fileContextMenu = moduleJson.module.fileContextMenu;
|
||||
innerModuleInfo.routerMap = moduleJson.module.routerMap;
|
||||
// abilities and fileContextMenu store in InnerBundleInfo
|
||||
return true;
|
||||
}
|
||||
|
@ -114,6 +114,7 @@
|
||||
<option name="push" value="stThirdBundle/bmsThirdBundle26.hap -> /data/test/bms_bundle/" src="res" />
|
||||
<option name="push" value="stThirdBundle/bmsThirdBundle28.rpk -> /data/test/bms_bundle/" src="res" />
|
||||
<option name="push" value="BundleClient/bundleClient1.hap -> /data/test/bms_bundle/" src="res" />
|
||||
<option name="push" value="testHapSo/hapIncludeso1.hap -> /data/test/bms_bundle/" src="res" />
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="BundleMgrClientSystemTest">
|
||||
|
@ -129,6 +129,7 @@
|
||||
"type": "entry",
|
||||
"virtualMachine": "ark",
|
||||
"compressNativeLibs": true,
|
||||
"libIsolation": true
|
||||
"libIsolation": true,
|
||||
"routerMap": "$profile:router_map"
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
{
|
||||
"routerMap": [
|
||||
{
|
||||
"url": "DynamicPage1",
|
||||
"moduleName": "entry",
|
||||
"path": "entry/src/index",
|
||||
"buildFunction": "myFunction"
|
||||
},
|
||||
{
|
||||
"url": "DynamicPage2",
|
||||
"moduleName": "entry",
|
||||
"path": "entry/src/index",
|
||||
"buildFunction": "myBuilder",
|
||||
"data": {
|
||||
"key1": "data1",
|
||||
"key2": "data2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -44,6 +44,7 @@ ohos_systemtest("ActsBmsKitSystemTest") {
|
||||
"${bundle_framework_path}/test/sceneProject/systemtest/stThirdBundle/bmsThirdBundle7:stbmsThirdBundle7",
|
||||
"${bundle_framework_path}/test/sceneProject/systemtest/stThirdBundle/bmsThirdBundle8:stbmsThirdBundle8",
|
||||
"${bundle_framework_path}/test/sceneProject/systemtest/stThirdBundle/bmsThirdBundle9:stbmsThirdBundle9",
|
||||
"${bundle_framework_path}/test/sceneProject/systemtest/testHapSo/hapIncludeso1:hapIncludeso1",
|
||||
"${common_path}:libappexecfwk_common",
|
||||
"${core_path}:appexecfwk_core",
|
||||
"${services_path}/test/moduletest/utils:tool_common",
|
||||
|
@ -65,6 +65,14 @@ const std::string DEFAULT_APP_BUNDLE_NAME = "com.test.defaultApp";
|
||||
const std::string DEFAULT_APP_MODULE_NAME = "module01";
|
||||
const std::string DEFAULT_APP_VIDEO = "VIDEO";
|
||||
const std::string DEVICE_ID = "deviceID";
|
||||
const std::string ROUTER_MAP_TEST_HAP = "/data/test/bms_bundle/hapIncludeso1.hap";
|
||||
const std::string ROUTER_MAP_TEST_BUNDLE_NAME = "com.example.testhapso1";
|
||||
const std::string ROUTER_INDEX_ZERO_URL = "DynamicPage1";
|
||||
const std::string ROUTER_INDEX_ZERO_MDOULE_NAME = "entry";
|
||||
const std::string ROUTER_INDEX_ZERO_PATH = "entry/src/index";
|
||||
const std::string ROUTER_INDEX_ZERO_BUILD_FUNCTION = "myFunction";
|
||||
const std::string ROUTER_INDEX_ONE_URL = "DynamicPage2";
|
||||
const std::string ROUTER_INDEX_ONE_BUILD_FUNCTION = "myBuilder";
|
||||
const int COMPATIBLEVERSION = 3;
|
||||
const int TARGETVERSION = 3;
|
||||
const int32_t USERID = 100;
|
||||
@ -717,6 +725,84 @@ HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_0900, Function | MediumTest | Level
|
||||
EXPECT_FALSE(getInfoResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfo_1000
|
||||
* @tc.name: test query bundle information
|
||||
* @tc.desc: 1.install the hap that contains router map json profile
|
||||
* 2.query bundleInfo
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_1000, Function | MediumTest | Level1)
|
||||
{
|
||||
std::cout << "START GetBundleInfo_1000" << std::endl;
|
||||
std::vector<std::string> resvec;
|
||||
Install(ROUTER_MAP_TEST_HAP, InstallFlag::REPLACE_EXISTING, resvec);
|
||||
CommonTool commonTool;
|
||||
std::string installResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(installResult, "Success") << "install fail!";
|
||||
sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
|
||||
ASSERT_NE(bundleMgrProxy, nullptr);
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
bool getInfoResult = bundleMgrProxy->GetBundleInfo(ROUTER_MAP_TEST_BUNDLE_NAME,
|
||||
static_cast<int32_t>(BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP), bundleInfo, USERID);
|
||||
EXPECT_TRUE(getInfoResult);
|
||||
ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
|
||||
ASSERT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.size(), PERMS_INDEX_TWO);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].url, ROUTER_INDEX_ZERO_URL);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].moduleName,
|
||||
ROUTER_INDEX_ZERO_MDOULE_NAME);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].path, ROUTER_INDEX_ZERO_PATH);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].buildFunction,
|
||||
ROUTER_INDEX_ZERO_BUILD_FUNCTION);
|
||||
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].url, ROUTER_INDEX_ONE_URL);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].moduleName,
|
||||
ROUTER_INDEX_ZERO_MDOULE_NAME);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].path, ROUTER_INDEX_ZERO_PATH);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].buildFunction,
|
||||
ROUTER_INDEX_ONE_BUILD_FUNCTION);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].data.size(), PERMS_INDEX_TWO);
|
||||
resvec.clear();
|
||||
Uninstall(ROUTER_MAP_TEST_BUNDLE_NAME, resvec);
|
||||
std::string uninstallResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
|
||||
|
||||
std::cout << "END GetBundleInfo_1000" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfo_1100
|
||||
* @tc.name: test query bundle information
|
||||
* @tc.desc: 1.install the hap that does not contain router map json profile
|
||||
* 2.query bundleInfo
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, GetBundleInfo_1100, Function | MediumTest | Level1)
|
||||
{
|
||||
std::cout << "START GetBundleInfo_1100" << std::endl;
|
||||
std::vector<std::string> resvec;
|
||||
std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
|
||||
std::string appName = BASE_BUNDLE_NAME + "1";
|
||||
Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
|
||||
CommonTool commonTool;
|
||||
std::string installResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(installResult, "Success") << "install fail!";
|
||||
sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
|
||||
ASSERT_NE(bundleMgrProxy, nullptr);
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
bool getInfoResult = bundleMgrProxy->GetBundleInfo(appName,
|
||||
static_cast<int32_t>(BundleFlag::GET_BUNDLE_WITH_ROUTER_MAP), bundleInfo, USERID);
|
||||
EXPECT_TRUE(getInfoResult);
|
||||
ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
|
||||
EXPECT_TRUE(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.empty());
|
||||
resvec.clear();
|
||||
Uninstall(appName, resvec);
|
||||
std::string uninstallResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
|
||||
|
||||
std::cout << "END GetBundleInfo_1100" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoV9_0010
|
||||
* @tc.name: test query bundle information
|
||||
@ -1197,6 +1283,86 @@ HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0023, Function | MediumTest | Lev
|
||||
std::cout << "END GetBundleInfoV9_0023" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoV9_0024
|
||||
* @tc.name: test query bundle information
|
||||
* @tc.desc: 1.install the hap that contains router map json profile
|
||||
* 2.query bundleInfo
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0024, Function | MediumTest | Level1)
|
||||
{
|
||||
std::cout << "START GetBundleInfoV9_0024" << std::endl;
|
||||
std::vector<std::string> resvec;
|
||||
Install(ROUTER_MAP_TEST_HAP, InstallFlag::REPLACE_EXISTING, resvec);
|
||||
CommonTool commonTool;
|
||||
std::string installResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(installResult, "Success") << "install fail!";
|
||||
sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
|
||||
ASSERT_NE(bundleMgrProxy, nullptr);
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(ROUTER_MAP_TEST_BUNDLE_NAME,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP), bundleInfo, USERID);
|
||||
EXPECT_EQ(getInfoResult, ERR_OK);
|
||||
ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
|
||||
ASSERT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.size(), PERMS_INDEX_TWO);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].url, ROUTER_INDEX_ZERO_URL);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].moduleName,
|
||||
ROUTER_INDEX_ZERO_MDOULE_NAME);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].path, ROUTER_INDEX_ZERO_PATH);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ZERO].buildFunction,
|
||||
ROUTER_INDEX_ZERO_BUILD_FUNCTION);
|
||||
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].url, ROUTER_INDEX_ONE_URL);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].moduleName,
|
||||
ROUTER_INDEX_ZERO_MDOULE_NAME);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].path, ROUTER_INDEX_ZERO_PATH);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].buildFunction,
|
||||
ROUTER_INDEX_ONE_BUILD_FUNCTION);
|
||||
EXPECT_EQ(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray[PERMS_INDEX_ONE].data.size(), PERMS_INDEX_TWO);
|
||||
resvec.clear();
|
||||
Uninstall(ROUTER_MAP_TEST_BUNDLE_NAME, resvec);
|
||||
std::string uninstallResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
|
||||
|
||||
std::cout << "END GetBundleInfoV9_0024" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfoV9_0025
|
||||
* @tc.name: test query bundle information
|
||||
* @tc.desc: 1.install the hap that does not contain router map json profile
|
||||
* 2.query bundleInfo
|
||||
*/
|
||||
HWTEST_F(ActsBmsKitSystemTest, GetBundleInfoV9_0025, Function | MediumTest | Level1)
|
||||
{
|
||||
std::cout << "START GetBundleInfoV9_0025" << std::endl;
|
||||
std::vector<std::string> resvec;
|
||||
std::string bundleFilePath = THIRD_BUNDLE_PATH + "bmsThirdBundle24.hap";
|
||||
std::string appName = BASE_BUNDLE_NAME + "1";
|
||||
Install(bundleFilePath, InstallFlag::REPLACE_EXISTING, resvec);
|
||||
CommonTool commonTool;
|
||||
std::string installResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(installResult, "Success") << "install fail!";
|
||||
sptr<BundleMgrProxy> bundleMgrProxy = GetBundleMgrProxy();
|
||||
ASSERT_NE(bundleMgrProxy, nullptr);
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
auto getInfoResult = bundleMgrProxy->GetBundleInfoV9(appName,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) |
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ROUTER_MAP), bundleInfo, USERID);
|
||||
EXPECT_EQ(getInfoResult, ERR_OK);
|
||||
ASSERT_FALSE(bundleInfo.hapModuleInfos.empty());
|
||||
EXPECT_TRUE(bundleInfo.hapModuleInfos[PERMS_INDEX_ZERO].routerArray.empty());
|
||||
resvec.clear();
|
||||
Uninstall(appName, resvec);
|
||||
std::string uninstallResult = commonTool.VectorToStr(resvec);
|
||||
EXPECT_EQ(uninstallResult, "Success") << "uninstall fail!";
|
||||
|
||||
std::cout << "END GetBundleInfoV9_0025" << std::endl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: GetBundleInfos_0100
|
||||
* @tc.name: test query bundleinfos
|
||||
|
Loading…
Reference in New Issue
Block a user