diff --git a/intention/adapters/input_adapter/src/input_adapter.cpp b/intention/adapters/input_adapter/src/input_adapter.cpp index 0a86709591728160563f6938bf12ce443cc6b4be..a5e08e8070c2ebb6b9c47fe604fa0b2b6c7c5788 100644 --- a/intention/adapters/input_adapter/src/input_adapter.cpp +++ b/intention/adapters/input_adapter/src/input_adapter.cpp @@ -233,6 +233,7 @@ bool InputAdapter::HasLocalPointerDevice() std::shared_ptr device) { if (this->IsLocalPointerDevice(device) && this->IsVirtualTrackpad(device)) { isLocalPointerDevice = true; + FI_HILOGI("Has VirtualTrackpad, id:%{public}d", device->GetId()); } }); if (ret != RET_OK) { diff --git a/intention/cooperate/client/include/cooperate_client.h b/intention/cooperate/client/include/cooperate_client.h index dbe5daadf72ee523140c3817158043328e4ad82a..2705c361928121b5434588b61bd5502971ca1032 100644 --- a/intention/cooperate/client/include/cooperate_client.h +++ b/intention/cooperate/client/include/cooperate_client.h @@ -65,12 +65,12 @@ public: int32_t Disable(CooperateMessageCallback callback, bool isCheckPermission = false); int32_t Start(const std::string &remoteNetworkId, int32_t startDeviceId, CooperateMessageCallback callback, bool isCheckPermission = false); - int32_t StartWithOptions(const std::string &remoteNetworkId, - int32_t startDeviceId, CooperateMessageCallback callback, const CooperateOptions &options); int32_t Stop(bool isUnchained, CooperateMessageCallback callback, bool isCheckPermission = false); int32_t GetCooperateState(const std::string &networkId, CooperateStateCallback callback, bool isCheckPermission = false); int32_t GetCooperateState(const std::string &udId, bool &state); + int32_t StartWithOptions(const std::string &remoteNetworkId, + int32_t startDeviceId, CooperateMessageCallback callback, const CooperateOptions &options); int32_t RegisterEventListener(const std::string &networkId, MouseLocationListenerPtr listener); int32_t UnregisterEventListener(const std::string &networkId, MouseLocationListenerPtr listener = nullptr); int32_t SetDamplingCoefficient(uint32_t direction, double coefficient); diff --git a/intention/cooperate/client/src/cooperate_client.cpp b/intention/cooperate/client/src/cooperate_client.cpp index 1c38738c689d3fa44fa0696c79d409b3120a42bc..c65ee8194a5addc0717b8b84fe6d1c9d17816e9c 100644 --- a/intention/cooperate/client/src/cooperate_client.cpp +++ b/intention/cooperate/client/src/cooperate_client.cpp @@ -134,6 +134,27 @@ int32_t CooperateClient::Start(const std::string &remoteNetworkId, return RET_OK; } +int32_t CooperateClient::StartWithOptions(const std::string &remoteNetworkId, + int32_t startDeviceId, CooperateMessageCallback callback, const CooperateOptions &options) +{ + CALL_DEBUG_ENTER; + std::lock_guard guard(mtx_); + CooperateEvent event { callback }; + auto userData = GenerateRequestID(); +#ifdef ENABLE_PERFORMANCE_CHECK + StartTrace(userData); +#endif // ENABLE_PERFORMANCE_CHECK + bool isCheckPermission = false; + int32_t ret = INTENTION_CLIENT->StartCooperateWithOptions(remoteNetworkId, userData, + startDeviceId, isCheckPermission, options); + if (ret != RET_OK) { + FI_HILOGE("Activate cooperate failed"); + return ret; + } + devCooperateEvent_.insert_or_assign(userData, event); + return RET_OK; +} + int32_t CooperateClient::Stop(bool isUnchained, CooperateMessageCallback callback, bool isCheckPermission) { CALL_DEBUG_ENTER; @@ -238,27 +259,6 @@ int32_t CooperateClient::UnregisterEventListener(const std::string &networkId, M return RET_OK; } -int32_t CooperateClient::StartWithOptions(const std::string &remoteNetworkId, - int32_t startDeviceId, CooperateMessageCallback callback, const CooperateOptions &options) -{ - CALL_DEBUG_ENTER; - std::lock_guard guard(mtx_); - CooperateEvent event { callback }; - auto userData = GenerateRequestID(); -#ifdef ENABLE_PERFORMANCE_CHECK - StartTrace(userData); -#endif // ENABLE_PERFORMANCE_CHECK - bool isCheckPermission = false; - int32_t ret = INTENTION_CLIENT->StartCooperateWithOptions(remoteNetworkId, userData, - startDeviceId, isCheckPermission, options); - if (ret != RET_OK) { - FI_HILOGE("Activate cooperate failed"); - return ret; - } - devCooperateEvent_.insert_or_assign(userData, event); - return RET_OK; -} - int32_t CooperateClient::SetDamplingCoefficient(uint32_t direction, double coefficient) { FI_HILOGI("SetDamplingCoefficient(0x%{public}x, %{public}.3f)", direction, coefficient); diff --git a/intention/cooperate/plugin/include/cooperate_context.h b/intention/cooperate/plugin/include/cooperate_context.h index 2da3592b3f2af42bd5aed8702657368853b90bbb..eff9e30350e79fbcfba84fa4ce4aba3775dbec8b 100644 --- a/intention/cooperate/plugin/include/cooperate_context.h +++ b/intention/cooperate/plugin/include/cooperate_context.h @@ -88,9 +88,9 @@ public: int32_t GetTouchPadSpeed(); void SetTouchPadSpeed(int32_t speed); void SetVirtualTrackpadDeviceId(int32_t deviceId); + void AdjustPointerPos(DSoftbusCooperateOptions& dSoftbusCooperateOptions); int32_t GetVirtualTrackpadDeviceId(); void ResetVirtualTrackpadDeviceId(); - void AdjustPointerPos(DSoftbusCooperateOptions& dSoftbusCooperateOptions); bool IsAllowCooperate(); void OnStartCooperate(StartCooperateData &data); void OnRemoteStartCooperate(RemoteStartCooperateData &data); @@ -152,7 +152,7 @@ private: int32_t originPointerSpeed_ { -1 }; int32_t peerTouchPadSpeed_ { -1 }; int32_t originTouchPadSpeed_ { -1 }; - int32_t VirtualTrackpadDeviceId_ { -1 }; + std::atomic VirtualTrackpadDeviceId_ { -1 }; std::shared_ptr eventHandler_; std::shared_ptr boardObserver_; std::shared_ptr hotplugObserver_; diff --git a/intention/cooperate/plugin/include/cooperate_events.h b/intention/cooperate/plugin/include/cooperate_events.h index e1118dfa1ae8f39f0916db19df5f323334280c09..62fff73fc6e29b9e5e200d575c79797ac965786b 100644 --- a/intention/cooperate/plugin/include/cooperate_events.h +++ b/intention/cooperate/plugin/include/cooperate_events.h @@ -76,11 +76,11 @@ enum class CooperateEventType { DSOFTBUS_INPUT_DEV_SYNC, DSOFTBUS_INPUT_DEV_HOT_PLUG, UPDATE_VIRTUAL_DEV_ID_MAP, + STOP_ABOUT_VIRTUALTRACKPAD, DSOFTBUS_COME_BACK_WITH_OPTIONS, DSOFTBUS_COOPERATE_WITH_OPTIONS, DSOFTBUS_RELAY_COOPERATE_WITHOPTIONS, - DSOFTBUS_RELAY_COOPERATE_WITHOPTIONS_FINISHED, - STOP_ABOUT_VIRTUALTRACKPAD + DSOFTBUS_RELAY_COOPERATE_WITHOPTIONS_FINISHED }; struct Rectangle { @@ -326,9 +326,9 @@ struct CooperateEvent { DSoftbusSyncInputDevice, DSoftbusHotPlugEvent, UpdateVirtualDeviceIdMapEvent, + NotAollowCooperateWhenMotionDragging, StartWithOptionsEvent, - DSoftbusCooperateOptions, - NotAollowCooperateWhenMotionDragging + DSoftbusCooperateOptions > event; }; diff --git a/intention/cooperate/plugin/include/cooperate_free.h b/intention/cooperate/plugin/include/cooperate_free.h index f95af994bfeb9d54db09938068f747e73cc32593..a82a830295f6b1fcedb5476eaaa847475c497b82 100644 --- a/intention/cooperate/plugin/include/cooperate_free.h +++ b/intention/cooperate/plugin/include/cooperate_free.h @@ -59,10 +59,10 @@ private: void OnRemoteStart(Context &context, const CooperateEvent &event); void OnPointerEvent(Context &context, const CooperateEvent &event); void OnUpdateCooperateFlag(Context &context, const CooperateEvent &event); - void OnStartWithOptions(Context &context, const CooperateEvent &event); - void OnRemoteStartWithOptions(Context &context, const CooperateEvent &event); void CooperateFail(Context &context, int32_t ret); void InitiatorPointerVisible(bool visible); + void OnStartWithOptions(Context &context, const CooperateEvent &event); + void OnRemoteStartWithOptions(Context &context, const CooperateEvent &event); CooperateFree &parent_; }; diff --git a/intention/cooperate/plugin/include/cooperate_out.h b/intention/cooperate/plugin/include/cooperate_out.h index 6a51fe9ccd58e276ace7acc126800567c367c6e2..3242ab0560ba6cc59b15da170cb5744315f2344e 100644 --- a/intention/cooperate/plugin/include/cooperate_out.h +++ b/intention/cooperate/plugin/include/cooperate_out.h @@ -57,11 +57,11 @@ private: void OnBoardOffline(Context &context, const CooperateEvent &event); void OnSwitchChanged(Context &context, const CooperateEvent &event); void OnSoftbusSessionClosed(Context &context, const CooperateEvent &event); + void OnStopAboutVirtualTrackpad(Context &context, const CooperateEvent &event); void OnRemoteStartWithOptions(Context &context, const CooperateEvent &event); void OnStartWithOptions(Context &context, const CooperateEvent &event); void OnComeBackWithOptions(Context &context, const CooperateEvent &event); void OnRelayWithOptions(Context &context, const CooperateEvent &event); - void OnStopAboutVirtualTrackpad(Context &context, const CooperateEvent &event); CooperateOut &parent_; }; diff --git a/intention/cooperate/plugin/include/event_manager.h b/intention/cooperate/plugin/include/event_manager.h index ec6b6a55d76a3c9e28cd7cc649e87559425cfd2f..d8e232ff97fa9eca3075e9ac08b7c39c510706d6 100644 --- a/intention/cooperate/plugin/include/event_manager.h +++ b/intention/cooperate/plugin/include/event_manager.h @@ -88,11 +88,11 @@ public: void OnStatusChanged(const StatusChangeEvent &event); void GetCooperateState(const CooperateStateNotice ¬ice); void OnClientDied(const ClientDiedEvent &event); + void ErrorNotAollowCooperateWhenMotionDragging(const NotAollowCooperateWhenMotionDragging &event); void RemoteStartWithOptions(const DSoftbusCooperateOptions &event); void RemoteStartWithOptionsFinish(const DSoftbusCooperateWithOptionsFinished &event); void StartCooperateWithOptionsFinish(const DSoftbusCooperateWithOptionsFinished &event); void StartCooperateWithOptions(const StartWithOptionsEvent &event); - void ErrorNotAollowCooperateWhenMotionDragging(const NotAollowCooperateWhenMotionDragging &event); private: void OnCooperateMessage(CoordinationMessage msg, const std::string &networkId); 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 467472d6db9daa3230b2f7b75b0bb2f5ec216104..990474067397836febbecb41facba21ee83ba3e3 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,8 +102,6 @@ private: void ResetPressedEvents(); double GetDamplingCoefficient(DamplingDirection direction) const; bool DampPointerMotion(std::shared_ptr pointerEvent); - void ExecuteInner(); - void HandleStopTimer(); void CheckLatency(int64_t sourceActionTime, int64_t interceptorTime, int64_t builderRecvTime, std::shared_ptr pointerEvent); 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 8a19dd27414d6416427427f9cd4c64e57caa76ea..3281a280d141e2cbba15a8cbc303d5f9bb361235 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,8 +16,6 @@ #ifndef INPUT_EVENT_INTERCEPTOR_H #define INPUT_EVENT_INTERCEPTOR_H -#include - #include "nocopyable.h" #include "channel.h" @@ -48,8 +46,6 @@ 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(); diff --git a/intention/cooperate/plugin/include/state_machine.h b/intention/cooperate/plugin/include/state_machine.h index 141fe40f30fb51d314119344f6b30e99b725ab94..61bf6869deb0e67b083544a925ecba042ea516a7 100644 --- a/intention/cooperate/plugin/include/state_machine.h +++ b/intention/cooperate/plugin/include/state_machine.h @@ -104,6 +104,7 @@ private: void OnRemoteStartWithOptions(Context &context, const CooperateEvent &event); bool CheckIsVirtualTrackpad(int32_t deviceId); void ResetCooperate(Context &context); + void OnPreMonitorKeyEvent(Context &context, std::shared_ptr keyEvent); IContext *env_ { nullptr }; std::map> handlers_; @@ -112,7 +113,6 @@ private: std::set onlineBoards_; int32_t monitorId_ { -1 }; int32_t preMonitorId_ { -1 }; - int32_t screenEventTimer_ { -1 }; std::vector clientBundleNames_; sptr appStateObserver_ { nullptr }; std::shared_ptr observer_ { nullptr }; diff --git a/intention/cooperate/plugin/src/cooperate.cpp b/intention/cooperate/plugin/src/cooperate.cpp index 4bd26600336341d1cf9b0b39c8b6bdc286cbbb89..2c7b92daae3aade2a2da0239d2feafa326f126ad 100644 --- a/intention/cooperate/plugin/src/cooperate.cpp +++ b/intention/cooperate/plugin/src/cooperate.cpp @@ -196,14 +196,13 @@ int32_t Cooperate::Start(int32_t pid, int32_t userData, const std::string &remot auto ret = context_.Sender().Send(CooperateEvent(CooperateEventType::START, event)); if (ret != Channel::NO_ERROR) { FI_HILOGE("Failed to send event via channel, error:%{public}d", ret); - } - if (ret != RET_OK) { radarInfo.bizStage = static_cast (BizCooperateStage::STAGE_CALLING_COOPERATE); radarInfo.stageRes = static_cast (BizCooperateStageRes::RES_FAIL); radarInfo.errCode = static_cast (CooperateRadarErrCode::CALLING_COOPERATE_FAILED); CooperateRadar::ReportCooperateRadarInfo(radarInfo); - }; + } radarInfo.bizState = static_cast (BizState::STATE_BEGIN), + radarInfo.bizStage = static_cast (BizCooperateStage::STAGE_CALLING_COOPERATE); radarInfo.stageRes = static_cast (BizCooperateStageRes::RES_SUCCESS), radarInfo.errCode = static_cast (CooperateRadarErrCode::CALLING_COOPERATE_SUCCESS), CooperateRadar::ReportCooperateRadarInfo(radarInfo); diff --git a/intention/cooperate/plugin/src/cooperate_free.cpp b/intention/cooperate/plugin/src/cooperate_free.cpp index 9005e493a16ceb80ae3ad7eeb1b3fe30cdd873a4..deb2327266fb788931b57781e3253ecb77e296cc 100644 --- a/intention/cooperate/plugin/src/cooperate_free.cpp +++ b/intention/cooperate/plugin/src/cooperate_free.cpp @@ -265,7 +265,7 @@ void CooperateFree::Initial::OnStartWithOptions(Context &context, const Cooperat CALL_INFO_TRACE; CHKPV(parent_.env_); StartWithOptionsEvent notice = std::get(event.event); - FI_HILOGI("[start With] With \'%{public}s\'", Utility::Anonymize(notice.remoteNetworkId).c_str()); + FI_HILOGI("[start with] With \'%{public}s\'", Utility::Anonymize(notice.remoteNetworkId).c_str()); context.StartCooperateWithOptions(notice); context.eventMgr_.StartCooperateWithOptions(notice); if (parent_.env_->GetDragManager().GetDragState() == DragState::MOTION_DRAGGING) { @@ -282,7 +282,7 @@ void CooperateFree::Initial::OnStartWithOptions(Context &context, const Cooperat } int32_t ret = context.dsoftbus_.OpenSession(context.Peer()); if (ret != RET_OK) { - FI_HILOGE("[start cooperation] Failed to connect\'%{public}s\'", Utility::Anonymize(context.Peer()).c_str()); + FI_HILOGE("[start cooperation] Failed to connect \'%{public}s\'", Utility::Anonymize(context.Peer()).c_str()); int32_t errNum = (ret == RET_ERR ? static_cast(CoordinationErrCode::OPEN_SESSION_FAILED) : ret); DSoftbusStartCooperateFinished failNotice { .success = false, diff --git a/intention/cooperate/plugin/src/cooperate_in.cpp b/intention/cooperate/plugin/src/cooperate_in.cpp index a5a06294656cf70e4139bd61f8d92443d0a48faa..1675287ee38dddbcb1a18eda1f38f8d2bc6529a7 100644 --- a/intention/cooperate/plugin/src/cooperate_in.cpp +++ b/intention/cooperate/plugin/src/cooperate_in.cpp @@ -48,22 +48,22 @@ void CooperateIn::OnEvent(Context &context, const CooperateEvent &event) void CooperateIn::OnEnterState(Context &context) { CALL_INFO_TRACE; + CHKPV(env_); int32_t ret = env_->GetInput().SetPointerVisibility(!context.NeedHideCursor(), PRIORITY); CooperateRadarInfo radarInfo { .funcName = __FUNCTION__, .bizState = static_cast (BizState::STATE_END), + .bizStage = static_cast (BizCooperateStage::STAGE_PASSIVE_CURSOR_VISIBILITY), .bizScene = static_cast (BizCooperateScene::SCENE_PASSIVE), .hostName = "", .localNetId = "", .peerNetId = "" }; if (ret != RET_OK) { - radarInfo.bizStage = static_cast (BizCooperateStage::STAGE_PASSIVE_CURSOR_VISIBILITY); radarInfo.stageRes = static_cast (BizCooperateStageRes::RES_FAIL); radarInfo.errCode = static_cast (CooperateRadarErrCode::PASSIVE_CURSOR_VISIBILITY_FAILED); CooperateRadar::ReportCooperateRadarInfo(radarInfo); } - radarInfo.bizStage = static_cast (BizCooperateStage::STAGE_PASSIVE_CURSOR_VISIBILITY); radarInfo.stageRes = static_cast (BizCooperateStageRes::RES_SUCCESS); radarInfo.errCode = static_cast (CooperateRadarErrCode::CALLING_COOPERATE_SUCCESS); CooperateRadar::ReportCooperateRadarInfo(radarInfo); diff --git a/intention/cooperate/plugin/src/cooperate_out.cpp b/intention/cooperate/plugin/src/cooperate_out.cpp index 0b5d05e0b779a437fa072d003bf4716e3a40dcf2..0fc0551345855784c6d6a071e4269a046b38ac2a 100644 --- a/intention/cooperate/plugin/src/cooperate_out.cpp +++ b/intention/cooperate/plugin/src/cooperate_out.cpp @@ -48,6 +48,7 @@ void CooperateOut::OnEvent(Context &context, const CooperateEvent &event) void CooperateOut::OnEnterState(Context &context) { CALL_INFO_TRACE; + CHKPV(env_); int32_t ret = env_->GetInput().SetPointerVisibility(false); if (ret != RET_OK) { CooperateRadarInfo radarInfo { @@ -155,7 +156,11 @@ CooperateOut::Initial::Initial(CooperateOut &parent) [this](Context &context, const CooperateEvent &event) { this->OnRelay(context, event); }); - AddHandler(CooperateEventType::DSOFTBUS_COOPERATE_WITH_OPTIONS, + AddHandler(CooperateEventType::STOP_ABOUT_VIRTUALTRACKPAD, + [this](Context &context, const CooperateEvent &event) { + this->OnStopAboutVirtualTrackpad(context, event); + }); + AddHandler(CooperateEventType::DSOFTBUS_COOPERATE_WITH_OPTIONS, [this](Context &context, const CooperateEvent &event) { this->OnRemoteStartWithOptions(context, event); }); @@ -167,10 +172,6 @@ CooperateOut::Initial::Initial(CooperateOut &parent) [this](Context &context, const CooperateEvent &event) { this->OnRelayWithOptions(context, event); }); - AddHandler(CooperateEventType::STOP_ABOUT_VIRTUALTRACKPAD, - [this](Context &context, const CooperateEvent &event) { - this->OnStopAboutVirtualTrackpad(context, event); - }); } void CooperateOut::Initial::OnDisable(Context &context, const CooperateEvent &event) @@ -411,7 +412,6 @@ void CooperateOut::Initial::OnRelayWithOptions(Context &context, const Cooperate } DSoftbusRelayCooperateFinished resp { .targetNetworkId = notice.targetNetworkId, - .uid = notice.uid, }; int32_t ret = context.dsoftbus_.OpenSession(notice.targetNetworkId); @@ -436,9 +436,9 @@ void CooperateOut::Initial::OnHotplug(Context &context, const CooperateEvent &ev { InputHotplugEvent notice = std::get(event.event); if (context.GetVirtualTrackpadDeviceId() > 0) { + FI_HILOGI("Cur device exist VirtualTrackpad"); return; - } else if ((context.GetVirtualTrackpadDeviceId() <= 0) && - !(parent_.env_->GetDeviceManager().HasLocalPointerDevice())) { + } else if (!(parent_.env_->GetDeviceManager().HasLocalPointerDevice())) { FI_HILOGI("Cur device not exist pointer device"); parent_.StopCooperate(context, event); } else if (notice.deviceId != context.StartDeviceId()) { diff --git a/intention/cooperate/plugin/src/dsoftbus_handler.cpp b/intention/cooperate/plugin/src/dsoftbus_handler.cpp index 04ddb83f09c6238b6e12c5e040c060e24f595fc2..403fa7dd288a51fe419aca9207fda96437abbdb5 100644 --- a/intention/cooperate/plugin/src/dsoftbus_handler.cpp +++ b/intention/cooperate/plugin/src/dsoftbus_handler.cpp @@ -613,27 +613,6 @@ void DSoftbusHandler::OnRelayCooperate(const std::string &networkId, NetPacket & event)); } -void DSoftbusHandler::OnRelayCooperateFinish(const std::string &networkId, NetPacket &packet) -{ - CALL_INFO_TRACE; - DSoftbusRelayCooperate event { - .networkId = networkId, - }; - packet >> event.targetNetworkId >> event.normal; - if (packet.ChkRWError()) { - FI_HILOGE("Failed to read data packet"); - return; - } - packet >> event.uid; - if (packet.ChkRWError()) { - event.uid = 0; - FI_HILOGD("Cur uid:%{public}d", event.uid); - } - SendEvent(CooperateEvent( - CooperateEventType::DSOFTBUS_RELAY_COOPERATE_FINISHED, - event)); -} - void DSoftbusHandler::OnRelayCooperateWithOptions(const std::string &networkId, NetPacket &packet) { CALL_INFO_TRACE; @@ -677,6 +656,27 @@ void DSoftbusHandler::OnRelayCooperateWithOptionsFinish(const std::string &netwo event)); } +void DSoftbusHandler::OnRelayCooperateFinish(const std::string &networkId, NetPacket &packet) +{ + CALL_INFO_TRACE; + DSoftbusRelayCooperate event { + .networkId = networkId, + }; + packet >> event.targetNetworkId >> event.normal; + if (packet.ChkRWError()) { + FI_HILOGE("Failed to read data packet"); + return; + } + packet >> event.uid; + if (packet.ChkRWError()) { + event.uid = 0; + FI_HILOGD("Cur uid:%{public}d", event.uid); + } + SendEvent(CooperateEvent( + CooperateEventType::DSOFTBUS_RELAY_COOPERATE_FINISHED, + event)); +} + void DSoftbusHandler::OnSubscribeMouseLocation(const std::string &networKId, NetPacket &packet) { CALL_INFO_TRACE; diff --git a/intention/cooperate/plugin/src/event_manager.cpp b/intention/cooperate/plugin/src/event_manager.cpp index 2a6bc83f3a6fb595d90f38fa402af8e5019a0d7b..a8c08b0eeb5b651f15c05403e248652f3c9f6534 100644 --- a/intention/cooperate/plugin/src/event_manager.cpp +++ b/intention/cooperate/plugin/src/event_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -14,6 +14,7 @@ */ #include "event_manager.h" + #include "devicestatus_define.h" #include "utility.h" @@ -119,7 +120,7 @@ void EventManager::StartCooperateWithOptions(const StartWithOptionsEvent &event) eventInfo->userData = event.userData; calls_[EventType::START] = eventInfo; } - + void EventManager::StartCooperateWithOptionsFinish(const DSoftbusCooperateWithOptionsFinished &event) { std::shared_ptr eventInfo = calls_[EventType::START]; @@ -156,7 +157,7 @@ void EventManager::RemoteStartWithOptions(const DSoftbusCooperateOptions &event) CALL_INFO_TRACE; OnCooperateMessage(CoordinationMessage::ACTIVATE, event.networkId); } - + void EventManager::RemoteStartWithOptionsFinish(const DSoftbusCooperateWithOptionsFinished &event) { CALL_INFO_TRACE; @@ -290,7 +291,6 @@ void EventManager::NotifyCooperateMessage(const CooperateNotice ¬ice) FI_HILOGD("session is null"); return; } - CHKPV(session); NetPacket pkt(notice.msgId); pkt << notice.userData << notice.networkId << static_cast(notice.msg) << notice.errCode; if (pkt.ChkRWError()) { 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 51e1150880c6afde92392661d0e9b1195d18338d..8b51ed71fdba3df6b47eefdcc8d5deeca7ac04de 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -23,8 +23,6 @@ #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,11 +42,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 MODE_ENABLE { 0 }; -const int32_t MODE_DISABLE { 1 }; const int32_t DRIVE_INTERCEPTOR_LATENCY { 5 }; const int32_t INTERCEPTOR_TRANSMISSION_LATENCY { 20 }; -const std::string LOW_LATENCY_KEY = "identity"; } InputEventBuilder::InputEventBuilder(IContext *env) @@ -118,7 +113,6 @@ void InputEventBuilder::Disable() env_->GetTimerManager().RemoveTimerAsync(pointerEventTimer_); pointerEventTimer_ = -1; } - HandleStopTimer(); } void InputEventBuilder::Update(Context &context) 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 b639c31559df3d2b00f5248f0b1252b0a9edbeee..7c7bcb09573a3512a73a8b34977c3cc879dcb07c 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 @@ -24,9 +24,6 @@ #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" @@ -43,9 +40,6 @@ const int32_t UPPER_SCENE_FPS { 0 }; const int32_t UPPER_SCENE_BW { 0 }; 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"; } std::set InputEventInterceptor::filterKeys_ { @@ -102,10 +96,9 @@ int32_t InputEventInterceptor::Enable(Context &context) } TurnOffChannelScan(); HeartBeatSend(); - ExecuteInner(); return RET_OK; } - + void InputEventInterceptor::HeartBeatSend() { CALL_DEBUG_ENTER; @@ -134,7 +127,7 @@ void InputEventInterceptor::Disable() pointerEventTimer_ = -1; } if (heartTimer_ < 0) { - FI_HILOGE("Invalid heartTimer_"); + FI_HILOGE("Failed to add heartTimer_"); return; } if (env_->GetTimerManager().RemoveTimerAsync(heartTimer_) != RET_OK) { @@ -237,15 +230,6 @@ void InputEventInterceptor::TurnOffChannelScan() } } -void InputEventInterceptor::ExecuteInner() -{ - 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, - {{LOW_LATENCY_KEY, FI_PKG_NAME}}); -} - void InputEventInterceptor::HandleStopTimer() { CALL_DEBUG_ENTER; 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 ec6c515373dadc11e47af19db517d2e48f9bb6f5..804f30d92314ea9eab2f12c548874742bc4ffa48 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 @@ -349,12 +349,7 @@ int32_t InputEventSerialization::SerializePointers(std::shared_ptr pointerIds = event->GetPointerIds(); std::vector::size_type nPointers = pointerIds.size(); - if (nPointers >= MAX_N_PRESSED_BUTTONS) { - FI_HILOGE("Exceed maximum allowed number of nPointers"); - return RET_ERR; - } pkt << nPointers; - for (const auto &pointerId : pointerIds) { MMI::PointerEvent::PointerItem item; @@ -378,10 +373,6 @@ int32_t InputEventSerialization::DeserializePointers(NetPacket &pkt, std::shared { std::vector::size_type nPointers; pkt >> nPointers; - if (nPointers >= MAX_N_PRESSED_BUTTONS) { - FI_HILOGE("Exceed maximum allowed number of nPointers"); - return RET_ERR; - } for (; nPointers > 0; --nPointers) { MMI::PointerEvent::PointerItem item; diff --git a/intention/cooperate/plugin/src/state_machine.cpp b/intention/cooperate/plugin/src/state_machine.cpp index 41a29180ed993ee430db82a950168da1a9dbd657..f04519ac7c98120e926941b68a82b5900eacb5f9 100644 --- a/intention/cooperate/plugin/src/state_machine.cpp +++ b/intention/cooperate/plugin/src/state_machine.cpp @@ -101,12 +101,12 @@ StateMachine::StateMachine(IContext *env) AddHandler(CooperateEventType::START, [this](Context &context, const CooperateEvent &event) { this->StartCooperate(context, event); }); - AddHandler(CooperateEventType::GET_COOPERATE_STATE, [this](Context &context, const CooperateEvent &event) { - this->GetCooperateState(context, event); - }); AddHandler(CooperateEventType::WITH_OPTIONS_START, [this](Context &context, const CooperateEvent &event) { this->StartCooperateWithOptions(context, event); }); + AddHandler(CooperateEventType::GET_COOPERATE_STATE, [this](Context &context, const CooperateEvent &event) { + this->GetCooperateState(context, event); + }); AddHandler(CooperateEventType::REGISTER_EVENT_LISTENER, [this](Context &context, const CooperateEvent &event) { this->RegisterEventListener(context, event); @@ -373,15 +373,6 @@ void StateMachine::StartCooperate(Context &context, const CooperateEvent &event) Transfer(context, event); } -void StateMachine::StopCooperate(Context &context, const CooperateEvent &event) -{ - CALL_DEBUG_ENTER; - context.CloseDistributedFileConnection(context.Peer()); - context.OnStopCooperate(); - context.inputDevMgr_.RemoveAllVirtualInputDevice(); - Transfer(context, event); -} - void StateMachine::StartCooperateWithOptions(Context &context, const CooperateEvent &event) { CALL_INFO_TRACE; @@ -426,6 +417,15 @@ void StateMachine::StartCooperateWithOptions(Context &context, const CooperateEv Transfer(context, event); } +void StateMachine::StopCooperate(Context &context, const CooperateEvent &event) +{ + CALL_DEBUG_ENTER; + context.CloseDistributedFileConnection(context.Peer()); + context.OnStopCooperate(); + context.inputDevMgr_.RemoveAllVirtualInputDevice(); + Transfer(context, event); +} + void StateMachine::GetCooperateState(Context &context, const CooperateEvent &event) { CALL_INFO_TRACE; @@ -773,14 +773,6 @@ void StateMachine::RemoveSessionObserver(Context &context, const DisableCooperat void StateMachine::OnCommonEvent(Context &context, const std::string &commonEvent) { FI_HILOGD("Current common event:%{public}s", commonEvent.c_str()); - CHKPV(env_); - if (commonEvent == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON || - commonEvent == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) { - if ((screenEventTimer_ >= 0) && (env_->GetTimerManager().IsExist(screenEventTimer_))) { - env_->GetTimerManager().RemoveTimer(screenEventTimer_); - screenEventTimer_ = -1; - } - } if (commonEvent == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF || commonEvent == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_LOCKED) { FI_HILOGD("Receive common event:%{public}s, stop cooperate", commonEvent.c_str()); @@ -792,18 +784,6 @@ void StateMachine::OnCommonEvent(Context &context, const std::string &commonEven if (ret != Channel::NO_ERROR) { FI_HILOGE("Failed to send event via channel, error:%{public}d", ret); } - screenEventTimer_ = env_->GetTimerManager().AddTimer(SCREEN_LOCKED_TIMEOUT, REPEAT_ONCE, - [sender = context.Sender(), this]() mutable { - auto res = sender.Send(CooperateEvent( - CooperateEventType::STOP, - StopCooperateEvent{ - .isUnchained = true - })); - if (res != Channel::NO_ERROR) { - FI_HILOGE("Failed to send event via channel, error:%{public}d", res); - } - screenEventTimer_ = -1; - }); } } @@ -862,21 +842,25 @@ void StateMachine::AddPreMonitor(Context &context) CHKPV(env_); std::vector keys; keys.push_back(MMI::KeyEvent::KEYCODE_KEY_PEN_AIR_MOUSE); - preMonitorId_ = env_->GetInput().AddPreMonitor(nullptr, [&context, this] - (std::shared_ptr keyEvent) mutable { - CHKPV(keyEvent); - if (keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_KEY_PEN_AIR_MOUSE) { - if (keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { - FI_HILOGI("Air mouse key down"); - env_->GetDeviceManager().SetPencilAirMouse(true); - } else { - FI_HILOGI("Air mouse key up or cancel or unknow"); - env_->GetDeviceManager().SetPencilAirMouse(false); - } - } - }, MMI::HANDLE_EVENT_TYPE_PRE_KEY, keys); + preMonitorId_ = env_->GetInput().AddPreMonitor(nullptr, + [&context, this](std::shared_ptr keyEvent) { this->OnPreMonitorKeyEvent(context, keyEvent); }, + MMI::HANDLE_EVENT_TYPE_PRE_KEY, keys); if (preMonitorId_ < 0) { - FI_HILOGE("MMI::Add Monitor fail"); + FI_HILOGE("MMI::Add pre monitor fail"); + } +} + +void StateMachine::OnPreMonitorKeyEvent(Context &context, std::shared_ptr keyEvent) +{ + FI_HILOGD("Pre monitor key: %{private}d", keyEvent->GetKeyCode()); + if (keyEvent->GetKeyCode() == MMI::KeyEvent::KEYCODE_KEY_PEN_AIR_MOUSE) { + if (keyEvent->GetKeyAction() == MMI::KeyEvent::KEY_ACTION_DOWN) { + FI_HILOGI("Air mouse key down"); + env_->GetDeviceManager().SetPencilAirMouse(true); + } else { + FI_HILOGI("Air mouse key up or cancel or unknow"); + env_->GetDeviceManager().SetPencilAirMouse(false); + } } } @@ -931,7 +915,7 @@ bool StateMachine::CheckIsVirtualTrackpad(int32_t deviceId) { CALL_INFO_TRACE; bool isLocalPointerDevice = false; - MMI::InputManager::GetInstance()->GetDevice(deviceId, [&isLocalPointerDevice, this] ( + int32_t res = MMI::InputManager::GetInstance()->GetDevice(deviceId, [&isLocalPointerDevice, this] ( std::shared_ptr device) -> bool { CHKPR(device, false); if (device->GetName() == VIRTUAL_TRACK_PAD_NAME) { @@ -941,6 +925,10 @@ bool StateMachine::CheckIsVirtualTrackpad(int32_t deviceId) } return isLocalPointerDevice; }); + if (res != ERR_OK) { + FI_HILOGE("Get device failed, ret:%{public}d", res); + return isLocalPointerDevice; + } return isLocalPointerDevice; } diff --git a/intention/ipc/tunnel/IIntention.idl b/intention/ipc/tunnel/IIntention.idl index b0a2d5715944c264ac1a579f76b89abf7caaf236..b3e4387b482ff61b153d0312d598e1ff5e00b3a0 100644 --- a/intention/ipc/tunnel/IIntention.idl +++ b/intention/ipc/tunnel/IIntention.idl @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + sequenceable OHOS.Msdp.DeviceStatus.SequenceableCooperateOptions; sequenceable OHOS.Msdp.DeviceStatus.SequenceableDragData; sequenceable OHOS.Msdp.DeviceStatus.SequenceableDragResult; @@ -28,15 +28,16 @@ sequenceable OHOS.Msdp.DeviceStatus.OnScreen.SequenceablePageContent; interface OHOS.Msdp.DeviceStatus.IRemoteBoomerangCallback; interface OHOS.Msdp.DeviceStatus.IRemoteDevStaCallback; sequenceable OHOS.Media.PixelMap; - + interface OHOS.Msdp.IIntention { // Socket void Socket([in] String programName, [in] int moduleType, [out] FileDescriptor socketFd, [out] int tokenType); - + // Cooperate void EnableCooperate([in] int userData); void DisableCooperate([in] int userData); - void StartCooperate([in] String remoteNetworkId, [in] int userData, [in] int startDeviceId, [in] boolean checkPermission); + void StartCooperate([in] String remoteNetworkId, [in] int userData, [in] int startDeviceId, + [in] boolean checkPermission); void StartCooperateWithOptions([in] String remoteNetworkId, [in] int userData, [in] int startDeviceId, [in] boolean checkPermission, [in] SequenceableCooperateOptions options); void StopCooperate([in] int userData, [in] boolean isUnchained, [in] boolean checkPermission); @@ -49,7 +50,7 @@ interface OHOS.Msdp.IIntention { void GetCooperateStateSync([in] String udid, [out] boolean state); void GetCooperateStateAsync([in] String networkId, [in] int userData, [in] boolean isCheckPermission); void SetDamplingCoefficient([in] unsigned int direction, [in] double coefficient); - + // Drag void StartDrag([in] SequenceableDragData sequenceableDragData); void StopDrag([in] SequenceableDragResult sequenceableDragResult); @@ -94,7 +95,7 @@ interface OHOS.Msdp.IIntention { void BoomerangEncodeImage([in] sharedptr pixelMap, [in] String metadata, [in] IRemoteBoomerangCallback encodeCallback); void BoomerangDecodeImage([in] sharedptr pixelMap, [in] IRemoteBoomerangCallback decodeCallback); - + // Stationary void SubscribeStationaryCallback([in] int type, [in] int event, [in] int latency, [in] IRemoteDevStaCallback subCallback); diff --git a/intention/ipc/tunnel/include/intention_client.h b/intention/ipc/tunnel/include/intention_client.h index 2de89b19296ec307bf62418d9e24070df95d7e30..8a30a97a8d29c299d561ed4ddaec5162f0565e88 100644 --- a/intention/ipc/tunnel/include/intention_client.h +++ b/intention/ipc/tunnel/include/intention_client.h @@ -69,7 +69,7 @@ public: int32_t GetShadowOffset(ShadowOffset &shadowOffset); int32_t GetDragData(DragData &dragData); int32_t UpdatePreviewStyle(const PreviewStyle &previewStyle); - int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); + int32_t UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle, const PreviewAnimation &animation); int32_t RotateDragWindowSync(const std::shared_ptr& rsTransaction); int32_t SetDragWindowScreenId(uint64_t displayId, uint64_t screenId); int32_t GetDragSummary(std::map &summarys, bool isJsCaller);