From 19f5c1e127b73ab665a9ef2b93bd409ec4041547 Mon Sep 17 00:00:00 2001 From: shilei Date: Fri, 23 Sep 2022 22:26:02 +0800 Subject: [PATCH 01/12] fixed 72ca2e4 from https://gitee.com/shilei91/bundlemanager_bundle_framework_lite/pulls/198 fix problem Signed-off-by: shilei Change-Id: Ic715851da296e542e157b91da9b3f3cb36a739e9 --- .../include/bundle_callback_utils.h | 5 + frameworks/bundle_lite/src/bundle_manager.cpp | 112 +++++++++++++++++- .../bundlemgr_lite/bundle_inner_interface.h | 2 + .../include/bundle_ms_feature.h | 3 + .../bundlemgr_lite/src/bundle_ms_feature.cpp | 93 +++++++++++++++ 5 files changed, 214 insertions(+), 1 deletion(-) diff --git a/frameworks/bundle_lite/include/bundle_callback_utils.h b/frameworks/bundle_lite/include/bundle_callback_utils.h index ec1031d..6053d58 100755 --- a/frameworks/bundle_lite/include/bundle_callback_utils.h +++ b/frameworks/bundle_lite/include/bundle_callback_utils.h @@ -72,4 +72,9 @@ struct ResultOfGetBundleSize { uint8_t resultCode; uint32_t bundleSize; }; + +struct BasicInfo { + char *metaDataKey; + int32_t flags; +}; #endif // OHOS_BUNDLE_CALLBACK_UTILS_H \ No newline at end of file diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index 6822a7d..50be38d 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -92,6 +92,7 @@ static uint8_t DeserializeInnerAbilityInfo(IOwner owner, IpcIo *reply) static uint8_t DeserializeInnerBundleInfo(IOwner owner, IpcIo *reply) { + HILOG_DEBUG(HILOG_MODULE_APP, "DeserializeInnerBundleInfo start"); if ((reply == nullptr) || (owner == nullptr)) { return OHOS_FAILURE; } @@ -112,14 +113,17 @@ static uint8_t DeserializeInnerBundleInfo(IOwner owner, IpcIo *reply) info->bundleInfo = OHOS::ConvertUtils::ConvertStringToBundleInfo(jsonStr, len); if (info->bundleInfo == nullptr) { info->resultCode = ERR_APPEXECFWK_DESERIALIZATION_FAILED; + HILOG_ERROR(HILOG_MODULE_APP, "ConvertStringToBundleInfo failed"); return ERR_APPEXECFWK_DESERIALIZATION_FAILED; } info->resultCode = resultCode; + HILOG_DEBUG(HILOG_MODULE_APP, "DeserializeInnerBundleInfo finished"); return resultCode; } static uint8_t DeserializeInnerBundleInfos(IOwner owner, IpcIo *reply) { + HILOG_DEBUG(HILOG_MODULE_APP, "DeserializeInnerBundleInfos start"); if ((reply == nullptr) || (owner == nullptr)) { return OHOS_FAILURE; } @@ -145,6 +149,7 @@ static uint8_t DeserializeInnerBundleInfos(IOwner owner, IpcIo *reply) } info->resultCode = resultCode; + HILOG_DEBUG(HILOG_MODULE_APP, "DeserializeInnerBundleInfos finished"); return resultCode; } @@ -276,6 +281,22 @@ static int Notify(IOwner owner, int code, IpcIo *reply) case GET_BUNDLE_INFOS_BY_METADATA: { return DeserializeInnerBundleInfos(owner, reply); } + case GET_BUNDLE_INFO_LENGTH: { + ResultOfGetBundleInfos *resultOfGetBundleInfos = reinterpret_cast(owner); + uint8_t errCode; + ReadUint8(reply, &errCode); + if (errCode != ERR_OK) { + HILOG_INFO(HILOG_MODULE_APP, "BundleManager get bundleInfos length failed due to %{public}d", errCode); + resultOfGetBundleInfos->resultCode = errCode; + return errCode; + } + ReadInt32(reply, &(resultOfGetBundleInfos->length)); + HILOG_INFO(HILOG_MODULE_APP, "BundleManager bundleInfo len is: %{public}d", resultOfGetBundleInfos->length); + break; + } + case GET_BUNDLE_INFO_BY_INDEX: { + return DeserializeInnerBundleInfo(owner, reply); + } case GET_BUNDLENAME_FOR_UID: { return DeserializeInnerBundleName(owner, reply); } @@ -557,6 +578,91 @@ static uint8_t ObtainInnerBundleInfos(const int flags, BundleInfo **bundleInfos, return resultOfGetBundleInfos.resultCode; } +static uint8_t ObtainBundleInfosOneByOne(BasicInfo basicInfo, int32_t len, uint8_t code, IClientProxy *bmsClient, + BundleInfo **bundleInfos) +{ + if (bmsClient == nullptr || bundleInfos == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne failed due to nullptr parma"); + return ERR_APPEXECFWK_OBJECT_NULL; + } + for (int32_t i = 0; i < len; ++i) { + IpcIo innerIpcIo; + char data[MAX_IO_SIZE]; + IpcIoInit(&innerIpcIo, data, MAX_IO_SIZE, 0); + WriteInt32(&innerIpcIo, static_cast(code)); + if (code == GET_BUNDLE_INFOS) { + WriteInt32(&innerIpcIo, basicInfo.flags); + } + if (code == GET_BUNDLE_INFOS_BY_METADATA) { + WriteString(&innerIpcIo, basicInfo.metaDataKey); + } + WriteInt32(&innerIpcIo, i); + ResultOfGetBundleInfo resultOfGetBundleInfo; + resultOfGetBundleInfo.bundleInfo = nullptr; + int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, &resultOfGetBundleInfo, Notify); + if (ret != OHOS_SUCCESS) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d\n", ret); + return ERR_APPEXECFWK_INVOKE_ERROR; + } + OHOS::BundleInfoUtils::CopyBundleInfo(basicInfo.flags, *bundleInfos + i, *(resultOfGetBundleInfo.bundleInfo)); + ClearBundleInfo(resultOfGetBundleInfo.bundleInfo); + AdapterFree(resultOfGetBundleInfo.bundleInfo); + } + return OHOS_SUCCESS; +} + +static uint8_t ObtainBundleInfos(BasicInfo basicInfo, BundleInfo **bundleInfos, int32_t *len, + uint8_t code, IpcIo *ipcIo) +{ + if ((bundleInfos == nullptr) || (len == nullptr) || (ipcIo == nullptr)) { + return ERR_APPEXECFWK_OBJECT_NULL; + } + if (CheckSelfPermission(static_cast(PERMISSION_GET_BUNDLE_INFO)) != GRANTED) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfos failed due to permission denied"); + return ERR_APPEXECFWK_PERMISSION_DENIED; + } + auto bmsClient = GetBmsClient(); + if (bmsClient == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfos failed due to nullptr bms client"); + return ERR_APPEXECFWK_OBJECT_NULL; + } + + ResultOfGetBundleInfos resultOfGetBundleInfos; + resultOfGetBundleInfos.length = 0; + resultOfGetBundleInfos.bundleInfo = nullptr; + int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_LENGTH, ipcIo, &resultOfGetBundleInfos, Notify); + if (ret != OHOS_SUCCESS) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfos invoke failed: %{public}d\n", ret); + return ERR_APPEXECFWK_INVOKE_ERROR; + } + + if (resultOfGetBundleInfos.length == 0 || resultOfGetBundleInfos.resultCode != ERR_OK) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfos fail"); + *bundleInfos = nullptr; + return resultOfGetBundleInfos.resultCode; + } + + *bundleInfos = reinterpret_cast(AdapterMalloc(sizeof(BundleInfo) * resultOfGetBundleInfos.length)); + if (*bundleInfos == nullptr) { + OHOS::BundleInfoUtils::FreeBundleInfos(resultOfGetBundleInfos.bundleInfo, resultOfGetBundleInfos.length); + return ERR_APPEXECFWK_OBJECT_NULL; + } + if (memset_s(*bundleInfos, sizeof(BundleInfo) * (resultOfGetBundleInfos.length), 0, sizeof(BundleInfo) * + (resultOfGetBundleInfos.length)) != EOK) { + AdapterFree(*bundleInfos); + OHOS::BundleInfoUtils::FreeBundleInfos(resultOfGetBundleInfos.bundleInfo, resultOfGetBundleInfos.length); + return ERR_APPEXECFWK_SYSTEM_INTERNAL_ERROR; + } + + uint8_t res = ObtainBundleInfosOneByOne(basicInfo, resultOfGetBundleInfos.length, code, bmsClient, bundleInfos); + if (res != OHOS_SUCCESS) { + HILOG_WARN(HILOG_MODULE_APP, "BundleManager ObtainBundleInfos invoke failed: %{public}d\n", res); + } + *len = resultOfGetBundleInfos.length; + OHOS::BundleInfoUtils::FreeBundleInfos(resultOfGetBundleInfos.bundleInfo, resultOfGetBundleInfos.length); + return resultOfGetBundleInfos.resultCode; +} + uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len) { if ((bundleInfos == nullptr) || (len == nullptr)) { @@ -569,8 +675,12 @@ uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len) IpcIo ipcIo; char data[MAX_IO_SIZE]; IpcIoInit(&ipcIo, data, MAX_IO_SIZE, 0); + WriteInt32(&ipcIo, GET_BUNDLE_INFOS); WriteInt32(&ipcIo, flags); - return ObtainInnerBundleInfos(flags, bundleInfos, len, GET_BUNDLE_INFOS, &ipcIo); + BasicInfo basicInfo; + basicInfo.flags = flags; + basicInfo.metaDataKey = nullptr; + return ObtainBundleInfos(basicInfo, bundleInfos, len, GET_BUNDLE_INFOS, &ipcIo); } uint32_t GetBundleSize(const char *bundleName) diff --git a/interfaces/inner_api/bundlemgr_lite/bundle_inner_interface.h b/interfaces/inner_api/bundlemgr_lite/bundle_inner_interface.h index c5b679c..2399bf6 100755 --- a/interfaces/inner_api/bundlemgr_lite/bundle_inner_interface.h +++ b/interfaces/inner_api/bundlemgr_lite/bundle_inner_interface.h @@ -41,6 +41,8 @@ enum BmsCmd { GET_BUNDLE_INFOS_BY_METADATA, CHECK_SYS_CAP, GET_BUNDLE_SIZE, + GET_BUNDLE_INFO_LENGTH, + GET_BUNDLE_INFO_BY_INDEX, GET_SYS_CAP, BMS_INNER_BEGIN, INSTALL = BMS_INNER_BEGIN, // bms install application diff --git a/services/bundlemgr_lite/include/bundle_ms_feature.h b/services/bundlemgr_lite/include/bundle_ms_feature.h index f33cfdb..4769e31 100755 --- a/services/bundlemgr_lite/include/bundle_ms_feature.h +++ b/services/bundlemgr_lite/include/bundle_ms_feature.h @@ -62,6 +62,9 @@ private: static uint8_t HasSystemCapability(const uint8_t funcId, IpcIo *req, IpcIo *reply); static uint8_t GetSystemAvailableCapabilities(const uint8_t funcId, IpcIo *req, IpcIo *reply); static uint8_t GetInnerBundleSize(const uint8_t funcId, IpcIo *req, IpcIo *reply); + static uint8_t HandleGetBundleInfosByIndex(const uint8_t funcId, IpcIo *req, IpcIo *reply); + static uint8_t HandleGetBundleInfosLength(const uint8_t funcId, IpcIo *req, IpcIo *reply); + static BundleInfo *GetInnerBundleInfos(IpcIo *req, IpcIo *reply, int32_t *length); Identity identity_; static BundleInvokeType BundleMsInvokeFuc[BMS_INNER_BEGIN]; diff --git a/services/bundlemgr_lite/src/bundle_ms_feature.cpp b/services/bundlemgr_lite/src/bundle_ms_feature.cpp index b8412f6..10f44ef 100644 --- a/services/bundlemgr_lite/src/bundle_ms_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_ms_feature.cpp @@ -57,6 +57,8 @@ BundleInvokeType BundleMsFeature::BundleMsInvokeFuc[BMS_INNER_BEGIN] { HandleGetBundleInfos, HasSystemCapability, GetInnerBundleSize, + HandleGetBundleInfosLength, + HandleGetBundleInfosByIndex, GetSystemAvailableCapabilities, }; @@ -562,4 +564,95 @@ uint8_t BundleMsFeature::GetBundleNameForUid(int32_t uid, char **bundleName) } return OHOS_SUCCESS; } + +BundleInfo *BundleMsFeature::GetInnerBundleInfos(IpcIo *req, IpcIo *reply, int32_t *length) +{ + HILOG_INFO(HILOG_MODULE_APP, "BundleMS GetInnerBundleInfos start"); + if ((req == nullptr) || (reply == nullptr)) { + return nullptr; + } + BundleInfo *bundleInfos = nullptr; + uint8_t errorCode = 0; + int32_t codeFlag = -1; + ReadInt32(req, &codeFlag); + if (codeFlag == GET_BUNDLE_INFOS) { + int32_t flag; + ReadInt32(req, &flag); + errorCode = GetBundleInfos(flag, &bundleInfos, length); + } else if (codeFlag == QUERY_KEEPALIVE_BUNDLE_INFOS) { + errorCode = QueryKeepAliveBundleInfos(&bundleInfos, length); + } else if (codeFlag == GET_BUNDLE_INFOS_BY_METADATA) { + size_t len = 0; + char *metaDataKey = reinterpret_cast(ReadString(req, &len)); + if (metaDataKey == nullptr) { + return nullptr; + } + errorCode = GetBundleInfosByMetaData(metaDataKey, &bundleInfos, length); + } else { + return nullptr; + } + if (errorCode != OHOS_SUCCESS) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS GetInnerBundleInfos failed with errorcode: %{public}d\n", errorCode); + BundleInfoUtils::FreeBundleInfos(bundleInfos, *length); + return nullptr; + } + HILOG_DEBUG(HILOG_MODULE_APP, "BundleMS GetInnerBundleInfos with length is: %{public}d\n", *length); + return bundleInfos; +} + +uint8_t BundleMsFeature::HandleGetBundleInfosLength(const uint8_t funcId, IpcIo *req, IpcIo *reply) +{ + HILOG_INFO(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosLength start"); + if ((req == nullptr) || (reply == nullptr)) { + return ERR_APPEXECFWK_OBJECT_NULL; + } + int32_t lengthOfBundleInfo = 0; + BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo); + if (bundleInfos == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS bundleInfos is nullptr"); + return ERR_APPEXECFWK_OBJECT_NULL; + } + WriteUint8(reply, static_cast(OHOS_SUCCESS)); + WriteInt32(reply, lengthOfBundleInfo); + BundleInfoUtils::FreeBundleInfos(bundleInfos, lengthOfBundleInfo); + HILOG_INFO(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosLength finished"); + return OHOS_SUCCESS; +} + +uint8_t BundleMsFeature::HandleGetBundleInfosByIndex(const uint8_t funcId, IpcIo *req, IpcIo *reply) +{ + HILOG_INFO(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosByIndex start"); + if ((req == nullptr) || (reply == nullptr)) { + return ERR_APPEXECFWK_OBJECT_NULL; + } + int32_t lengthOfBundleInfo = 0; + BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo);; + int32_t index = 0; + ReadInt32(req, &index); + HILOG_INFO(HILOG_MODULE_APP, "BundleMS index is : %{public}d\n", index); + char *str = ConvertUtils::ConvertBundleInfoToString(bundleInfos + index); + if (str == nullptr) { + BundleInfoUtils::FreeBundleInfos(bundleInfos, lengthOfBundleInfo); + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosByIndex strs is nullptr"); + return ERR_APPEXECFWK_SERIALIZATION_FAILED; + } + HILOG_DEBUG(HILOG_MODULE_APP, "BundleMS length of str is: %{public}d\n", static_cast(strlen(str))); +#ifdef __LINUX__ + if (strlen(str) > MAX_IPC_STRING_LENGTH) { + BundleInfoUtils::FreeBundleInfos(bundleInfos, lengthOfBundleInfo); + HILOG_ERROR(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosByIndex is too larger to be transformed by ipc"); + cJSON_free(str); + return ERR_APPEXECFWK_SERIALIZATION_FAILED; + } +#endif + WriteUint8(reply, static_cast(OHOS_SUCCESS)); + WriteString(reply, str); + HILOG_INFO(HILOG_MODULE_APP, "BundleMS bundleInfo length is %{public}d of index %{public}d", + static_cast(strlen(str)), index); + BundleInfoUtils::FreeBundleInfos(bundleInfos, lengthOfBundleInfo); + + cJSON_free(str); + HILOG_INFO(HILOG_MODULE_APP, "BundleMS HandleGetBundleInfosByIndex finished"); + return OHOS_SUCCESS; +} } // namespace OHOS -- Gitee From 1013b274d74addd080a09acd2fd14f0363111aea Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 26 Sep 2022 09:12:58 +0800 Subject: [PATCH 02/12] sync code to beta3 branch Signed-off-by: shilei --- .../bundle_daemon/include/bundle_file_utils.h | 1 + .../bundle_daemon/src/bundle_daemon.cpp | 2 +- .../src/bundle_daemon_handler.cpp | 4 +-- .../bundle_daemon/src/bundle_file_utils.cpp | 26 +++++++++++++++++++ .../src/bundle_daemon_client.cpp | 2 +- .../src/gt_bundle_extractor.cpp | 2 +- 6 files changed, 32 insertions(+), 5 deletions(-) diff --git a/services/bundlemgr_lite/bundle_daemon/include/bundle_file_utils.h b/services/bundlemgr_lite/bundle_daemon/include/bundle_file_utils.h index 1e62034..738943d 100644 --- a/services/bundlemgr_lite/bundle_daemon/include/bundle_file_utils.h +++ b/services/bundlemgr_lite/bundle_daemon/include/bundle_file_utils.h @@ -29,6 +29,7 @@ const char PATH_SEPARATOR = '/'; class BundleFileUtils : public NoCopyable { public: static bool MkRecursiveDir(const char *dir, bool isReadOthers); + static bool MkOwnerDir(const char *dir); static bool IsExistDir(const char *path); static bool IsExistFile(const char *file); static bool RemoveFile(const char *path); diff --git a/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon.cpp b/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon.cpp index 3e6b6f7..9e36b5b 100644 --- a/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon.cpp +++ b/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon.cpp @@ -200,7 +200,7 @@ int32_t BundleDaemon::CreateDataDirectoryInvoke(IpcIo *req) ReadInt32(req, &gid); bool isChown; ReadBool(req, &isChown); - + PRINTI("BundleDaemonClient", "uid is %{public}d, isChown is %{public}d", uid, isChown); return BundleDaemon::GetInstance().handler_.CreateDataDirectory(dataPath, uid, gid, isChown); } diff --git a/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon_handler.cpp b/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon_handler.cpp index b48b498..efd972a 100755 --- a/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon_handler.cpp +++ b/services/bundlemgr_lite/bundle_daemon/src/bundle_daemon_handler.cpp @@ -140,12 +140,12 @@ int32_t BundleDaemonHandler::CreateDataDirectory(const char *dataPath, int32_t u } if (!BundleFileUtils::IsExistDir(dataDir.c_str())) { - if (!BundleFileUtils::MkRecursiveDir(dataDir.c_str(), false)) { + if (!BundleFileUtils::MkOwnerDir(dataDir.c_str())) { PRINTE("BundleDaemonHandler", "create dataPath fail"); return EC_NODIR; } } - + PRINTI("BundleDaemonClient", "uid is %{public}d, isChown is %{public}d", uid, isChown); if (isChown && !BundleFileUtils::ChownFile(dataDir.c_str(), uid, gid)) { PRINTE("BundleDaemonHandler", "chown file fail"); return EC_NOFILE; diff --git a/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp b/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp index 95e7ad3..68474db 100644 --- a/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp +++ b/services/bundlemgr_lite/bundle_daemon/src/bundle_file_utils.cpp @@ -78,6 +78,32 @@ bool BundleFileUtils::MkRecursiveDir(const char *dir, bool isReadOthers) return true; } +bool BundleFileUtils::MkOwnerDir(const char *dir) +{ + if (dir == nullptr) { + return false; + } + if (IsExistDir(dir)) { + return true; + } + size_t len = strlen(dir); + if (len == 0 || len > PATH_MAX) { + return false; + } + // Create directories level by level + char rootDir[PATH_MAX] = { '\0' }; + for (size_t i = 0; i < len; ++i) { + rootDir[i] = dir[i]; + if ((rootDir[i] == PATH_SEPARATOR || i == (len - 1)) && !IsExistDir(rootDir)) { + mode_t mode = S_IRWXU | S_IRWXG; + if (mkdir(rootDir, mode) < 0) { + return false; + } + } + } + return true; +} + bool BundleFileUtils::RemoveFile(const char *path) { if (IsExistFile(path)) { diff --git a/services/bundlemgr_lite/src/bundle_daemon_client.cpp b/services/bundlemgr_lite/src/bundle_daemon_client.cpp index 140ac1b..9c2d38b 100644 --- a/services/bundlemgr_lite/src/bundle_daemon_client.cpp +++ b/services/bundlemgr_lite/src/bundle_daemon_client.cpp @@ -283,7 +283,7 @@ int32_t BundleDaemonClient::CreateDataDirectory(const char *dataPath, int32_t ui WriteInt32(&request, uid); WriteInt32(&request, gid); WriteBool(&request, isChown); - + PRINTI("BundleDaemonClient", "uid is %{public}d, isChown is %{public}d", uid, isChown); Lock lock(mutex_); #ifdef __LINUX__ return WaitResultSync(bdsClient_->Invoke(bdsClient_, CREATE_DATA_DIRECTORY, &request, this, Notify)); diff --git a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp index 5a3f6eb..cfc0de1 100755 --- a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp @@ -154,7 +154,7 @@ bool GtBundleExtractor::ExtractResourceFile(const char *path, int32_t fp, uint32 } int32_t fileNameLen = strlen(fileName); - if ((strlen(relativeFilePath) == 0 && (fileName != nullptr && strcmp(fileName, PROFILE_NAME) == 0)) || + if ((strlen(relativeFilePath) == 0 && (strcmp(fileName, PROFILE_NAME) == 0)) || !BundleUtil::StartWith(relativeFilePath, ASSET_JS_PATH)) { if (!GtExtractorUtil::HasWrittenFile(path, relativeFilePath, fileName, fp, fileSize)) { UI_Free(fileName); -- Gitee From 1a594802d2e7d4f35825963b8a13358f10a71116 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 26 Sep 2022 09:33:58 +0800 Subject: [PATCH 03/12] update Signed-off-by: shilei --- frameworks/bundle_lite/src/bundle_manager.cpp | 3 ++- services/bundlemgr_lite/src/bundle_ms_feature.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index 50be38d..d11f4dc 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -599,7 +599,8 @@ static uint8_t ObtainBundleInfosOneByOne(BasicInfo basicInfo, int32_t len, uint8 WriteInt32(&innerIpcIo, i); ResultOfGetBundleInfo resultOfGetBundleInfo; resultOfGetBundleInfo.bundleInfo = nullptr; - int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, &resultOfGetBundleInfo, Notify); + int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, + &resultOfGetBundleInfo, Notify); if (ret != OHOS_SUCCESS) { HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d\n", ret); return ERR_APPEXECFWK_INVOKE_ERROR; diff --git a/services/bundlemgr_lite/src/bundle_ms_feature.cpp b/services/bundlemgr_lite/src/bundle_ms_feature.cpp index 10f44ef..eea762a 100644 --- a/services/bundlemgr_lite/src/bundle_ms_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_ms_feature.cpp @@ -626,7 +626,7 @@ uint8_t BundleMsFeature::HandleGetBundleInfosByIndex(const uint8_t funcId, IpcIo return ERR_APPEXECFWK_OBJECT_NULL; } int32_t lengthOfBundleInfo = 0; - BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo);; + BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo); int32_t index = 0; ReadInt32(req, &index); HILOG_INFO(HILOG_MODULE_APP, "BundleMS index is : %{public}d\n", index); -- Gitee From 7e99b8e2ee1e36885a8cb6be6a2b42e9bac022eb Mon Sep 17 00:00:00 2001 From: Lotol Date: Mon, 26 Sep 2022 01:20:00 +0000 Subject: [PATCH 04/12] fixed 7fbf962 from https://gitee.com/lotol/appexecfwk_appexecfwk_lite/pulls/201 update services/bundlemgr_lite/src/bundle_ms_feature.cpp. Signed-off-by: Lotol --- services/bundlemgr_lite/src/bundle_ms_feature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/bundlemgr_lite/src/bundle_ms_feature.cpp b/services/bundlemgr_lite/src/bundle_ms_feature.cpp index 10f44ef..eea762a 100644 --- a/services/bundlemgr_lite/src/bundle_ms_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_ms_feature.cpp @@ -626,7 +626,7 @@ uint8_t BundleMsFeature::HandleGetBundleInfosByIndex(const uint8_t funcId, IpcIo return ERR_APPEXECFWK_OBJECT_NULL; } int32_t lengthOfBundleInfo = 0; - BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo);; + BundleInfo *bundleInfos = GetInnerBundleInfos(req, reply, &lengthOfBundleInfo); int32_t index = 0; ReadInt32(req, &index); HILOG_INFO(HILOG_MODULE_APP, "BundleMS index is : %{public}d\n", index); -- Gitee From 075b63615e13b400363ab90b870030d15e7160e3 Mon Sep 17 00:00:00 2001 From: Lotol Date: Mon, 26 Sep 2022 01:11:26 +0000 Subject: [PATCH 05/12] fixed 4107b34 from https://gitee.com/lotol/appexecfwk_appexecfwk_lite/pulls/201 update frameworks/bundle_lite/src/bundle_manager.cpp. Signed-off-by: Lotol --- frameworks/bundle_lite/src/bundle_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index 50be38d..d11f4dc 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -599,7 +599,8 @@ static uint8_t ObtainBundleInfosOneByOne(BasicInfo basicInfo, int32_t len, uint8 WriteInt32(&innerIpcIo, i); ResultOfGetBundleInfo resultOfGetBundleInfo; resultOfGetBundleInfo.bundleInfo = nullptr; - int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, &resultOfGetBundleInfo, Notify); + int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, + &resultOfGetBundleInfo, Notify); if (ret != OHOS_SUCCESS) { HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d\n", ret); return ERR_APPEXECFWK_INVOKE_ERROR; -- Gitee From 19a4af4940df40be75ddbc61d26301ae1b034bf4 Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 26 Sep 2022 11:10:18 +0800 Subject: [PATCH 06/12] update Signed-off-by: shilei --- frameworks/bundle_lite/src/bundle_manager.cpp | 2 +- .../bundlemgr_lite/src/bundle_installer.cpp | 11 ++++----- .../src/bundle_manager_service.cpp | 7 +++--- .../bundlemgr_lite/src/bundle_ms_feature.cpp | 7 ------ .../src/gt_bundle_extractor.cpp | 2 +- .../src/gt_bundle_installer.cpp | 6 +---- .../src/gt_bundle_manager_service.cpp | 23 +++++++++++++++---- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index d11f4dc..205080d 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -172,7 +172,7 @@ static uint8_t DeserializeInnerBundleName(IOwner owner, IpcIo *reply) info->resultCode = ERR_APPEXECFWK_DESERIALIZATION_FAILED; return ERR_APPEXECFWK_DESERIALIZATION_FAILED; } - if (length < 0 || length > MAX_BUNDLE_NAME) { + if (length > MAX_BUNDLE_NAME) { info->resultCode = ERR_APPEXECFWK_DESERIALIZATION_FAILED; return ERR_APPEXECFWK_DESERIALIZATION_FAILED; } diff --git a/services/bundlemgr_lite/src/bundle_installer.cpp b/services/bundlemgr_lite/src/bundle_installer.cpp index c902c12..c401c5d 100755 --- a/services/bundlemgr_lite/src/bundle_installer.cpp +++ b/services/bundlemgr_lite/src/bundle_installer.cpp @@ -330,13 +330,10 @@ bool BundleInstaller::MatchPermissions(const std::vector & restrict int32_t size = realRestrictedPermissions.size(); for (int32_t i = 0; i < size; i++) { - bool isMatched = false; - for (const auto & restrictedPermission : restrictedPermissions) { - if (realRestrictedPermissions[i] == restrictedPermission) { - isMatched = true; - break; - } - } + bool isMatched = std::any_of(restrictedPermissions.begin(), restrictedPermissions.end(), + [realRestrictedPermissions, i](const auto & restrictedPermission)->bool { + return realRestrictedPermissions[i] == restrictedPermission; + }); if (!isMatched) { HILOG_WARN(HILOG_MODULE_APP, "provisionPermissions is not match the bundle reqPermissions!"); return false; diff --git a/services/bundlemgr_lite/src/bundle_manager_service.cpp b/services/bundlemgr_lite/src/bundle_manager_service.cpp index fd5bf03..8fab372 100644 --- a/services/bundlemgr_lite/src/bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/bundle_manager_service.cpp @@ -672,10 +672,9 @@ static int32_t GenerateInnerUid(std::map &innerMap, const std: } int32_t ret = 0; for (int32_t i = 0; i < innerMap.rbegin()->first; ++i) { - if (innerMap.find(i) == innerMap.end()) { - innerMap.emplace(i, bundleName); - ret = i + baseUid; - return ret; + auto res = innerMap.emplace(i, bundleName); + if (res.second) { + return i + baseUid; } } diff --git a/services/bundlemgr_lite/src/bundle_ms_feature.cpp b/services/bundlemgr_lite/src/bundle_ms_feature.cpp index eea762a..a26c874 100644 --- a/services/bundlemgr_lite/src/bundle_ms_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_ms_feature.cpp @@ -122,13 +122,6 @@ BOOL BundleMsFeature::OnFeatureMessage(Feature *feature, Request *request) return TRUE; } -static void InnerFreeDataBuff(void *ptr) -{ - if (ptr != nullptr) { - cJSON_free(ptr); - } -} - uint8_t BundleMsFeature::HasSystemCapability(const uint8_t funcId, IpcIo *req, IpcIo *reply) { if ((req == nullptr) || (reply == nullptr)) { diff --git a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp index cfc0de1..650e58b 100755 --- a/services/bundlemgr_lite/src/gt_bundle_extractor.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_extractor.cpp @@ -109,7 +109,7 @@ char *GtBundleExtractor::ExtractHapProfile(int32_t fp, uint32_t totalFileSize) } int32_t fileNameLen = strlen(fileName); - if (pathLen == 0 && (fileName != nullptr && strcmp(fileName, PROFILE_NAME) == 0)) { + if (pathLen == 0 && (strcmp(fileName, PROFILE_NAME) == 0)) { UI_Free(fileName); fileName = nullptr; fileData = reinterpret_cast(AdapterMalloc(fileSize * sizeof(char))); diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 1c1bfb3..3392dce 100755 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -109,8 +109,7 @@ uint8_t GtBundleInstaller::VerifySignature(const char *path, SignatureInfo &sign VerifyResult verifyResult; // verify signature (void) APPVERI_SetDebugMode(true); - int32_t ret = (bundleStyle == THIRD_APP_FLAG) ? APPVERI_AppVerify(path, &verifyResult) : - APPVERI_AppVerify(path, &verifyResult); + int32_t ret = APPVERI_AppVerify(path, &verifyResult); HILOG_INFO(HILOG_MODULE_AAFWK, "[BMS] APPVERI_AppVerify is %d", ret); uint8_t errorCode = SwitchErrorCode(ret); if (errorCode != ERR_OK) { @@ -523,9 +522,6 @@ uint8_t GtBundleInstaller::UpdateBundleInfo(uint8_t bundleStyle, uint32_t labelI if (bundleStyle == SYSTEM_APP_FLAG) { bundleInfo->isSystemApp = true; GtManagerService::GetInstance().AddBundleInfo(bundleInfo); - } else if (bundleStyle == THIRD_SYSTEM_APP_FLAG) { - bundleInfo->isSystemApp = false; - GtManagerService::GetInstance().AddBundleInfo(bundleInfo); } else { bundleInfo->isSystemApp = false; GtManagerService::GetInstance().AddBundleInfo(bundleInfo); diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index d5bb5fc..2d35f6f 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -317,6 +317,9 @@ void GtManagerService::InstallAllSystemBundle(InstallerCallback installerCallbac AppInfoList *currentNode = nullptr; AppInfoList *nextNode = nullptr; LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(currentNode, nextNode, &list->appDoubleList, AppInfoList, appDoubleList) { + if (currentNode == nullptr) { + return; + } if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { continue; @@ -411,10 +414,12 @@ void GtManagerService::RemoveSystemAppPathList(List *systemP for (auto node = systemPathList->Begin(); node != systemPathList->End(); node = node->next_) { ToBeInstalledApp *toBeInstalledApp = node->value_; - AdapterFree(toBeInstalledApp->installedPath); - AdapterFree(toBeInstalledApp->path); - AdapterFree(toBeInstalledApp->appId); - UI_Free(toBeInstalledApp); + if (toBeInstalledApp != nullptr) { + AdapterFree(toBeInstalledApp->installedPath); + AdapterFree(toBeInstalledApp->path); + AdapterFree(toBeInstalledApp->appId); + UI_Free(toBeInstalledApp); + } } } @@ -433,6 +438,9 @@ void GtManagerService::ScanSystemApp(const cJSON *uninstallRecord, ListappDoubleList, AppInfoList, appDoubleList) { + if (currentNode == nullptr) { + return; + } if ((strcmp(((AppInfoList *)currentNode)->filePath, ".") == 0) || (strcmp(((AppInfoList *)currentNode)->filePath, "..") == 0)) { continue; @@ -696,6 +704,9 @@ void GtManagerService::RemoveBundleResList(const char *bundleName) for (auto node = bundleResList_->Begin(); node != bundleResList_->End(); node = node->next_) { BundleRes *res = node->value_; + if (res == nullptr) { + return; + } if (res->bundleName != nullptr && strcmp(bundleName, res->bundleName) == 0) { AdapterFree(res->abilityRes); AdapterFree(res); @@ -997,6 +1008,9 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) return; } char *fileName = reinterpret_cast(AdapterMalloc(MAX_NAME_LEN + 1)); + if (fileName == nullptr) { + return; + } while ((ent = readdir(dir)) != nullptr) { if (memset_s(fileName, MAX_NAME_LEN + 1, 0, MAX_NAME_LEN + 1) != EOK) { break; @@ -1029,6 +1043,7 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) APP_InsertAppInfo(appPath, (AppInfoList *)&list->appDoubleList); AdapterFree(appPath); } + closedir(dir); AdapterFree(fileName); } -- Gitee From dce3b376aba7e15580d256d73b4c1bd16f8687cb Mon Sep 17 00:00:00 2001 From: shilei Date: Mon, 26 Sep 2022 22:29:34 +0800 Subject: [PATCH 07/12] fix problem Signed-off-by: shilei --- frameworks/bundle_lite/src/bundle_manager.cpp | 9 +++++++-- .../bundlemgr_lite/src/gt_bundle_manager_service.cpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index 205080d..eb76e00 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -602,9 +602,14 @@ static uint8_t ObtainBundleInfosOneByOne(BasicInfo basicInfo, int32_t len, uint8 int32_t ret = bmsClient->Invoke(bmsClient, GET_BUNDLE_INFO_BY_INDEX, &innerIpcIo, &resultOfGetBundleInfo, Notify); if (ret != OHOS_SUCCESS) { - HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d\n", ret); + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne invoke failed: %{public}d", ret); return ERR_APPEXECFWK_INVOKE_ERROR; } + if (resultOfGetBundleInfo.bundleInfo == nullptr) { + HILOG_ERROR(HILOG_MODULE_APP, "BundleManager ObtainBundleInfosOneByOne failed: %{public}d", + resultOfGetBundleInfo.resultCode); + return resultOfGetBundleInfo.resultCode; + } OHOS::BundleInfoUtils::CopyBundleInfo(basicInfo.flags, *bundleInfos + i, *(resultOfGetBundleInfo.bundleInfo)); ClearBundleInfo(resultOfGetBundleInfo.bundleInfo); AdapterFree(resultOfGetBundleInfo.bundleInfo); @@ -661,7 +666,7 @@ static uint8_t ObtainBundleInfos(BasicInfo basicInfo, BundleInfo **bundleInfos, } *len = resultOfGetBundleInfos.length; OHOS::BundleInfoUtils::FreeBundleInfos(resultOfGetBundleInfos.bundleInfo, resultOfGetBundleInfos.length); - return resultOfGetBundleInfos.resultCode; + return res; } uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len) diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 2d35f6f..4b00319 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -1009,6 +1009,7 @@ void GtManagerService::APP_QueryAppInfo(const char *appDir, AppInfoList *list) } char *fileName = reinterpret_cast(AdapterMalloc(MAX_NAME_LEN + 1)); if (fileName == nullptr) { + closedir(dir); return; } while ((ent = readdir(dir)) != nullptr) { -- Gitee From 8a1055e5dede2ddc3e9b7e54847fe2d61ad7a078 Mon Sep 17 00:00:00 2001 From: shilei Date: Tue, 27 Sep 2022 19:31:23 +0800 Subject: [PATCH 08/12] sync code Signed-off-by: shilei --- services/bundlemgr_lite/src/bundle_parser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/bundlemgr_lite/src/bundle_parser.cpp b/services/bundlemgr_lite/src/bundle_parser.cpp index 530b774..de1c6d1 100755 --- a/services/bundlemgr_lite/src/bundle_parser.cpp +++ b/services/bundlemgr_lite/src/bundle_parser.cpp @@ -711,8 +711,9 @@ uint8_t BundleParser::ParseAbilityDeviceCap(const cJSON *abilityObjectItem, Abil continue; } deviceCapName = abilityInfo.deviceCap.systemCapName + index; - if (strncpy_s(deviceCapName->name, sizeof(deviceCapName->name), - deviceCapObject->valuestring, strlen(deviceCapObject->valuestring)) != EOK) { + if ((deviceCapObject->valuestring != nullptr) && + (strncpy_s(deviceCapName->name, sizeof(deviceCapName->name), + deviceCapObject->valuestring, strlen(deviceCapObject->valuestring)) != EOK)) { HILOG_ERROR(HILOG_MODULE_APP, "ParseAbilityDeviceCap strncpy deviceCap fail!"); AdapterFree(abilityInfo.deviceCap.systemCapName); abilityInfo.deviceCap.systemCapNum = 0; -- Gitee From fb54dc0e6f35b400cc654380b1fde7189ff49773 Mon Sep 17 00:00:00 2001 From: shilei Date: Tue, 27 Sep 2022 21:52:28 +0800 Subject: [PATCH 09/12] fix problem Signed-off-by: shilei --- frameworks/bundle_lite/src/bundle_manager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frameworks/bundle_lite/src/bundle_manager.cpp b/frameworks/bundle_lite/src/bundle_manager.cpp index eb76e00..44d1c4a 100644 --- a/frameworks/bundle_lite/src/bundle_manager.cpp +++ b/frameworks/bundle_lite/src/bundle_manager.cpp @@ -681,12 +681,17 @@ uint8_t GetBundleInfos(const int flags, BundleInfo **bundleInfos, int32_t *len) IpcIo ipcIo; char data[MAX_IO_SIZE]; IpcIoInit(&ipcIo, data, MAX_IO_SIZE, 0); +#ifdef __LINUX__ + WriteInt32(&ipcIo, flags); + return ObtainInnerBundleInfos(flags, bundleInfos, len, GET_BUNDLE_INFOS, &ipcIo); +#else WriteInt32(&ipcIo, GET_BUNDLE_INFOS); WriteInt32(&ipcIo, flags); BasicInfo basicInfo; basicInfo.flags = flags; basicInfo.metaDataKey = nullptr; return ObtainBundleInfos(basicInfo, bundleInfos, len, GET_BUNDLE_INFOS, &ipcIo); +#endif } uint32_t GetBundleSize(const char *bundleName) -- Gitee From 7ae4ad7284a1bfcb5d017859022f5bab90d66ab9 Mon Sep 17 00:00:00 2001 From: shilei Date: Tue, 18 Oct 2022 12:51:14 +0800 Subject: [PATCH 10/12] add' Signed-off-by: shilei --- .../bundle_lite/src/slite/bundlems_slite_client.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index fe13706..5aa81a6 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -159,6 +159,9 @@ uint8_t BundleMsClient::QueryAbilityInfo (const Want *want, AbilityInfo *ability uint8_t BundleMsClient::GetBundleInfo (const char *bundleName, int32_t flags, BundleInfo *bundleInfo) const { + if ((bundleName == nullptr) || (bundleInfo == nullptr)) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } if (!Initialize()) { return -1; } @@ -167,6 +170,12 @@ uint8_t BundleMsClient::GetBundleInfo (const char *bundleName, int32_t flags, Bu uint8_t BundleMsClient::GetBundleInfos (int32_t flags, BundleInfo **bundleInfos, int32_t *len) const { + if (bundleInfos == nullptr) { + return ERR_APPEXECFWK_QUERY_PARAMETER_ERROR; + } + if (len == nullptr) { + return ERR_APPEXECFWK_QUERY_NO_INFOS; + } if (!Initialize()) { return -1; } -- Gitee From 9cfa9eb84d38ec5ee4137e783800fbebe0edcca4 Mon Sep 17 00:00:00 2001 From: shilei Date: Sat, 29 Oct 2022 15:13:08 +0800 Subject: [PATCH 11/12] fixed 30e1f9c from https://gitee.com/shilei91/bundlemanager_bundle_framework_lite/pulls/217 add Signed-off-by: shilei Change-Id: Ia4444a26a37465ebdaa1f2e8ddbf448da026c846 --- services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp index 2e1d201..b54f29c 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -54,7 +54,6 @@ static void Init() BOOL apiResult = samgrLite->RegisterFeatureApi(BMS_SERVICE, BMS_SLITE_FEATURE, publicApi); PRINTI("BundleMgrSliteFeature", "bms feature init %{public}s", apiResult ? "success" : "failure"); } -SYSEX_FEATURE_INIT(Init); BundleMgrSliteFeature::BundleMgrSliteFeature() : Feature(), identity_() { -- Gitee From 042a5f1b047cde1f933a1af3ea6110a43ece6161 Mon Sep 17 00:00:00 2001 From: shilei Date: Sat, 29 Oct 2022 14:44:55 +0800 Subject: [PATCH 12/12] fixed d3beafa from https://gitee.com/shilei91/bundlemanager_bundle_framework_lite/pulls/217 add Signed-off-by: shilei Change-Id: Icfff4ccced72857558c9d560c4460f79ed3d63ae --- frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp | 1 + services/bundlemgr_lite/include/bundle_mgr_service.h | 1 - services/bundlemgr_lite/include/bundle_mgr_slite_feature.h | 1 + services/bundlemgr_lite/src/bundle_mgr_service.cpp | 2 ++ services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp | 2 +- 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp index 5aa81a6..add659c 100755 --- a/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp +++ b/frameworks/bundle_lite/src/slite/bundlems_slite_client.cpp @@ -27,6 +27,7 @@ #include "want_utils.h" namespace OHOS { +const unsigned int BMS_INSTALL_MSG = 100; const unsigned int ERROR_SLEEP_TIMES = 300; const unsigned int RETRY_TIMES = 10; Bmsbuff *g_bmsbuff = nullptr; diff --git a/services/bundlemgr_lite/include/bundle_mgr_service.h b/services/bundlemgr_lite/include/bundle_mgr_service.h index 7bbcc5a..fcddf8e 100755 --- a/services/bundlemgr_lite/include/bundle_mgr_service.h +++ b/services/bundlemgr_lite/include/bundle_mgr_service.h @@ -21,7 +21,6 @@ #include "nocopyable.h" namespace OHOS { -const unsigned int BMS_INSTALL_MSG = 100; const unsigned int BMS_UNINSTALL_MSG = 101; const unsigned int BMS_SCAN_PACKAGE_MSG = 102; const unsigned int BMS_REGISTER_CALLBACK_MSG = 103; diff --git a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h index d9ff3bc..7e94047 100755 --- a/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h +++ b/services/bundlemgr_lite/include/bundle_mgr_slite_feature.h @@ -40,6 +40,7 @@ public: static bool RegisterInstallerCallback(InstallerCallback installerCallback); static void UpdateBundleInfoList(); static uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len); + static void Init(); static BundleMgrSliteFeature *GetInstance() { diff --git a/services/bundlemgr_lite/src/bundle_mgr_service.cpp b/services/bundlemgr_lite/src/bundle_mgr_service.cpp index 72c9676..475a288 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_service.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_service.cpp @@ -17,6 +17,7 @@ #include "bundle_service_interface.h" #include "bundlems_log.h" +#include "bundle_mgr_slite_feature.h" #include "gt_bundle_manager_service.h" #include "ohos_init.h" #include "samgr_lite.h" @@ -40,6 +41,7 @@ static void Init() CHECK_NULLPTR_RETURN(sm, "BundleManagerService", "get samgr error"); #ifdef __LITEOS_M__ sm->RegisterService(BundleMgrService::GetInstance()); + BundleMgrSliteFeature::Init(); #else BOOL result = sm->RegisterService(BundleMgrService::GetInstance()); PRINTI("BundleManagerService", "bms starts %{public}s", result ? "successfully" : "unsuccessfully"); diff --git a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp index b54f29c..c76e1a0 100755 --- a/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_mgr_slite_feature.cpp @@ -39,7 +39,7 @@ BundleMgrSliteFeatureImpl g_bmsSliteImpl = { DEFAULT_IUNKNOWN_ENTRY_END }; -static void Init() +void BundleMgrSliteFeature::Init() { SamgrLite *samgrLite = SAMGR_GetInstance(); CHECK_NULLPTR_RETURN(samgrLite, "BundleMgrSliteFeature", "get samgr error"); -- Gitee