add base class for embeddable context.

Signed-off-by: bobie <zhouchuanbo2@huawei.com>
This commit is contained in:
bobie 2023-11-27 20:06:19 +08:00
parent 553e5d85a5
commit 99444ea2fb
4 changed files with 139 additions and 0 deletions

View File

@ -50,6 +50,7 @@ group("napi_packages") {
"${ability_runtime_napi_path}/configuration_constant:configurationconstant_napi",
"${ability_runtime_napi_path}/dataUriUtils:datauriutils_napi",
"${ability_runtime_napi_path}/embeddable_ui_ability:embeddableuiability_napi",
"${ability_runtime_napi_path}/embeddable_ui_ability_context:embeddableuiabilitycontext_napi",
"${ability_runtime_napi_path}/extension_ability:extensionability_napi",
"${ability_runtime_napi_path}/extensioncontext:extensioncontext_napi",
"${ability_runtime_napi_path}/featureAbility:featureability",

View File

@ -0,0 +1,51 @@
# Copyright (c) 2023 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
import("//build/ohos.gni")
es2abc_gen_abc("gen_embeddable_ui_ability_context_abc") {
src_js = rebase_path("embeddable_ui_ability_context.js")
dst_file = rebase_path(target_out_dir + "/embeddable_ui_ability_context.abc")
in_puts = [ "embeddable_ui_ability_context.js" ]
out_puts = [ target_out_dir + "/embeddable_ui_ability_context.abc" ]
extra_args = [ "--module" ]
}
gen_js_obj("embeddable_ui_ability_context_js") {
input = "embeddable_ui_ability_context.js"
output = target_out_dir + "/embeddable_ui_ability_context.o"
}
gen_js_obj("embeddable_ui_ability_context_abc") {
input =
get_label_info(":gen_embeddable_ui_ability_context_abc",
"target_out_dir") + "/embeddable_ui_ability_context.abc"
output = target_out_dir + "/embeddable_ui_ability_context_abc.o"
dep = ":gen_embeddable_ui_ability_context_abc"
}
ohos_shared_library("embeddableuiabilitycontext_napi") {
sources = [ "embeddable_ui_ability_context_module.cpp" ]
deps = [
":embeddable_ui_ability_context_abc",
":embeddable_ui_ability_context_js",
]
external_deps = [ "napi:ace_napi" ]
relative_install_dir = "module/application"
subsystem_name = "ability"
part_name = "ability_runtime"
}

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 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.
*/
let AbilityContext = requireNapi('application.AbilityContext');
class EmbeddableUIAbilityContext extends AbilityContext {
constructor(obj) {
super(obj);
this.abilityInfo = obj.abilityInfo;
this.currentHapModuleInfo = obj.currentHapModuleInfo;
this.config = obj.config;
}
onUpdateConfiguration(config) {
this.config = config;
}
}
export default EmbeddableUIAbilityContext;

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 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_embeddable_ui_ability_context_js_start[];
extern const char _binary_embeddable_ui_ability_context_js_end[];
extern const char _binary_embeddable_ui_ability_context_abc_start[];
extern const char _binary_embeddable_ui_ability_context_abc_end[];
static napi_module _module = {
.nm_version = 0,
.nm_filename = "application/libembeddableuiabilitycontext_napi.so/embeddable_ui_ability_context.js",
.nm_modname = "application.EmbeddableUIAbilityContext",
};
extern "C" __attribute__((constructor)) void NAPI_application_EmbeddableUIAbilityContext_AutoRegister()
{
napi_module_register(&_module);
}
extern "C" __attribute__((visibility("default"))) void NAPI_application_EmbeddableUIAbilityContext_GetJSCode(
const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_embeddable_ui_ability_context_js_start;
}
if (bufLen != nullptr) {
*bufLen = _binary_embeddable_ui_ability_context_js_end - _binary_embeddable_ui_ability_context_js_start;
}
}
// embeddable_ui_ability_context JS register
extern "C" __attribute__((visibility("default"))) void NAPI_application_EmbeddableUIAbilityContext_GetABCCode(
const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_embeddable_ui_ability_context_abc_start;
}
if (buflen != nullptr) {
*buflen = _binary_embeddable_ui_ability_context_abc_end - _binary_embeddable_ui_ability_context_abc_start;
}
}