• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_PACK_INFO_UTILS_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_PACK_INFO_UTILS_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "pack_info.h"
23 #include "pt_json.h"
24 
25 namespace OHOS {
26 namespace AppPackingTool {
27 
28 class PackInfoUtils {
29 public:
PackInfoUtils()30     PackInfoUtils() {};
~PackInfoUtils()31     virtual ~PackInfoUtils() {};
32 
33     PackInfoUtils(const PackInfoUtils &) = delete;
34     PackInfoUtils &operator=(const PackInfoUtils &) = delete;
35 
36     static bool MergeTwoPackInfos(const std::string& srcPackInfoJsonStr1, const std::string& srcPackInfoJsonStr2,
37         std::string& dstPackInfoJsonStr);
38     static bool MergeTwoPackInfosByPackagePair(const std::string& srcPackInfoJsonStr1,
39         const std::string& srcPackInfoJsonStr2, const std::map<std::string, std::string>& packagesMap,
40         std::string& dstPackInfoJsonStr);
41 
42 private:
43     static bool MergeTwoPackInfos(PackInfo& srcPackInfo1, PackInfo& srcPackInfo2);
44     static bool MergeTwoPackInfosByPackagePair(PackInfo& srcPackInfo1, PackInfo& srcPackInfo2,
45         const std::string& packageName, const std::string& moduleName);
46     static bool FindAndMergeModulesByPackagePair(PackInfo& srcPackInfo1, PackInfo& srcPackInfo2,
47         const std::string& moduleName);
48     static bool FindAndMergePackagesByPackagePair(PackInfo& srcPackInfo1, PackInfo& srcPackInfo2,
49         const std::string& packageName);
50     static bool VerifyPackInfos(const PackInfo& finalPackInfo, const PackInfo& srcPackInfo);
51     static bool CheckBundleNameInPackInfo(const PackInfo& packInfo1, const PackInfo& packInfo2);
52     static bool CheckBundleTypeInPackInfo(const PackInfo& packInfo1, const PackInfo& packInfo2);
53     static bool CheckVersionCodeInPackInfo(const PackInfo& packInfo1, const PackInfo& packInfo2);
54 };
55 }  // namespace AppPackingTool
56 }  // namespace OHOS
57 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_MODULE_JSON_UTILS_H
58