• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_QUICK_FIX_DEPLOYER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_QUICK_FIX_DEPLOYER_H
18 
19 #include "inner_bundle_info.h"
20 #include "quick_fix_checker.h"
21 #include "quick_fix_data_mgr.h"
22 #include "quick_fix_interface.h"
23 #include "quick_fix/quick_fix_status_callback_interface.h"
24 
25 namespace OHOS {
26 namespace AppExecFwk {
27 class QuickFixDeployer final : public IQuickFix {
28 public:
29     explicit QuickFixDeployer(const std::vector<std::string> &bundleFilePaths);
30 
31     virtual ~QuickFixDeployer() = default;
32 
33     virtual ErrCode Execute() override;
34 
35     DeployQuickFixResult GetDeployQuickFixResult() const;
36 
37     ErrCode ToDeployEndStatus(InnerAppQuickFix &newInnerAppQuickFix,
38         const InnerAppQuickFix &oldInnerAppQuickFix);
39 
40 private:
41     ErrCode DeployQuickFix();
42 
43     ErrCode GetQuickFixDataMgr();
44 
45     ErrCode SaveToInnerBundleInfo(const InnerAppQuickFix &newInnerAppQuickFix);
46 
47     ErrCode ToDeployStartStatus(const std::vector<std::string> &bundleFilePaths,
48         InnerAppQuickFix &newInnerAppQuickFix, InnerAppQuickFix &oldInnerAppQuickFix);
49 
50     ErrCode ParseAndCheckAppQuickFixInfos(
51         const std::vector<std::string> &bundleFilePaths,
52         std::unordered_map<std::string, AppQuickFix> &infos);
53 
54     ErrCode ToInnerAppQuickFix(const std::unordered_map<std::string, AppQuickFix> infos,
55         const InnerAppQuickFix &oldInnerAppQuickFix, InnerAppQuickFix &newInnerAppQuickFix);
56 
57     ErrCode GetBundleInfo(const std::string &bundleName, BundleInfo &bundleInfo);
58 
59     ErrCode ProcessPatchDeployStart(
60         const std::vector<std::string> bundleFilePaths,
61         const BundleInfo &bundleInfo,
62         std::unordered_map<std::string, AppQuickFix> &infos);
63 
64     ErrCode ProcessHotReloadDeployStart(const BundleInfo &bundleInfo, const AppQuickFix &appQuickFix);
65 
66     ErrCode ProcessPatchDeployEnd(const AppQuickFix &appQuickFix, std::string &patchPath);
67 
68     ErrCode ProcessHotReloadDeployEnd(const AppQuickFix &appQuickFix, std::string &patchPath);
69 
70     ErrCode CheckPatchVersionCode(
71         const AppQuickFix &newAppQuickFix,
72         const AppQuickFix &oldAppQuickFix);
73 
74     ErrCode SaveAppQuickFix(const InnerAppQuickFix &innerAppQuickFix);
75 
76     ErrCode MoveHqfFiles(InnerAppQuickFix &innerAppQuickFix, const std::string &targetPath);
77 
78     ErrCode ProcessBundleFilePaths(const std::vector<std::string> &bundleFilePaths,
79         std::vector<std::string> &realFilePaths);
80 
81     void ToDeployQuickFixResult(const AppQuickFix &appQuickFix);
82 
83     void ProcessNativeLibraryPath(const std::string &patchPath, InnerAppQuickFix &innerAppQuickFix);
84 
85     void ProcessNativeLibraryPath(
86         const std::string &patchPath, const InnerAppQuickFix &innerAppQuickFix, std::string &nativeLibraryPath);
87 
88     void ResetNativeSoAttrs(std::unordered_map<std::string, AppQuickFix> &infos);
89 
90     void ResetNativeSoAttrs(AppQuickFix &appQuickFix);
91 
92     bool IsLibIsolated(const std::string &bundleName, const std::string &moduleName);
93 
94     bool FetchInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo);
95 
96     bool FetchPatchNativeSoAttrs(const AppqfInfo &appqfInfo,
97         const HqfInfo hqfInfo, bool isLibIsolated, std::string &nativeLibraryPath, std::string &cpuAbi);
98 
99     bool HasNativeSoInBundle(const AppQuickFix &appQuickFix);
100 
101     std::vector<std::string> patchPaths_;
102     std::shared_ptr<QuickFixDataMgr> quickFixDataMgr_ = nullptr;
103     DeployQuickFixResult deployQuickFixResult_;
104 };
105 } // AppExecFwk
106 } // OHOS
107 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_QUICK_FIX_DEPLOYER_H