From 7e35964535dc38cf5f56dbb29116cbc0010f0375 Mon Sep 17 00:00:00 2001 From: anqi Date: Wed, 12 Oct 2022 09:29:13 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8B=96=E6=8B=BD=E6=8B=89=E8=B5=B7?= =?UTF-8?q?=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 | 33 +++++++++++++ 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, 156 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 faed7b7224a..762ceab3705 100644 --- a/adapter/ohos/osal/BUILD.gn +++ b/adapter/ohos/osal/BUILD.gn @@ -46,6 +46,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..10eeea0d0e8 --- /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/loh.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 517c105b05a..2e3ec7d8db8 100644 --- a/adapter/preview/osal/BUILD.gn +++ b/adapter/preview/osal/BUILD.gn @@ -45,6 +45,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 c19b78fc870..5b390267a37 100644 --- a/frameworks/core/BUILD.gn +++ b/frameworks/core/BUILD.gn @@ -60,6 +60,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/card_scope.cpp", "common/clipboard/clipboard_proxy.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..42bfa38d737 --- /dev/null +++ b/frameworks/core/common/ace_engine_ext.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2021-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 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 e466d96b907..b2eb1559f66 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 88664d6399f..df1488d530d 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" @@ -978,6 +979,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; } @@ -996,6 +1000,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 b20d3260cfc137638ec5d3707c7ceb1895cbdacc Mon Sep 17 00:00:00 2001 From: anqi Date: Wed, 12 Oct 2022 09:34:08 +0000 Subject: [PATCH 2/3] update adapter/ohos/osal/ace_engine_ext.cpp. Signed-off-by: anqi --- adapter/ohos/osal/ace_engine_ext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/osal/ace_engine_ext.cpp b/adapter/ohos/osal/ace_engine_ext.cpp index 10eeea0d0e8..734e3febac5 100644 --- a/adapter/ohos/osal/ace_engine_ext.cpp +++ b/adapter/ohos/osal/ace_engine_ext.cpp @@ -17,7 +17,7 @@ #include -#include "base/log/loh.h" +#include "base/log/log.h" namespace OHOS::Ace { namespace { -- Gitee From b47f3df4ce88b799b0bf333705144856d2da42a2 Mon Sep 17 00:00:00 2001 From: anqi Date: Wed, 12 Oct 2022 09:53:42 +0000 Subject: [PATCH 3/3] update adapter/ohos/osal/ace_engine_ext.cpp. Signed-off-by: anqi --- adapter/ohos/osal/ace_engine_ext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapter/ohos/osal/ace_engine_ext.cpp b/adapter/ohos/osal/ace_engine_ext.cpp index 734e3febac5..af88573c9e5 100644 --- a/adapter/ohos/osal/ace_engine_ext.cpp +++ b/adapter/ohos/osal/ace_engine_ext.cpp @@ -15,7 +15,7 @@ #include "core/common/ace_engine_ext.h" -#include +#include #include "base/log/log.h" -- Gitee