From 57963803c894f0dadefea4891676be8b215b6ff9 Mon Sep 17 00:00:00 2001 From: b30058220 Date: Tue, 12 Nov 2024 12:51:21 +0000 Subject: [PATCH 01/46] Update drague yaml Signed-off-by: b30058220 Change-Id: Ie182f5bd96c1bf234ac883cc22f0013b3b188d47 --- bundle.json | 5 ++++- hisyseventdrague.yaml | 50 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 hisyseventdrague.yaml diff --git a/bundle.json b/bundle.json index 08307222a..48fabdaa5 100644 --- a/bundle.json +++ b/bundle.json @@ -14,7 +14,10 @@ "SystemCapability.Msdp.DeviceStatus.Cooperate", "SystemCapability.Msdp.DeviceStatus.Stationary" ], - "hisysevent_config": [ "//base/msdp/device_status/hisysevent.yaml" ], + "hisysevent_config": [ + "//base/msdp/device_status/hisysevent.yaml", + "//base/msdp/device_status/hisyseventdrague.yaml" + ], "features": [ "device_status_intention_framework", "device_status_rust_enabled", diff --git a/hisyseventdrague.yaml b/hisyseventdrague.yaml new file mode 100644 index 000000000..a178f5017 --- /dev/null +++ b/hisyseventdrague.yaml @@ -0,0 +1,50 @@ +# 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. + +domain: DRAG_UE + +DRAG_START: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: start drag, preserve: true} + PNAMEID: {type: STRING, desc: package name} + PVERSIONID: {type: STRING, desc: application version} + RESULT: {type: INT32, desc: dragging result} + HOSTNAME: {type: STRING, desc: invoking application package name} + SUMMARYTYPE: {type: STRING, desc: type of the object to be dragged} + SUMMARYNUM: {type: INT32, desc: number of objects to be dragged} + +DRAG_STOP: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: stop drag, preserve: true} + PNAMEID: {type: STRING, desc: package name} + PVERSIONID: {type: STRING, desc: application version} + ISCROSSING: {type: INT32, desc: cross-end drag} + RESULT: {type: INT32, desc: dragging result} + HOSTNAME: {type: STRING, desc: invoking application package name} + ALLOW_DROP_TYPE: {type: STRING, desc: dragging an app to allow the app to fall into the type} + SUMMARYTYPE: {type: STRING, desc: type of the object to be dragged} + SUMMARYNUM: {type: INT32, desc: number of objects to be dragged} + +START_CROSSING_DRAG: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: Start crossing drag, preserve: true} + PNAMEID: {type: STRING, desc: package name} + PVERSIONID: {type: STRING, desc: application version} + HOSTNAME: {type: STRING, desc: host module name} + LOCAL_NET_ID: {type: STRING, desc: local device network id} + PEER_NET_ID: {type: STRING, desc: peer device network id} + +END_CROSSING_DRAG: + __BASE: {type: BEHAVIOR, level: CRITICAL, desc: Stop crossing drag, preserve: true} + PNAMEID: {type: STRING, desc: package name} + PVERSIONID: {type: STRING, desc: application version} + HOSTNAME: {type: STRING, desc: host module name} + LOCAL_NET_ID: {type: STRING, desc: local device network id} + PEER_NET_ID: {type: STRING, desc: peer device network id} \ No newline at end of file From 62fbc824dae3f507aed44e769bb9a90ac498ec30 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:23:57 +0000 Subject: [PATCH 02/46] update bundle.json. Signed-off-by: yang123 --- bundle.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index 08307222a..3900ce580 100644 --- a/bundle.json +++ b/bundle.json @@ -64,7 +64,8 @@ "os_account", "libxml2", "wifi", - "power_manager" + "power_manager", + "resource_schedule_service" ], "third_party": [ "libuv", From a74fdd39b71952e6da4c35ed9072e98155df806d Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:25:10 +0000 Subject: [PATCH 03/46] update intention/cooperate/plugin/BUILD.gn. Signed-off-by: yang123 --- intention/cooperate/plugin/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/intention/cooperate/plugin/BUILD.gn b/intention/cooperate/plugin/BUILD.gn index c3d7a5b39..1281c952b 100644 --- a/intention/cooperate/plugin/BUILD.gn +++ b/intention/cooperate/plugin/BUILD.gn @@ -84,6 +84,7 @@ ohos_shared_library("intention_cooperate") { "wifi:wifi_sdk", "window_manager:libdm", "window_manager:libwmutil_base", + "resource_s", ] if (device_status_hisysevent_enable) { From 28bf8162648fc0893a082955083bd6ce2fbea60f Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:30:49 +0000 Subject: [PATCH 04/46] update intention/cooperate/plugin/BUILD.gn. Signed-off-by: yang123 --- intention/cooperate/plugin/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/BUILD.gn b/intention/cooperate/plugin/BUILD.gn index 1281c952b..4760ac8f1 100644 --- a/intention/cooperate/plugin/BUILD.gn +++ b/intention/cooperate/plugin/BUILD.gn @@ -84,7 +84,7 @@ ohos_shared_library("intention_cooperate") { "wifi:wifi_sdk", "window_manager:libdm", "window_manager:libwmutil_base", - "resource_s", + "resource_schedule_service:ressched_client", ] if (device_status_hisysevent_enable) { From 2592e3e0d33857a5419b9b8d3303bb5b346426db Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:33:38 +0000 Subject: [PATCH 05/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_builder.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h index 20611e142..86efd75ef 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h @@ -101,6 +101,8 @@ private: void ResetPressedEvents(); double GetDamplingCoefficient(DamplingDirection direction) const; bool DampPointerMotion(std::shared_ptr pointerEvent) const; + void ExecuteInner(); + void handleStopTimer(); IContext *env_ { nullptr }; bool enable_ { false }; From 46300598870de9080accaa5d776e3546d7e609db Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:41:17 +0000 Subject: [PATCH 06/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../input_event_transmission/input_event_interceptor.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index 7e5381f14..91a4a723c 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -16,6 +16,8 @@ #ifndef INPUT_EVENT_INTERCEPTOR_H #define INPUT_EVENT_INTERCEPTOR_H +#include + #include "nocopyable.h" #include "channel.h" @@ -45,17 +47,22 @@ private: void ReportPointerEvent(std::shared_ptr pointerEvent); void TurnOffChannelScan(); void TurnOnChannelScan(); + void ExecuteInner(); + void HandleStopTimer(); int32_t SetWifiScene(unsigned int scene); void RefreshActivity(); + void HeartBeatSend(); IContext *env_ { nullptr }; int32_t interceptorId_ { -1 }; bool scanState_ { true }; int32_t pointerEventTimer_ { -1 }; + std::atomic heartBeatRunning_ { true }; std::string remoteNetworkId_; Channel::Sender sender_; static std::set filterKeys_; static std::set filterPointers_; + std:: thread thread; }; } // namespace Cooperate } // namespace DeviceStatus From 512005a9721d92284777b0fedb1a44337095660d Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 08:42:46 +0000 Subject: [PATCH 07/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_serialization.h | 1 + 1 file changed, 1 insertion(+) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h index 99d7ad33c..8d4eb4741 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_serialization.h @@ -34,6 +34,7 @@ public: static int32_t NetPacketToKeyEvent(NetPacket &pkt, std::shared_ptr key); static int32_t SwitchEventToNetPacket(const std::shared_ptr key, NetPacket &pkt); static int32_t NetPacketToSwitchEvent(NetPacket &pkt, std::shared_ptr key); + static int32_t HeartBeatMarshalling(NetPacket &pkt); static int32_t Marshalling(std::shared_ptr event, NetPacket &pkt); static int32_t Unmarshalling(NetPacket &pkt, std::shared_ptr event); #ifdef OHOS_BUILD_ENABLE_SECURITY_PART From 76d63bc04390be119c4601a227e51bf31acfd6e8 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 09:01:49 +0000 Subject: [PATCH 08/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp. Signed-off-by: yang123 --- .../input_event_builder.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp index 8ae78a26c..2680546de 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp @@ -22,6 +22,8 @@ #include "input_event_transmission/input_event_serialization.h" #include "utility.h" #include "kits/c/wifi_hid2d.h" +#include "res_sched_client.h" +#include "res_type.h" #undef LOG_TAG #define LOG_TAG "InputEventBuilder" @@ -44,6 +46,9 @@ const int32_t UPPER_SCENE_BW { 0 }; constexpr double MIN_POSITIVE_RAW { 1.0 }; constexpr double MIN_NEGATIVE_RAW { -1.0 }; constexpr float EPSILON { 1E-6 }; +const int32_t MODE_ENABLE { 0 }; +const int32_t MODE_DISABLE { 1 }; +const std::string LOW_LATENCY_KEY = "identity"; } InputEventBuilder::InputEventBuilder(IContext *env) @@ -78,6 +83,7 @@ void InputEventBuilder::Enable(Context &context) Coordinate cursorPos = context.CursorPosition(); TurnOffChannelScan(); FI_HILOGI("Cursor transite in (%{private}d, %{private}d)", cursorPos.x, cursorPos.y); + ExecuteInner(); } void InputEventBuilder::Disable() @@ -93,6 +99,7 @@ void InputEventBuilder::Disable() env_->GetTimerManager().RemoveTimer(pointerEventTimer_); pointerEventTimer_ = -1; } + HandleStopTimer(); } void InputEventBuilder::Update(Context &context) @@ -173,6 +180,10 @@ bool InputEventBuilder::OnPacket(const std::string &networkId, Msdp::NetPacket & OnKeyEvent(packet); break; } + case MessageId::DSOFTBUS_HEART_BEAT_PACKET: { + FI_HILOGI("Heart beat received"); + break; + } default: { FI_HILOGW("Unexpected message(%{public}d) from \'%{public}s\'", static_cast(packet.GetMsgId()), Utility::Anonymize(networkId).c_str()); @@ -252,6 +263,22 @@ void InputEventBuilder::TurnOffChannelScan() FI_HILOGE("Forbidden scene failed"); } } +void InputEventBuilder::ExecuteInner() +{ + CALL_INFO_TRACE; + // to enable low latency mode: value = 0 + OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_ENABLE, + {{LOW_LATENCY_KEY, FI_PKG_NAME}}); +} + +void InputEventBuilder::HandleStopTimer() +{ + CALL_INFO_TRACE; + OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_DISABLE, + {{LOW_LATENCY_KEY, FI_PKG_NAME}}); +} void InputEventBuilder::TurnOnChannelScan() { From 3a1eb7ef6d3221951d09c055820dfd1a82d2a547 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 09:21:55 +0000 Subject: [PATCH 09/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_interceptor.cpp | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 3267aceb9..110effbcf 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -23,6 +23,9 @@ #include "utility.h" #include "kits/c/wifi_hid2d.h" +#include "res_sched_client.h" +#include "res_type.h" + #undef LOG_TAG #define LOG_TAG "InputEventInterceptor" @@ -37,6 +40,9 @@ const int32_t RESTORE_SCENE { 0 }; const int32_t FORBIDDEN_SCENE { 1 }; const int32_t UPPER_SCENE_FPS { 0 }; const int32_t UPPER_SCENE_BW { 0 }; +const int32_t MODE_ENABLE { 0 }; +const int32_t MODE_DISABLE { 1 }; +const std::string LOW_LATENCY_KEY = "identity"; } std::set InputEventInterceptor::filterKeys_ { @@ -73,6 +79,27 @@ void InputEventInterceptor::Enable(Context &context) FI_HILOGE("Input::AddInterceptor fail"); } TurnOffChannelScan(); + heartBeatRunning_ = true; + thread_ = std::thread([this] {this->HeartBeatSend(); }); + ExecuteInner(); +} + +void InputEventInterceptor::HeartBeatSend() +{ + CALL_INFO_TRACE; + while (heartBeatRunning_.load()) { + NetPacket packet(MessageId::DSOFTBUS_HEART_BEAT_PACKET); + int32_t ret = InputEventSerialization::HeartBeatMarshalling(packet); + if (ret != RET_OK) { + FI_HILOGE("Failed to serialize pointer event"); + return; + } + CHKPV(env_); + env_->GetDSoftbus().SendPacket(remoteNetworkId_,packet); + FI_HILOGI("heart beat send"); + HandlsStopTimer(); + std::this_thread::sleep_for(std::chrono::seconds(3)); + } } void InputEventInterceptor::Disable() @@ -87,6 +114,11 @@ void InputEventInterceptor::Disable() env_->GetTimerManager().RemoveTimer(pointerEventTimer_); pointerEventTimer_ = -1; } + heartBeatRunning_.store(false); + if (thread_.joinable()) { + thread_.join(); + FI_HILOGI("thread_ is stop"); + } } void InputEventInterceptor::Update(Context &context) @@ -180,6 +212,23 @@ void InputEventInterceptor::TurnOffChannelScan() } } +void InputEventInterceptor::ExecuteInner() +{ + CALL_INFO_TRACE; + // to enable low latency mode: value = 0 + OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_ENABLE, + {{LOW_LATENCY_KEY, FI_PKG_NAME}}); +} + +void InputEventInterceptor::HandleStopTimer() +{ + CALL_INFO_TRACE; + OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_DISABLE, + {{LOW_LATENCY_KEY, FI_PKG_NAME}}); +} + void InputEventInterceptor::TurnOnChannelScan() { scanState_ = true; From eaf5b85ff078515a4df10a9f89e8a916a632aa8a Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 09:30:33 +0000 Subject: [PATCH 10/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp. Signed-off-by: yang123 --- .../input_event_serialization.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp index b3cc4fc33..44127f037 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp @@ -32,6 +32,8 @@ namespace DeviceStatus { namespace Cooperate { namespace { constexpr int32_t MAX_KEY_SIZE { 395 }; +const std::string HEART_BEAT_PACKET { "heart_beat_packet" }; + } // namespace int32_t InputEventSerialization::KeyEventToNetPacket( @@ -444,6 +446,18 @@ int32_t InputEventSerialization::SerializeBuffer(std::shared_ptr event) { std::vector::size_type bufSize {}; From 1b5700aec1869e16c1745b731f7c31a1c111ae2f Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 09:32:03 +0000 Subject: [PATCH 11/46] update utils/common/include/proto.h. Signed-off-by: yang123 --- utils/common/include/proto.h | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/common/include/proto.h b/utils/common/include/proto.h index b90f5a8b7..40f63e2c7 100644 --- a/utils/common/include/proto.h +++ b/utils/common/include/proto.h @@ -71,6 +71,7 @@ enum class MessageId : int32_t { DRAG_STYLE_LISTENER, DSOFTBUS_INPUT_DEV_HOT_PLUG, DSOFTBUS_INPUT_DEV_SYNC, + DSOFTBUS_HEART_BEAT_PACKET; MAX_MESSAGE_ID, ADD_SELECTED_PIXELMAP_RESULT }; From c29bd3f15bd18226f1f8f2dd4465558f1c7501f3 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:00:13 +0000 Subject: [PATCH 12/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_interceptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index 91a4a723c..7d2c9b010 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -62,7 +62,7 @@ private: Channel::Sender sender_; static std::set filterKeys_; static std::set filterPointers_; - std:: thread thread; + std:: thread thread_; }; } // namespace Cooperate } // namespace DeviceStatus From ee1a13826e0154a2315798856095446c64e9bbf7 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:02:20 +0000 Subject: [PATCH 13/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_builder.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp index 2680546de..f2d840b17 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp @@ -263,12 +263,13 @@ void InputEventBuilder::TurnOffChannelScan() FI_HILOGE("Forbidden scene failed"); } } + void InputEventBuilder::ExecuteInner() { CALL_INFO_TRACE; // to enable low latency mode: value = 0 OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( - OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_ENABLE, + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); } @@ -276,7 +277,7 @@ void InputEventBuilder::HandleStopTimer() { CALL_INFO_TRACE; OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( - OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_DISABLE, + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); } From 65a4eb1ce7d3f771886a6e529e233bdb4a964169 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:04:21 +0000 Subject: [PATCH 14/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_interceptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index 7d2c9b010..34177606e 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -62,7 +62,7 @@ private: Channel::Sender sender_; static std::set filterKeys_; static std::set filterPointers_; - std:: thread thread_; + std::thread thread_; }; } // namespace Cooperate } // namespace DeviceStatus From f33a0f35798730882b5d36a2b59d57c245be8a13 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:12:49 +0000 Subject: [PATCH 15/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_transmission/input_event_interceptor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 110effbcf..d1145d971 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -95,7 +95,7 @@ void InputEventInterceptor::HeartBeatSend() return; } CHKPV(env_); - env_->GetDSoftbus().SendPacket(remoteNetworkId_,packet); + env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); FI_HILOGI("heart beat send"); HandlsStopTimer(); std::this_thread::sleep_for(std::chrono::seconds(3)); @@ -217,7 +217,7 @@ void InputEventInterceptor::ExecuteInner() CALL_INFO_TRACE; // to enable low latency mode: value = 0 OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( - OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_ENABLE, + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); } @@ -225,7 +225,7 @@ void InputEventInterceptor::HandleStopTimer() { CALL_INFO_TRACE; OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( - OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST,MODE_DISABLE, + OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); } From dfc573479cb4d860e62aa0ff64357a788c800f2d Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:18:28 +0000 Subject: [PATCH 16/46] update intention/cooperate/plugin/BUILD.gn. Signed-off-by: yang123 --- intention/cooperate/plugin/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/BUILD.gn b/intention/cooperate/plugin/BUILD.gn index 4760ac8f1..66dba1bc4 100644 --- a/intention/cooperate/plugin/BUILD.gn +++ b/intention/cooperate/plugin/BUILD.gn @@ -80,11 +80,11 @@ ohos_shared_library("intention_cooperate") { "input:libmmi-client", "ipc:ipc_single", "power_manager:powermgr_client", + "resource_schedule_service:ressched_client", "samgr:samgr_proxy", "wifi:wifi_sdk", "window_manager:libdm", "window_manager:libwmutil_base", - "resource_schedule_service:ressched_client", ] if (device_status_hisysevent_enable) { From 4f9d39782a6c3c960e14f722e9b8933bcf8e0490 Mon Sep 17 00:00:00 2001 From: yang123 Date: Wed, 13 Nov 2024 10:24:30 +0000 Subject: [PATCH 17/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_interceptor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index d1145d971..d578d7e23 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -40,6 +40,7 @@ const int32_t RESTORE_SCENE { 0 }; const int32_t FORBIDDEN_SCENE { 1 }; const int32_t UPPER_SCENE_FPS { 0 }; const int32_t UPPER_SCENE_BW { 0 }; +const int32_t INTERVAL { 3 }; const int32_t MODE_ENABLE { 0 }; const int32_t MODE_DISABLE { 1 }; const std::string LOW_LATENCY_KEY = "identity"; @@ -98,7 +99,7 @@ void InputEventInterceptor::HeartBeatSend() env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); FI_HILOGI("heart beat send"); HandlsStopTimer(); - std::this_thread::sleep_for(std::chrono::seconds(3)); + std::this_thread::sleep_for(std::chrono::seconds(INTERVAL)); } } From 1a0486b1757b668fcf4e87e71ac8613fd0eb6b17 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Thu, 14 Nov 2024 09:42:45 +0800 Subject: [PATCH 18/46] Signed-off-by: pengyanggit yangpeng177@huawei.com Signed-off-by: pengyanggit Change-Id: I93bf0fe1c2d1e557e3e9aad273c6f75b46470e95 --- .../cooperate/plugin/include/cooperate_context.h | 1 + .../cooperate/plugin/src/cooperate_context.cpp | 14 ++++++++++++++ intention/cooperate/plugin/src/state_machine.cpp | 1 + intention/prototype/include/i_cooperate.h | 1 + .../cooperate/src/cooperate_plugin_test.cpp | 1 + .../intention/cooperate/src/cooperate_test.cpp | 1 + 6 files changed, 19 insertions(+) diff --git a/intention/cooperate/plugin/include/cooperate_context.h b/intention/cooperate/plugin/include/cooperate_context.h index b3146458a..18f2eef6b 100644 --- a/intention/cooperate/plugin/include/cooperate_context.h +++ b/intention/cooperate/plugin/include/cooperate_context.h @@ -84,6 +84,7 @@ public: bool IsAllowCooperate(); void OnStartCooperate(StartCooperateData &data); void OnRemoteStartCooperate(RemoteStartCooperateData &data); + void OnStopCooperate(); void OnTransitionOut(); void OnTransitionIn(); void OnBack(); diff --git a/intention/cooperate/plugin/src/cooperate_context.cpp b/intention/cooperate/plugin/src/cooperate_context.cpp index 9191d7b3b..41f489374 100644 --- a/intention/cooperate/plugin/src/cooperate_context.cpp +++ b/intention/cooperate/plugin/src/cooperate_context.cpp @@ -281,6 +281,20 @@ void Context::OnRemoteStartCooperate(RemoteStartCooperateData &data) }); } +void Context::OnStopCooperate() +{ + CHKPV(eventHandler_); + FI_HILOGI("Notify observers of stop cooperate"); + for (const auto &observer : observers_) { + eventHandler_->PostTask( + [observer, remoteNetworkId = Peer()] { + FI_HILOGI{"Notify observer of stop cooperate"}; + CHKPV(observer); + observer->OnStopCooperate(remoteNetworkId); + }); + } +} + void Context::OnTransitionOut() { CHKPV(eventHandler_); diff --git a/intention/cooperate/plugin/src/state_machine.cpp b/intention/cooperate/plugin/src/state_machine.cpp index 14d4394d1..507a72607 100644 --- a/intention/cooperate/plugin/src/state_machine.cpp +++ b/intention/cooperate/plugin/src/state_machine.cpp @@ -308,6 +308,7 @@ void StateMachine::StopCooperate(Context &context, const CooperateEvent &event) { CALL_DEBUG_ENTER; context.CloseDistributedFileConnection(context.Peer()); + context.OnStopCooperate(); Transfer(context, event); } diff --git a/intention/prototype/include/i_cooperate.h b/intention/prototype/include/i_cooperate.h index 7aa5449b7..99dd1c11a 100644 --- a/intention/prototype/include/i_cooperate.h +++ b/intention/prototype/include/i_cooperate.h @@ -45,6 +45,7 @@ public: virtual bool IsAllowCooperate() = 0; virtual void OnStartCooperate(StartCooperateData &data) = 0; virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) = 0; + virtual void OnStopCooperate(const std::string &remoteNetworkId) = 0; virtual void OnTransitionOut(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; virtual void OnTransitionIn(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; virtual void OnBack(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) = 0; diff --git a/test/unittest/intention/cooperate/src/cooperate_plugin_test.cpp b/test/unittest/intention/cooperate/src/cooperate_plugin_test.cpp index e37489c22..1b3184ade 100644 --- a/test/unittest/intention/cooperate/src/cooperate_plugin_test.cpp +++ b/test/unittest/intention/cooperate/src/cooperate_plugin_test.cpp @@ -234,6 +234,7 @@ public: } virtual void OnStartCooperate(StartCooperateData &data) {} virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) {} + virtual void OnStopCooperate(const std::string &remoteNetworkId) {} virtual void OnTransitionOut(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} virtual void OnTransitionIn(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} virtual void OnBack(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} diff --git a/test/unittest/intention/cooperate/src/cooperate_test.cpp b/test/unittest/intention/cooperate/src/cooperate_test.cpp index 757bafcf4..572a215b9 100644 --- a/test/unittest/intention/cooperate/src/cooperate_test.cpp +++ b/test/unittest/intention/cooperate/src/cooperate_test.cpp @@ -120,6 +120,7 @@ public: } virtual void OnStartCooperate(StartCooperateData &data) {} virtual void OnRemoteStartCooperate(RemoteStartCooperateData &data) {} + virtual void OnStopCooperate(const std::string &remoteNetworkId) {} virtual void OnTransitionOut(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} virtual void OnTransitionIn(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} virtual void OnBack(const std::string &remoteNetworkId, const NormalizedCoordinate &cursorPos) {} From 3132616a394a4c6465f77583e0fcce85c487ee1d Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Thu, 14 Nov 2024 10:07:13 +0800 Subject: [PATCH 19/46] Signed-off-by: pengyanggit yangpeng177@huawei.com Signed-off-by: pengyanggit Change-Id: I218aed0920c7ba965871784992d078d40309a0c0 --- intention/cooperate/plugin/src/cooperate_context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/src/cooperate_context.cpp b/intention/cooperate/plugin/src/cooperate_context.cpp index 41f489374..d72d8b8d8 100644 --- a/intention/cooperate/plugin/src/cooperate_context.cpp +++ b/intention/cooperate/plugin/src/cooperate_context.cpp @@ -288,7 +288,7 @@ void Context::OnStopCooperate() for (const auto &observer : observers_) { eventHandler_->PostTask( [observer, remoteNetworkId = Peer()] { - FI_HILOGI{"Notify observer of stop cooperate"}; + FI_HILOGI("Notify observer of stop cooperate"); CHKPV(observer); observer->OnStopCooperate(remoteNetworkId); }); From 1e9025d7d499192c8f02d7601d51447014bf0532 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 03:48:28 +0000 Subject: [PATCH 20/46] update utils/common/include/proto.h. Signed-off-by: yang123 --- utils/common/include/proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/common/include/proto.h b/utils/common/include/proto.h index 40f63e2c7..d92870163 100644 --- a/utils/common/include/proto.h +++ b/utils/common/include/proto.h @@ -71,7 +71,7 @@ enum class MessageId : int32_t { DRAG_STYLE_LISTENER, DSOFTBUS_INPUT_DEV_HOT_PLUG, DSOFTBUS_INPUT_DEV_SYNC, - DSOFTBUS_HEART_BEAT_PACKET; + DSOFTBUS_HEART_BEAT_PACKET, MAX_MESSAGE_ID, ADD_SELECTED_PIXELMAP_RESULT }; From db599a1c6c099b67adda3d5fe41038cb54db4031 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 03:49:31 +0000 Subject: [PATCH 21/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_interceptor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index d578d7e23..fb5d57a25 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -40,7 +40,7 @@ const int32_t RESTORE_SCENE { 0 }; const int32_t FORBIDDEN_SCENE { 1 }; const int32_t UPPER_SCENE_FPS { 0 }; const int32_t UPPER_SCENE_BW { 0 }; -const int32_t INTERVAL { 3 }; +const int32_t INTERVAL { 2 }; const int32_t MODE_ENABLE { 0 }; const int32_t MODE_DISABLE { 1 }; const std::string LOW_LATENCY_KEY = "identity"; @@ -96,9 +96,13 @@ void InputEventInterceptor::HeartBeatSend() return; } CHKPV(env_); + if (heartSwtich_ == false) { + FI_HILOGI("heartSwtich is false"); + return; + } env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); FI_HILOGI("heart beat send"); - HandlsStopTimer(); + HandleStopTimer(); std::this_thread::sleep_for(std::chrono::seconds(INTERVAL)); } } @@ -161,6 +165,9 @@ void InputEventInterceptor::OnPointerEvent(std::shared_ptr po FI_HILOGD("PointerEvent(No:%{public}d,Source:%{public}s,Action:%{public}s)", pointerEvent->GetId(), pointerEvent->DumpSourceType(), pointerEvent->DumpPointerAction()); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); + env_->GetTimerManager().RemoveTimer(heartTimer_); + heartSwtich_ = false; + heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwtich_ = true; }); pointerEventTimer_ = env_->GetTimerManager().AddTimer(POINTER_EVENT_TIMEOUT, REPEAT_ONCE, [this]() { TurnOnChannelScan(); pointerEventTimer_ = -1; From 5786bb036e991b0ee95cb3269c54c4d1ed206e74 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 03:50:14 +0000 Subject: [PATCH 22/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_interceptor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index 34177606e..bf5b8c009 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -57,6 +57,8 @@ private: int32_t interceptorId_ { -1 }; bool scanState_ { true }; int32_t pointerEventTimer_ { -1 }; + bool heartSwtich_ { true }; + int32_t heartTimer_ { -1 }; std::atomic heartBeatRunning_ { true }; std::string remoteNetworkId_; Channel::Sender sender_; From 59a452dc5365101dd194c0008f7037b72815dffb Mon Sep 17 00:00:00 2001 From: wuliangdong Date: Thu, 14 Nov 2024 04:11:06 +0000 Subject: [PATCH 23/46] RemoveVirtualInputDevice When Session Closed Signed-off-by: wuliangdong Change-Id: I0b7d5f43802382c07abec8f80e78e68ae6dd64c3 --- intention/cooperate/plugin/src/input_device_mgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/intention/cooperate/plugin/src/input_device_mgr.cpp b/intention/cooperate/plugin/src/input_device_mgr.cpp index 920acd1a9..d33c8c4fb 100644 --- a/intention/cooperate/plugin/src/input_device_mgr.cpp +++ b/intention/cooperate/plugin/src/input_device_mgr.cpp @@ -213,6 +213,11 @@ void InputDeviceMgr::AddRemoteInputDevice(const std::string &networkId, std::sha void InputDeviceMgr::RemoveAllRemoteInputDevice(const std::string &networkId) { CALL_INFO_TRACE; + if (virtualInputDevicesAdded_.find(networkId) != virtualInputDevicesAdded_.end()) { + FI_HILOGI("NetworkId:%{public}s has device added as virtual one already, remove all", + Utility::Anonymize(networkId).c_str()); + RemoveVirtualInputDevice(networkId); + } if (remoteDevices_.find(networkId) == remoteDevices_.end()) { FI_HILOGE("NetworkId:%{public}s have no device existed", Utility::Anonymize(networkId).c_str()); return; From 9422335755457c408275a26f359c29f580cbcdf2 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:02:08 +0000 Subject: [PATCH 24/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_interceptor.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index fb5d57a25..273ddc085 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -96,14 +96,12 @@ void InputEventInterceptor::HeartBeatSend() return; } CHKPV(env_); - if (heartSwtich_ == false) { - FI_HILOGI("heartSwtich is false"); - return; + if (heartSwtich_) { + env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); + FI_HILOGI("heart beat send"); + HandleStopTimer(); + std::this_thread::sleep_for(std::chrono::seconds(INTERVAL)); } - env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); - FI_HILOGI("heart beat send"); - HandleStopTimer(); - std::this_thread::sleep_for(std::chrono::seconds(INTERVAL)); } } @@ -165,7 +163,9 @@ void InputEventInterceptor::OnPointerEvent(std::shared_ptr po FI_HILOGD("PointerEvent(No:%{public}d,Source:%{public}s,Action:%{public}s)", pointerEvent->GetId(), pointerEvent->DumpSourceType(), pointerEvent->DumpPointerAction()); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); - env_->GetTimerManager().RemoveTimer(heartTimer_); + if (heartTimer_ > 0) { + env_->GetTimerManager().RemoveTimer(heartTimer_); + } heartSwtich_ = false; heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwtich_ = true; }); pointerEventTimer_ = env_->GetTimerManager().AddTimer(POINTER_EVENT_TIMEOUT, REPEAT_ONCE, [this]() { @@ -209,6 +209,11 @@ void InputEventInterceptor::OnKeyEvent(std::shared_ptr keyEvent) FI_HILOGD("KeyEvent(No:%{public}d,Key:%{private}d,Action:%{public}d)", keyEvent->GetId(), keyEvent->GetKeyCode(), keyEvent->GetKeyAction()); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); + if (heartTimer_ > 0) { + env_->GetTimerManager().RemoveTimer(heartTimer_); + } + heartSwtich_ = false; + heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwtich_ = true; }); } void InputEventInterceptor::TurnOffChannelScan() From efd8eb8d7ed3098332ff6f5c50c27675e7a67aa7 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:23:03 +0000 Subject: [PATCH 25/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_builder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h index 86efd75ef..696d91254 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_builder.h @@ -102,7 +102,7 @@ private: double GetDamplingCoefficient(DamplingDirection direction) const; bool DampPointerMotion(std::shared_ptr pointerEvent) const; void ExecuteInner(); - void handleStopTimer(); + void HandleStopTimer(); IContext *env_ { nullptr }; bool enable_ { false }; From d1ea7225c4e587ffe12e412af9c06c02f34e3638 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:23:47 +0000 Subject: [PATCH 26/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../include/input_event_transmission/input_event_interceptor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index bf5b8c009..225071564 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -57,7 +57,7 @@ private: int32_t interceptorId_ { -1 }; bool scanState_ { true }; int32_t pointerEventTimer_ { -1 }; - bool heartSwtich_ { true }; + std::atomic_bool heartSwitch_ { true }; int32_t heartTimer_ { -1 }; std::atomic heartBeatRunning_ { true }; std::string remoteNetworkId_; From 48aaaece67204f159a6b3641e58c9abc7c6b518a Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:24:52 +0000 Subject: [PATCH 27/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_builder.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp index f2d840b17..9feb63f85 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp @@ -266,7 +266,7 @@ void InputEventBuilder::TurnOffChannelScan() void InputEventBuilder::ExecuteInner() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; // to enable low latency mode: value = 0 OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE, @@ -275,7 +275,7 @@ void InputEventBuilder::ExecuteInner() void InputEventBuilder::HandleStopTimer() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); From 5b1a985f7c016b128bd2e10d4fb9e791ca303ae6 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:35:03 +0000 Subject: [PATCH 28/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_interceptor.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 273ddc085..28fa312e1 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -87,16 +87,16 @@ void InputEventInterceptor::Enable(Context &context) void InputEventInterceptor::HeartBeatSend() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; + NetPacket packet(MessageId::DSOFTBUS_HEART_BEAT_PACKET); + int32_t ret = InputEventSerialization::HeartBeatMarshalling(packet); + if (ret != RET_OK) { + FI_HILOGE("Failed to serialize packet"); + return; + } while (heartBeatRunning_.load()) { - NetPacket packet(MessageId::DSOFTBUS_HEART_BEAT_PACKET); - int32_t ret = InputEventSerialization::HeartBeatMarshalling(packet); - if (ret != RET_OK) { - FI_HILOGE("Failed to serialize pointer event"); - return; - } - CHKPV(env_); - if (heartSwtich_) { + if (heartSwitch_) { + CHKPV(env_); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); FI_HILOGI("heart beat send"); HandleStopTimer(); @@ -107,7 +107,7 @@ void InputEventInterceptor::HeartBeatSend() void InputEventInterceptor::Disable() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; TurnOnChannelScan(); if (interceptorId_ > 0) { env_->GetInput().RemoveInterceptor(interceptorId_); @@ -166,8 +166,8 @@ void InputEventInterceptor::OnPointerEvent(std::shared_ptr po if (heartTimer_ > 0) { env_->GetTimerManager().RemoveTimer(heartTimer_); } - heartSwtich_ = false; - heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwtich_ = true; }); + heartSwitch_ = false; + heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwitch_ = true; }); pointerEventTimer_ = env_->GetTimerManager().AddTimer(POINTER_EVENT_TIMEOUT, REPEAT_ONCE, [this]() { TurnOnChannelScan(); pointerEventTimer_ = -1; @@ -212,8 +212,8 @@ void InputEventInterceptor::OnKeyEvent(std::shared_ptr keyEvent) if (heartTimer_ > 0) { env_->GetTimerManager().RemoveTimer(heartTimer_); } - heartSwtich_ = false; - heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwtich_ = true; }); + heartSwitch_ = false; + heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwitch_ = true; }); } void InputEventInterceptor::TurnOffChannelScan() @@ -227,7 +227,7 @@ void InputEventInterceptor::TurnOffChannelScan() void InputEventInterceptor::ExecuteInner() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; // to enable low latency mode: value = 0 OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_ENABLE, @@ -236,7 +236,7 @@ void InputEventInterceptor::ExecuteInner() void InputEventInterceptor::HandleStopTimer() { - CALL_INFO_TRACE; + CALL_DEBUG_ENTER; OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData( OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE, {{LOW_LATENCY_KEY, FI_PKG_NAME}}); From 20f4446c76a02a40481f5a2e1ecaa43ebb1f18b4 Mon Sep 17 00:00:00 2001 From: yang123 Date: Thu, 14 Nov 2024 11:35:35 +0000 Subject: [PATCH 29/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_serialization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp index 44127f037..33612ce76 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp @@ -448,7 +448,7 @@ int32_t InputEventSerialization::SerializeBuffer(std::shared_ptr Date: Thu, 14 Nov 2024 11:36:48 +0000 Subject: [PATCH 30/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_interceptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 28fa312e1..5321b98fb 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -107,7 +107,7 @@ void InputEventInterceptor::HeartBeatSend() void InputEventInterceptor::Disable() { - CALL_DEBUG_ENTER; + CALL_INFO_TRACE; TurnOnChannelScan(); if (interceptorId_ > 0) { env_->GetInput().RemoveInterceptor(interceptorId_); From ac612da8a30908ee23bd31bddf84fa3926a01745 Mon Sep 17 00:00:00 2001 From: lwx1285820 Date: Fri, 15 Nov 2024 08:17:00 +0000 Subject: [PATCH 31/46] fix intentionservicetest cfi check Signed-off-by: lwx1285820 --- test/unittest/intention/services/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unittest/intention/services/BUILD.gn b/test/unittest/intention/services/BUILD.gn index af2b85093..a70ed045f 100644 --- a/test/unittest/intention/services/BUILD.gn +++ b/test/unittest/intention/services/BUILD.gn @@ -40,6 +40,7 @@ ohos_unittest("IntentionServiceTest") { cfi = true cfi_cross_dso = true debug = false + blocklist = "./../../ipc_blocklist.txt" } defines = device_status_default_defines From 58ec33b6d10e27fc6486324140c9cce9d8b07ddc Mon Sep 17 00:00:00 2001 From: yang123 Date: Tue, 19 Nov 2024 03:04:04 +0000 Subject: [PATCH 32/46] update intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h. Signed-off-by: yang123 --- .../input_event_transmission/input_event_interceptor.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h index 225071564..78dc0d9d3 100644 --- a/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h +++ b/intention/cooperate/plugin/include/input_event_transmission/input_event_interceptor.h @@ -56,15 +56,12 @@ private: IContext *env_ { nullptr }; int32_t interceptorId_ { -1 }; bool scanState_ { true }; + std::atomic heartTimer_ { -1 }; int32_t pointerEventTimer_ { -1 }; - std::atomic_bool heartSwitch_ { true }; - int32_t heartTimer_ { -1 }; - std::atomic heartBeatRunning_ { true }; std::string remoteNetworkId_; Channel::Sender sender_; static std::set filterKeys_; static std::set filterPointers_; - std::thread thread_; }; } // namespace Cooperate } // namespace DeviceStatus From 5305b399023cc7914646d913308e9268b3250cac Mon Sep 17 00:00:00 2001 From: yang123 Date: Tue, 19 Nov 2024 03:10:48 +0000 Subject: [PATCH 33/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp. Signed-off-by: yang123 --- .../plugin/src/input_event_transmission/input_event_builder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp index 9feb63f85..a4a9bc145 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_builder.cpp @@ -181,7 +181,7 @@ bool InputEventBuilder::OnPacket(const std::string &networkId, Msdp::NetPacket & break; } case MessageId::DSOFTBUS_HEART_BEAT_PACKET: { - FI_HILOGI("Heart beat received"); + FI_HILOGD("Heart beat received"); break; } default: { From 83ed319be27e5ce62ecd493ac8e5bf7ecac67238 Mon Sep 17 00:00:00 2001 From: yang123 Date: Tue, 19 Nov 2024 03:36:24 +0000 Subject: [PATCH 34/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../input_event_interceptor.cpp | 46 +++++++------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 5321b98fb..496e2ddcc 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -40,7 +40,8 @@ const int32_t RESTORE_SCENE { 0 }; const int32_t FORBIDDEN_SCENE { 1 }; const int32_t UPPER_SCENE_FPS { 0 }; const int32_t UPPER_SCENE_BW { 0 }; -const int32_t INTERVAL { 2 }; +const int32_t INTERVAL_MS { 2000 }; +const int32_t REPEAT_MAX { 10000 }; const int32_t MODE_ENABLE { 0 }; const int32_t MODE_DISABLE { 1 }; const std::string LOW_LATENCY_KEY = "identity"; @@ -88,21 +89,15 @@ void InputEventInterceptor::Enable(Context &context) void InputEventInterceptor::HeartBeatSend() { CALL_DEBUG_ENTER; - NetPacket packet(MessageId::DSOFTBUS_HEART_BEAT_PACKET); - int32_t ret = InputEventSerialization::HeartBeatMarshalling(packet); - if (ret != RET_OK) { - FI_HILOGE("Failed to serialize packet"); - return; - } - while (heartBeatRunning_.load()) { - if (heartSwitch_) { - CHKPV(env_); - env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); - FI_HILOGI("heart beat send"); - HandleStopTimer(); - std::this_thread::sleep_for(std::chrono::seconds(INTERVAL)); + CHKPV(env_); + heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL_MS, REPEAT_MAX, [this]() { + NetPacket packet(MessageId::DSOFTBUS_HEART_BEAT_PACKET); + if (InputEventSerialization::HeartBeatMarshalling(packet) != RET_OK) { + FI_HILOGE("Failed to serialize packet"); + return; } - } + env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); + }); } void InputEventInterceptor::Disable() @@ -117,11 +112,14 @@ void InputEventInterceptor::Disable() env_->GetTimerManager().RemoveTimer(pointerEventTimer_); pointerEventTimer_ = -1; } - heartBeatRunning_.store(false); - if (thread_.joinable()) { - thread_.join(); - FI_HILOGI("thread_ is stop"); + if (heartTimer_ < 0) { + FI_HILOGE("Invalid heartTimer_"); + return; } + if (env_->GetTimerManager().RemoveTimer(heartTimer_) != RET_OK) { + FI_HILOGE("Failed to RemoveTimer"); + } + heartTimer_ = -1; } void InputEventInterceptor::Update(Context &context) @@ -163,11 +161,6 @@ void InputEventInterceptor::OnPointerEvent(std::shared_ptr po FI_HILOGD("PointerEvent(No:%{public}d,Source:%{public}s,Action:%{public}s)", pointerEvent->GetId(), pointerEvent->DumpSourceType(), pointerEvent->DumpPointerAction()); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); - if (heartTimer_ > 0) { - env_->GetTimerManager().RemoveTimer(heartTimer_); - } - heartSwitch_ = false; - heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwitch_ = true; }); pointerEventTimer_ = env_->GetTimerManager().AddTimer(POINTER_EVENT_TIMEOUT, REPEAT_ONCE, [this]() { TurnOnChannelScan(); pointerEventTimer_ = -1; @@ -209,11 +202,6 @@ void InputEventInterceptor::OnKeyEvent(std::shared_ptr keyEvent) FI_HILOGD("KeyEvent(No:%{public}d,Key:%{private}d,Action:%{public}d)", keyEvent->GetId(), keyEvent->GetKeyCode(), keyEvent->GetKeyAction()); env_->GetDSoftbus().SendPacket(remoteNetworkId_, packet); - if (heartTimer_ > 0) { - env_->GetTimerManager().RemoveTimer(heartTimer_); - } - heartSwitch_ = false; - heartTimer_ = env_->GetTimerManager().AddTimer(INTERVAL, REPEAT_ONCE, [this]() { heartSwitch_ = true; }); } void InputEventInterceptor::TurnOffChannelScan() From f7988480a4ad56e16c9468297913eca54a64439b Mon Sep 17 00:00:00 2001 From: yang123 Date: Tue, 19 Nov 2024 03:38:06 +0000 Subject: [PATCH 35/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_serialization.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp index 33612ce76..f08ef0e85 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_serialization.cpp @@ -33,7 +33,6 @@ namespace Cooperate { namespace { constexpr int32_t MAX_KEY_SIZE { 395 }; const std::string HEART_BEAT_PACKET { "heart_beat_packet" }; - } // namespace int32_t InputEventSerialization::KeyEventToNetPacket( @@ -449,7 +448,6 @@ int32_t InputEventSerialization::SerializeBuffer(std::shared_ptr Date: Tue, 19 Nov 2024 04:08:57 +0000 Subject: [PATCH 36/46] update intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp. Signed-off-by: yang123 --- .../src/input_event_transmission/input_event_interceptor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp index 496e2ddcc..c52f028d7 100644 --- a/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp +++ b/intention/cooperate/plugin/src/input_event_transmission/input_event_interceptor.cpp @@ -81,8 +81,7 @@ void InputEventInterceptor::Enable(Context &context) FI_HILOGE("Input::AddInterceptor fail"); } TurnOffChannelScan(); - heartBeatRunning_ = true; - thread_ = std::thread([this] {this->HeartBeatSend(); }); + HeartBeatSend(); ExecuteInner(); } From f611fe315ce89f1fc29f1bb4f71fbdfdfe12dfdc Mon Sep 17 00:00:00 2001 From: lwx1285820 Date: Wed, 20 Nov 2024 10:55:47 +0800 Subject: [PATCH 37/46] fix taint index alarm Signed-off-by: lwx1285820 --- intention/services/device_manager/src/monitor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/intention/services/device_manager/src/monitor.cpp b/intention/services/device_manager/src/monitor.cpp index 49dddbbd3..5fa1f713f 100644 --- a/intention/services/device_manager/src/monitor.cpp +++ b/intention/services/device_manager/src/monitor.cpp @@ -133,6 +133,10 @@ void Monitor::ReceiveDevice() for (char *p = buf; p < buf + numRead;) { struct inotify_event *event = reinterpret_cast(p); HandleInotifyEvent(event); + if (event->len > NAME_MAX) { + FI_HILOGW("Invalid name, exceed NAME_MAX"); + break; + } p += sizeof(struct inotify_event) + event->len; } } From acfe13f3b6cc94a7b0b9993c3d518ab8a2272689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=91=E9=9B=84?= Date: Wed, 20 Nov 2024 03:40:34 +0000 Subject: [PATCH 38/46] update test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李少雄 --- .../ipcsocket_fuzzer/ipcsocket_fuzzer.cpp | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp b/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp index 931161269..05f5341d1 100644 --- a/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp +++ b/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp @@ -58,24 +58,6 @@ template T GetData() return objetct; } - -bool SocketClientFuzzTest(const uint8_t* data, size_t size) -{ - std::shared_ptr tunnel = std::make_shared(); - std::unique_ptr client = std::make_unique(tunnel); - client->Connect(); - client->Socket(); - MessageId msgId { MessageId::INVALID }; - NetPacket pkt(msgId); - client->OnPacket(pkt); - client->Reconnect(); - client->Stop(); - client->OnDisconnected(); - tunnel = nullptr; - client = nullptr; - return true; -} - bool SocketConnectionFuzzTest(const uint8_t* data, size_t size) { if ((data == nullptr) || (size < 1)) { @@ -97,10 +79,28 @@ bool SocketConnectionFuzzTest(const uint8_t* data, size_t size) auto socket = []() { return 0; }; + NetPacket packet(MessageId::COORDINATION_ADD_LISTENER); + struct epoll_event ev{}; + std::shared_ptr tunnel = std::make_shared(); + std::unique_ptr client = std::make_unique(tunnel); + client->Connect(); + client->Socket(); + MessageId msgId { MessageId::INVALID }; + NetPacket pkt(msgId); + client->OnPacket(pkt); + client->Reconnect(); + client->Stop(); + client->OnDisconnected(); + SocketSession socketSession("testProgramName", 1, 1, 1, 1, 1); + socketSession.SendMsg(packet); + socketSession.ToString(); + socketSession.Dispatch(ev); socketConnection.OnReadable(fd); socketConnection.OnShutdown(fd); socketConnection.OnException(fd); Msdp::DeviceStatus::SocketConnection::Connect(socket, recv, onDisconnected); + tunnel = nullptr; + client = nullptr; return true; } @@ -121,19 +121,6 @@ bool SocketParamsFuzzTest(const uint8_t* data, size_t size) return true; } - -bool SocketSessionFuzzTest(const uint8_t* data, size_t size) -{ - NetPacket packet(MessageId::COORDINATION_ADD_LISTENER); - struct epoll_event ev{}; - - SocketSession socketSession("testProgramName", 1, 1, 1, 1, 1); - socketSession.SendMsg(packet); - socketSession.ToString(); - socketSession.Dispatch(ev); - return true; -} - } // namespace OHOS extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { @@ -142,10 +129,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) return 0; } - OHOS::SocketClientFuzzTest(data, size); OHOS::SocketConnectionFuzzTest(data, size); OHOS::SocketParamsFuzzTest(data, size); - OHOS::SocketSessionFuzzTest(data, size); return 0; } } // namespace DeviceStatus From f6da0b2c315882924d5bc1e0af22e6550405a033 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Wed, 20 Nov 2024 14:06:23 +0800 Subject: [PATCH 39/46] Signed-off-by: pengyanggit yangpeng177@huawei.com Signed-off-by: pengyanggit Change-Id: I1fb2fe0af722971bd6501dd265ee3b96f664697a --- intention/prototype/include/i_drag_manager.h | 2 ++ .../interaction/drag/include/drag_manager.h | 4 +++- .../interaction/drag/src/drag_manager.cpp | 21 +++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/intention/prototype/include/i_drag_manager.h b/intention/prototype/include/i_drag_manager.h index 71379746d..3757f9917 100644 --- a/intention/prototype/include/i_drag_manager.h +++ b/intention/prototype/include/i_drag_manager.h @@ -65,6 +65,8 @@ public: virtual int32_t GetDragAction(DragAction &dragAction) const = 0; virtual int32_t OnSetDragWindowVisible(bool visible, bool isForce = false) = 0; virtual OHOS::MMI::ExtraData GetExtraData(bool appended) const = 0; + virtual bool GetControlCollaborationVisible() const = 0; + virtual void SetControlCollaborationVisible(bool visible) = 0; #ifndef OHOS_BUILD_ENABLE_ARKUI_X virtual void RegisterStateChange(std::function callback) = 0; virtual void UnregisterStateChange() = 0; diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index fccf37681..82a1795d6 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -92,6 +92,8 @@ public: int32_t OnSetDragWindowVisible(bool visible, bool isForce = false) override; MMI::ExtraData GetExtraData(bool appended) const override; int32_t OnGetShadowOffset(ShadowOffset &shadowOffset) override; + bool GetControlCollaborationVisible() const override = 0; + void SetControlCollaborationVisible(bool visible) override; #ifndef OHOS_BUILD_ENABLE_ARKUI_X void Dump(int32_t fd) const override; void RegisterStateChange(std::function callback) override; @@ -215,7 +217,7 @@ private: DragResult dragResult_ { DragResult::DRAG_FAIL }; std::atomic dragAction_ { DragAction::MOVE }; DragDrawing dragDrawing_; - bool isControlMultiScreenVisible_ = false; + bool isControlCollaborationVisible_ { false }; inline static std::atomic pullId_ { -1 }; #ifndef OHOS_BUILD_ENABLE_ARKUI_X StateChangeNotify stateNotify_; diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index eac2cb366..dfe0fcce4 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -437,8 +437,8 @@ int32_t DragManager::StopDrag(const DragDropResult &dropResult, const std::strin dragResult_ = static_cast(dropResult.result); #endif // OHOS_BUILD_ENABLE_ARKUI_X SetDragState(DragState::STOP); - if (isControlMultiScreenVisible_) { - isControlMultiScreenVisible_ = false; + if (GetControlCollaborationVisible()) { + SetControlCollaborationVisible(false); } #ifndef OHOS_BUILD_ENABLE_ARKUI_X ReportStopDragRadarInfo(BizState::STATE_END, StageRes::RES_SUCCESS, DragRadarErrCode::DRAG_SUCCESS, pid, @@ -1045,8 +1045,8 @@ int32_t DragManager::OnStartDrag(const std::string &packageName, int32_t pid) FI_HILOGI("enter"); pullId_ = GenerateId(); FI_HILOGI("Current pullId:%{public}d", pullId_.load()); - if (isControlMultiScreenVisible_) { - isControlMultiScreenVisible_ = false; + if (GetControlCollaborationVisible()) { + SetControlCollaborationVisible(false); } auto extraData = CreateExtraData(true); DragData dragData = DRAG_DATA_MGR.GetDragData(); @@ -1163,7 +1163,7 @@ int32_t DragManager::OnSetDragWindowVisible(bool visible, bool isForce) #endif // OHOS_BUILD_ENABLE_ARKUI_X return RET_ERR; } - if (!isForce && isControlMultiScreenVisible_) { + if (!isForce && GetControlCollaborationVisible()) { FI_HILOGW("The drag-and-drop window is controlled by multi-screen coordination," "can not set drag window visible:%{public}d", visible); return RET_OK; @@ -1183,7 +1183,7 @@ int32_t DragManager::OnSetDragWindowVisible(bool visible, bool isForce) #endif // OHOS_BUILD_ENABLE_ARKUI_X } if (isForce) { - isControlMultiScreenVisible_ = isForce; + SetControlCollaborationVisible(isForce); FI_HILOGW("The drag-and-drop window is controlled by multi-screen coordination"); } return RET_OK; @@ -1295,6 +1295,15 @@ DragResult DragManager::GetDragResult() const return dragResult_; } +void SetControlCollaborationVisible(bool visible) +{ + isControlCollaborationVisible_ = visible; +} +bool GetControlCollaborationVisible() const +{ + return isControlCollaborationVisible_; +} + int32_t DragManager::GetDragSummary(std::map &summarys) { FI_HILOGI("enter"); From 6833c81778e5e8ade7cac07fe44eabeabcb51623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=91=E9=9B=84?= Date: Wed, 20 Nov 2024 07:08:23 +0000 Subject: [PATCH 40/46] update test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李少雄 --- test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp b/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp index 05f5341d1..7ef2a5ba8 100644 --- a/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp +++ b/test/fuzztest/ipcsocket_fuzzer/ipcsocket_fuzzer.cpp @@ -81,8 +81,8 @@ bool SocketConnectionFuzzTest(const uint8_t* data, size_t size) }; NetPacket packet(MessageId::COORDINATION_ADD_LISTENER); struct epoll_event ev{}; - std::shared_ptr tunnel = std::make_shared(); - std::unique_ptr client = std::make_unique(tunnel); + auto tunnel = std::make_shared(); + auto client = std::make_unique(tunnel); client->Connect(); client->Socket(); MessageId msgId { MessageId::INVALID }; From 5554e3ea72bef910b7a3a379b371a25a305ce6f7 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Wed, 20 Nov 2024 15:24:48 +0800 Subject: [PATCH 41/46] Signed-off-by: pengyanggit yangpeng177@huawei.com Signed-off-by: pengyanggit Change-Id: I940f97b1ca7fc7c7b8742b13cf40dff93e3c1bb1 --- services/interaction/drag/src/drag_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/interaction/drag/src/drag_manager.cpp b/services/interaction/drag/src/drag_manager.cpp index dfe0fcce4..dcf7a8863 100644 --- a/services/interaction/drag/src/drag_manager.cpp +++ b/services/interaction/drag/src/drag_manager.cpp @@ -1295,11 +1295,11 @@ DragResult DragManager::GetDragResult() const return dragResult_; } -void SetControlCollaborationVisible(bool visible) +void DragManager::SetControlCollaborationVisible(bool visible) { isControlCollaborationVisible_ = visible; } -bool GetControlCollaborationVisible() const +bool DragManager::GetControlCollaborationVisible() const { return isControlCollaborationVisible_; } From 15aeb9737cb72bc9c57bac4dfa4b69466970503a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=91=E9=9B=84?= Date: Wed, 20 Nov 2024 08:42:09 +0000 Subject: [PATCH 42/46] update intention/services/device_manager/src/monitor.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李少雄 --- intention/services/device_manager/src/monitor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/intention/services/device_manager/src/monitor.cpp b/intention/services/device_manager/src/monitor.cpp index 5fa1f713f..cefa1e194 100644 --- a/intention/services/device_manager/src/monitor.cpp +++ b/intention/services/device_manager/src/monitor.cpp @@ -132,6 +132,7 @@ void Monitor::ReceiveDevice() FI_HILOGD("Read %{public}zd bytes from inotify events", numRead); for (char *p = buf; p < buf + numRead;) { struct inotify_event *event = reinterpret_cast(p); + CHKPV(event); HandleInotifyEvent(event); if (event->len > NAME_MAX) { FI_HILOGW("Invalid name, exceed NAME_MAX"); From 30cb76797d1e45a2ff583e1d33ad3274b0adab5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B0=91=E9=9B=84?= Date: Wed, 20 Nov 2024 08:48:10 +0000 Subject: [PATCH 43/46] update intention/services/device_manager/src/monitor.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李少雄 --- intention/services/device_manager/src/monitor.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/intention/services/device_manager/src/monitor.cpp b/intention/services/device_manager/src/monitor.cpp index cefa1e194..3350cd031 100644 --- a/intention/services/device_manager/src/monitor.cpp +++ b/intention/services/device_manager/src/monitor.cpp @@ -145,7 +145,6 @@ void Monitor::ReceiveDevice() void Monitor::HandleInotifyEvent(struct inotify_event *event) const { CALL_DEBUG_ENTER; - CHKPV(event); if (Utility::IsEmpty(event->name)) { return; } From 4a177fa3d7daf53c1990de2d9a666df37bbd1f40 Mon Sep 17 00:00:00 2001 From: pengyanggit Date: Wed, 20 Nov 2024 18:15:06 +0800 Subject: [PATCH 44/46] Signed-off-by: pengyanggit yangpeng177@huawei.com Signed-off-by: pengyanggit Change-Id: Id3534085a95bc91854a84eb5dc5dea5379c615a3 --- services/interaction/drag/include/drag_manager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/interaction/drag/include/drag_manager.h b/services/interaction/drag/include/drag_manager.h index 82a1795d6..70f55f2ef 100644 --- a/services/interaction/drag/include/drag_manager.h +++ b/services/interaction/drag/include/drag_manager.h @@ -92,7 +92,7 @@ public: int32_t OnSetDragWindowVisible(bool visible, bool isForce = false) override; MMI::ExtraData GetExtraData(bool appended) const override; int32_t OnGetShadowOffset(ShadowOffset &shadowOffset) override; - bool GetControlCollaborationVisible() const override = 0; + bool GetControlCollaborationVisible() const override; void SetControlCollaborationVisible(bool visible) override; #ifndef OHOS_BUILD_ENABLE_ARKUI_X void Dump(int32_t fd) const override; From 884033187896c4786eae230a4f4362cb37df663f Mon Sep 17 00:00:00 2001 From: lwx1285820 Date: Thu, 21 Nov 2024 10:45:18 +0800 Subject: [PATCH 45/46] vdevadm disable in system bin Signed-off-by: lwx1285820 --- tools/vdev/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vdev/BUILD.gn b/tools/vdev/BUILD.gn index f2921655e..f3f8e4ba9 100644 --- a/tools/vdev/BUILD.gn +++ b/tools/vdev/BUILD.gn @@ -101,7 +101,7 @@ ohos_executable("vdevadm") { "json:nlohmann_json_static", ] - install_enable = true + install_enable = false subsystem_name = "${device_status_subsystem_name}" part_name = "${device_status_part_name}" } From dd932e556364e200bce0bbe5d8d87e6a4a1142a0 Mon Sep 17 00:00:00 2001 From: hellohyh001 Date: Fri, 22 Nov 2024 10:36:11 +0800 Subject: [PATCH 46/46] add drag state interface Signed-off-by: hellohyh001 Change-Id: Ia4a2fb714c181e85507d116da7f64a633992faee --- .../interaction/src/interaction_manager.cpp | 5 +++++ intention/drag/client/include/drag_client.h | 1 + intention/drag/client/src/drag_client.cpp | 11 +++++++++++ intention/drag/data/include/drag_params.h | 11 +++++++++++ intention/drag/data/src/drag_params.cpp | 15 +++++++++++++++ intention/drag/server/include/drag_server.h | 1 + intention/drag/server/src/drag_server.cpp | 14 ++++++++++++++ .../frameworks/client/include/intention_manager.h | 1 + .../frameworks/client/src/intention_manager.cpp | 6 ++++++ .../interaction/include/interaction_manager.h | 8 ++++++++ interfaces/innerkits/libdevicestatus_client_map | 1 + 11 files changed, 74 insertions(+) diff --git a/frameworks/native/interaction/src/interaction_manager.cpp b/frameworks/native/interaction/src/interaction_manager.cpp index 797dae6b0..52998df28 100644 --- a/frameworks/native/interaction/src/interaction_manager.cpp +++ b/frameworks/native/interaction/src/interaction_manager.cpp @@ -73,6 +73,11 @@ int32_t InteractionManager::DeactivateCoordination(bool isUnchained, CooperateMs return INTER_MGR_IMPL.DeactivateCoordination(isUnchained, callback, isCompatible); } +int32_t InteractionManager::SetDraggableState(bool state) +{ + return INTER_MGR_IMPL.SetDraggableState(state); +} + int32_t InteractionManager::GetCoordinationState( const std::string &networkId, std::function callback, bool isCompatible) { diff --git a/intention/drag/client/include/drag_client.h b/intention/drag/client/include/drag_client.h index 91b3bc894..9022b7a26 100644 --- a/intention/drag/client/include/drag_client.h +++ b/intention/drag/client/include/drag_client.h @@ -74,6 +74,7 @@ public: int32_t OnAddSelectedPixelMapResult(const StreamClient &client, NetPacket &pkt); void OnConnected(ITunnelClient &tunnel); void OnDisconnected(ITunnelClient &tunnel); + int32_t SetDraggableState(ITunnelClient &tunnel, bool state); private: mutable std::mutex mtx_; diff --git a/intention/drag/client/src/drag_client.cpp b/intention/drag/client/src/drag_client.cpp index 98532e606..63595ab51 100644 --- a/intention/drag/client/src/drag_client.cpp +++ b/intention/drag/client/src/drag_client.cpp @@ -506,6 +506,17 @@ int32_t DragClient::OnNotifyHideIcon(const StreamClient& client, NetPacket& pkt) return RET_OK; } +int32_t DragClient::SetDraggableState(ITunnelClient &tunnel, bool state) +{ + SetDraggableStateParam param {state}; + DefaultReply reply {}; + int32_t ret = tunnel.SetParam(Intention::DRAG, DragRequestID::SET_DRAGGABLE_STATE, param, reply); + if (ret != RET_OK) { + FI_HILOGE("ITunnelClient::SetParam fail"); + } + return ret; +} + int32_t DragClient::OnStateChangedMessage(const StreamClient &client, NetPacket &pkt) { CALL_DEBUG_ENTER; diff --git a/intention/drag/data/include/drag_params.h b/intention/drag/data/include/drag_params.h index 369886a05..625537a1d 100644 --- a/intention/drag/data/include/drag_params.h +++ b/intention/drag/data/include/drag_params.h @@ -53,6 +53,7 @@ enum DragRequestID : uint32_t { ERASE_MOUSE_ICON, SET_DRAG_WINDOW_SCREEN_ID, ADD_SELECTED_PIXELMAP, + SET_DRAGGABLE_STATE, }; struct StartDragParam final : public ParamBase { @@ -268,6 +269,16 @@ struct AddSelectedPixelMapParam final : public ParamBase { std::shared_ptr pixelMap_ { nullptr }; }; + +struct SetDraggableStateParam final : public ParamBase { + SetDraggableStateParam() = default; + SetDraggableStateParam(bool draggable); + + bool Marshalling(MessageParcel &parcel) const override; + bool Unmarshalling(MessageParcel &parcel) override; + + bool state_ { false }; +}; } // namespace DeviceStatus } // namespace Msdp } // namespace OHOS diff --git a/intention/drag/data/src/drag_params.cpp b/intention/drag/data/src/drag_params.cpp index 9435e2992..0f1560591 100644 --- a/intention/drag/data/src/drag_params.cpp +++ b/intention/drag/data/src/drag_params.cpp @@ -405,6 +405,21 @@ bool GetExtraInfoReply::Unmarshalling(MessageParcel &parcel) { return parcel.ReadString(extraInfo_); } + +SetDraggableStateParam::SetDraggableStateParam(bool state) +{ + state_ = state; +} + +bool SetDraggableStateParam::Marshalling(MessageParcel &parcel) const +{ + return parcel.WriteBool(state_); +} + +bool SetDraggableStateParam::Unmarshalling(MessageParcel &parcel) +{ + return parcel.ReadBool(state_); +} } // namespace DeviceStatus } // namespace Msdp } // namespace OHOS \ No newline at end of file diff --git a/intention/drag/server/include/drag_server.h b/intention/drag/server/include/drag_server.h index 97650fc8f..796521c44 100644 --- a/intention/drag/server/include/drag_server.h +++ b/intention/drag/server/include/drag_server.h @@ -42,6 +42,7 @@ public: int32_t Control(CallingContext &context, uint32_t id, MessageParcel &data, MessageParcel &reply) override; bool IsSystemServiceCalling(CallingContext &context); bool IsSystemHAPCalling(CallingContext &context); + int32_t SetDraggableState(CallingContext &context, MessageParcel &data, MessageParcel &reply); private: int32_t SetDragWindowVisible(CallingContext &context, MessageParcel &data, MessageParcel &reply); diff --git a/intention/drag/server/src/drag_server.cpp b/intention/drag/server/src/drag_server.cpp index 9c3915339..19e72f78f 100644 --- a/intention/drag/server/src/drag_server.cpp +++ b/intention/drag/server/src/drag_server.cpp @@ -135,6 +135,9 @@ int32_t DragServer::SetParam(CallingContext &context, uint32_t id, MessageParcel case DragRequestID::ADD_SELECTED_PIXELMAP: { return AddSelectedPixelMap(context, data, reply); } + case DragRequestID::SET_DRAGGABLE_STATE: { + return SetDraggableState(context, data, reply); + } default: { FI_HILOGE("Unexpected request ID (%{public}u)", id); return RET_ERR; @@ -560,6 +563,17 @@ bool DragServer::IsSystemHAPCalling(CallingContext &context) } return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(context.fullTokenId); } + +int32_t DragServer::SetDraggableState(CallingContext &context, MessageParcel &data, MessageParcel &reply) +{ + SetDraggableStateParam param {}; + + if (!param.Unmarshalling(data)) { + FI_HILOGE("SetDraggableStateParam::Unmarshalling fail"); + return RET_ERR; + } + return RET_OK; +} } // namespace DeviceStatus } // namespace Msdp } // namespace OHOS \ No newline at end of file diff --git a/intention/frameworks/client/include/intention_manager.h b/intention/frameworks/client/include/intention_manager.h index 3919d017a..e33ef1783 100644 --- a/intention/frameworks/client/include/intention_manager.h +++ b/intention/frameworks/client/include/intention_manager.h @@ -87,6 +87,7 @@ public: int32_t AddSelectedPixelMap(std::shared_ptr pixelMap, std::function callback); void OnConnected(); void OnDisconnected(); + int32_t SetDraggableState(bool state); private: void InitClient(); diff --git a/intention/frameworks/client/src/intention_manager.cpp b/intention/frameworks/client/src/intention_manager.cpp index 374a13dbc..d6090aed3 100644 --- a/intention/frameworks/client/src/intention_manager.cpp +++ b/intention/frameworks/client/src/intention_manager.cpp @@ -503,6 +503,12 @@ void IntentionManager::OnDisconnected() CHKPV(tunnel_); drag_.OnDisconnected(*tunnel_); } + +int32_t IntentionManager::SetDraggableState(bool state) +{ + CALL_DEBUG_ENTER; + return drag_.SetDraggableState(*tunnel_, state); +} } // namespace DeviceStatus } // namespace Msdp } // namespace OHOS diff --git a/interfaces/innerkits/interaction/include/interaction_manager.h b/interfaces/innerkits/interaction/include/interaction_manager.h index afac4f2d4..8db4ef3e0 100644 --- a/interfaces/innerkits/interaction/include/interaction_manager.h +++ b/interfaces/innerkits/interaction/include/interaction_manager.h @@ -396,6 +396,14 @@ public: * @since 12 */ int32_t AddSelectedPixelMap(std::shared_ptr pixelMap, std::function callback); + + /** + * @brief Set drag state. + * @param state drag state, if application can drag, set true, else set false. + * @return Returns 0 if the operation is successful; returns a non-zero value otherwise. + * @since 14 + */ + int32_t SetDraggableState(bool state); #else /** * @brief convert relative pointerEvent action to PULL_MOVE or PULL_UP. diff --git a/interfaces/innerkits/libdevicestatus_client_map b/interfaces/innerkits/libdevicestatus_client_map index a797db189..10e7756f7 100644 --- a/interfaces/innerkits/libdevicestatus_client_map +++ b/interfaces/innerkits/libdevicestatus_client_map @@ -73,6 +73,7 @@ "OHOS::Msdp::DeviceStatus::InteractionManager::SetDragWindowScreenId(unsigned long long, unsigned long long)"; "OHOS::Msdp::DeviceStatus::InteractionManager::SetMouseDragMonitorState(bool)"; "OHOS::Msdp::DeviceStatus::InteractionManager::AddSelectedPixelMap(std::__h::shared_ptr, std::__h::function)"; + "OHOS::Msdp::DeviceStatus::InteractionManager::SetDraggableState(bool)"; }; local: *;