1 /*
2 * Copyright (C) 2021-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 <napi/native_api.h>
17 #include "napi_call_manager.h"
18
19 extern const char _binary_call_js_start[];
20 extern const char _binary_call_js_end[];
21 extern const char _binary_call_abc_start[];
22 extern const char _binary_call_abc_end[];
23
24 namespace OHOS {
25 namespace Telephony {
26
RegisterModule(void)27 extern "C" __attribute__((constructor)) void RegisterModule(void)
28 {
29 napi_module module = {
30 .nm_version = 1, // NAPI v1
31 .nm_flags = 0, // normal
32 .nm_filename = nullptr,
33 .nm_register_func = NapiCallManager::RegisterCallManagerFunc,
34 .nm_modname = "telephony.call",
35 .nm_priv = nullptr,
36 .reserved = {},
37 };
38 napi_module_register(&module);
39 }
40
NAPI_telephony_call_GetJSCode(const char ** buf,int * bufLen)41 extern "C" __attribute__((visibility("default"))) void NAPI_telephony_call_GetJSCode(const char** buf,
42 int* bufLen)
43 {
44 if (buf != nullptr) {
45 *buf = _binary_call_js_start;
46 }
47
48 if (bufLen != nullptr) {
49 *bufLen = _binary_call_js_end - _binary_call_js_start;
50 }
51 }
52
NAPI_telephony_call_GetABCCode(const char ** buf,int * bufLen)53 extern "C" __attribute__((visibility("default"))) void NAPI_telephony_call_GetABCCode(const char** buf,
54 int* bufLen)
55 {
56 if (buf != nullptr) {
57 *buf = _binary_call_abc_start;
58 }
59
60 if (bufLen != nullptr) {
61 *bufLen = _binary_call_abc_end - _binary_call_abc_start;
62 }
63 }
64 } // namespace Telephony
65 } // namespace OHOS