• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2025 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_BASE_BUNDLE_INSTALLER_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BASE_BUNDLE_INSTALLER_H
18 
19 #include <map>
20 #include <unordered_map>
21 #include <string>
22 #include <sys/stat.h>
23 #include "nocopyable.h"
24 
25 #include "access_token.h"
26 #include "bundle_app_spawn_client.h"
27 #include "bundle_common_event_mgr.h"
28 #include "bundle_data_mgr.h"
29 #include "bundle_install_checker.h"
30 #include "event_report.h"
31 #include "hap_token_info.h"
32 #include "install_param.h"
33 #include "installer_bundle_tmp_info.h"
34 #include "quick_fix/appqf_info.h"
35 #include "shared_bundle_installer.h"
36 
37 #ifdef APP_DOMAIN_VERIFY_ENABLED
38 #include "app_domain_verify_mgr_client.h"
39 #endif
40 
41 namespace OHOS {
42 namespace AppExecFwk {
43 struct ArkStartupCache {
44     BundleType bundleType;
45     int32_t mode = (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
46     int32_t uid = 0;
47     int32_t gid = 0;
48     std::string bundleName;
49     std::string cacheDir;
50 };
51 class BaseBundleInstaller {
52 public:
53     BaseBundleInstaller();
54     virtual ~BaseBundleInstaller();
55     void SetCallingUid(int32_t callingUid);
56     void SetCallingTokenId(const Security::AccessToken::AccessTokenID callerToken);
57 
58 protected:
59     bool otaInstall_ = false;
60     enum class InstallerState : uint8_t {
61         INSTALL_START,
62         INSTALL_BUNDLE_CHECKED = 5,
63         INSTALL_SYSCAP_CHECKED = 10,
64         INSTALL_SIGNATURE_CHECKED = 15,
65         INSTALL_PARSED = 20,
66         INSTALL_HAP_HASH_PARAM_CHECKED = 25,
67         INSTALL_OVERLAY_CHECKED = 30,
68         INSTALL_VERSION_AND_BUNDLENAME_CHECKED = 35,
69         INSTALL_NATIVE_SO_CHECKED = 40,
70         INSTALL_PROXY_DATA_CHECKED = 45,
71         INSTALL_REMOVE_SANDBOX_APP = 50,
72         INSTALL_EXTRACTED = 60,
73         INSTALL_INFO_SAVED = 80,
74         INSTALL_RENAMED = 90,
75         INSTALL_SUCCESS = 100,
76         INSTALL_FAILED,
77     };
78 
79     enum SingletonState {
80         DEFAULT,
81         SINGLETON_TO_NON = 1,
82         NON_TO_SINGLETON = 2,
83     };
84 
85     struct SharedBundleRollBackInfo {
86         std::vector<std::string> newDirs; // record newly created directories, delete when rollback
87         std::vector<std::string> newBundles; // record newly installed bundle, uninstall when rollback
88         std::unordered_map<std::string, InnerBundleInfo> backupBundles; // record initial InnerBundleInfo
89     };
90 
91     /**
92      * @brief The main function for system and normal bundle install.
93      * @param bundlePath Indicates the path for storing the HAP file of the application
94      *                   to install or update.
95      * @param installParam Indicates the install parameters.
96      * @param appType Indicates the application type.
97      * @return Returns ERR_OK if the application install successfully; returns error code otherwise.
98      */
99     ErrCode InstallBundle(
100         const std::string &bundlePath, const InstallParam &installParam, const Constants::AppType appType);
101     /**
102      * @brief The main function for system and normal bundle install.
103      * @param bundlePaths Indicates the paths for storing the HAP file sof the application
104      *                   to install or update.
105      * @param installParam Indicates the install parameters.
106      * @param appType Indicates the application type.
107      * @return Returns ERR_OK if the application install successfully; returns error code otherwise.
108      */
109     ErrCode InstallBundle(const std::vector<std::string> &bundlePaths, const InstallParam &installParam,
110         const Constants::AppType appType);
111     /**
112      * @brief The main function for uninstall a bundle.
113      * @param bundleName Indicates the bundle name of the application to uninstall.
114      * @param installParam Indicates the uninstall parameters.
115      * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise.
116      */
117     ErrCode UninstallBundle(const std::string &bundleName, const InstallParam &installParam);
118     /**
119      * @brief The main function for uninstall a module in a specific bundle.
120      * @param bundleName Indicates the bundle name of the application to uninstall.
121      * @param modulePackage Indicates the module package of the module to uninstall.
122      * @param installParam Indicates the uninstall parameters.
123      * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise.
124      */
125     ErrCode UninstallBundle(
126         const std::string &bundleName, const std::string &modulePackage, const InstallParam &installParam);
127     /**
128      * @brief The main function for uninstall a bundle by uninstallParam.
129      * @param uninstallParam Indicates the input of uninstallParam.
130      * @return Returns ERR_OK if the application uninstall successfully; returns error code otherwise.
131      */
132     ErrCode CheckUninstallInnerBundleInfo(const InnerBundleInfo &info, const std::string &bundleName);
133     ErrCode UninstallBundleByUninstallParam(const UninstallParam &uninstallParam);
134     /**
135      * @brief Update the installer state.
136      * @attention This function changes the base class state only.
137      * @param state Indicates the state to be updated to.
138      * @return
139      */
140     virtual void UpdateInstallerState(const InstallerState state);
141     /**
142      * @brief Get the installer state.
143      * @return The current state of the installer object.
144      */
GetInstallerState()145     inline InstallerState GetInstallerState()
146     {
147         return state_;
148     }
149     /**
150      * @brief Get the installer state.
151      * @param state Indicates the state to be updated to.
152      * @return
153      */
SetInstallerState(InstallerState state)154     inline void SetInstallerState(InstallerState state)
155     {
156         state_ = state;
157     }
158 
GetCurrentBundleName()159     std::string GetCurrentBundleName() const
160     {
161         return bundleName_;
162     }
163     /**
164      * @brief The main function for bundle install by bundleName.
165      * @param bundleName Indicates the bundleName of the application to install.
166      * @param installParam Indicates the install parameters.
167      * @return Returns ERR_OK if the application install successfully; returns error code otherwise.
168      */
169     ErrCode Recover(const std::string &bundleName, const InstallParam &installParam);
170     /**
171      * @brief The main function for bundle install by bundleName.
172      * @param bundleName Indicates the bundleName of the application to install.
173      * @param installParam Indicates the install parameters.
174      * @return Returns ERR_OK if the application install successfully; returns error code otherwise.
175      */
176     ErrCode InstallBundleByBundleName(const std::string &bundleName, const InstallParam &installParam);
177     /**
178      * @brief Reset install properties.
179      */
180     void ResetInstallProperties();
181     /**
182      * @brief Reset install properties.
183      * @param isBootScene Indicates the event occurs in the boot phase.
184      */
MarkPreBundleSyeEventBootTag(bool isBootScene)185     void MarkPreBundleSyeEventBootTag(bool isBootScene)
186     {
187         sysEventInfo_.preBundleScene =
188             isBootScene ? InstallScene::BOOT : InstallScene::REBOOT;
189     }
190 
191     bool NotifyAllBundleStatus();
192 
193     std::string GetCheckResultMsg() const;
194 
195     void SetCheckResultMsg(const std::string checkResultMsg) const;
196 
197     void SetVerifyPermissionResult(const Security::AccessToken::HapInfoCheckResult &checkResult);
198 
199     ErrCode RollbackHmpUserInfo(const std::string &bundleName);
200 
201     ErrCode RollbackHmpCommonInfo(const std::string &bundleName);
202 
203     bool IsDriverForAllUser(const std::string &bundleName);
204 
205     int32_t GetDriverInstallUser(const std::string &bundleName);
206 
207     bool IsEnterpriseForAllUser(const InstallParam &installParam, const std::string &bundleName);
208 
209 private:
210     /**
211      * @brief The real procedure for system and normal bundle install.
212      * @param bundlePath Indicates the path for storing the HAP file of the application
213      *                   to install or update.
214      * @param installParam Indicates the install parameters.
215      * @param appType Indicates the application type.
216      * @param uid Indicates the uid of the application.
217      * @param isRecover Indicates whether this is a recovery scenario.
218      * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise.
219      */
220     ErrCode ProcessBundleInstall(const std::vector<std::string> &bundlePaths, const InstallParam &installParam,
221         const Constants::AppType appType, int32_t &uid, bool isRecover = false);
222 
223     ErrCode InnerProcessBundleInstall(std::unordered_map<std::string, InnerBundleInfo> &newInfos,
224         InnerBundleInfo &oldInfo, const InstallParam &installParam, int32_t &uid);
225 
226     /**
227      * @brief The real procedure function for uninstall a bundle.
228      * @param bundleName Indicates the bundle name of the application to uninstall.
229      * @param installParam Indicates the uninstall parameters.
230      * @param uid Indicates the uid of the application.
231      * @return Returns ERR_OK if the bundle uninstall successfully; returns error code otherwise.
232      */
233     ErrCode ProcessBundleUninstall(const std::string &bundleName, const InstallParam &installParam, int32_t &uid);
234     /**
235      * @brief The real procedure for uninstall a module in a specific bundle.
236      * @param bundleName Indicates the bundle name of the application to uninstall.
237      * @param modulePackage Indicates the module package of the module to uninstall.
238      * @param installParam Indicates the uninstall parameters.
239      * @param uid Indicates the uid of the application.
240      * @return Returns ERR_OK if the module uninstall successfully; returns error code otherwise.
241      */
242     ErrCode ProcessBundleUninstall(const std::string &bundleName, const std::string &modulePackage,
243         const InstallParam &installParam, int32_t &uid);
244     /**
245      * @brief The process of installing a new bundle.
246      * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package.
247      * @param uid Indicates the uid of the application.
248      * @return Returns ERR_OK if the new bundle install successfully; returns error code otherwise.
249      */
250     ErrCode ProcessBundleInstallStatus(InnerBundleInfo &info, int32_t &uid);
251     /**
252      * @brief The process of installing a native bundle.
253      * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package.
254      * @param uid Indicates the uid of the application.
255      * @return Returns ERR_OK if the native bundle install successfully; returns error code otherwise.
256      */
257     ErrCode ProcessBundleInstallNative(InnerBundleInfo &info, int32_t &userId);
258     /**
259      * @brief The process of uninstalling a native bundle.
260      * @param info Indicates the InnerBundleInfo parsed from the config.json in the HAP package.
261      * @param uid Indicates the uid of the application.
262      * @param bundleName Indicates the bundleName of the application.
263      * @return Returns ERR_OK if the native bundle uninstall successfully; returns error code otherwise.
264      */
265     ErrCode ProcessBundleUnInstallNative(InnerBundleInfo &info, int32_t &userId, std::string bundleName);
266     /**
267      * @brief The process of updating an exist bundle.
268      * @param oldInfo Indicates the exist InnerBundleInfo object get from the database.
269      * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package.
270      * @param isReplace Indicates whether there is the replace flag in the install flag.
271      * @return Returns ERR_OK if the bundle updating successfully; returns error code otherwise.
272      */
273     ErrCode ProcessBundleUpdateStatus(InnerBundleInfo &oldInfo,
274         InnerBundleInfo &newInfo, bool isReplace, bool killProcess = true);
275     /**
276      * @brief Remove a whole bundle.
277      * @param info Indicates the InnerBundleInfo object of a bundle.
278      * @param isKeepData Indicates that whether to save data.
279      * @return Returns ERR_OK if the bundle removed successfully; returns error code otherwise.
280      */
281     ErrCode RemoveBundle(InnerBundleInfo &info, bool isKeepData, const bool async = false);
282     /**
283      * @brief Create the code and data directories of a bundle.
284      * @param info Indicates the InnerBundleInfo object of a bundle.
285      * @return Returns ERR_OK if the bundle directories created successfully; returns error code otherwise.
286      */
287     ErrCode CreateBundleAndDataDir(InnerBundleInfo &info) const;
288     /**
289      * @brief Extract the code to temporilay directory and rename it.
290      * @param info Indicates the InnerBundleInfo object of a bundle.
291      * @param modulePath normal files decompression path.
292      * @return Returns ERR_OK if the bundle extract and renamed successfully; returns error code otherwise.
293      */
294     ErrCode ExtractModule(InnerBundleInfo &info, const std::string &modulePath);
295     /**
296      * @brief Remove the code and data directories of a bundle.
297      * @param info Indicates the InnerBundleInfo object of a bundle.
298      * @param isKeepData Indicates that whether to save data.
299      * @return Returns ERR_OK if the bundle directories removed successfully; returns error code otherwise.
300      */
301     ErrCode RemoveBundleAndDataDir(const InnerBundleInfo &info, bool isKeepData, const bool async = false);
302     /**
303      * @brief Remove the code and data directories of a module in a bundle.
304      * @param info Indicates the InnerBundleInfo object of a bundle.
305      * @param modulePackage Indicates the module to be removed.
306      * @param userId Indicates the userId.
307      * @param isKeepData Indicates that whether to save data.
308      * @return Returns ERR_OK if the bundle directories removed successfully; returns error code otherwise.
309      */
310     ErrCode RemoveModuleAndDataDir(const InnerBundleInfo &info,
311         const std::string &modulePackage, int32_t userId, bool isKeepData) const;
312     /**
313      * @brief Remove the current installing module directory.
314      * @param info Indicates the InnerBundleInfo object of a bundle under installing.
315      * @return Returns ERR_OK if the module directory removed successfully; returns error code otherwise.
316      */
317     ErrCode RemoveModuleDir(const std::string &modulePath) const;
318     /**
319      * @brief Extract files of the current installing module package.
320      * @param info Indicates the InnerBundleInfo object of a bundle under installing.
321      * @param modulePath normal files decompression path.
322      * @param targetSoPath so files decompression path.
323      * @param cpuAbi cpuAbi.
324      * @return Returns ERR_OK if the module files extraced successfully; returns error code otherwise.
325      */
326     ErrCode ExtractModuleFiles(const InnerBundleInfo &info, const std::string &modulePath,
327         const std::string &targetSoPath, const std::string &cpuAbi);
328     /**
329      * @brief Rename the directory of current installing module package.
330      * @param info Indicates the InnerBundleInfo object of a bundle under installing.
331      * @return Returns ERR_OK if the module directory renamed successfully; returns error code otherwise.
332      */
333     ErrCode RenameModuleDir(const InnerBundleInfo &info) const;
334     /**
335      * @brief The process of install a new module package.
336      * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package.
337      * @param oldInfo Indicates the exist InnerBundleInfo object get from the database.
338      * @return Returns ERR_OK if the new module install successfully; returns error code otherwise.
339      */
340     ErrCode ProcessNewModuleInstall(InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo);
341     /**
342      * @brief The process of updating an exist module package.
343      * @param newInfo Indicates the InnerBundleInfo object parsed from the config.json in the HAP package.
344      * @param oldInfo Indicates the exist InnerBundleInfo object get from the database.
345      * @return Returns ERR_OK if the module updating successfully; returns error code otherwise.
346      */
347     ErrCode ProcessModuleUpdate(InnerBundleInfo &newInfo,
348         InnerBundleInfo &oldInfo, bool isReplace, bool killProcess = true);
349     /**
350      * @brief The real procedure for bundle install by bundleName.
351      * @param bundleName Indicates the bundleName the application to install.
352      * @param installParam Indicates the install parameters.
353      * @param uid Indicates the uid of the application.
354      * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise.
355      */
356     ErrCode ProcessRecover(
357         const std::string &bundleName, const InstallParam &installParam, int32_t &uid);
358     /**
359      * @brief The real procedure for bundle install by bundleName.
360      * @param bundleName Indicates the bundleName the application to install.
361      * @param installParam Indicates the install parameters.
362      * @param uid Indicates the uid of the application.
363      * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise.
364      */
365     ErrCode ProcessInstallBundleByBundleName(
366         const std::string &bundleName, const InstallParam &installParam, int32_t &uid);
367     /**
368      * @brief The real procedure for bundle install by bundleName.
369      * @param bundleName Indicates the bundleName the application to install.
370      * @param installParam Indicates the install parameters.
371      * @param uid Indicates the uid of the application.
372      * @return Returns ERR_OK if the bundle install successfully; returns error code otherwise.
373      */
374     ErrCode InnerProcessInstallByPreInstallInfo(
375         const std::string &bundleName, const InstallParam &installParam, int32_t &uid);
376     /**
377      * @brief Check syscap.
378      * @param bundlePaths Indicates the file paths of all HAP packages.
379      * @return Returns ERR_OK if the syscap satisfy; returns error code otherwise.
380      */
381     ErrCode CheckSysCap(const std::vector<std::string> &bundlePaths);
382     /**
383      * @brief Check signature info of multiple haps.
384      * @param bundlePaths Indicates the file paths of all HAP packages.
385      * @param installParam Indicates the install parameters.
386      * @param hapVerifyRes Indicates the signature info.
387      * @return Returns ERR_OK if the every hap has signature info and all haps have same signature info.
388      */
389     ErrCode CheckMultipleHapsSignInfo(
390         const std::vector<std::string> &bundlePaths,
391         const InstallParam &installParam,
392         std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
393     /**
394      * @brief To parse hap files and to obtain innerBundleInfo of each hap.
395      * @param bundlePaths Indicates the file paths of all HAP packages.
396      * @param installParam Indicates the install parameters.
397      * @param appType Indicates the app type of the hap.
398      * @param hapVerifyRes Indicates all signature info of all haps.
399      * @param infos Indicates the innerBundleinfo of each hap.
400      * @return Returns ERR_OK if each hap is parsed successfully; returns error code otherwise.
401      */
402     ErrCode ParseHapFiles(
403         const std::vector<std::string> &bundlePaths,
404         const InstallParam &installParam,
405         const Constants::AppType appType,
406         std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes,
407         std::unordered_map<std::string, InnerBundleInfo> &infos);
408 
409     ErrCode CheckShellInstall(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
410 
411     ErrCode CheckU1Enable(const InnerBundleInfo &info, const int32_t userId);
412 
413 #ifdef X86_EMULATOR_MODE
414     ErrCode CheckShellInstallForEmulator(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
415 #endif
416 
417     ErrCode CheckShellInstallInOobe();
418 
419     ErrCode CheckInstallCondition(std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes,
420         std::unordered_map<std::string, InnerBundleInfo> &infos, bool isSysCapValid);
421 
422     ErrCode CheckInstallPermission(const InstallParam &installParam,
423         std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
424     /**
425      * @brief To check dependency whether or not exists.
426      * @param infos Indicates all innerBundleInfo for all haps need to be installed.
427      * @param sharedBundleInstaller Cross-app shared bundle installer
428      * @return Returns ERR_OK if haps checking successfully; returns error code otherwise.
429      */
430     ErrCode CheckDependency(std::unordered_map<std::string, InnerBundleInfo> &infos,
431         const SharedBundleInstaller &sharedBundleInstaller);
432 
433     /**
434      * @brief To check the hap hash param.
435      * @param infos .Indicates all innerBundleInfo for all haps need to be installed.
436      * @param hashParams .Indicates all hashParams in installParam.
437      * @return Returns ERR_OK if haps checking successfully; returns error code otherwise.
438      */
439     ErrCode CheckHapHashParams(
440         std::unordered_map<std::string, InnerBundleInfo> &infos,
441         std::map<std::string, std::string> hashParams);
442     /**
443      * @brief To check the version code and bundleName in all haps.
444      * @param infos .Indicates all innerBundleInfo for all haps need to be installed.
445      * @return Returns ERR_OK if haps checking successfully; returns error code otherwise.
446      */
447     ErrCode CheckAppLabelInfo(const std::unordered_map<std::string, InnerBundleInfo> &infos);
448 
449     /**
450      * @brief send notify to start install applicaiton
451      * @param installParam Indicates the install parameters.
452      * @param infos .Indicates all innerBundleInfo for all haps need to be installed.
453     */
454     void SendStartInstallNotify(const InstallParam &installParam,
455         const std::unordered_map<std::string, InnerBundleInfo> &infos);
456 
457     ErrCode CheckSharedBundleLabelInfo(std::unordered_map<std::string, InnerBundleInfo> &infos);
458     /**
459      * @brief To check native file in all haps.
460      * @param infos .Indicates all innerBundleInfo for all haps need to be installed.
461      * @return Returns ERR_OK if haps checking successfully; returns error code otherwise.
462      */
463     ErrCode CheckMultiNativeFile(
464         std::unordered_map<std::string, InnerBundleInfo> &infos);
465     /**
466      * @brief To roll back when the installation is failed.
467      * @param infos .Indicates the innerBundleInfo needs to be roll back.
468      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
469      * @return Returns ERR_OK if roll back successfully; returns error code otherwise.
470      */
471     void RollBack(const InnerBundleInfo &info, InnerBundleInfo &oldInfo);
472     /**
473      * @brief To check the version code and bundleName in all haps.
474      * @param newInfos .Indicates all innerBundleInfo for all haps need to be rolled back.
475      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
476      * @return Returns ERR_OK if roll back successfully; returns error code otherwise.
477      */
478     void RollBack(const std::unordered_map<std::string, InnerBundleInfo> &newInfos, InnerBundleInfo &oldInfo);
479     /**
480      * @brief To remove innerBundleInfo or moduleInfo of the corresponding haps.
481      * @param bundleName Indicates the bundle name of the bundle which needs to be removed innerBundleInfo or
482      *                   moudleInfo.
483      * @param packageName Indicates the package name of the hap which needs to be removed the moduleInfo.
484      * @return Returns ERR_OK if the removing is successful; returns error code otherwise.
485      */
486     void RemoveInfo(const std::string &bundleName, const std::string &packageName);
487     /**
488      * @brief To roll back the moduleInfo of the corresponding haps.
489      * @param bundleName Indicates the bundle name of the bundle which needs to be rolled back the moudleInfo.
490      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
491      * @return Returns ERR_OK if the rollback is successful; returns error code otherwise.
492      */
493     void RollBackModuleInfo(const std::string &bundleName, InnerBundleInfo &oldInfo);
494     /**
495      * @brief To obtain the innerBundleInfo of the corresponding hap.
496      * @param info Indicates the innerBundleInfo obtained.
497      * @param isAppExist Indicates if the innerBundleInfo is existed or not.
498      * @return Returns ERR_OK if the innerBundleInfo is obtained successfully; returns error code otherwise.
499      */
500     bool GetInnerBundleInfoWithDisable(InnerBundleInfo &info, bool &isAppExist);
501     /**
502      * @brief To check whether the version code is compatible for application or not.
503      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
504      * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise.
505      */
506     ErrCode CheckVersionCompatibility(const InnerBundleInfo &oldInfo);
507     /**
508      * @brief To check whether the version code is compatible for application or not.
509      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
510      * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise.
511      */
512     ErrCode CheckVersionCompatibilityForApplication(const InnerBundleInfo &oldInfo);
513     /**
514      * @brief To check whether the version code is compatible for openharmony service or not.
515      * @param info Indicates the original innerBundleInfo of the bundle.
516      * @return Returns ERR_OK if version code is checked successfully; returns error code otherwise.
517      */
518     ErrCode CheckVersionCompatibilityForHmService(const InnerBundleInfo &oldInfo);
519     /**
520      * @brief To uninstall lower version feature haps.
521      * @param info Indicates the innerBundleInfo of the bundle.
522      * @param packageVec Indicates the array of package names of the high version entry or feature hap.
523      * @return Returns ERR_OK if uninstall successfully; returns error code otherwise.
524      */
525     ErrCode UninstallLowerVersionFeature(const std::vector<std::string> &packageVec, bool killProcess = false);
526     /**
527      * @brief To get userId.
528      * @param installParam Indicates the installParam of the bundle.
529      * @return Returns userId.
530      */
531     int32_t GetUserId(const int32_t &userId) const;
532     /**
533      * @brief Remove bundle user data.
534      * @param innerBundleInfo Indicates the innerBundleInfo of the bundle.
535      * @param needRemoveData Indicates need remove data or not.
536      * @return Returns BundleUserMgr.
537      */
538     ErrCode RemoveBundleUserData(
539         InnerBundleInfo &innerBundleInfo, bool needRemoveData = true, const bool async = false);
540     /**
541      * @brief Create bundle user data.
542      * @param innerBundleInfo Indicates the bundle type of the application.
543      * @return Returns ERR_OK if result is ok; returns error code otherwise.
544      */
545     ErrCode CreateBundleUserData(InnerBundleInfo &innerBundleInfo);
546     void AddBundleStatus(const NotifyBundleEvents &installRes);
547     ErrCode CheckInstallationFree(const InnerBundleInfo &innerBundleInfo,
548         const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
549 
550     bool UninstallAppControl(const std::string &appId, int32_t userId);
551 
552     ErrCode InstallNormalAppControl(const std::string &installAppId, int32_t userId, bool isPreInstallApp = false);
553 
554     ErrCode CreateBundleCodeDir(InnerBundleInfo &info) const;
555     ErrCode CreateBundleDataDir(InnerBundleInfo &info) const;
556     ErrCode RemoveBundleCodeDir(const InnerBundleInfo &info) const;
557     ErrCode RemoveBundleDataDir(
558         const InnerBundleInfo &info, bool forException = false, const bool async = false);
559     void RemoveEmptyDirs(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
560     std::string GetModuleNames(const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
561     ErrCode UpdateHapToken(bool needUpdate, InnerBundleInfo &newInfo);
562     ErrCode SetDirApl(const InnerBundleInfo &info);
563     ErrCode SetDirApl(const CreateDirParam &createDirParam, const std::string &CloneBundleName);
564     /**
565      * @brief Check to set isRemovable true when install.
566      * @param newInfos Indicates all innerBundleInfo for all haps need to be installed.
567      * @param oldInfo Indicates the original innerBundleInfo of the bundle.
568      * @param userId Indicates the userId.
569      * @param isFreeInstallFlag Indicates whether is FREE_INSTALL flag.
570      * @param isAppExist Indicates whether app is exist.
571      * @return
572      */
573     void CheckEnableRemovable(std::unordered_map<std::string, InnerBundleInfo> &newInfos,
574         InnerBundleInfo &oldInfo, int32_t &userId, bool isFreeInstallFlag, bool isAppExist);
575     /**
576      * @brief Save oldInfo isRemovable to newInfo isRemovable.
577      * @param newModuleInfo Indicates the old innerModuleInfo of the bundle..
578      * @param oldInfo Indicates the old innerBundleInfo of the bundle.
579      * @param existModule Indicates whether module is exist.
580      * @return
581      */
582     void SaveOldRemovableInfo(InnerModuleInfo &newModuleInfo, InnerBundleInfo &oldInfo, bool existModule);
583     /**
584      * @brief Save hap path to records.
585      * @param isPreInstallApp Indicates isPreInstallApp or not.
586      * @param infos Indicates all innerBundleInfo for all haps need to be installed.
587      * @return
588      */
589     void SaveHapPathToRecords(
590         bool isPreInstallApp, const std::unordered_map<std::string, InnerBundleInfo> &infos);
591     void OnSingletonChange(bool killProcess);
592     void RestoreHaps(const std::vector<std::string> &bundlePaths, const InstallParam &installParam);
593     bool AllowSingletonChange(const std::string &bundleName);
594     void MarkPreInstallState(const std::string &bundleName, bool isUninstalled);
595     ErrCode UninstallAllSandboxApps(const std::string &bundleName, int32_t userId = Constants::INVALID_USERID);
596     ErrCode CheckAppLabel(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
597     bool CheckReleaseTypeIsCompatible(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const;
598     void SendBundleSystemEvent(const std::string &bundleName, BundleEventType bundleEventType,
599         const InstallParam &installParam, InstallScene preBundleScene, ErrCode errCode);
600     ErrCode CheckNativeFileWithOldInfo(
601         const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos);
602     bool HasAllOldModuleUpdate(
603         const InnerBundleInfo &oldInfo, const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
604     ErrCode CheckArkNativeFileWithOldInfo(
605         const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos);
606     ErrCode CheckNativeSoWithOldInfo(
607         const InnerBundleInfo &oldInfo, std::unordered_map<std::string, InnerBundleInfo> &newInfos);
608     void NotifyBundleStatus(const NotifyBundleEvents &installRes);
609     void AddNotifyBundleEvents(const NotifyBundleEvents &notifyBundleEvents);
610     void ProcessHqfInfo(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo);
611     ErrCode ProcessDiffFiles(const AppqfInfo &appQfInfo, const std::string &nativeLibraryPath,
612         const std::string &cpuAbi) const;
613     ErrCode ProcessDeployedHqfInfo(const std::string &nativeLibraryPath,
614         const std::string &cpuAbi, const InnerBundleInfo &newInfo, const AppQuickFix &appQuickFix);
615     ErrCode ProcessDeployingHqfInfo(
616         const std::string &nativeLibraryPath, const std::string &cpuAbi, const InnerBundleInfo &newInfo) const;
617     ErrCode UpdateLibAttrs(const InnerBundleInfo &newInfo,
618         const std::string &cpuAbi, const std::string &nativeLibraryPath, AppqfInfo &appQfInfo) const;
619     bool CheckHapLibsWithPatchLibs(
620         const std::string &nativeLibraryPath, const std::string &hqfLibraryPath) const;
621     ErrCode ExtractArkNativeFile(InnerBundleInfo &info, const std::string &modulePath);
622     ErrCode DeleteOldArkNativeFile(const InnerBundleInfo &oldInfo);
623     int32_t GetConfirmUserId(
624         const int32_t &userId, std::unordered_map<std::string, InnerBundleInfo> &newInfos);
625     ErrCode CheckUserId(const int32_t &userId) const;
626     ErrCode CreateArkProfile(
627         const std::string &bundleName, int32_t userId, int32_t uid, int32_t gid) const;
628     ErrCode DeleteArkProfile(const std::string &bundleName, int32_t userId) const;
629     bool RemoveDataPreloadHapFiles(const std::string &bundleName) const;
630     bool IsDataPreloadHap(const std::string &path) const;
631     ErrCode ExtractArkProfileFile(const std::string &modulePath, const std::string &bundleName,
632         int32_t userId) const;
633     ErrCode ExtractAllArkProfileFile(const InnerBundleInfo &oldInfo, bool checkRepeat = false) const;
634     ErrCode CopyPgoFileToArkProfileDir(const std::string &moduleName, const std::string &modulePath,
635         const std::string &bundleName, int32_t userId) const;
636     ErrCode CopyPgoFile(const std::string &moduleName, const std::string &pgoPath,
637         const std::string &bundleName, int32_t userId) const;
638     ErrCode CheckOverlayInstallation(std::unordered_map<std::string, InnerBundleInfo> &newInfos, int32_t userId);
639     ErrCode CheckOverlayUpdate(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo, int32_t userId) const;
640     NotifyType GetNotifyType();
641     void KillRelatedProcessIfArkWeb(bool isOta);
642     ErrCode CheckAppService(
643         const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo, bool isAppExist);
644     ErrCode CheckSingleton(const InnerBundleInfo &newInfo, const int32_t userId);
645     void GetCallingEventInfo(EventInfo &eventInfo);
646     void GetInstallEventInfo(EventInfo &eventInfo);
647     void GetInstallEventInfo(const InnerBundleInfo &bundleInfo, EventInfo &eventInfo);
648     ErrCode CheckArkProfileDir(const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo) const;
649     ErrCode ProcessAsanDirectory(InnerBundleInfo &info) const;
650     ErrCode CleanAsanDirectory(InnerBundleInfo &info) const;
651     void AddAppProvisionInfo(const std::string &bundleName,
652         const Security::Verify::ProvisionInfo &provisionInfo, const InstallParam &installParam) const;
653     void UpdateRouterInfo();
654     void DeleteRouterInfo(const std::string &bundleName, const std::string &moduleName = "");
655     ErrCode UninstallHspBundle(std::string &uninstallDir, const std::string &bundleName);
656     ErrCode UninstallHspVersion(std::string &uninstallDir, int32_t versionCode, InnerBundleInfo &info);
657     ErrCode UninstallHspAndBundle(InnerBundleInfo &info, int32_t &versionCode,
658         std::string &uninstallDir);
659     ErrCode CheckProxyDatas(const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
660     bool CheckDuplicateProxyData(const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
661     bool CheckDuplicateProxyData(const InnerBundleInfo &newInfo, const InnerBundleInfo &oldInfo);
662     bool CheckDuplicateProxyData(const std::vector<ProxyData> &proxyDatas);
663     bool CheckApiInfo(const std::unordered_map<std::string, InnerBundleInfo> &infos);
664     ErrCode InnerProcessNativeLibs(InnerBundleInfo &info, const std::string &modulePath);
665     ErrCode CheckSoEncryption(InnerBundleInfo &info, const std::string &cpuAbi, const std::string &targetSoPath);
666     bool ExtractSoFiles(const std::string &soPath, const std::string &cpuAbi) const;
667     void ProcessOldNativeLibraryPath(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
668         uint32_t oldVersionCode, const std::string &oldNativeLibraryPath) const;
669     void ProcessAOT(bool isOTA, const std::unordered_map<std::string, InnerBundleInfo> &infos) const;
670     void RemoveOldHapIfOTA(const InstallParam &installParam,
671         const std::unordered_map<std::string, InnerBundleInfo> &newInfos, const InnerBundleInfo &oldInfo);
672     ErrCode CopyHapsToSecurityDir(const InstallParam &installParam, std::vector<std::string> &bundlePaths);
673     ErrCode ParseHapPaths(const InstallParam &installParam, const std::vector<std::string> &inBundlePaths,
674         std::vector<std::string> &parsedPaths);
675     ErrCode RenameAllTempDir(const std::unordered_map<std::string, InnerBundleInfo> &newInfos) const;
676     ErrCode FindSignatureFileDir(const std::string &moduleName, std::string &signatureFileDir);
677     ErrCode MoveFileToRealInstallationDir(const std::unordered_map<std::string, InnerBundleInfo> &infos);
678     std::string GetTempHapPath(const InnerBundleInfo &info);
679     ErrCode SaveHapToInstallPath(const std::unordered_map<std::string, InnerBundleInfo> &infos,
680         const InnerBundleInfo &oldInfo);
681     ErrCode CheckHapEncryption(const std::unordered_map<std::string, InnerBundleInfo> &infos,
682         const InnerBundleInfo &oldInfo, bool isHapCopied = true);
683     void UpdateEncryptionStatus(const std::unordered_map<std::string, InnerBundleInfo> &infos,
684         const InnerBundleInfo &oldInfo, InnerBundleInfo &newInfo);
685     bool IsBundleEncrypted(const std::unordered_map<std::string, InnerBundleInfo> &infos,
686         const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo);
687     void UpdateAppInstallControlled(int32_t userId);
688     void UpdateHasCloudkitConfig();
689     ErrCode MoveSoFileToRealInstallationDir(const std::unordered_map<std::string, InnerBundleInfo> &infos,
690         bool needDeleteOldLibraryPath);
691     ErrCode FinalProcessHapAndSoForBundleUpdate(const std::unordered_map<std::string, InnerBundleInfo> &infos,
692         bool needCopyHapToInstallPath, bool needDeleteOldLibraryPath);
693     void GetDataGroupIds(const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes,
694         std::unordered_set<std::string> &groupIds);
695     void GenerateNewUserDataGroupInfos(InnerBundleInfo &info) const;
696     void RemoveOldGroupDirs(const InnerBundleInfo &oldInfo);
697     ErrCode RemoveDataGroupDirs(const std::string &bundleName, int32_t userId, bool isKeepData = false) const;
698     void DeleteGroupDirsForException(const InnerBundleInfo &oldInfo) const;
699     ErrCode CreateDataGroupDirs(
700         const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes, const InnerBundleInfo &oldInfo);
701     bool NeedDeleteOldNativeLib(
702         const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
703         const InnerBundleInfo &oldInfo);
704     ErrCode UninstallBundleFromBmsExtension(const std::string &bundleName);
705     ErrCode CheckBundleInBmsExtension(const std::string &bundleName, int32_t userId);
706     ErrCode CheckMDMUpdateBundleForSelf(const InstallParam &installParam, InnerBundleInfo &oldInfo,
707         const std::unordered_map<std::string, InnerBundleInfo> &newInfos, bool isAppExist);
708     void ExtractResourceFiles(const InnerBundleInfo &info, const std::string &targetPath) const;
709     void RemoveTempSoDir(const std::string &tempSoDir);
710     bool CheckAppIdentifier(const std::string &oldAppIdentifier, const std::string &newAppIdentifier,
711         const std::string &oldAppId, const std::string &newAppId);
712     ErrCode InstallEntryMoudleFirst(std::unordered_map<std::string, InnerBundleInfo> &newInfos,
713         InnerBundleInfo &bundleInfo, const InnerBundleUserInfo &innerBundleUserInfo, const InstallParam &installParam);
714     void ProcessQuickFixWhenInstallNewModule(const InstallParam &installParam,
715         const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
716     bool ExtractEncryptedSoFiles(const InnerBundleInfo &info, const std::string &tmpSoPath, int32_t uid) const;
717     void SetOldAppIsEncrypted(const InnerBundleInfo &oldInfo);
718     bool UpdateEncryptedStatus(const InnerBundleInfo &oldInfo);
719     bool DeleteEncryptedStatus(const std::string &bundleName, int32_t uid);
720     void ProcessEncryptedKeyExisted(int32_t res, uint32_t type,
721         const std::vector<CodeProtectBundleInfo> &infos);
722     ErrCode VerifyCodeSignatureForNativeFiles(InnerBundleInfo &info, const std::string &cpuAbi,
723         const std::string &targetSoPath, const std::string &signatureFileDir) const;
724     ErrCode VerifyCodeSignatureForHap(const std::unordered_map<std::string, InnerBundleInfo> &infos,
725         const std::string &srcHapPath, const std::string &realHapPath);
726     ErrCode DeliveryProfileToCodeSign() const;
727     ErrCode RemoveProfileFromCodeSign(const std::string &bundleName) const;
728     ErrCode ExtractResFileDir(const std::string &modulePath) const;
729     ErrCode ExtractHnpFileDir(const std::string &cpuAbi, const std::string &hnpPackageInfoString,
730         const std::string &modulePath) const;
731     void DeleteOldNativeLibraryPath() const;
732     std::string GetRealSoPath(const std::string &bundleName, const std::string &nativeLibraryPath,
733         bool isNeedDeleteOldPath) const;
734     void RemoveTempPathOnlyUsedForSo(const InnerBundleInfo &innerBundleInfo) const;
735     void GenerateOdid(std::unordered_map<std::string, InnerBundleInfo> &infos,
736         const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes) const;
737     void SetAppDistributionType(const std::unordered_map<std::string, InnerBundleInfo> &infos);
738     ErrCode CreateShaderCache(const std::string &bundleName, int32_t uid, int32_t gid) const;
739     ErrCode DeleteShaderCache(const std::string &bundleName) const;
740     ErrCode CleanShaderCache(const InnerBundleInfo &oldInfo, const std::string &bundleName, int32_t userId) const;
741     ErrCode CleanBundleClonesShaderCache(const std::vector<int32_t> allAppIndexes,
742         const std::string &bundleName, int32_t userId) const;
743     void CreateCloudShader(const std::string &bundleName, int32_t uid, int32_t gid) const;
744     ErrCode DeleteCloudShader(const std::string &bundleName) const;
745     ErrCode DeleteEl1ShaderCache(const InnerBundleInfo &oldInfo, const std::string &bundleName, int32_t userId) const;
746     ErrCode DeleteBundleClonesShaderCache(const std::vector<int32_t> allAppIndexes,
747         const std::string &bundleName, int32_t userId) const;
748     ArkStartupCache CreateArkStartupCacheParameter(const std::string &bundleName,
749         int32_t userId, BundleType bundleType, int32_t uid);
750     ErrCode ProcessArkStartupCache(const ArkStartupCache &createArk,
751         int32_t moduleNum, int32_t userId) const;
752     ErrCode CreateArkStartupCache(const ArkStartupCache &createArk) const;
753     ErrCode CleanArkStartupCache(const std::string &cacheDir, const std::string &bundleName, int32_t userId) const;
754     ErrCode DeleteArkStartupCache(const std::string &cacheDir, const std::string &bundleName, int32_t userId) const;
755     bool VerifyActivationLock() const;
756     bool VerifyActivationLockToken() const;
757     std::vector<std::string> GenerateScreenLockProtectionDir(const std::string &bundleName) const;
758     void CreateScreenLockProtectionDir();
759     void CreateEl5AndSetPolicy(InnerBundleInfo &info);
760     void DeleteScreenLockProtectionDir(const std::string bundleName) const;
761     void DeleteEncryptionKeyId(const InnerBundleUserInfo &userInfo, bool isKeepData) const;
762 #ifdef APP_DOMAIN_VERIFY_ENABLED
763     void PrepareSkillUri(const std::vector<Skill> &skills, std::vector<AppDomainVerify::SkillUri> &skillUris) const;
764 #endif
765     void PrepareBundleDirQuota(const std::string &bundleName, const int32_t uid,
766         const std::string &bundleDataDirPath, const int32_t limitSize) const;
767     void ParseSizeFromProvision(int32_t &sizeMb) const;
768     void VerifyDomain();
769     void ClearDomainVerifyStatus(const std::string &appIdentifier, const std::string &bundleName) const;
770     bool IsRdDevice() const;
771     void SetAtomicServiceModuleUpgrade(const InnerBundleInfo &oldInfo);
772     void UpdateExtensionSandboxInfo(std::unordered_map<std::string, InnerBundleInfo> &newInfos,
773         const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
774     void GetValidDataGroupIds(const std::vector<std::string> &extensionDataGroupIds,
775         const std::vector<std::string> &bundleDataGroupIds, std::vector<std::string> &validGroupIds) const;
776     void GetExtensionDirsChange(std::unordered_map<std::string, InnerBundleInfo> &newInfos,
777         const InnerBundleInfo &oldInfo);
778     void GetCreateExtensionDirs(std::unordered_map<std::string, InnerBundleInfo> &newInfos);
779     void GetRemoveExtensionDirs(
780         std::unordered_map<std::string, InnerBundleInfo> &newInfos, const InnerBundleInfo &oldInfo);
781     void CreateExtensionDataDir(InnerBundleInfo &info) const;
782     void RemoveCreatedExtensionDirsForException() const;
783     void RemoveOldExtensionDirs() const;
784     ErrCode InnerProcessUpdateHapToken(const bool isOldSystemApp);
785     bool InitDataMgr();
786     std::string GetInstallSource(const InstallParam &installParam) const;
787     void SetApplicationFlagsAndInstallSource(std::unordered_map<std::string, InnerBundleInfo> &infos,
788         const InstallParam &installParam) const;
789     bool IsAppInBlocklist(const std::string &bundleName, const int32_t userId) const;
790     bool CheckWhetherCanBeUninstalled(const std::string &bundleName, const std::string &appIdentifier) const;
791     void CheckSystemFreeSizeAndClean() const;
792     void CheckBundleNameAndStratAbility(const std::string &bundleName, const std::string &appIdentifier) const;
793     void GetUninstallBundleInfo(bool isKeepData, int32_t userId,
794         const InnerBundleInfo &oldInfo, UninstallBundleInfo &uninstallBundleInfo);
795     bool CheckInstallOnKeepData(const std::string &bundleName, bool isOTA,
796         const std::unordered_map<std::string, InnerBundleInfo> &infos);
797     void SaveUninstallBundleInfo(const std::string bundleName, bool isKeepData,
798         const UninstallBundleInfo &uninstallBundleInfo);
799     void DeleteUninstallBundleInfo(const std::string &bundleName);
800     void SetFirstInstallTime(const std::string &bundleName, const int64_t &time, InnerBundleInfo &info);
801     bool SaveFirstInstallBundleInfo(const std::string &bundleName, const int32_t userId,
802         bool isPreInstallApp, const InnerBundleUserInfo &innerBundleUserInfo);
803     ErrCode MarkInstallFinish();
804     bool IsArkWeb(const std::string &bundleName) const;
805     void UninstallDebugAppSandbox(const std::string &bundleName, const int32_t uid,
806         const InnerBundleInfo& innerBundleInfo);
807     ErrCode CheckAppDistributionType();
808 #ifdef WEBVIEW_ENABLE
809     ErrCode VerifyArkWebInstall();
810     void RestoreconForArkweb();
811 #endif
812 
813     bool SetDisposedRuleWhenBundleUpdateStart(const std::unordered_map<std::string, InnerBundleInfo> &infos,
814         const InnerBundleInfo &oldBundleInfo, bool isPreInstallApp);
815 
816     bool DeleteDisposedRuleWhenBundleUpdateEnd(const InnerBundleInfo &oldBundleInfo);
817 
818     bool SetDisposedRuleWhenBundleUninstallStart(const std::string &bundleName,
819         const std::string &appId, bool isMultiUser);
820     bool DeleteDisposedRuleWhenBundleUninstallEnd(const std::string &bundleName,
821         const std::string &appId, bool isMultiUser);
822     bool AddAppGalleryHapToTempPath(const bool isPreInstallApp,
823         const std::unordered_map<std::string, InnerBundleInfo> &infos);
824     bool DeleteAppGalleryHapFromTempPath();
825     bool GetTempBundleInfo(InnerBundleInfo &info) const;
826     bool InitTempBundleFromCache(InnerBundleInfo &info, bool &isAppExist, std::string bundleName = "");
827     ErrCode UpdateAppEncryptedStatus(const std::string &bundleName, bool isExisted, int32_t appIndex);
828     void CheckPreBundle(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
829         const InstallParam &installParam, bool isRecover);
830     ErrCode CheckShellCanInstallPreApp(const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
831     bool DeleteUninstallBundleInfoFromDb(const std::string &bundleName);
832 
833     bool RecoverHapToken(const std::string &bundleName, const int32_t userId,
834         Security::AccessToken::AccessTokenIDEx& accessTokenIdEx, const InnerBundleInfo &innerBundleInfo);
835     std::string GetAssetAccessGroups(const std::string &bundleName);
836     std::string GetDeveloperId(const std::string &bundleName);
837     void GetModuleNames(const std::string &bundleName, std::vector<std::string> &moduleNames);
838     void UpdateKillApplicationProcess(const InnerBundleInfo &innerBundleInfo);
839     ErrCode CheckPreAppAllowHdcInstall(const InstallParam &installParam,
840         const std::vector<Security::Verify::HapVerifyResult> &hapVerifyRes);
841     void CheckPreBundleRecoverResult(ErrCode &result);
842 
843     bool IsAllowEnterPrise();
844     void MarkIsForceUninstall(const std::string &bundleName, bool isForceUninstalled);
845     bool CheckCanInstallPreBundle(const std::string &bundleName, const int32_t userId);
846     void RemovePluginOnlyInCurrentUser(const InnerBundleInfo &info);
847     std::string GetModulePath(const InnerBundleInfo &info, const bool isBundleUpdate, const bool isModuleUpdate);
848     ErrCode ProcessBundleCodePath(const std::unordered_map<std::string, InnerBundleInfo> &newInfos,
849         const InnerBundleInfo &oldInfo, const std::string &bundleName,
850         const bool isBundleUpdate, const bool needCopyHap);
851     void ProcessOldCodePath(const std::string &bundleName, const bool isBundleUpdate);
852     void RollbackCodePath(const std::string &bundleName, bool isBundleUpdate);
853     void InnerProcessTargetSoPath(const InnerBundleInfo &info, const bool isBundleUpdate,
854         const std::string &modulePath, std::string &nativeLibraryPath, std::string &targetSoPath);
855     ErrCode RecoverOnDemandInstallBundle(const std::string &bundleName,
856         const InstallParam &installParam, int32_t &uid);
857     void PrintStartWindowIconId(const InnerBundleInfo &info);
858     bool ProcessExtProfile(const InstallParam &installParam);
859     void SetHybridSpawn();
860     bool IsBundleCrossAppSharedConfig(const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
861     ErrCode ProcessDynamicIconFileWhenUpdate(const InnerBundleInfo &oldInfo, const std::string &oldPath,
862         const std::string &newPath);
863     void ProcessUpdateShortcut();
864     ErrCode CheckArkTSMode(const std::unordered_map<std::string, InnerBundleInfo> &newInfos);
865 
866     bool isAppExist_ = false;
867     bool isContainEntry_ = false;
868     bool isAppService_ = false;
869     // used for bundle update
870     bool isFeatureNeedUninstall_ = false;
871     // for quick fix
872     bool needDeleteQuickFixInfo_ = false;
873     bool hasInstalledInUser_ = false;
874     bool isModuleUpdate_ = false;
875     bool isEntryInstalled_ = false;
876     bool isEnterpriseBundle_ = false;
877     bool isInternaltestingBundle_ = false;
878     // When it is true, it means that the same bundleName and same userId was uninstalled with keepData before
879     bool existBeforeKeepDataApp_ = false;
880     bool copyHapToInstallPath_ = false;
881     bool needSetDisposeRule_ = false;
882     bool needDeleteAppTempPath_ = false;
883     bool isBundleExist_ = false;
884     bool isBundleCrossAppSharedConfig_ = false;
885     InstallerState state_ = InstallerState::INSTALL_START;
886     uint32_t versionCode_ = 0;
887     uint32_t accessTokenId_ = 0;
888     uint32_t oldApplicationReservedFlag_ = 0;
889 
890     int32_t userId_ = Constants::INVALID_USERID;
891     int32_t overlayType_ = NON_OVERLAY_TYPE;
892     int32_t atomicServiceModuleUpgrade_ = 0;
893     SingletonState singletonState_ = SingletonState::DEFAULT;
894     BundleType bundleType_ = BundleType::APP;
895     Security::AccessToken::AccessTokenID callerToken_ = 0;
896     std::string bundleName_;
897     std::string modulePath_;
898     std::string baseDataPath_;
899     std::string modulePackage_;
900     std::string mainAbility_;
901     std::string moduleName_;
902     std::string uninstallBundleAppId_;
903     std::string entryModuleName_ = "";
904     std::string appDistributionType_;
905     std::string appIdentifier_ = "";
906     std::unique_ptr<BundleInstallChecker> bundleInstallChecker_ = nullptr;
907     std::shared_ptr<BundleDataMgr> dataMgr_ = nullptr;  // this pointer will get when public functions called
908     // key is package name, value is boolean
909     std::unordered_map<std::string, bool> installedModules_;
910     std::vector<std::string> uninstallModuleVec_;
911     std::map<std::string, std::string> hapPathRecords_;
912     // utilizing for code-signature
913     std::map<std::string, std::string> verifyCodeParams_;
914     std::vector<std::string> toDeleteTempHapPath_;
915     std::vector<NotifyBundleEvents> bundleEvents_;
916     // key is the temp path of hap or hsp
917     // value is the signature file path
918     std::map<std::string, std::string> signatureFileMap_;
919     std::vector<std::string> bundlePaths_;
920     std::unordered_map<std::string, std::string> signatureFileTmpMap_;
921     // utilize for install entry firstly from multi-installation
922     std::map<std::string, std::string> pgoParams_;
923     std::map<std::string, std::string> targetSoPathMap_;
924     // indicates sandboxd dirs need to create by extension
925     std::vector<std::string> newExtensionDirs_;
926     // indicates sandboxd dirs need to create by extension
927     std::vector<std::string> createExtensionDirs_;
928     // indicates sandboxd dirs need to remove by extension
929     std::vector<std::string> removeExtensionDirs_;
930     // used to record system event infos
931     EventInfo sysEventInfo_;
932     Security::Verify::HapVerifyResult verifyRes_;
933     InstallerBundleTempInfo tempInfo_;
934     // indicates whether the application has been restored to the preinstall
935     bool isPreBundleRecovered_ = false;
936 
937     DISALLOW_COPY_AND_MOVE(BaseBundleInstaller);
938 
939 #define CHECK_RESULT(errcode, errmsg)                                              \
940     do {                                                                           \
941         if ((errcode) != ERR_OK) {                                                   \
942             APP_LOGE(errmsg, errcode);                                             \
943             return errcode;                                                        \
944         }                                                                          \
945     } while (0)
946 
947 #define CHECK_RESULT_WITH_ROLLBACK(errcode, errmsg, newInfos, oldInfo)             \
948     do {                                                                           \
949         if ((errcode) == ERR_APPEXECFWK_INSTALL_SINGLETON_NOT_SAME ||              \
950             (errcode) == ERR_APPEXECFWK_INSTALL_ZERO_USER_WITH_NO_SINGLETON) {     \
951             APP_LOGE(errmsg, errcode);                                             \
952             return errcode;                                                        \
953         }                                                                          \
954                                                                                    \
955         if ((errcode) != ERR_OK) {                                                   \
956             APP_LOGE(errmsg, errcode);                                             \
957             RollBack(newInfos, oldInfo);                                           \
958             return errcode;                                                        \
959         }                                                                          \
960     } while (0)
961 };
962 }  // namespace AppExecFwk
963 }  // namespace OHOS
964 #endif  // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BASE_BUNDLE_INSTALLER_H
965