From 24ecadd080d841d681e5506a3560cd33c4dfe9fc Mon Sep 17 00:00:00 2001 From: dubj Date: Mon, 25 Apr 2022 19:44:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=B9=E5=A4=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dubj Change-Id: Ib322eaa5d71fa83984d5beba7afdc1def68160ae --- bundle.json | 10 ++++++++++ extension/extension_connection/BUILD.gn | 19 ++++++++++--------- .../src/window_extension_client_proxy.cpp | 4 ++-- .../src/window_extension_connection.cpp | 13 ++++++++++++- extension/window_extension/BUILD.gn | 12 +----------- .../include/js_window_extension_context.h | 1 - .../include/window_extension_context.h | 5 +++-- .../src/js_window_extension.cpp | 10 +++++----- .../src/js_window_extension_context.cpp | 8 ++------ .../window_extension/src/window_extension.cpp | 2 +- .../src/window_extension_stub_impl.cpp | 1 - .../window_extension_connection.h | 2 ++ 12 files changed, 48 insertions(+), 39 deletions(-) rename interfaces/innerkits/{wm => extension}/window_extension_connection.h (97%) diff --git a/bundle.json b/bundle.json index fbc57c0e..d1825e0f 100644 --- a/bundle.json +++ b/bundle.json @@ -91,6 +91,16 @@ ], "header_base": "//foundation/windowmanager/interfaces/innerkits/dm" } + }, + { + "type": "so", + "name": "//foundation/windowmanager/extension/extension_connection:libwindow_extension_client", + "header": { + "header_files": [ + "window_extension_connection.h" + ], + "header_base": "//foundation/windowmanager/interfaces/innerkits/extension" + } } ], "test": [ diff --git a/extension/extension_connection/BUILD.gn b/extension/extension_connection/BUILD.gn index 97c6333b..cf57cf17 100644 --- a/extension/extension_connection/BUILD.gn +++ b/extension/extension_connection/BUILD.gn @@ -19,17 +19,16 @@ config("libwindow_extension_client_private_config") { include_dirs = [ "include", "include/zidl", - "../window_extension/include", "../window_extension/include/zidl", - "../../interface/innerkits/wm", - "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime/include", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager/include", ] } +config("libextension_connection_public_config") { + include_dirs = [ "../../interfaces/innerkits/extension" ] +} + ohos_shared_library("libwindow_extension_client") { install_enable = true - sources = [ "../window_extension/src/window_extension_proxy.cpp", "src/window_extension_connection.cpp", @@ -37,21 +36,23 @@ ohos_shared_library("libwindow_extension_client") { "src/window_extension_client_stub_impl.cpp", ] + public_configs = [ ":libextension_connection_public_config" ] + configs = [ ":libwindow_extension_client_private_config" ] deps = [ - "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", - "//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", "//foundation/windowmanager/wm:libwm", "//foundation/windowmanager/extension/window_extension:libwindow_extension", - "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base", - "//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler", ] external_deps = [ "ability_base:want", + "ability_runtime:abilitykit_native", + "ability_runtime:ability_manager", "ability_runtime:runtime", + "bundle_framework:appexecfwk_base", + "eventhandler:libeventhandler", "graphic_standard:surface", "hiviewdfx_hilog_native:libhilog", "input:libmmi-client", diff --git a/extension/extension_connection/src/window_extension_client_proxy.cpp b/extension/extension_connection/src/window_extension_client_proxy.cpp index 3f6ba8a4..24722260 100644 --- a/extension/extension_connection/src/window_extension_client_proxy.cpp +++ b/extension/extension_connection/src/window_extension_client_proxy.cpp @@ -74,8 +74,8 @@ void WindowExtensionClientProxy::OnKeyEvent(std::shared_ptr& keyE } if (!keyEvent->WriteToParcel(data)) { - WLOGFE("write key event failed"); - return; + WLOGFE("write key event failed"); + return; } if (Remote()->SendRequest(TRANS_ID_ON_KEY_EVENT, data, replay, option) != ERR_NONE) { WLOGFE("send request failed"); diff --git a/extension/extension_connection/src/window_extension_connection.cpp b/extension/extension_connection/src/window_extension_connection.cpp index 415f3300..60c420b4 100644 --- a/extension/extension_connection/src/window_extension_connection.cpp +++ b/extension/extension_connection/src/window_extension_connection.cpp @@ -116,7 +116,6 @@ void WindowExtensionConnection::Impl::ConnectExtension(const AppExecFwk::Element void WindowExtensionConnection::Impl::Show() { - if (proxy_ != nullptr) { proxy_->Show(); WLOGFI("show window"); @@ -139,6 +138,13 @@ void WindowExtensionConnection::Impl::RequestFocus() } } +void WindowExtensionConnection::Impl::Resize(Rect rect) +{ + if (proxy_ != nullptr) { + proxy_->Resize(rect); + } +} + void WindowExtensionConnection::Impl::OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) { @@ -197,5 +203,10 @@ void WindowExtensionConnection::RequestFocus() { pImpl_->RequestFocus(); } + +void WindowExtensionConnection::SetBounds(Rect rect) +{ + pImpl_->Resize(rect); +} } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/extension/window_extension/BUILD.gn b/extension/window_extension/BUILD.gn index 79b429b4..4cdd47ff 100644 --- a/extension/window_extension/BUILD.gn +++ b/extension/window_extension/BUILD.gn @@ -22,16 +22,8 @@ config("libwindow_extension_private_config") { "../extension_connection/include", "../extension_connection/include/zidl", "../../interfaces/kits/napi/window_runtime/window_napi", - "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime/include", - "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common", - "//foundation/aafwk/standard/interfaces/innerkits/runtime/include", - ] -} - -config("libwindow_extension_public_config") { - include_dirs = [ + "../../interfaces/innerkits/extension", "../../interfaces/innerkits/wm", - "../../utils/include", ] } @@ -48,8 +40,6 @@ ohos_shared_library("libwindow_extension") { configs = [ ":libwindow_extension_private_config" ] - public_configs = [ ":libwindow_extension_public_config" ] - deps = [ "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", diff --git a/extension/window_extension/include/js_window_extension_context.h b/extension/window_extension/include/js_window_extension_context.h index 3f39858c..61b79c02 100644 --- a/extension/window_extension/include/js_window_extension_context.h +++ b/extension/window_extension/include/js_window_extension_context.h @@ -30,7 +30,6 @@ class JsWindowConnectCallback : public AbilityRuntime::AbilityConnectCallback { public: explicit JsWindowConnectCallback() = default; ~JsWindowConnectCallback() = default; - // void OnWindowCreate(sptr window); //TODO virtual void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; virtual void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; diff --git a/extension/window_extension/include/window_extension_context.h b/extension/window_extension/include/window_extension_context.h index de52f899..ee02470a 100644 --- a/extension/window_extension/include/window_extension_context.h +++ b/extension/window_extension/include/window_extension_context.h @@ -13,10 +13,11 @@ * limitations under the License. */ -#include - #ifndef WINDOW_EXTENSION_CONTEXT_H #define WINDOW_EXTENSION_CONTEXT_H + +#include + namespace OHOS { namespace Rosen { class WindowExtensionContext : public AbilityRuntime::ExtensionContext { diff --git a/extension/window_extension/src/js_window_extension.cpp b/extension/window_extension/src/js_window_extension.cpp index 5234b3a5..f0c73ab9 100644 --- a/extension/window_extension/src/js_window_extension.cpp +++ b/extension/window_extension/src/js_window_extension.cpp @@ -124,13 +124,13 @@ void JsWindowExtension::GetSrcPath(std::string &srcPath) if (!Extension::abilityInfo_->isModuleJson) { srcPath.append(Extension::abilityInfo_->package); - srcPath.append("/assets/js/"); + srcPath.append("/assets/js/"); if (!Extension::abilityInfo_->srcPath.empty()) { srcPath.append(Extension::abilityInfo_->srcPath); } srcPath.append("/").append(Extension::abilityInfo_->name).append(".abc"); return; - } + } if (!Extension::abilityInfo_->srcEntrance.empty()) { srcPath.append(Extension::abilityInfo_->moduleName + "/"); @@ -189,12 +189,12 @@ void JsWindowExtension::OnStart(const AAFwk::Want &want) { Extension::OnStart(want); - ElementName elementName = want.GetElement(); // TODO 为何之前是GetElementName()? + ElementName elementName = want.GetElement(); std::string windowName = elementName.GetBundleName(); stub_ = new(std::nothrow)WindowExtensionStubImpl(windowName); WLOGFI("JsWindowExtension OnStart begin.."); - Rect rect { want.GetIntParam(RECT_FORM_KEY_POS_X, 0), + Rect rect { want.GetIntParam(RECT_FORM_KEY_POS_X, 0), want.GetIntParam(RECT_FORM_KEY_POS_Y, 0), want.GetIntParam(RECT_FORM_KEY_WIDTH, 0), want.GetIntParam(RECT_FORM_KEY_HEIGHT, 0) }; @@ -211,7 +211,7 @@ void JsWindowExtension::OnStart(const AAFwk::Want &want) } OnWindowCreated(); WLOGFI("ability context onWindowReady rect x =%{public}d y=%{public}d w=%{public}d h=%{public}d ", - rect.posX_, rect.posY_, rect.width_, rect.height_); + rect.posX_, rect.posY_, rect.width_, rect.height_); } } diff --git a/extension/window_extension/src/js_window_extension_context.cpp b/extension/window_extension/src/js_window_extension_context.cpp index e22e20f7..58f884ba 100644 --- a/extension/window_extension/src/js_window_extension_context.cpp +++ b/extension/window_extension/src/js_window_extension_context.cpp @@ -42,13 +42,9 @@ public: private: std::shared_ptr context_; }; -// void JsWindowConnectCallback::OnWindowCreate(sptr window) -// { -// // call js api -// } void JsWindowConnectCallback::OnAbilityConnectDone(const AppExecFwk::ElementName &element, - const sptr &remoteObject, int resultCode) + const sptr &remoteObject, int resultCode) { WLOGFI("called"); } @@ -62,7 +58,7 @@ NativeValue* CreateJsWindowExtensionContext(NativeEngine& engine, std::shared_ptr context) { WLOGFI("CreateJsWindowExtensionContext begin"); - NativeValue* objValue = CreateJsExtensionContext(engine, context); // TODO CreateJsBaseContext? + NativeValue* objValue = CreateJsExtensionContext(engine, context); NativeObject* object = AbilityRuntime::ConvertNativeValueTo(objValue); std::unique_ptr jsContext diff --git a/extension/window_extension/src/window_extension.cpp b/extension/window_extension/src/window_extension.cpp index 75d35586..6e17ac30 100644 --- a/extension/window_extension/src/window_extension.cpp +++ b/extension/window_extension/src/window_extension.cpp @@ -49,7 +49,7 @@ void WindowExtension::Init(const std::shared_ptr &token) { ExtensionBase::Init(record, application, handler, token); - WLOGFI("WindowExtension begin init"); + WLOGFI("WindowExtension begin init"); } std::shared_ptr WindowExtension::CreateAndInitContext( diff --git a/extension/window_extension/src/window_extension_stub_impl.cpp b/extension/window_extension/src/window_extension_stub_impl.cpp index 657b3a92..245c5b91 100644 --- a/extension/window_extension/src/window_extension_stub_impl.cpp +++ b/extension/window_extension/src/window_extension_stub_impl.cpp @@ -33,7 +33,6 @@ WindowExtensionStubImpl::WindowExtensionStubImpl(const std::string& windowName) WindowExtensionStubImpl::~WindowExtensionStubImpl() { if (window_ != nullptr) { - // window_->RemoveDispatchInoutEventLisenser(); // TODO window_->Destroy(); } } diff --git a/interfaces/innerkits/wm/window_extension_connection.h b/interfaces/innerkits/extension/window_extension_connection.h similarity index 97% rename from interfaces/innerkits/wm/window_extension_connection.h rename to interfaces/innerkits/extension/window_extension_connection.h index d53290bb..c9ff07d1 100644 --- a/interfaces/innerkits/wm/window_extension_connection.h +++ b/interfaces/innerkits/extension/window_extension_connection.h @@ -52,9 +52,11 @@ public: ~WindowExtensionConnection() = default; void ConnectExtension(const AppExecFwk::ElementName &element, Rect rect, uint32_t uid, sptr& callback); + void DisconnectExtension(); void Show(); void Hide(); void RequestFocus(); + void SetBounds(Rect rect); private: class Impl; sptr pImpl_;