diff --git a/interfaces/kits/bundle_lite/bundle_manager.h b/interfaces/kits/bundle_lite/bundle_manager.h index c55791cab45ca3d7b5fed84e54d7cfe129c35235..39086ae6b95041242cec444df43dd225ba445415 100755 --- a/interfaces/kits/bundle_lite/bundle_manager.h +++ b/interfaces/kits/bundle_lite/bundle_manager.h @@ -94,7 +94,7 @@ int32_t RegisterCallback(BundleStatusCallback *BundleStatusCallback); * @since 1.0 * @version 1.0 */ -int32_t UnregisterCallback(); +int32_t UnregisterCallback(void); /** * @brief Installs or updates an application. @@ -216,6 +216,7 @@ uint8_t GetBundleInfosByMetaData(const char *metaDataKey, BundleInfo **bundleInf */ uint8_t GetBundleNameForUid(int32_t uid, char **bundleName); +#ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER /** * @brief Check if the specify syscap name is supported by the system. * @@ -246,6 +247,17 @@ SystemCapability *GetSystemAvailableCapabilities(); * @version 4 */ void FreeSystemAvailableCapabilitiesInfo(SystemCapability *sysCap); +#endif +/** + * @brief Get bundle size + * + * @param bundleName Indicates the bundle name. + * @return Returns the bundle size (Byte) if this function is successfully called; returns 0 otherwise. + * + * @since 7 + * @version 7 + */ +uint32_t GetBundleSize(const char *bundleName); #ifdef __cplusplus #if __cplusplus } diff --git a/services/bundlemgr_lite/include/bundle_extractor.h b/services/bundlemgr_lite/include/bundle_extractor.h index ade31787fca31e8aad53cc0f6cb7fc2900b6918b..9e969ac0c865d9cbb59b26108eb35b424459f8ab 100755 --- a/services/bundlemgr_lite/include/bundle_extractor.h +++ b/services/bundlemgr_lite/include/bundle_extractor.h @@ -16,9 +16,9 @@ #ifndef OHOS_BUNDLE_EXTRACTOR_H #define OHOS_BUNDLE_EXTRACTOR_H -#include "stdint.h" #include #include +#include "stdint.h" namespace OHOS { class BundleExtractor { diff --git a/services/bundlemgr_lite/include/bundle_installer.h b/services/bundlemgr_lite/include/bundle_installer.h index b9945ff9326ed63b1eecf90a2611ed3a96794f02..c1991e88459bfc888919c9f7618e02c8866ce269 100755 --- a/services/bundlemgr_lite/include/bundle_installer.h +++ b/services/bundlemgr_lite/include/bundle_installer.h @@ -70,9 +70,9 @@ private: #define CHECK_PRO_RESULT(errcode, bundleInfo, permissions, abilityRes) \ do { \ - if (errcode != ERR_OK) { \ + if ((errcode) != ERR_OK) { \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ - AdapterFree(permissions.permissionTrans); \ + AdapterFree((permissions).permissionTrans); \ AdapterFree(abilityRes); \ return errcode; \ } \ @@ -80,19 +80,19 @@ private: #define CLEAR_INSTALL_ENV(bundleInfo) \ do { \ - if (bundleInfo != nullptr) { \ + if ((bundleInfo) != nullptr) { \ BundleDaemonClient::GetInstance().RemoveInstallDirectory( \ - bundleInfo->codePath, bundleInfo->dataPath, false); \ + (bundleInfo)->codePath, (bundleInfo)->dataPath, false); \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ } \ } while (0) #define CHECK_PRO_PART_ROLLBACK(errcode, path, permissions, bundleInfo, abilityRes) \ do { \ - if (errcode != ERR_OK && bundleInfo != nullptr) { \ - BundleDaemonClient::GetInstance().RemoveFile(path.c_str()); \ + if ((errcode) != ERR_OK && (bundleInfo) != nullptr) { \ + BundleDaemonClient::GetInstance().RemoveFile((path).c_str()); \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ - AdapterFree(permissions.permissionTrans); \ + AdapterFree((permissions).permissionTrans); \ AdapterFree(abilityRes); \ return errcode; \ } \ @@ -100,11 +100,11 @@ private: #define CHECK_PRO_ROLLBACK(errcode, permissions, bundleInfo, abilityRes, randStr) \ do { \ - if (errcode != ERR_OK && bundleInfo != nullptr) { \ - AdapterFree(permissions.permissionTrans); \ + if ((errcode) != ERR_OK && (bundleInfo) != nullptr) { \ + AdapterFree((permissions).permissionTrans); \ AdapterFree(abilityRes); \ - ManagerService::GetInstance().RemoveBundleInfo(bundleInfo->bundleName); \ - BundleUtil::DeleteJsonFile(bundleInfo->bundleName, randStr); \ + ManagerService::GetInstance().RemoveBundleInfo((bundleInfo)->bundleName); \ + BundleUtil::DeleteJsonFile((bundleInfo)->bundleName, randStr); \ CLEAR_INSTALL_ENV(bundleInfo); \ return errcode; \ } \ diff --git a/services/bundlemgr_lite/include/bundle_parser.h b/services/bundlemgr_lite/include/bundle_parser.h index 51dfa6637c06dc8033068604ec9d55af89a2251a..4c29d5804e5a630ac6cbc539d57485c527a1db65 100755 --- a/services/bundlemgr_lite/include/bundle_parser.h +++ b/services/bundlemgr_lite/include/bundle_parser.h @@ -71,14 +71,14 @@ private: #define CHECK_NULL(object, errorCode) \ do { \ - if (object == nullptr) { \ + if ((object) == nullptr) { \ return errorCode; \ } \ } while (0) #define CHECK_LENGTH(length, maxLength, errorCode) \ do { \ - if (length > maxLength) { \ + if ((length) > (maxLength)) { \ return errorCode; \ } \ } while (0) @@ -92,19 +92,19 @@ private: #define CHECK_PARSE_RESULT(errorCode, object, bundleProfile) \ do { \ - if (errorCode != ERR_OK) { \ + if ((errorCode) != ERR_OK) { \ FREE_BUNDLE_PROFILE(bundleProfile); \ cJSON_Delete(object); \ return errorCode; \ } \ } while (0) -#define FREE_BUNDLE_PROFILE(bundleProfile) \ - do { \ - AdapterFree(bundleProfile.abilityInfos); \ - for (uint8_t i = 0; i < METADATA_SIZE; i++) { \ - AdapterFree(bundleProfile.moduleInfo.metaData[i]); \ - } \ +#define FREE_BUNDLE_PROFILE(bundleProfile) \ + do { \ + AdapterFree((bundleProfile).abilityInfos); \ + for (uint8_t i = 0; i < METADATA_SIZE; i++) { \ + AdapterFree((bundleProfile).moduleInfo.metaData[i]); \ + } \ } while (0) } // namespace OHOS #endif // OHOS_BUNDLE_PARSER_H diff --git a/services/bundlemgr_lite/include/bundlems_log.h b/services/bundlemgr_lite/include/bundlems_log.h index 933673cafb2c22485a15dbc0ce8bc71e3e8f1d3e..2f4fde26bacc7b73269ad9b8942de6c19440bd1c 100755 --- a/services/bundlemgr_lite/include/bundlems_log.h +++ b/services/bundlemgr_lite/include/bundlems_log.h @@ -64,7 +64,7 @@ namespace OHOS { #define CHECK_NULLPTR_RETURN_PTR(point, name, fmt) \ do { \ - if (point == nullptr) { \ + if ((point) == nullptr) { \ PRINTE(name, fmt); \ return nullptr; \ } \ @@ -72,7 +72,7 @@ namespace OHOS { #define CHECK_NULLPTR_RETURN(point, name, fmt) \ do { \ - if (point == nullptr) { \ + if ((point) == nullptr) { \ PRINTE(name, fmt); \ return; \ } \ @@ -80,7 +80,7 @@ namespace OHOS { #define CHECK_NULLPTR_RETURN_CODE(point, name, fmt, code) \ do { \ - if (point == nullptr) { \ + if ((point) == nullptr) { \ PRINTE(name, fmt); \ return code; \ } \ diff --git a/services/bundlemgr_lite/include/gt_bundle_installer.h b/services/bundlemgr_lite/include/gt_bundle_installer.h index ed558e541c792c9ae8ebaf0372c50a78b7fb5ff5..098d3863e30b0f15f4213ac3673dfbf89f180792 100755 --- a/services/bundlemgr_lite/include/gt_bundle_installer.h +++ b/services/bundlemgr_lite/include/gt_bundle_installer.h @@ -75,19 +75,19 @@ private: close(fp); \ } \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ - UI_Free(permissions.permissionTrans); \ + UI_Free((permissions).permissionTrans); \ } while (0) -#define FREE_SIGNATUREINFO(signatureInfo) \ - do { \ - AdapterFree(signatureInfo.appId); \ - AdapterFree(signatureInfo.bundleName); \ - BundleUtil::FreeStrArrayMemory(signatureInfo.restricPermission, signatureInfo.restricNum); \ +#define FREE_SIGNATUREINFO(signatureInfo) \ + do { \ + AdapterFree(signatureInfo.appId); \ + AdapterFree(signatureInfo.bundleName); \ + BundleUtil::FreeStrArrayMemory((signatureInfo).restricPermission, (signatureInfo).restricNum); \ } while (0) #define CHECK_PRO_RESULT(errcode, fp, permissions, bundleInfo, signatureInfo) \ do { \ - if (errcode != ERR_OK) { \ + if ((errcode) != ERR_OK) { \ FREE_PRO_RESOURCE(fp, permissions, bundleInfo); \ FREE_SIGNATUREINFO(signatureInfo); \ return errcode; \ @@ -97,31 +97,31 @@ private: #define CLEAR_INSTALL_ENV(bundleInfo) \ do { \ if (bundleInfo != nullptr) { \ - BundleUtil::RemoveDir(bundleInfo->codePath); \ - BundleUtil::RemoveDir(bundleInfo->dataPath); \ + BundleUtil::RemoveDir((bundleInfo)->codePath); \ + BundleUtil::RemoveDir((bundleInfo)->dataPath); \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ } \ } while (0) #define CHECK_PRO_PART_ROLLBACK(errcode, path, permissions, bundleInfo, signatureInfo) \ do { \ - if (errcode != ERR_OK) { \ + if ((errcode) != ERR_OK) { \ BundleUtil::RemoveDir(path); \ AdapterFree(path); \ BundleInfoUtils::FreeBundleInfo(bundleInfo); \ FREE_SIGNATUREINFO(signatureInfo); \ - UI_Free(permissions.permissionTrans); \ + UI_Free((permissions).permissionTrans); \ return errcode; \ } \ } while (0) #define CHECK_PRO_ROLLBACK(errcode, permissions, bundleInfo, signatureInfo, randStr) \ do { \ - if (errcode != ERR_OK && bundleInfo != nullptr) { \ + if ((errcode) != ERR_OK && (bundleInfo) != nullptr) { \ FREE_SIGNATUREINFO(signatureInfo); \ UI_Free(permissions.permissionTrans); \ GtManagerService::GetInstance().RemoveBundleInfo(bundleInfo->bundleName); \ - BundleUtil::DeleteJsonFile(bundleInfo->bundleName, randStr); \ + BundleUtil::DeleteJsonFile((bundleInfo)->bundleName, randStr); \ CLEAR_INSTALL_ENV(bundleInfo); \ return errcode; \ } \ diff --git a/services/bundlemgr_lite/include/gt_bundle_parser.h b/services/bundlemgr_lite/include/gt_bundle_parser.h index be0443fdbbd01d6d64d68a17bafcf115df1e9669..807f6b4af06168436caf6058c63d8cff5b236b5a 100644 --- a/services/bundlemgr_lite/include/gt_bundle_parser.h +++ b/services/bundlemgr_lite/include/gt_bundle_parser.h @@ -56,21 +56,21 @@ private: #define CHECK_NULL(object, errorCode) \ do { \ - if (object == nullptr) { \ + if ((object) == nullptr) { \ return errorCode; \ } \ } while (0) #define CHECK_LENGTH(length, maxLength, errorCode) \ do { \ - if (length > maxLength) { \ + if ((length) > (maxLength)) { \ return errorCode; \ } \ } while (0) #define CHECK_IS_TRUE(result, errorCode) \ do { \ - if (!result) { \ + if (!(result)) { \ return errorCode; \ } \ } while (0) @@ -78,20 +78,20 @@ private: #define FREE_BUNDLE_PROFILE(bundleProfile) \ do { \ for (int32_t i = 0; i < METADATA_SIZE; i++) { \ - AdapterFree(bundleProfile.moduleInfo.metaData[i]); \ + AdapterFree((bundleProfile).moduleInfo.metaData[i]); \ } \ } while (0) #define FREE_BUNDLE_RES(bundleRes) \ do { \ - if (bundleRes.abilityRes != nullptr) { \ - AdapterFree(bundleRes.abilityRes); \ + if ((bundleRes).abilityRes != nullptr) { \ + AdapterFree((bundleRes).abilityRes); \ } \ } while (0) #define CHECK_PARSE_RESULT(errorCode, object, bundleProfile, bundleRes) \ do { \ - if (errorCode != ERR_OK) { \ + if ((errorCode) != ERR_OK) { \ FREE_BUNDLE_PROFILE(bundleProfile); \ FREE_BUNDLE_RES(bundleRes); \ cJSON_Delete(object); \ diff --git a/services/bundlemgr_lite/src/bundle_ms_feature.cpp b/services/bundlemgr_lite/src/bundle_ms_feature.cpp index 6edbe6cfcd9db52ea606524292a518bc1e4cc8b1..e94e85a18cf6891f7c9000369c3e5bda3b841897 100755 --- a/services/bundlemgr_lite/src/bundle_ms_feature.cpp +++ b/services/bundlemgr_lite/src/bundle_ms_feature.cpp @@ -117,7 +117,7 @@ BOOL BundleMsFeature::OnFeatureMessage(Feature *feature, Request *request) return TRUE; } -void static InnerFreeDataBuff(void *ptr) +static void InnerFreeDataBuff(void *ptr) { if (ptr != nullptr) { cJSON_free(ptr); diff --git a/services/bundlemgr_lite/src/bundle_util.cpp b/services/bundlemgr_lite/src/bundle_util.cpp index 745816180b3f29306e264befbd96437a8059a4a2..aaa4b57f96c3d766d464e479548279b2a0f0bcda 100755 --- a/services/bundlemgr_lite/src/bundle_util.cpp +++ b/services/bundlemgr_lite/src/bundle_util.cpp @@ -27,16 +27,16 @@ #include #include "bundle_daemon_client.h" #else +#include #include "adapter.h" #include "bundlems_log.h" #include "dirent.h" #include "fcntl.h" #include "los_tick.h" -#include "stdio.h" #include "sys/stat.h" #include "unistd.h" #endif -#include +#include #include "utils.h" namespace OHOS { diff --git a/services/bundlemgr_lite/src/gt_bundle_installer.cpp b/services/bundlemgr_lite/src/gt_bundle_installer.cpp index 69eeefcd9b7d94ebcd3e7dbe29b2ff93c20b3a2d..29ec26e7188b7c7ee3c9d6981cc4fce7744f16cc 100755 --- a/services/bundlemgr_lite/src/gt_bundle_installer.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_installer.cpp @@ -22,6 +22,7 @@ extern "C" { #ifdef __cplusplus } #endif +#include #include "appexecfwk_errors.h" #include "bundle_util.h" #include "bundlems_log.h" @@ -31,7 +32,6 @@ extern "C" { #include "gt_bundle_extractor.h" #include "gt_bundle_manager_service.h" #include "gt_bundle_parser.h" -#include "stdio.h" #include "sys/stat.h" #include "unistd.h" #include "utils.h" diff --git a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp index 4d9e53477c7b7138fb5d0ea3696519ccf682a059..f144658a22b80a6cc3ee2a7c13a5f129566c09c7 100755 --- a/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp +++ b/services/bundlemgr_lite/src/gt_bundle_manager_service.cpp @@ -15,6 +15,7 @@ #include "gt_bundle_manager_service.h" +#include #include "ability_info_utils.h" #include "ability_message_id.h" #include "appexecfwk_errors.h" @@ -30,7 +31,6 @@ #include "gt_extractor_util.h" #include "jerryscript_adapter.h" #include "los_tick.h" -#include "stdio.h" #include "sys/stat.h" #include "unistd.h" #include "utils.h" diff --git a/services/bundlemgr_lite/src/gt_extractor_util.cpp b/services/bundlemgr_lite/src/gt_extractor_util.cpp index 02ab2c566996892d3cb321ef7ba8da28adf0f424..9ab5c72361c829bf989aa2edf319b296ea613cf5 100755 --- a/services/bundlemgr_lite/src/gt_extractor_util.cpp +++ b/services/bundlemgr_lite/src/gt_extractor_util.cpp @@ -15,14 +15,14 @@ #include "gt_extractor_util.h" -#include +#include +#include #include "appexecfwk_errors.h" #include "bundle_common.h" #include "bundle_util.h" #include "bundlems_log.h" #include "dirent.h" #include "fcntl.h" -#include "stdio.h" #include "sys/stat.h" #include "unistd.h" #include "utils.h" diff --git a/services/bundlemgr_lite/src/zip_file.cpp b/services/bundlemgr_lite/src/zip_file.cpp index ef9452992822b319db0908554ce89a41ba50af98..294518ce7b006cc60d923e253b433930e9b77161 100755 --- a/services/bundlemgr_lite/src/zip_file.cpp +++ b/services/bundlemgr_lite/src/zip_file.cpp @@ -26,12 +26,12 @@ namespace OHOS { namespace { -#define ZIPPOS_ADD_AND_CHECK_OVERFLOW(first, second, sum) \ -{ \ - if ((second > 0) && (first > (std::numeric_limits::max() - second))) { \ - return false; \ - } \ - sum = first + second; \ +#define ZIPPOS_ADD_AND_CHECK_OVERFLOW(first, second, sum) \ +{ \ + if (((second) > 0) && ((first) > (std::numeric_limits::max() - (second)))) { \ + return false; \ + } \ + (sum) = (first) + (second); \ } constexpr uint32_t MAX_FILE_NAME = 256; diff --git a/utils/bundle_lite/adapter.h b/utils/bundle_lite/adapter.h index 0f53edb9dcb0aa64185fbf127eb1bf6c608cd282..2ecd0386df3864dffd4529aa25480b25b7259668 100755 --- a/utils/bundle_lite/adapter.h +++ b/utils/bundle_lite/adapter.h @@ -32,8 +32,8 @@ #define AdapterMalloc(a) malloc(a) #define AdapterFree(a) \ do { \ - if (a != nullptr) { \ - (void) free((void *)a); \ + if ((a) != nullptr) { \ + (void) free((void *)(a)); \ a = nullptr; \ } \ } while (0)