Merge branch 'master' of gitee.com:openharmony/msdp_device_status into master

Signed-off-by: hongtao <wanghongtao15@huawei.com>
This commit is contained in:
hongtao 2024-11-22 03:46:07 +00:00 committed by Gitee
commit b2ce7d613f
35 changed files with 299 additions and 44 deletions

View File

@ -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",
@ -64,7 +67,8 @@
"os_account",
"libxml2",
"wifi",
"power_manager"
"power_manager",
"resource_schedule_service"
],
"third_party": [
"libuv",

View File

@ -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<void(bool)> callback, bool isCompatible)
{

50
hisyseventdrague.yaml Normal file
View File

@ -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}

View File

@ -80,6 +80,7 @@ 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",

View File

@ -84,6 +84,7 @@ public:
bool IsAllowCooperate();
void OnStartCooperate(StartCooperateData &data);
void OnRemoteStartCooperate(RemoteStartCooperateData &data);
void OnStopCooperate();
void OnTransitionOut();
void OnTransitionIn();
void OnBack();

View File

@ -101,6 +101,8 @@ private:
void ResetPressedEvents();
double GetDamplingCoefficient(DamplingDirection direction) const;
bool DampPointerMotion(std::shared_ptr<MMI::PointerEvent> pointerEvent) const;
void ExecuteInner();
void HandleStopTimer();
IContext *env_ { nullptr };
bool enable_ { false };

View File

@ -16,6 +16,8 @@
#ifndef INPUT_EVENT_INTERCEPTOR_H
#define INPUT_EVENT_INTERCEPTOR_H
#include <atomic>
#include "nocopyable.h"
#include "channel.h"
@ -45,12 +47,16 @@ private:
void ReportPointerEvent(std::shared_ptr<MMI::PointerEvent> 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 };
std::atomic<int32_t> heartTimer_ { -1 };
int32_t pointerEventTimer_ { -1 };
std::string remoteNetworkId_;
Channel<CooperateEvent>::Sender sender_;

View File

@ -34,6 +34,7 @@ public:
static int32_t NetPacketToKeyEvent(NetPacket &pkt, std::shared_ptr<MMI::KeyEvent> key);
static int32_t SwitchEventToNetPacket(const std::shared_ptr<MMI::SwitchEvent> key, NetPacket &pkt);
static int32_t NetPacketToSwitchEvent(NetPacket &pkt, std::shared_ptr<MMI::SwitchEvent> key);
static int32_t HeartBeatMarshalling(NetPacket &pkt);
static int32_t Marshalling(std::shared_ptr<MMI::PointerEvent> event, NetPacket &pkt);
static int32_t Unmarshalling(NetPacket &pkt, std::shared_ptr<MMI::PointerEvent> event);
#ifdef OHOS_BUILD_ENABLE_SECURITY_PART

View File

@ -282,6 +282,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_);

View File

@ -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;

View File

@ -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_HILOGD("Heart beat received");
break;
}
default: {
FI_HILOGW("Unexpected message(%{public}d) from \'%{public}s\'",
static_cast<int32_t>(packet.GetMsgId()), Utility::Anonymize(networkId).c_str());
@ -253,6 +264,23 @@ void InputEventBuilder::TurnOffChannelScan()
}
}
void InputEventBuilder::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 InputEventBuilder::HandleStopTimer()
{
CALL_DEBUG_ENTER;
OHOS::ResourceSchedule::ResSchedClient::GetInstance().ReportData(
OHOS::ResourceSchedule::ResType::RES_TYPE_NETWORK_LATENCY_REQUEST, MODE_DISABLE,
{{LOW_LATENCY_KEY, FI_PKG_NAME}});
}
void InputEventBuilder::TurnOnChannelScan()
{
scanState_ = true;

View File

@ -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,11 @@ 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_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<int32_t> InputEventInterceptor::filterKeys_ {
@ -73,6 +81,22 @@ void InputEventInterceptor::Enable(Context &context)
FI_HILOGE("Input::AddInterceptor fail");
}
TurnOffChannelScan();
HeartBeatSend();
ExecuteInner();
}
void InputEventInterceptor::HeartBeatSend()
{
CALL_DEBUG_ENTER;
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()
@ -87,6 +111,14 @@ void InputEventInterceptor::Disable()
env_->GetTimerManager().RemoveTimer(pointerEventTimer_);
pointerEventTimer_ = -1;
}
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)
@ -180,6 +212,23 @@ 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;
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;

View File

@ -32,6 +32,7 @@ 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 +445,17 @@ int32_t InputEventSerialization::SerializeBuffer(std::shared_ptr<MMI::PointerEve
return RET_OK;
}
int32_t InputEventSerialization::HeartBeatMarshalling(NetPacket &pkt)
{
CALL_DEBUG_ENTER;
pkt << HEART_BEAT_PACKET;
if (pkt.ChkRWError()) {
FI_HILOGE("Serialize packet is failed");
return RET_ERR;
}
return RET_OK;
}
int32_t InputEventSerialization::DeserializeBuffer(NetPacket &pkt, std::shared_ptr<MMI::PointerEvent> event)
{
std::vector<uint8_t>::size_type bufSize {};

View File

@ -308,6 +308,7 @@ void StateMachine::StopCooperate(Context &context, const CooperateEvent &event)
{
CALL_DEBUG_ENTER;
context.CloseDistributedFileConnection(context.Peer());
context.OnStopCooperate();
Transfer(context, event);
}

View File

@ -77,6 +77,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_;

View File

@ -530,6 +530,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;

View File

@ -55,6 +55,7 @@ enum DragRequestID : uint32_t {
ERASE_MOUSE_ICON,
SET_DRAG_WINDOW_SCREEN_ID,
ADD_SELECTED_PIXELMAP,
SET_DRAGGABLE_STATE,
};
struct StartDragParam final : public ParamBase {
@ -293,6 +294,16 @@ struct AddSelectedPixelMapParam final : public ParamBase {
std::shared_ptr<OHOS::Media::PixelMap> 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

View File

@ -433,6 +433,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

View File

@ -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);

View File

@ -141,6 +141,9 @@ int32_t DragServer::SetParam(CallingContext &context, uint32_t id, MessageParcel
case DragRequestID::SET_APP_DRAG_SWITCH_STATE: {
return SetAppDragSwitchState(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;
@ -596,6 +599,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

View File

@ -89,6 +89,7 @@ public:
int32_t AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap, std::function<void(bool)> callback);
void OnConnected();
void OnDisconnected();
int32_t SetDraggableState(bool state);
private:
void InitClient();

View File

@ -515,6 +515,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

View File

@ -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;

View File

@ -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<void(DragState)> callback) = 0;
virtual void UnregisterStateChange() = 0;

View File

@ -132,7 +132,12 @@ 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<struct inotify_event *>(p);
CHKPV(event);
HandleInotifyEvent(event);
if (event->len > NAME_MAX) {
FI_HILOGW("Invalid name, exceed NAME_MAX");
break;
}
p += sizeof(struct inotify_event) + event->len;
}
}
@ -140,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;
}

View File

@ -415,6 +415,14 @@ public:
* @since 12
*/
int32_t AddSelectedPixelMap(std::shared_ptr<OHOS::Media::PixelMap> pixelMap, std::function<void(bool)> callback);
/**
* @brief Set drag state.
* @param state drag state, if application can drag, set true, else set false.
* @return Returns <b>0</b> 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.

View File

@ -75,6 +75,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<OHOS::Media::PixelMap>, std::__h::function<void (bool)>)";
"OHOS::Msdp::DeviceStatus::InteractionManager::SetDraggableState(bool)";
};
local:
*;

View File

@ -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;
void SetControlCollaborationVisible(bool visible) override;
#ifndef OHOS_BUILD_ENABLE_ARKUI_X
void Dump(int32_t fd) const override;
void RegisterStateChange(std::function<void(DragState)> callback) override;
@ -215,7 +217,7 @@ private:
DragResult dragResult_ { DragResult::DRAG_FAIL };
std::atomic<DragAction> dragAction_ { DragAction::MOVE };
DragDrawing dragDrawing_;
bool isControlMultiScreenVisible_ = false;
bool isControlCollaborationVisible_ { false };
inline static std::atomic<int32_t> pullId_ { -1 };
#ifndef OHOS_BUILD_ENABLE_ARKUI_X
StateChangeNotify stateNotify_;

View File

@ -436,8 +436,8 @@ int32_t DragManager::StopDrag(const DragDropResult &dropResult, const std::strin
dragResult_ = static_cast<DragResult>(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,
@ -1057,8 +1057,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();
@ -1175,7 +1175,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;
@ -1195,7 +1195,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;
@ -1307,6 +1307,15 @@ DragResult DragManager::GetDragResult() const
return dragResult_;
}
void DragManager::SetControlCollaborationVisible(bool visible)
{
isControlCollaborationVisible_ = visible;
}
bool DragManager::GetControlCollaborationVisible() const
{
return isControlCollaborationVisible_;
}
int32_t DragManager::GetDragSummary(std::map<std::string, int64_t> &summarys)
{
FI_HILOGI("enter");

View File

@ -58,24 +58,6 @@ template <class T> T GetData()
return objetct;
}
bool SocketClientFuzzTest(const uint8_t* data, size_t size)
{
std::shared_ptr<TunnelClient> tunnel = std::make_shared<TunnelClient>();
std::unique_ptr<SocketClient> client = std::make_unique<SocketClient>(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{};
auto tunnel = std::make_shared<TunnelClient>();
auto client = std::make_unique<SocketClient>(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

View File

@ -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) {}

View File

@ -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) {}

View File

@ -40,6 +40,7 @@ ohos_unittest("IntentionServiceTest") {
cfi = true
cfi_cross_dso = true
debug = false
blocklist = "./../../ipc_blocklist.txt"
}
defines = device_status_default_defines

View File

@ -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}"
}

View File

@ -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
};