• 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_APP_PACKAGER_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_APP_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 AppPackager : public Packager {
29 public:
30     AppPackager(const std::map<std::string, std::string> &parameterMap, std::string &resultReceiver);
~AppPackager()31     ~AppPackager() override {}
32 
33     bool CheckBundleTypeConsistency(const std::string &hapPath, const std::string &hspPath);
34     bool VerifyIsSharedApp(const std::list<std::string> &hspPath);
35     bool IsSharedApp(const std::string &hapPath, const std::string &hspPath);
36     bool VerifyIsAppService(const std::list<std::string> &modulePathList);
37     bool IsAppService(const std::string &hapPath, const std::string &hspPath);
38     bool CheckInputModulePath(const std::string &hapPath, const std::string &hspPath);
39     bool IsVerifyValidInAppMode();
40     bool PrepareDirectoriesAndFiles(const std::string outPath);
41     bool CompressHapAndHspFiles(const fs::path &tempPath, const fs::path &hspTempDirPath);
42     bool AddHapListToApp(const std::list<std::string> &fileList);
43     bool CompressOtherFiles();
44     bool CompressAppMode();
45     bool GetAndCheckOutPath(std::string &outPath);
46     bool GetAndCheckHapPathAndHspPath(std::string &hapPath, std::string &hspPath);
47     bool GetAndCheckPackInfoPath(std::string &packInfoPath);
48     bool CheckSignaturePath();
49     bool CheckCertificatePath();
50     bool CheckEntrycardPath();
51     bool CheckPackResPath();
52     bool CheckPacJsonPath();
53 
54 protected:
55     int32_t InitAllowedParam() override;
56     int32_t PreProcess() override;
57     int32_t Process() override;
58     int32_t PostProcess() override;
59 
60 private:
61     ZipWrapper zipWrapper_;
62     std::list<std::string> formattedHapPathList_;
63     std::list<std::string> formattedHspPathList_;
64     std::list<std::string> formattedEntryCardPathList_;
65     bool isSharedApp_ = false;
66     bool isAppService_ = false;
67     std::map<std::string, std::shared_ptr<HapVerifyInfo>> hapVerifyInfoMap_;
68 };
69 }  // namespace AppExecFwk
70 }  // namespace OHOS
71 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_APP_PACKAGER_H