1 /* 2 * Copyright (c) 2020-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_BUNDLEINFO_UTILS_H 17 #define OHOS_BUNDLEINFO_UTILS_H 18 19 #include "bundle_info.h" 20 #ifdef _MINI_BMS_PARSE_METADATA_ 21 #include "bundle_common.h" 22 #endif 23 24 namespace OHOS { 25 struct BundleInfoUtils { 26 static void CopyBundleInfo(int32_t flags, BundleInfo *des, BundleInfo src); 27 static void CopyBundleInfoNoReplication(int32_t flags, BundleInfo *des, BundleInfo src); 28 static bool SetBundleInfoBundleName(BundleInfo *bundleInfo, const char *bundleName); 29 static bool SetBundleInfoVendor(BundleInfo *bundleInfo, const char *vendor); 30 static bool SetBundleInfoLabel(BundleInfo *bundleInfo, const char *label); 31 static bool SetBundleInfoVersionName(BundleInfo *bundleInfo, const char *versionName); 32 static bool SetBundleInfoBigIconPath(BundleInfo *bundleInfo, const char *bigIconPath); 33 static bool SetBundleInfoCodePath(BundleInfo *bundleInfo, const char *codePath); 34 static bool SetBundleInfoDataPath(BundleInfo *bundleInfo, const char *dataPath); 35 static bool SetBundleInfoModuleInfos(BundleInfo *bundleInfo, const ModuleInfo *moduleInfos, uint32_t numOfModule); 36 static void ClearModuleInfos(ModuleInfo *moduleInfos, uint32_t numOfModule); 37 static void FreeBundleInfos(BundleInfo *bundleInfos, uint32_t len); 38 static void FreeBundleInfo(BundleInfo *bundleInfo); 39 static bool SetBundleInfoAppId(BundleInfo *bundleInfo, const char *appId); 40 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER 41 static bool SetBundleInfoAbilityInfos(BundleInfo *bundleInfo, const AbilityInfo *abilityInfos, 42 uint32_t numOfAbility); 43 static void ClearAbilityInfos(AbilityInfo *abilityInfos, uint32_t numOfAbility); 44 #else 45 static bool SetBundleInfoSmallIconPath(BundleInfo *bundleInfo, const char *smallIconPath); 46 static bool SetBundleInfoAbilityInfo(BundleInfo *bundleInfo, const AbilityInfo &abilityInfo); 47 #ifdef _MINI_BMS_PARSE_METADATA_ 48 static bool SetBundleInfoAbilityInfo(BundleInfo *bundleInfo, const AbilityInfo &abilityInfo, 49 const BundleProfile &bundleProfile); 50 #endif 51 #endif 52 private: 53 BundleInfoUtils() = default; 54 ~BundleInfoUtils() = default; 55 }; // BundleInfoUtils 56 } // OHOS 57 #endif // OHOS_BUNDLEINFO_UTILS_H