diff --git a/adapter/ohos/capability/BUILD.gn b/adapter/ohos/capability/BUILD.gn index 651ad0a150b..d726ba1bb69 100644 --- a/adapter/ohos/capability/BUILD.gn +++ b/adapter/ohos/capability/BUILD.gn @@ -36,6 +36,7 @@ template("ace_capability_ohos_source_set") { external_deps = [ "ability_base:want", "common_event_service:cesfwk_innerkits", + "hicollie:libhicollie", "hilog:libhilog", "ipc:ipc_core", "preferences:native_preferences", @@ -45,6 +46,8 @@ template("ace_capability_ohos_source_set") { external_deps += [ "pasteboard:pasteboard_client" ] defines += [ "SYSTEM_CLIPBOARD_SUPPORTED" ] } + + sources += [ "xcollie/xcollieInterface_impl.cpp" ] if (defined(config.enable_drag_framework) && config.enable_drag_framework) { if (defined(global_parts_info.distributeddatamgr_udmf)) { external_deps += [ "udmf:udmf_client" ] diff --git a/adapter/ohos/capability/xcollie/xcollieInterface_impl.cpp b/adapter/ohos/capability/xcollie/xcollieInterface_impl.cpp new file mode 100644 index 00000000000..6d000f87d2e --- /dev/null +++ b/adapter/ohos/capability/xcollie/xcollieInterface_impl.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 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 "xcollieInterface_impl.h" +#include +#include "xcollie/xcollie.h" + +namespace OHOS::Ace { +XcollieInterface& XcollieInterface::GetInstance() +{ + static XcollieInterfaceImpl instance; + return instance; +} + +int32_t XcollieInterfaceImpl::SetTimerCount(const std::string& name, uint32_t timeLimit, int32_t countLimit) +{ + return HiviewDFX::XCollie::GetInstance().SetTimerCount(name, timeLimit, countLimit); +} + +void XcollieInterfaceImpl::TriggerTimerCount(const std::string& name, bool bTrigger, const std::string& message) +{ + HiviewDFX::XCollie::GetInstance().TriggerTimerCount(name, bTrigger, message); +} +} //namespace OHOS::Ace diff --git a/adapter/ohos/capability/xcollie/xcollieInterface_impl.h b/adapter/ohos/capability/xcollie/xcollieInterface_impl.h new file mode 100644 index 00000000000..9660cca5268 --- /dev/null +++ b/adapter/ohos/capability/xcollie/xcollieInterface_impl.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H +#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H + +#include "base/memory/ace_type.h" +#include "base/utils/utils.h" +#include "core/common/xcollie/xcollieInterface.h" + +namespace OHOS::Ace { +class XcollieInterfaceImpl : public XcollieInterface { + DECLARE_ACE_TYPE(XcollieInterfaceImpl, XcollieInterface); +public: + int32_t SetTimerCount(const std::string& name, uint32_t timeLimit, int countLimit) override; + void TriggerTimerCount(const std::string& name, bool bTrigger, const std::string& message) override; +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H diff --git a/adapter/ohos/entrance/ui_content_impl.cpp b/adapter/ohos/entrance/ui_content_impl.cpp index 99db90d8952..322930046b1 100644 --- a/adapter/ohos/entrance/ui_content_impl.cpp +++ b/adapter/ohos/entrance/ui_content_impl.cpp @@ -75,6 +75,7 @@ #include "core/common/modal_ui_extension.h" #include "core/common/recorder/event_recorder.h" #include "core/common/resource/resource_manager.h" +#include "core/common/xcollie/xcollieInterface.h" #include "core/components/theme/shadow_theme.h" #include "core/components_ng/base/inspector.h" #include "core/components_ng/base/view_abstract.h" @@ -134,6 +135,8 @@ const char ENABLE_TRACE_INPUTEVENT_KEY[] = "persist.ace.trace.inputEvent.enabled const char ENABLE_SECURITY_DEVELOPERMODE_KEY[] = "const.security.developermode.state"; const char ENABLE_DEBUG_STATEMGR_KEY[] = "persist.ace.debug.statemgr.enabled"; const int32_t REQUEST_CODE = -1; +constexpr uint32_t TIMEOUT_LIMIT = 60; +constexpr int32_t COUNT_LIMIT = 3; using ContentFinishCallback = std::function; using ContentStartAbilityCallback = std::function; @@ -1193,6 +1196,7 @@ UIContentErrorCode UIContentImpl::CommonInitialize( CapabilityRegistry::Register(); ImageFileCache::GetInstance().SetImageCacheFilePath(context->GetCacheDir()); ImageFileCache::GetInstance().SetCacheFileInfo(); + XcollieInterface::GetInstance().SetTimerCount("HIT_EMPTY_WARNING", TIMEOUT_LIMIT, COUNT_LIMIT); }); AceNewPipeJudgement::InitAceNewPipeConfig(); auto apiCompatibleVersion = context->GetApplicationInfo()->apiCompatibleVersion; diff --git a/adapter/preview/entrance/BUILD.gn b/adapter/preview/entrance/BUILD.gn index c3e4e99530d..bf131f088fd 100644 --- a/adapter/preview/entrance/BUILD.gn +++ b/adapter/preview/entrance/BUILD.gn @@ -56,6 +56,7 @@ ohos_source_set("preview_entrance_source") { "subwindow_preview.cpp", "udmf/udmf_impl.cpp", "ui_content_impl.cpp", + "xcollie/xcollieInterface_impl.cpp", ] deps = [ diff --git a/adapter/preview/entrance/xcollie/xcollieInterface_impl.cpp b/adapter/preview/entrance/xcollie/xcollieInterface_impl.cpp new file mode 100644 index 00000000000..f9eddfb5ed6 --- /dev/null +++ b/adapter/preview/entrance/xcollie/xcollieInterface_impl.cpp @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 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 "xcollieInterface_impl.h" + +namespace OHOS::Ace { +XcollieInterface& XcollieInterface::GetInstance() +{ + static XcollieInterfaceImpl instance; + return instance; +} +} //namespace OHOS::Ace diff --git a/adapter/preview/entrance/xcollie/xcollieInterface_impl.h b/adapter/preview/entrance/xcollie/xcollieInterface_impl.h new file mode 100644 index 00000000000..82338da62e0 --- /dev/null +++ b/adapter/preview/entrance/xcollie/xcollieInterface_impl.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 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_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H +#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H + +#include "base/memory/ace_type.h" +#include "base/utils/utils.h" +#include "core/common/xcollie/xcollieInterface.h" + +namespace OHOS::Ace { +class XcollieInterfaceImpl : public XcollieInterface { + DECLARE_ACE_TYPE(XcollieInterfaceImpl, XcollieInterface); +public: +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_IMPL_H diff --git a/frameworks/core/common/event_manager.cpp b/frameworks/core/common/event_manager.cpp index 256a53e1ade..003edae16ae 100644 --- a/frameworks/core/common/event_manager.cpp +++ b/frameworks/core/common/event_manager.cpp @@ -16,12 +16,14 @@ #include "core/common/event_manager.h" #include "base/geometry/ng/point_t.h" +#include "base/json/json_util.h" #include "base/log/ace_trace.h" #include "base/log/dump_log.h" #include "base/memory/ace_type.h" #include "base/thread/frame_trace_adapter.h" #include "base/utils/utils.h" #include "core/common/container.h" +#include "core/common/xcollie/xcollieInterface.h" #include "core/components_ng/base/frame_node.h" #include "core/components_ng/event/touch_event.h" #include "core/components_ng/gestures/recognizers/recognizer_group.h" @@ -176,10 +178,34 @@ void EventManager::TouchTest(const TouchEvent& touchPoint, const RefPtrGetWindowId(); + hitEmptyMessage->Put("windowId", static_cast(windowId)); + auto window = container->GetPipelineContext()->GetWindow(); + if (window) { + hitEmptyMessage->Put("windowName", window->GetWindowName().c_str()); + } + hitEmptyMessage->Put("resultInfo", resultInfo.c_str()); + hitEmptyMessage->Put("x", touchPoint.x); + hitEmptyMessage->Put("y", touchPoint.y); + hitEmptyMessage->Put("currentTime", static_cast(touchPoint.time.time_since_epoch().count())); + hitEmptyMessage->Put("bundleName", container->GetBundleName().c_str()); + auto frontEnd = container->GetFrontend(); + if (frontEnd) { + hitEmptyMessage->Put("pageInfo", frontEnd->GetCurrentPageUrl().c_str()); + } + XcollieInterface::GetInstance().TriggerTimerCount("HIT_EMPTY_WARNING", true, hitEmptyMessage->ToString()); +} + void EventManager::LogTouchTestResultRecognizers(const TouchTestResult& result) { std::map> hittedRecognizerInfo; diff --git a/frameworks/core/common/event_manager.h b/frameworks/core/common/event_manager.h index 6bdd6053715..b00c92f98a5 100644 --- a/frameworks/core/common/event_manager.h +++ b/frameworks/core/common/event_manager.h @@ -244,6 +244,8 @@ public: } } + void RecordHitEmptyMessage(const TouchEvent& touchPoint, const std::string& resultInfo); + private: void SetHittedFrameNode(const std::list>& touchTestResults); void CleanGestureEventHub(); diff --git a/frameworks/core/common/xcollie/xcollieInterface.h b/frameworks/core/common/xcollie/xcollieInterface.h new file mode 100644 index 00000000000..ad298839e7b --- /dev/null +++ b/frameworks/core/common/xcollie/xcollieInterface.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 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_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_H +#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_H + +#include "base/memory/ace_type.h" +#include "base/utils/utils.h" + +namespace OHOS::Ace { +class XcollieInterface : public AceType { + DECLARE_ACE_TYPE(XcollieInterface, AceType); +public: + static XcollieInterface& GetInstance(); + virtual int32_t SetTimerCount(const std::string& name, uint32_t timeLimit, int32_t countLimit) + { + return -1; + } + virtual void TriggerTimerCount(const std::string& name, bool bTrigger, const std::string& message) {}; +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_XCOLLIEINTERFACE_H diff --git a/test/mock/core/common/mock_xcollieInterface.cpp b/test/mock/core/common/mock_xcollieInterface.cpp new file mode 100644 index 00000000000..608a2ebfd9b --- /dev/null +++ b/test/mock/core/common/mock_xcollieInterface.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 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 "test/mock/core/common/mock_xcollieInterface.h" + +namespace OHOS::Ace { +XcollieInterface& XcollieInterface::GetInstance() +{ + static XcollieInterfaceImpl instance; + return instance; +} +} //namespace OHOS::Ace + diff --git a/test/mock/core/common/mock_xcollieInterface.h b/test/mock/core/common/mock_xcollieInterface.h new file mode 100644 index 00000000000..f1c7503e9ec --- /dev/null +++ b/test/mock/core/common/mock_xcollieInterface.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 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_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_MOCK_XCOLLIEINTERFACE_H +#define FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_MOCK_XCOLLIEINTERFACE_H + +#include "gmock/gmock-function-mocker.h" +#include "gmock/gmock.h" + +#include "base/memory/ace_type.h" +#include "base/utils/utils.h" +#include "core/common/xcollie/xcollieInterface.h" + + +namespace OHOS::Ace { +class XcollieInterfaceImpl : public XcollieInterface { + DECLARE_ACE_TYPE(XcollieInterfaceImpl, XcollieInterface); +public: +}; +} // namespace OHOS::Ace +#endif // FOUNDATION_ACE_ACE_ENGINE_ADAPTER_OHOS_CAPABILITY_MOCK_XCOLLIEINTERFACE_H \ No newline at end of file diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 22c28ec9e71..85ec0665cd7 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -475,6 +475,7 @@ ohos_source_set("ace_components_mock") { "$ace_root/test/mock/core/common/mock_theme_constants.cpp", "$ace_root/test/mock/core/common/mock_theme_utils.cpp", "$ace_root/test/mock/core/common/mock_udmf.cpp", + "$ace_root/test/mock/core/common/mock_xcollieInterface.cpp", "$ace_root/test/mock/core/event/mock_time_event_proxy.cpp", "$ace_root/test/mock/core/event/mock_touch_event.cpp", "$ace_root/test/mock/core/image_provider/mock_image_cache.cpp", diff --git a/test/unittest/core/pipeline/BUILD.gn b/test/unittest/core/pipeline/BUILD.gn index 405bd3af65b..a8be321287b 100644 --- a/test/unittest/core/pipeline/BUILD.gn +++ b/test/unittest/core/pipeline/BUILD.gn @@ -72,6 +72,7 @@ ace_unittest("pipeline_context_test_ng") { "$ace_root/test/mock/core/common/mock_theme_constants.cpp", "$ace_root/test/mock/core/common/mock_udmf.cpp", "$ace_root/test/mock/core/common/mock_window.cpp", + "$ace_root/test/mock/core/common/mock_xcollieInterface.cpp", "$ace_root/test/mock/core/event/mock_touch_event.cpp", "$ace_root/test/mock/core/image_provider/mock_image_cache.cpp", "$ace_root/test/mock/core/image_provider/mock_image_file_cache.cpp",