• 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_MULTIAPP_PACKAGER_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_MULTIAPP_PACKAGER_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "packager.h"
23 #include "zip_wrapper.h"
24 
25 namespace OHOS {
26 namespace AppPackingTool {
27 
28 class MultiAppPackager : public Packager {
29 public:
30     MultiAppPackager(const std::map<std::string, std::string> &parameterMap, std::string &resultReceiver);
~MultiAppPackager()31     ~MultiAppPackager() override {}
32     bool IsVerifyValidInMultiAppMode();
33     bool CompressAppModeForMultiProject();
34     bool PrepareFilesForCompression(std::list<std::string> &fileList, fs::path &tempHapDirPath,
35         fs::path &tempSelectedHapDirPath, std::string &finalPackInfoStr, std::string &finalPackInfoPath);
36     std::string GetJsonInZips(const std::string &filePath, const std::string &jsonName);
37     std::string ReadModuleNameFromHap(const std::string &hapPath);
38     std::string SelectHapInApp(const std::string &appPath, std::list<std::string> &selectedHaps,
39         const std::string &tempDir, std::string &finalAppPackInfo);
40     std::string DisposeApp(std::list<std::string> &selectedHaps, const std::string &tempDir);
41     std::string DisposeHapAndHsp(std::list<std::string> &selectedHaps,
42         const std::string &tempDir, std::string finalPackInfoStr);
43     bool CopyHapAndHspFromApp(const std::string &appPath, std::list<std::string> &selectedHapsInApp,
44         std::list<std::string> &selectedHaps, const std::string &tempDir);
45     void WritePackInfo(const std::string &filePath, const std::string &packInfoStr);
46     bool GetAndCheckOutPath(std::string &outPath);
47     bool GetAndCheckHapAndHspAndAppListStr(std::string &hapListStr, std::string &hspListStr, std::string &appListStr);
48 
49 protected:
50     int32_t InitAllowedParam() override;
51     int32_t PreProcess() override;
52     int32_t Process() override;
53     int32_t PostProcess() override;
54 
55 private:
56     ZipWrapper zipWrapper_;
57     std::list<std::string> formattedAppList_;
58     std::list<std::string> formattedHapAndHspList_;
59 };
60 }  // namespace AppExecFwk
61 }  // namespace OHOS
62 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_MULTIAPP_PACKAGER_H