From 2a55aeea25e047a9556479452ee76ba2278b32df Mon Sep 17 00:00:00 2001 From: jiangwensai Date: Wed, 2 Mar 2022 18:08:35 +0800 Subject: [PATCH] IssueNo: #I4W0R2 Description: Fix extension. Sig: SIG_ApplicationFramework Feature or Bugfix: Bugfix Binary Source: No Signed-off-by: jiangwensai --- .../native/src/js_service_extension.cpp | 2 +- interfaces/kits/napi/BUILD.gn | 4 +- .../napi/aafwk/ext_ability_context/BUILD.gn | 50 ------------ .../ext_ability_context.js | 29 ------- .../ext_ability_context_module.cpp | 57 -------------- .../napi/aafwk/service_ext_ability/BUILD.gn | 50 ------------ .../service_ext_ability_context/BUILD.gn | 50 ------------ .../service_ext_ability_context.js | 55 -------------- .../service_ext_ability_context_module.cpp | 57 -------------- .../aafwk/service_extension_ability/BUILD.gn | 50 ++++++++++++ .../service_extension_ability.js} | 76 +++++++++---------- .../service_extension_ability_module.cpp} | 25 +++--- 12 files changed, 102 insertions(+), 403 deletions(-) delete mode 100644 interfaces/kits/napi/aafwk/ext_ability_context/BUILD.gn delete mode 100644 interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context.js delete mode 100644 interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context_module.cpp delete mode 100644 interfaces/kits/napi/aafwk/service_ext_ability/BUILD.gn delete mode 100644 interfaces/kits/napi/aafwk/service_ext_ability_context/BUILD.gn delete mode 100644 interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context.js delete mode 100644 interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context_module.cpp create mode 100644 interfaces/kits/napi/aafwk/service_extension_ability/BUILD.gn rename interfaces/kits/napi/aafwk/{service_ext_ability/service_ext_ability.js => service_extension_ability/service_extension_ability.js} (87%) rename interfaces/kits/napi/aafwk/{service_ext_ability/service_ext_ability_module.cpp => service_extension_ability/service_extension_ability_module.cpp} (57%) diff --git a/frameworks/kits/ability/native/src/js_service_extension.cpp b/frameworks/kits/ability/native/src/js_service_extension.cpp index 4dd410ad0a..a6f45cd3a9 100755 --- a/frameworks/kits/ability/native/src/js_service_extension.cpp +++ b/frameworks/kits/ability/native/src/js_service_extension.cpp @@ -81,7 +81,7 @@ void JsServiceExtension::Init(const std::shared_ptr &record, } HILOG_INFO("JsServiceExtension::Init CreateJsServiceExtensionContext."); NativeValue* contextObj = CreateJsServiceExtensionContext(engine, context); - shellContextRef_ = jsRuntime_.LoadSystemModule("application.ServiceExtAbilityContext", &contextObj, ARGC_ONE); + shellContextRef_ = jsRuntime_.LoadSystemModule("application.ServiceExtensionContext", &contextObj, ARGC_ONE); contextObj = shellContextRef_->Get(); HILOG_INFO("JsServiceExtension::Init Bind."); context->Bind(jsRuntime_, shellContextRef_.get()); diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index debd5878c3..890f6ac8d5 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -34,15 +34,13 @@ group("napi_packages") { "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/dataUriUtils:datauriutils", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/datashare_ext_ability:datashareextensionability_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/datashare_ext_ability_context:datashareextensionabilitycontext_napi", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/ext_ability_context:extabilitycontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/extensioncontext:extensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/featureAbility:featureability", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:distributedmissionmanager", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/mission_manager:missionmanager_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/particleAbility:particleability", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_ext_ability:serviceextability_napi", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_ext_ability_context:serviceextabilitycontext_napi", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_extension_ability:serviceextensionability_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/service_extension_context:serviceextensioncontext_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/serviceextension:serviceextension_napi", "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/static_subscriber_extension:staticsubscriberextension_napi", diff --git a/interfaces/kits/napi/aafwk/ext_ability_context/BUILD.gn b/interfaces/kits/napi/aafwk/ext_ability_context/BUILD.gn deleted file mode 100644 index b686072176..0000000000 --- a/interfaces/kits/napi/aafwk/ext_ability_context/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") -import("//build/ohos.gni") - -ts2abc_gen_abc("gen_ext_ability_context_abc") { - src_js = rebase_path("ext_ability_context.js") - dst_file = rebase_path(target_out_dir + "/ext_ability_context.abc") - in_puts = [ "ext_ability_context.js" ] - out_puts = [ target_out_dir + "/ext_ability_context.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("ext_ability_context_js") { - input = "ext_ability_context.js" - output = target_out_dir + "/ext_ability_context.o" -} - -gen_js_obj("ext_ability_context_abc") { - input = get_label_info(":gen_ext_ability_context_abc", "target_out_dir") + - "/ext_ability_context.abc" - output = target_out_dir + "/ext_ability_context_abc.o" - dep = ":gen_ext_ability_context_abc" -} - -ohos_shared_library("extabilitycontext_napi") { - sources = [ "ext_ability_context_module.cpp" ] - - deps = [ - ":ext_ability_context_abc", - ":ext_ability_context_js", - ] - - external_deps = [ "napi:ace_napi" ] - - relative_install_dir = "module/application" - subsystem_name = "aafwk" - part_name = "ability_runtime" -} diff --git a/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context.js b/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context.js deleted file mode 100644 index 9f0af27655..0000000000 --- a/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -var Context = requireNapi("application.Context") - -class ExtAbilityContext extends Context { - constructor(obj) { - super(obj); - this.currentHapModuleInfo = obj.currentHapModuleInfo - this.config = obj.config - } - - onUpdateConfiguration(config) { - this.config = config - } -} - -export default ExtAbilityContext \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context_module.cpp b/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context_module.cpp deleted file mode 100644 index 8dd6d814cf..0000000000 --- a/interfaces/kits/napi/aafwk/ext_ability_context/ext_ability_context_module.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -extern const char _binary_ext_ability_context_js_start[]; -extern const char _binary_ext_ability_context_js_end[]; -extern const char _binary_ext_ability_context_abc_start[]; -extern const char _binary_ext_ability_context_abc_end[]; - -extern "C" __attribute__((constructor)) -void NAPI_application_ExtAbilityContext_AutoRegister() -{ - auto moduleManager = NativeModuleManager::GetInstance(); - NativeModule newModuleInfo = { - .name = "application.ExtAbilityContext", - .fileName = "application/libextensioncontext_napi.so/ext_ability_context.js", - }; - - moduleManager->Register(&newModuleInfo); -} - -extern "C" __attribute__((visibility("default"))) -void NAPI_application_ExtAbilityContext_GetJSCode(const char **buf, int *bufLen) -{ - if (buf != nullptr) { - *buf = _binary_ext_ability_context_js_start; - } - - if (bufLen != nullptr) { - *bufLen = _binary_ext_ability_context_js_end - _binary_ext_ability_context_js_start; - } -} - -// extension_context JS register -extern "C" __attribute__((visibility("default"))) -void NAPI_application_ExtAbilityContext_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_ext_ability_context_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_ext_ability_context_abc_end - _binary_ext_ability_context_abc_start; - } -} \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/service_ext_ability/BUILD.gn b/interfaces/kits/napi/aafwk/service_ext_ability/BUILD.gn deleted file mode 100644 index e852cdf201..0000000000 --- a/interfaces/kits/napi/aafwk/service_ext_ability/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") -import("//build/ohos.gni") - -ts2abc_gen_abc("gen_service_ext_ability_abc") { - src_js = rebase_path("service_ext_ability.js") - dst_file = rebase_path(target_out_dir + "/service_ext_ability.abc") - in_puts = [ "service_ext_ability.js" ] - out_puts = [ target_out_dir + "/service_ext_ability.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("service_ext_ability_js") { - input = "service_ext_ability.js" - output = target_out_dir + "/service_ext_ability.o" -} - -gen_js_obj("service_ext_ability_abc") { - input = get_label_info(":gen_service_ext_ability_abc", "target_out_dir") + - "/service_ext_ability.abc" - output = target_out_dir + "/service_ext_ability_abc.o" - dep = ":gen_service_ext_ability_abc" -} - -ohos_shared_library("serviceextability_napi") { - sources = [ "service_ext_ability_module.cpp" ] - - deps = [ - ":service_ext_ability_abc", - ":service_ext_ability_js", - ] - - external_deps = [ "napi:ace_napi" ] - - relative_install_dir = "module/application" - subsystem_name = "aafwk" - part_name = "ability_runtime" -} diff --git a/interfaces/kits/napi/aafwk/service_ext_ability_context/BUILD.gn b/interfaces/kits/napi/aafwk/service_ext_ability_context/BUILD.gn deleted file mode 100644 index e67fb3dd80..0000000000 --- a/interfaces/kits/napi/aafwk/service_ext_ability_context/BUILD.gn +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//ark/ts2abc/ts2panda/ts2abc_config.gni") -import("//build/ohos.gni") - -ts2abc_gen_abc("gen_service_ext_ability_context_abc") { - src_js = rebase_path("service_ext_ability_context.js") - dst_file = rebase_path(target_out_dir + "/service_ext_ability_context.abc") - in_puts = [ "service_ext_ability_context.js" ] - out_puts = [ target_out_dir + "/service_ext_ability_context.abc" ] - extra_args = [ "--module" ] -} - -gen_js_obj("service_ext_ability_context_js") { - input = "service_ext_ability_context.js" - output = target_out_dir + "/service_ext_ability_context.o" -} - -gen_js_obj("service_ext_ability_context_abc") { - input = get_label_info(":gen_service_ext_ability_context_abc", - "target_out_dir") + "/service_ext_ability_context.abc" - output = target_out_dir + "/service_ext_ability_context_abc.o" - dep = ":gen_service_ext_ability_context_abc" -} - -ohos_shared_library("serviceextabilitycontext_napi") { - sources = [ "service_ext_ability_context_module.cpp" ] - - deps = [ - ":service_ext_ability_context_abc", - ":service_ext_ability_context_js", - ] - - external_deps = [ "napi:ace_napi" ] - - relative_install_dir = "module/application" - subsystem_name = "aafwk" - part_name = "ability_runtime" -} diff --git a/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context.js b/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context.js deleted file mode 100644 index b56e8128e2..0000000000 --- a/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var ExtAbilityContext = requireNapi("application.ExtAbilityContext") - -class ServiceExtAbilityContext extends ExtAbilityContext { - constructor(obj) { - super(obj); - this.extensionAbilityInfo = obj.extensionAbilityInfo - } - - startAbility(want, options, callback) { - console.log("startAbility"); - return this.__context_impl__.startAbility(want, options, callback); - } - - connectAbility(want, options) { - console.log("connectAbility"); - return this.__context_impl__.connectAbility(want, options); - } - - startAbilityWithAccount(want, accountId, options, callback) { - console.log("startAbilityWithAccount"); - return this.__context_impl__.startAbilityWithAccount(want, accountId, options, callback); - } - - connectAbilityWithAccount(want, accountId, options) { - console.log("connectAbilityWithAccount"); - return this.__context_impl__.connectAbilityWithAccount(want, accountId, options); - } - - disconnectAbility(connection, callback) { - console.log("disconnectAbility"); - return this.__context_impl__.disconnectAbility(connection, callback); - } - - terminateSelf(callback) { - console.log("terminateSelf"); - return this.__context_impl__.terminateSelf(callback); - } -} - -export default ServiceExtAbilityContext \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context_module.cpp b/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context_module.cpp deleted file mode 100644 index 79d6e13f82..0000000000 --- a/interfaces/kits/napi/aafwk/service_ext_ability_context/service_ext_ability_context_module.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "native_engine/native_engine.h" - -extern const char _binary_service_ext_ability_context_js_start[]; -extern const char _binary_service_ext_ability_context_js_end[]; -extern const char _binary_service_ext_ability_context_abc_start[]; -extern const char _binary_service_ext_ability_context_abc_end[]; - -extern "C" __attribute__((constructor)) -void NAPI_application_ServiceExtAbilityContext_AutoRegister() -{ - auto moduleManager = NativeModuleManager::GetInstance(); - NativeModule newModuleInfo = { - .name = "application.ServiceExtAbilityContext", - .fileName = "application/libserviceextabilitycontext_napi.so/service_ext_ability_context.js", - }; - - moduleManager->Register(&newModuleInfo); -} - -extern "C" __attribute__((visibility("default"))) -void NAPI_application_ServiceExtAbilityContext_GetJSCode(const char **buf, int *bufLen) -{ - if (buf != nullptr) { - *buf = _binary_service_ext_ability_context_js_start; - } - - if (bufLen != nullptr) { - *bufLen = _binary_service_ext_ability_context_js_end - _binary_service_ext_ability_context_js_start; - } -} - -// ability_context JS register -extern "C" __attribute__((visibility("default"))) -void NAPI_application_ServiceExtAbilityContext_GetABCCode(const char **buf, int *buflen) -{ - if (buf != nullptr) { - *buf = _binary_service_ext_ability_context_abc_start; - } - if (buflen != nullptr) { - *buflen = _binary_service_ext_ability_context_abc_end - _binary_service_ext_ability_context_abc_start; - } -} diff --git a/interfaces/kits/napi/aafwk/service_extension_ability/BUILD.gn b/interfaces/kits/napi/aafwk/service_extension_ability/BUILD.gn new file mode 100644 index 0000000000..f4d8782c39 --- /dev/null +++ b/interfaces/kits/napi/aafwk/service_extension_ability/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//ark/ts2abc/ts2panda/ts2abc_config.gni") +import("//build/ohos.gni") + +ts2abc_gen_abc("gen_service_extension_ability_abc") { + src_js = rebase_path("service_extension_ability.js") + dst_file = rebase_path(target_out_dir + "/service_extension_ability.abc") + in_puts = [ "service_extension_ability.js" ] + out_puts = [ target_out_dir + "/service_extension_ability.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("service_extension_ability_js") { + input = "service_extension_ability.js" + output = target_out_dir + "/service_extension_ability.o" +} + +gen_js_obj("service_extension_ability_abc") { + input = get_label_info(":gen_service_extension_ability_abc", + "target_out_dir") + "/service_extension_ability.abc" + output = target_out_dir + "/service_extension_ability_abc.o" + dep = ":gen_service_extension_ability_abc" +} + +ohos_shared_library("serviceextensionability_napi") { + sources = [ "service_extension_ability_module.cpp" ] + + deps = [ + ":service_extension_ability_abc", + ":service_extension_ability_js", + ] + + external_deps = [ "napi:ace_napi" ] + + relative_install_dir = "module/application" + subsystem_name = "aafwk" + part_name = "ability_runtime" +} diff --git a/interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability.js b/interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability.js similarity index 87% rename from interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability.js rename to interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability.js index 01d0ea33c5..490ff7ad03 100644 --- a/interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability.js +++ b/interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability.js @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -class ServiceExtAbility { - onCreate(want) { - console.log('onCreate, want:' + want.abilityName); - } - - onRequest(want, startId) { - console.log('onRequest, want:' + want.abilityName + ', startId:' + startId); - } - - onConnect(want) { - console.log('onConnect, want:' + want.abilityName); - } - - onDisconnect(want) { - console.log('onDisconnect'); - } - - onDestroy() { - console.log('onDestroy'); - } -} - -export default ServiceExtAbility \ No newline at end of file +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class ServiceExtensionAbility { + onCreate(want) { + console.log('onCreate, want:' + want.abilityName); + } + + onRequest(want, startId) { + console.log('onRequest, want:' + want.abilityName + ', startId:' + startId); + } + + onConnect(want) { + console.log('onConnect, want:' + want.abilityName); + } + + onDisconnect(want) { + console.log('onDisconnect'); + } + + onDestroy() { + console.log('onDestroy'); + } +} + +export default ServiceExtensionAbility \ No newline at end of file diff --git a/interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability_module.cpp b/interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability_module.cpp similarity index 57% rename from interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability_module.cpp rename to interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability_module.cpp index 03b25ba25f..cfe23038b0 100644 --- a/interfaces/kits/napi/aafwk/service_ext_ability/service_ext_ability_module.cpp +++ b/interfaces/kits/napi/aafwk/service_extension_ability/service_extension_ability_module.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -15,13 +15,13 @@ #include "native_engine/native_engine.h" -extern const char _binary_service_ext_ability_js_start[]; -extern const char _binary_service_ext_ability_js_end[]; -extern const char _binary_service_ext_ability_abc_start[]; -extern const char _binary_service_ext_ability_abc_end[]; +extern const char _binary_service_extension_ability_js_start[]; +extern const char _binary_service_extension_ability_js_end[]; +extern const char _binary_service_extension_ability_abc_start[]; +extern const char _binary_service_extension_ability_abc_end[]; extern "C" __attribute__((constructor)) -void NAPI_application_ServiceExtAbility_AutoRegister() +void NAPI_application_ServiceExtensionAbility_AutoRegister() { auto moduleManager = NativeModuleManager::GetInstance(); NativeModule newModuleInfo = { @@ -33,25 +33,24 @@ void NAPI_application_ServiceExtAbility_AutoRegister() } extern "C" __attribute__((visibility("default"))) -void NAPI_application_ServiceExtAbility_GetJSCode(const char **buf, int *bufLen) +void NAPI_application_ServiceExtensionAbility_GetJSCode(const char **buf, int *bufLen) { if (buf != nullptr) { - *buf = _binary_service_ext_ability_js_start; + *buf = _binary_service_extension_ability_js_start; } if (bufLen != nullptr) { - *bufLen = _binary_service_ext_ability_js_end - _binary_service_ext_ability_js_start; + *bufLen = _binary_service_extension_ability_js_end - _binary_service_extension_ability_js_start; } } -// service_extension JS register extern "C" __attribute__((visibility("default"))) -void NAPI_application_ServiceExtAbility_GetABCCode(const char **buf, int *buflen) +void NAPI_application_ServiceExtensionAbility_GetABCCode(const char **buf, int *buflen) { if (buf != nullptr) { - *buf = _binary_service_ext_ability_abc_start; + *buf = _binary_service_extension_ability_abc_start; } if (buflen != nullptr) { - *buflen = _binary_service_ext_ability_abc_end - _binary_service_ext_ability_abc_start; + *buflen = _binary_service_extension_ability_abc_end - _binary_service_extension_ability_abc_start; } } \ No newline at end of file