From 7e64d14dbe1db0a92ebb5cc07fb2cd9578537331 Mon Sep 17 00:00:00 2001 From: anqi Date: Tue, 18 Oct 2022 11:49:41 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8B=96=E6=8B=BD=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E6=97=B6=E6=8B=89=E8=B5=B7=E6=8B=96=E6=8B=BD=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: anqi --- adapter/ohos/osal/BUILD.gn | 1 + adapter/ohos/osal/ace_engine_ext.cpp | 48 +++++++++++++++++++ adapter/preview/osal/BUILD.gn | 1 + adapter/preview/osal/ace_engine_ext.cpp | 20 ++++++++ frameworks/core/BUILD.gn | 1 + frameworks/core/common/ace_engine_ext.cpp | 34 +++++++++++++ frameworks/core/common/ace_engine_ext.h | 38 +++++++++++++++ .../core/components/image/render_image.cpp | 7 +++ .../core/components/text/render_text.cpp | 7 +++ 9 files changed, 157 insertions(+) create mode 100644 adapter/ohos/osal/ace_engine_ext.cpp create mode 100644 adapter/preview/osal/ace_engine_ext.cpp create mode 100644 frameworks/core/common/ace_engine_ext.cpp create mode 100644 frameworks/core/common/ace_engine_ext.h diff --git a/adapter/ohos/osal/BUILD.gn b/adapter/ohos/osal/BUILD.gn index e2764deb51d..35831890cf5 100644 --- a/adapter/ohos/osal/BUILD.gn +++ b/adapter/ohos/osal/BUILD.gn @@ -45,6 +45,7 @@ template("ace_osal_ohos_source_set") { ] sources = [ + "ace_engine_ext.cpp", "ace_trace.cpp", "anr_thread.cpp", "event_report.cpp", diff --git a/adapter/ohos/osal/ace_engine_ext.cpp b/adapter/ohos/osal/ace_engine_ext.cpp new file mode 100644 index 00000000000..af88573c9e5 --- /dev/null +++ b/adapter/ohos/osal/ace_engine_ext.cpp @@ -0,0 +1,48 @@ +/* + * 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 "core/common/ace_engine_ext.h" + +#include + +#include "base/log/log.h" + +namespace OHOS::Ace { +namespace { +#ifdef __aarch64__ +const std::string DRAG_EXTENSION_SO_PATH = "system/lib64/module/autorun/libhmos_drag_drop.z.so"; +#else +const std::string DRAG_EXTENSION_SO_PATH = "system/lib/module/autorun/libhmos_drag_drop.z.so"; +#endif +} + +void CallDragExtFunc() +{ + auto handle = dlopen(DRAG_EXTENSION_SO_PATH.c_str(), RTLD_LAZY); + if (handle == nullptr) { + LOGE("Failed to open drag extension library, reason: %{public}s", dlerror()); + return; + } + auto dragFunc = reinterpret_cast(dlsym(handle, "StartDragService")); + if (dragFunc == nullptr) { + LOGE("Failed to get drag extension func"); + dlclose(handle); + return; + } + LOGI("Call drag extension func"); + dragFunc(); + dlclose(handle); +} +} // namespace OHOS::Ace \ No newline at end of file diff --git a/adapter/preview/osal/BUILD.gn b/adapter/preview/osal/BUILD.gn index 55889b7660c..399547d52fc 100644 --- a/adapter/preview/osal/BUILD.gn +++ b/adapter/preview/osal/BUILD.gn @@ -44,6 +44,7 @@ template("ace_osal_preview_source_set") { sources = [ "${ace_root}/adapter/ohos/osal/log_wrapper.cpp", + "ace_engine_ext.cpp", "ace_trace.cpp", "event_report.cpp", "exception_handler.cpp", diff --git a/adapter/preview/osal/ace_engine_ext.cpp b/adapter/preview/osal/ace_engine_ext.cpp new file mode 100644 index 00000000000..1a5748a5225 --- /dev/null +++ b/adapter/preview/osal/ace_engine_ext.cpp @@ -0,0 +1,20 @@ +/* + * 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 "core/common/ace_engine_ext.h" + +namespace OHOS::Ace { +void CallDragExtFunc() {} +} // namespace OHOS::Ace \ No newline at end of file diff --git a/frameworks/core/BUILD.gn b/frameworks/core/BUILD.gn index 7e9305a41d6..6cae978532d 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -59,6 +59,7 @@ template("ace_core_source_set") { # common "common/ace_application_info.cpp", "common/ace_engine.cpp", + "common/ace_engine_ext.cpp", "common/anr_thread.cpp", "common/clipboard/clipboard_proxy.cpp", "common/container.cpp", diff --git a/frameworks/core/common/ace_engine_ext.cpp b/frameworks/core/common/ace_engine_ext.cpp new file mode 100644 index 00000000000..bd323c7d75a --- /dev/null +++ b/frameworks/core/common/ace_engine_ext.cpp @@ -0,0 +1,34 @@ +/* + * 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 "core/common/ace_engine_ext.h" + +#include "base/log/log.h" + +namespace OHOS::Ace { + +AceEngineExt& AceEngineExt::GetInstance() +{ + static AceEngineExt instance; + return instance; +} + +void AceEngineExt::DragStartExt() +{ + LOGI("AceEngineExt DragStartExt"); + CallDragExtFunc(); +} +} // namespace OHOS::Ace +\ No newline at end of file \ No newline at end of file diff --git a/frameworks/core/common/ace_engine_ext.h b/frameworks/core/common/ace_engine_ext.h new file mode 100644 index 00000000000..84ce98238a0 --- /dev/null +++ b/frameworks/core/common/ace_engine_ext.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_ACE_ENGINE_EXT_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_ACE_ENGINE_EXT_H + +#include "base/utils/macros.h" +#include "base/utils/noncopyable.h" + +namespace OHOS::Ace { +using DragExtFunc = void (*)(); + +void ACE_EXPORT CallDragExtFunc(); + +class ACE_EXPORT AceEngineExt final { +public: + static AceEngineExt& GetInstance(); + void DragStartExt(); + +private: + AceEngineExt() = default; + ~AceEngineExt() = default; +}; +} // namespace OHOS::Ace + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_ACE_ENGINE_EXT_H \ No newline at end of file diff --git a/frameworks/core/components/image/render_image.cpp b/frameworks/core/components/image/render_image.cpp index 58301b477fa..9cec9c9e10d 100644 --- a/frameworks/core/components/image/render_image.cpp +++ b/frameworks/core/components/image/render_image.cpp @@ -18,6 +18,7 @@ #include "base/log/dump_log.h" #include "base/log/log.h" #include "base/utils/utils.h" +#include "core/common/ace_engine_ext.h" #include "core/common/clipboard/clipboard_proxy.h" #include "core/components/container_modal/container_modal_constants.h" #include "core/components/image/image_component.h" @@ -965,6 +966,9 @@ void RenderImage::PanOnActionStart(const GestureEvent& info) auto image = initRenderNode->GetSkImage(); dragWindow_->DrawImage(image); } + if (dragWindow_) { + AceEngineExt::GetInstance().DragStartExt(); + } return; } @@ -983,6 +987,9 @@ void RenderImage::PanOnActionStart(const GestureEvent& info) dragWindow_->SetOffset(rect.Left(), rect.Top()); dragWindow_->DrawPixelMap(dragItemInfo.pixelMap); } + if (dragWindow_) { + AceEngineExt::GetInstance().DragStartExt(); + } return; } #endif diff --git a/frameworks/core/components/text/render_text.cpp b/frameworks/core/components/text/render_text.cpp index 3519df3357c..5266668d616 100644 --- a/frameworks/core/components/text/render_text.cpp +++ b/frameworks/core/components/text/render_text.cpp @@ -17,6 +17,7 @@ #include "base/geometry/size.h" #include "base/log/dump_log.h" +#include "core/common/ace_engine_ext.h" #include "core/common/clipboard/clipboard_proxy.h" #include "core/common/font_manager.h" #include "core/components/container_modal/container_modal_constants.h" @@ -977,6 +978,9 @@ void RenderText::PanOnActionStart(const GestureEvent& info) dragWindow_->SetOffset(rect.Left(), rect.Top()); dragWindow_->DrawText(paragraph_, GetPaintRect().GetOffset(), initRenderNode); } + if (dragWindow_) { + AceEngineExt::GetInstance().DragStartExt(); + } return; } @@ -995,6 +999,9 @@ void RenderText::PanOnActionStart(const GestureEvent& info) dragWindow_->SetOffset(rect.Left(), rect.Top()); dragWindow_->DrawPixelMap(dragItemInfo.pixelMap); } + if (dragWindow_) { + AceEngineExt::GetInstance().DragStartExt(); + } return; } #endif -- Gitee From 33e48771eab867b85aef83ff03269d22a7d551b2 Mon Sep 17 00:00:00 2001 From: anqi Date: Tue, 18 Oct 2022 12:23:40 +0000 Subject: [PATCH 2/2] update frameworks/core/common/ace_engine_ext.cpp. Signed-off-by: anqi --- frameworks/core/common/ace_engine_ext.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/core/common/ace_engine_ext.cpp b/frameworks/core/common/ace_engine_ext.cpp index bd323c7d75a..4fd5b221bc3 100644 --- a/frameworks/core/common/ace_engine_ext.cpp +++ b/frameworks/core/common/ace_engine_ext.cpp @@ -30,5 +30,4 @@ void AceEngineExt::DragStartExt() LOGI("AceEngineExt DragStartExt"); CallDragExtFunc(); } -} // namespace OHOS::Ace -\ No newline at end of file \ No newline at end of file +} // namespace OHOS::Ace \ No newline at end of file -- Gitee