• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_HELPER_H
17 #define FOUNDATION_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_HELPER_H
18 
19 #include "base_cb_info.h"
20 #include "bundle_errors.h"
21 #include "clone_param.h"
22 #include "install_param.h"
23 #include "napi/native_api.h"
24 #include "napi/native_common.h"
25 #include "napi/native_node_api.h"
26 #include "plugin/install_plugin_param.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 struct InstallResult {
31     int32_t resultCode = 0;
32     std::string resultMsg;
33     int32_t innerCode = 0;
34 };
35 
36 enum class InstallOption {
37     INSTALL = 0,
38     RECOVER = 1,
39     UNINSTALL = 2,
40     UPDATE_BUNDLE_FOR_SELF = 3,
41     UNKNOWN = 4,
42     UNINSTALL_AND_RECOVER = 5,
43 };
44 
45 class InstallerHelper {
46 public:
47     static void CreateErrCodeMap(std::unordered_map<int32_t, int32_t>& errCodeMap);
48     static void ConvertInstallResult(InstallResult& installResult);
49     static void CreateProxyErrCode(std::unordered_map<int32_t, int32_t>& errCodeMap);
50     static ErrCode InnerCreateAppClone(std::string& bundleName, int32_t userId, int32_t& appIndex);
51     static ErrCode InnerDestroyAppClone(
52         std::string& bundleName, int32_t userId, int32_t appIndex, DestroyAppCloneParam& destroyAppCloneParam);
53     static ErrCode InnerAddExtResource(const std::string& bundleName, const std::vector<std::string>& filePaths);
54     static ErrCode InnerRemoveExtResource(const std::string& bundleName, const std::vector<std::string>& moduleNames);
55     static ErrCode InnerInstallPreexistingApp(std::string& bundleName, int32_t userId);
56     static ErrCode InnerInstallPlugin(const std::string& hostBundleName,
57         const std::vector<std::string>& pluginFilePaths, const InstallPluginParam& installPluginParam);
58     static ErrCode InnerUninstallPlugin(const std::string& hostBundleName, const std::string& pluginBundleName,
59         const InstallPluginParam& installPluginParam);
60 };
61 } // namespace AppExecFwk
62 } // namespace OHOS
63 #endif // FOUNDATION_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_HELPER_H