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_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_H 17 #define FOUNDATION_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_H 18 19 #include "install_param.h" 20 #include "napi/native_api.h" 21 #include "napi/native_common.h" 22 #include "napi/native_node_api.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 extern thread_local napi_ref g_classBundleInstaller; 27 28 struct InstallResult { 29 int32_t resultCode = 0; 30 std::string resultMsg; 31 }; 32 33 enum class InstallOption { 34 INSTALL = 0, 35 RECOVER = 1, 36 UNINSTALL = 2, 37 UNKNOWN = 3 38 }; 39 40 struct AsyncInstallCallbackInfo { AsyncInstallCallbackInfoAsyncInstallCallbackInfo41 explicit AsyncInstallCallbackInfo(napi_env napiEnv) : env(napiEnv) {} 42 ~AsyncInstallCallbackInfo(); 43 44 std::vector<std::string> hapFiles; 45 std::string bundleName; 46 std::string param; 47 OHOS::AppExecFwk::InstallParam installParam; 48 InstallResult installResult; 49 int32_t errCode = 0; 50 InstallOption option = InstallOption::UNKNOWN; 51 52 napi_env env; 53 napi_async_work asyncWork = nullptr; 54 napi_deferred deferred = nullptr; 55 napi_ref callback = nullptr; 56 }; 57 58 struct AsyncGetBundleInstallerCallbackInfo { AsyncGetBundleInstallerCallbackInfoAsyncGetBundleInstallerCallbackInfo59 explicit AsyncGetBundleInstallerCallbackInfo(napi_env napiEnv) : env(napiEnv) {} 60 ~AsyncGetBundleInstallerCallbackInfo(); 61 62 napi_env env; 63 napi_async_work asyncWork = nullptr; 64 napi_deferred deferred = nullptr; 65 napi_ref callback = nullptr; 66 }; 67 68 napi_value GetBundleInstaller(napi_env env, napi_callback_info info); 69 napi_value Install(napi_env env, napi_callback_info info); 70 napi_value Recover(napi_env env, napi_callback_info info); 71 napi_value Uninstall(napi_env env, napi_callback_info info); 72 napi_value BundleInstallerConstructor(napi_env env, napi_callback_info info); 73 } // AppExecFwk 74 } // OHOS 75 #endif // FOUNDATION_BUNDLEMGR_SERVICES_KITS_INCLUDE_INSTALLER_H