• 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_VERSION_NORMALIZE_H
17 #define DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_VERSION_NORMALIZE_H
18 
19 #include "json/module_json.h"
20 #include "packager.h"
21 #include "unzip_wrapper.h"
22 #include "zip_wrapper.h"
23 
24 namespace OHOS {
25 namespace AppPackingTool {
26 
27 class VersionNormalize : public Packager {
28 public:
29     VersionNormalize(const std::map<std::string, std::string> &parameterMap, std::string &resultReceiver);
~VersionNormalize()30     ~VersionNormalize() override {}
31 
32 protected:
33     int32_t InitAllowedParam() override;
34     int32_t PreProcess() override;
35     int32_t Process() override;
36     int32_t PostProcess() override;
37 
38 private:
39     bool ModifyModuleJson(const std::string &moduleJsonPath, NormalizeVersion &normalizeVersion,
40         const int32_t &newVersionCode, const std::string &newVersionName);
41     bool ModifyConfigJson(const std::string &moduleJsonPath, NormalizeVersion &normalizeVersion,
42         const int32_t &newVersionCode, const std::string &newVersionName);
43     bool ModifyPackInfo(const std::string &packInfoPath, const int32_t &newVersionCode,
44         const std::string &newVersionName);
45     bool VerifyModuleVersion(const NormalizeVersion &normalizeVersion, const int32_t &newVersionCode,
46         const std::string &newVersionName);
47     bool ProcessJsonFiles(const std::string &tempPath, std::list<NormalizeVersion> &normalizeVersionList,
48         const int32_t &versionCode, const std::string& versionName);
49     bool CompressDirToHap(const std::string &tempDir, const std::string &modifiedHapPath);
50     ZipWrapper zipWrapper_;
51     UnzipWrapper unzipWrapper_;
52     std::list<std::string> hspOrhapList_;
53 };
54 }  // namespace AppExecFwk
55 }  // namespace OHOS
56 #endif  // DEVELOPTOOLS_PACKING_TOOL_APT_FRAMEWORKS_INCLUDE_VERSION_NORMALIZE_H