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 #include "native_engine/native_engine.h"
17 
18 #include "napi/native_api.h"
19 #include "napi/native_node_api.h"
20 #include "advanced_ui_component/navpushpathhelper/include/hsp_silentinstall_napi.h"
21 
22 extern const char _binary_navpushpathhelper_abc_start[];
23 extern const char _binary_navpushpathhelper_abc_end[];
24 
25 namespace OHOS::NavPushPathHelper {
26     /*
27     * function for module exports
28     */
Init(napi_env env,napi_value exports)29     static napi_value Init(napi_env env, napi_value exports)
30     {
31         /*
32         * Properties define
33         */
34         napi_property_descriptor desc[] = {
35             DECLARE_NAPI_FUNCTION("silentInstall", HspSilentInstallNapi::SilentInstall),
36             DECLARE_NAPI_FUNCTION("isHspExist", HspSilentInstallNapi::IsHspExist),
37             DECLARE_NAPI_FUNCTION("initRouteMap", HspSilentInstallNapi::InitRouteMap),
38         };
39         NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
40         return exports;
41     }
42 
43     // Napi get abc code function
44     extern "C" __attribute__((visibility("default")))
NAPI_atomicservice_NavPushPathHelper_GetABCCode(const char ** buf,int * buflen)45     void NAPI_atomicservice_NavPushPathHelper_GetABCCode(const char **buf, int *buflen)
46     {
47         if (buf != nullptr) {
48             *buf = _binary_navpushpathhelper_abc_start;
49         }
50         if (buflen != nullptr) {
51             *buflen = _binary_navpushpathhelper_abc_end - _binary_navpushpathhelper_abc_start;
52         }
53     }
54 
55     /*
56     * Module define
57     */
58     static napi_module NavPushPathHelperModule = {
59         .nm_version = 1,
60         .nm_flags = 0,
61         .nm_filename = nullptr,
62         .nm_register_func = Init,
63         .nm_modname = "atomicservice.NavPushPathHelper",
64         .nm_priv = ((void*)0),
65         .reserved = { 0 },
66     };
67 
68     /*
69     * Module registerfunction
70     */
NavPushPathHelperRegisterModule(void)71     extern "C" __attribute__((constructor)) void NavPushPathHelperRegisterModule(void)
72     {
73         napi_module_register(&NavPushPathHelperModule);
74     }
75 }