!1141 windowExtension 改成windowExtensionAbility

Merge pull request !1141 from dubingjian/master
This commit is contained in:
openharmony_ci
2022-07-12 13:13:02 +00:00
committed by Gitee
8 changed files with 144 additions and 139 deletions
@@ -113,7 +113,7 @@ int WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::ElementN
want.SetParam(RECT_FORM_KEY_WIDTH, static_cast<int>(rect.width_));
want.SetParam(RECT_FORM_KEY_HEIGHT, static_cast<int>(rect.height_));
// 100 default userId
auto ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, this, nullptr, 100);
auto ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, this, nullptr, uid);
if (ret == ERR_OK) {
componentCallback_ = callback;
}
@@ -189,6 +189,12 @@ void JsWindowExtension::OnDisconnect(const AAFwk::Want& want)
std::unique_ptr<AbilityRuntime::AsyncTask::ExecuteCallback> execute = nullptr;
AbilityRuntime::AsyncTask::Schedule("JsWindowExtension::OnDisconnect", engine,
std::make_unique<AbilityRuntime::AsyncTask>(callback, std::move(execute), std::move(complete)));
auto window = stub_ != nullptr ? stub_->GetWindow() : nullptr;
if (window != nullptr) {
window->Destroy();
WLOGFI("Destroy window.");
}
WLOGFI("called.");
}
+1 -1
View File
@@ -20,7 +20,7 @@ group("napi_packages") {
"screen_recorder:screenrecorder_napi",
"screen_runtime:screen_napi",
"screenshot:screenshot",
"window_extension:windowextension_napi",
"window_extension_ability:windowextensionability_napi",
"window_extension_context:windowextensioncontext_napi",
"window_runtime:window_napi",
"window_runtime:window_native_kit",
@@ -1,50 +0,0 @@
# Copyright (c) 2022-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_window_extension_abc") {
src_js = rebase_path("window_extension.js")
dst_file = rebase_path(target_out_dir + "/window_extension.abc")
in_puts = [ "window_extension.js" ]
out_puts = [ target_out_dir + "/window_extension.abc" ]
extra_args = [ "--module" ]
}
gen_js_obj("window_extension_js") {
input = "window_extension.js"
output = target_out_dir + "/window_extension.o"
}
gen_js_obj("window_extension_abc") {
input = get_label_info(":gen_window_extension_abc", "target_out_dir") +
"/window_extension.abc"
output = target_out_dir + "/window_extension_abc.o"
dep = ":gen_window_extension_abc"
}
ohos_shared_library("windowextension_napi") {
sources = [ "window_extension_module.cpp" ]
deps = [
":window_extension_abc",
":window_extension_js",
]
external_deps = [ "napi:ace_napi" ]
relative_install_dir = "module/application"
subsystem_name = "window"
part_name = "window_manager"
}
@@ -1,57 +0,0 @@
/*
* Copyright (c) 2022-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.
*/
#include <native_engine/native_engine.h>
extern const char _binary_window_extension_js_start[];
extern const char _binary_window_extension_js_end[];
extern const char _binary_window_extension_abc_start[];
extern const char _binary_window_extension_abc_end[];
extern "C" __attribute__((constructor))
void NAPI_application_WindowExtension_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
.name = "application.WindowExtension",
.fileName = "application/libwindowextension_napi.so/WindowExtension.js",
};
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_WindowExtension_GetJSCode(const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_window_extension_js_start;
}
if (bufLen != nullptr) {
*bufLen = _binary_window_extension_js_end - _binary_window_extension_js_start;
}
}
// window_extension JS register
extern "C" __attribute__((visibility("default")))
void NAPI_application_WindowExtension_GetABCCode(const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_window_extension_abc_start;
}
if (buflen != nullptr) {
*buflen = _binary_window_extension_abc_end - _binary_window_extension_abc_start;
}
}
@@ -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_window_extension_ability_abc") {
src_js = rebase_path("window_extension_ability.js")
dst_file = rebase_path(target_out_dir + "/window_extension_ability.abc")
in_puts = [ "window_extension_ability.js" ]
out_puts = [ target_out_dir + "/window_extension_ability.abc" ]
extra_args = [ "--module" ]
}
gen_js_obj("window_extension_ability_js") {
input = "window_extension_ability.js"
output = target_out_dir + "/window_extension_ability.o"
}
gen_js_obj("window_extension_ability_abc") {
input = get_label_info(":gen_window_extension_ability_abc",
"target_out_dir") + "/window_extension_ability.abc"
output = target_out_dir + "/window_extension_ability_abc.o"
dep = ":gen_window_extension_ability_abc"
}
ohos_shared_library("windowextensionability_napi") {
sources = [ "window_extension_ability_module.cpp" ]
deps = [
":window_extension_ability_abc",
":window_extension_ability_js",
]
external_deps = [ "napi:ace_napi" ]
relative_install_dir = "module/application"
subsystem_name = "window"
part_name = "window_manager"
}
@@ -1,30 +1,30 @@
/*
* 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 WindowExtension {
onWindowReady(window) {
console.log('WindowExtension windowReady');
}
onConnect(want) {
console.log('WindowExtension onConnect, want:' + want.abilityName);
}
onDisconnect(want) {
console.log('WindowExtension onDisconnect' + want.abilityName);
}
}
export default WindowExtension
/*
* 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 WindowExtensionAbility {
onWindowReady(window) {
console.log('WindowExtension windowReady');
}
onConnect(want) {
console.log('WindowExtension onConnect, want:' + want.abilityName);
}
onDisconnect(want) {
console.log('WindowExtension onDisconnect' + want.abilityName);
}
}
export default WindowExtensionAbility
@@ -0,0 +1,56 @@
/*
* 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.
*/
#include "native_engine/native_engine.h"
extern const char _binary_window_extension_ability_js_start[];
extern const char _binary_window_extension_ability_js_end[];
extern const char _binary_window_extension_ability_abc_start[];
extern const char _binary_window_extension_ability_abc_end[];
extern "C" __attribute__((constructor))
void NAPI_application_WindowExtensionAbility_AutoRegister()
{
auto moduleManager = NativeModuleManager::GetInstance();
NativeModule newModuleInfo = {
.name = "application.WindowExtensionAbility",
.fileName = "application/libwindowextensionability_napi.so/window_extension_ability.js",
};
moduleManager->Register(&newModuleInfo);
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_WindowExtensionAbility_GetJSCode(const char **buf, int *bufLen)
{
if (buf != nullptr) {
*buf = _binary_window_extension_ability_js_start;
}
if (bufLen != nullptr) {
*bufLen = _binary_window_extension_ability_js_end - _binary_window_extension_ability_js_start;
}
}
extern "C" __attribute__((visibility("default")))
void NAPI_application_WindowExtensionAbility_GetABCCode(const char **buf, int *buflen)
{
if (buf != nullptr) {
*buf = _binary_window_extension_ability_abc_start;
}
if (buflen != nullptr) {
*buflen = _binary_window_extension_ability_abc_end - _binary_window_extension_ability_abc_start;
}
}