mirror of
https://gitee.com/openharmony/msdp_device_status
synced 2024-11-23 07:29:52 +00:00
CFI
Signed-off-by: yang123 <yangyanling13@huawei.com>
This commit is contained in:
parent
d673036354
commit
589a8b75af
@ -32,7 +32,9 @@ napi_value JsCooperateManager::Enable(napi_env env, bool enable, napi_value hand
|
||||
sptr<JsUtilCooperate::CallbackInfo> cb = new (std::nothrow) JsUtilCooperate::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsEnable, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &networkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsEnable(cb, &networkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = 0;
|
||||
if (enable) {
|
||||
errCode = INTERACTION_MGR->PrepareCoordination(callback);
|
||||
@ -53,7 +55,9 @@ napi_value JsCooperateManager::Start(napi_env env, const std::string &remoteNetw
|
||||
sptr<JsUtilCooperate::CallbackInfo> cb = new (std::nothrow) JsUtilCooperate::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsStart, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &remoteNetworkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsStart(cb, &remoteNetworkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->ActivateCoordination(remoteNetworkDescriptor, startDeviceId, callback);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "start", COOPERATE_PERMISSION);
|
||||
@ -68,7 +72,9 @@ napi_value JsCooperateManager::Stop(napi_env env, napi_value handle)
|
||||
sptr<JsUtilCooperate::CallbackInfo> cb = new (std::nothrow) JsUtilCooperate::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsStop, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &networkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsStop(cb, networkId, msgInfo);
|
||||
};
|
||||
bool isUnchained = false;
|
||||
int32_t errCode = INTERACTION_MGR->DeactivateCoordination(isUnchained, callback);
|
||||
if (errCode != RET_OK) {
|
||||
@ -84,7 +90,9 @@ napi_value JsCooperateManager::GetState(napi_env env, const std::string &deviceD
|
||||
sptr<JsUtilCooperate::CallbackInfo> cb = new (std::nothrow) JsUtilCooperate::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsGetState, cb, std::placeholders::_1);
|
||||
auto callback = [this, cb](bool state) {
|
||||
this->EmitJsGetState(cb, state);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->GetCoordinationState(deviceDescriptor, callback);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "getState", COOPERATE_PERMISSION);
|
||||
|
@ -32,7 +32,9 @@ napi_value JsCoordinationManager::Prepare(napi_env env, bool isCompatible, napi_
|
||||
sptr<JsUtil::CallbackInfo> cb = new (std::nothrow) JsUtil::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsPrepare, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &networkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsPrepare(cb, &networkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->PrepareCoordination(callback, isCompatible);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "prepare", COOPERATE_PERMISSION);
|
||||
@ -47,7 +49,9 @@ napi_value JsCoordinationManager::Unprepare(napi_env env, bool isCompatible, nap
|
||||
sptr<JsUtil::CallbackInfo> cb = new (std::nothrow) JsUtil::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsPrepare, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &networkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsPrepare(cb, &networkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->UnprepareCoordination(callback, isCompatible);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "unprepare", COOPERATE_PERMISSION);
|
||||
@ -63,7 +67,9 @@ napi_value JsCoordinationManager::Activate(napi_env env, const std::string &remo
|
||||
sptr<JsUtil::CallbackInfo> cb = new (std::nothrow) JsUtil::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsActivate, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &remoteNetworkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsActivate(cb, &remoteNetworkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->ActivateCoordination(
|
||||
remoteNetworkId, startDeviceId, callback, isCompatible);
|
||||
if (errCode != RET_OK) {
|
||||
@ -80,7 +86,9 @@ napi_value JsCoordinationManager::Deactivate(napi_env env,
|
||||
sptr<JsUtil::CallbackInfo> cb = new (std::nothrow) JsUtil::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsDeactivate, cb, std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this, cb](const std::string &networkId, const CoordinationMsgInfo &msgInfo) {
|
||||
this->EmitJsDeactivate(cb, &networkId, &msgInfo);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->DeactivateCoordination(isUnchained, callback, isCompatible);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "deactivate", COOPERATE_PERMISSION);
|
||||
@ -96,7 +104,9 @@ napi_value JsCoordinationManager::GetCrossingSwitchState(napi_env env,
|
||||
sptr<JsUtil::CallbackInfo> cb = new (std::nothrow) JsUtil::CallbackInfo();
|
||||
CHKPP(cb);
|
||||
napi_value result = CreateCallbackInfo(env, handle, cb);
|
||||
auto callback = std::bind(EmitJsGetCrossingSwitchState, cb, std::placeholders::_1);
|
||||
auto callback = [this, cb](bool state) {
|
||||
this->EmitJsGetCrossingSwitchState(cb, state);
|
||||
};
|
||||
int32_t errCode = INTERACTION_MGR->GetCoordinationState(networkId, callback, isCompatible);
|
||||
if (errCode != RET_OK) {
|
||||
UtilNapiError::HandleExecuteResult(env, errCode, "getCrossingSwitchState", COOPERATE_PERMISSION);
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "interaction_manager_impl.h"
|
||||
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_func_callback.h"
|
||||
#include "drag_data.h"
|
||||
#include "drag_manager_impl.h"
|
||||
|
||||
@ -40,7 +39,9 @@ bool InteractionManagerImpl::InitClient()
|
||||
client_ = std::make_shared<Client>();
|
||||
InitMsgHandler();
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
client_->RegisterConnectedFunction(std::bind(&CoordinationManagerImpl::OnConnected, &coordinationManagerImpl_));
|
||||
client_->RegisterConnectedFunction([coordinationManagerImpl_&]{
|
||||
coordinationManagerImpl_->OnConnected();
|
||||
});
|
||||
#endif // OHOS_BUILD_ENABLE_COORDINATION
|
||||
if (!(client_->Start())) {
|
||||
client_.reset();
|
||||
@ -56,23 +57,31 @@ void InteractionManagerImpl::InitMsgHandler()
|
||||
CALL_DEBUG_ENTER;
|
||||
Client::MsgCallback funs[] = {
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
{MessageId::COORDINATION_ADD_LISTENER,
|
||||
MsgCallbackBind2(&CoordinationManagerImpl::OnCoordinationListener, &coordinationManagerImpl_)},
|
||||
{MessageId::COORDINATION_MESSAGE,
|
||||
MsgCallbackBind2(&CoordinationManagerImpl::OnCoordinationMessage, &coordinationManagerImpl_)},
|
||||
{MessageId::COORDINATION_GET_STATE,
|
||||
MsgCallbackBind2(&CoordinationManagerImpl::OnCoordinationState, &coordinationManagerImpl_)},
|
||||
{MessageId::HOT_AREA_ADD_LISTENER,
|
||||
MsgCallbackBind2(&CoordinationManagerImpl::OnHotAreaListener, &coordinationManagerImpl_)},
|
||||
{MessageId::COORDINATION_ADD_LISTENER, [&coordinationManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return coordinationManagerImpl_->OnCoordinationListener(&client, &pkt);
|
||||
}},
|
||||
{MessageId::COORDINATION_MESSAGE, [&coordinationManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return coordinationManagerImpl_->OnCoordinationMessage(&client, &pkt);
|
||||
}},
|
||||
{MessageId::COORDINATION_GET_STATE, [&coordinationManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return coordinationManagerImpl_->OnCoordinationState(&client, &pkt);
|
||||
}},
|
||||
{MessageId::HOT_AREA_ADD_LISTENER, [&coordinationManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return coordinationManagerImpl_->OnHotAreaListener(&client, &pkt);
|
||||
}},
|
||||
#endif // OHOS_BUILD_ENABLE_COORDINATION
|
||||
{MessageId::DRAG_NOTIFY_RESULT,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnNotifyResult, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_STATE_LISTENER,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnStateChangedMessage, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_NOTIFY_HIDE_ICON,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnNotifyHideIcon, &dragManagerImpl_)},
|
||||
{MessageId::DRAG_STYLE_LISTENER,
|
||||
MsgCallbackBind2(&DragManagerImpl::OnDragStyleChangedMessage, &dragManagerImpl_)}
|
||||
{MessageId::DRAG_NOTIFY_RESULT, [&dragManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return dragManagerImpl_->OnNotifyResult(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_STATE_LISTENER, [&dragManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return dragManagerImpl_->OnStateChangedMessage(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_NOTIFY_HIDE_ICON, [&dragManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return dragManagerImpl_->OnNotifyHideIcon(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_STYLE_LISTENER, [&dragManagerImpl_](const StreamClient &client, NetPacket &pkt) {
|
||||
return dragManagerImpl_->OnDragStyleChangedMessage(&client, &pkt);
|
||||
}}
|
||||
};
|
||||
CHKPV(client_);
|
||||
for (auto &it : funs) {
|
||||
|
@ -83,8 +83,9 @@ IClientPtr Client::GetSharedPtr()
|
||||
bool Client::Start()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
auto callback = std::bind(&Client::OnMsgHandler, this,
|
||||
std::placeholders::_1, std::placeholders::_2);
|
||||
auto callback = [this](const StreamClient &client, NetPacket &pkt) {
|
||||
this->OnMsgHandler(&client, &pkt);
|
||||
};
|
||||
if (!StartClient(callback)) {
|
||||
FI_HILOGE("Client startup failed");
|
||||
Stop();
|
||||
@ -119,7 +120,7 @@ bool Client::StartEventRunner()
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!eventHandler_->PostTask(std::bind(&Client::OnReconnect, this), CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
if (!eventHandler_->PostTask([this] { this->OnReconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
FI_HILOGE("Send reconnect event failed");
|
||||
return false;
|
||||
}
|
||||
@ -183,7 +184,7 @@ void Client::OnRecvMsg(const char *buf, size_t size)
|
||||
if (!circBuf_.Write(buf, size)) {
|
||||
FI_HILOGW("Write data failed, size:%{public}zu", size);
|
||||
}
|
||||
OnReadPackets(circBuf_, std::bind(&Client::OnPacket, this, std::placeholders::_1));
|
||||
OnReadPackets(circBuf_, [this](NetPacket &pkt) { this->OnPacket(pkt); });
|
||||
}
|
||||
|
||||
int32_t Client::Reconnect()
|
||||
@ -198,7 +199,7 @@ void Client::OnReconnect()
|
||||
return;
|
||||
}
|
||||
CHKPV(eventHandler_);
|
||||
if (!eventHandler_->PostTask(std::bind(&Client::OnReconnect, this), CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
if (!eventHandler_->PostTask([this] { this->OnReconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
FI_HILOGE("Post reconnect event failed");
|
||||
}
|
||||
}
|
||||
@ -233,7 +234,7 @@ void Client::OnDisconnected()
|
||||
}
|
||||
StreamClient::Stop();
|
||||
if (hasClient_ && eventHandler_ != nullptr) {
|
||||
if (!eventHandler_->PostTask(std::bind(&Client::OnReconnect, this), CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
if (!eventHandler_->PostTask([this] { this->OnReconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
FI_HILOGE("Send reconnect event task failed");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "cooperate_params.h"
|
||||
#include "default_params.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_func_callback.h"
|
||||
#include "utility.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
|
@ -27,7 +27,6 @@ namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
namespace Cooperate {
|
||||
class DSoftbusHandler final {
|
||||
using SoftbusHandleType = void (DSoftbusHandler::*)(const std::string &networkId, NetPacket &packet);
|
||||
class DSoftbusObserver final : public IDSoftbusObserver {
|
||||
public:
|
||||
DSoftbusObserver(DSoftbusHandler &parent) : parent_(parent) {}
|
||||
@ -101,7 +100,7 @@ private:
|
||||
std::mutex lock_;
|
||||
Channel<CooperateEvent>::Sender sender_;
|
||||
std::shared_ptr<DSoftbusObserver> observer_;
|
||||
std::map<int32_t, SoftbusHandleType> handles_;
|
||||
std::map<int32_t, std::function<void(DSoftbusHandler *self, const std::string &networkId, NetPacket &packet)>> handles_;
|
||||
};
|
||||
} // namespace Cooperate
|
||||
} // namespace DeviceStatus
|
||||
|
@ -52,10 +52,9 @@ protected:
|
||||
void SetNext(std::shared_ptr<ICooperateStep> next);
|
||||
|
||||
protected:
|
||||
template<typename T, typename = std::enable_if_t<std::is_base_of_v<ICooperateStep, T>>>
|
||||
void AddHandler(CooperateEventType event, void (T::*handler)(Context&, const CooperateEvent&), T *objPtr)
|
||||
void AddHandler(CooperateEventType event, std::function<void(Context&, const CooperateEvent&)> handler)
|
||||
{
|
||||
handlers_.emplace(event, std::bind(handler, objPtr, std::placeholders::_1, std::placeholders::_2));
|
||||
handlers_.emplace(event, handler);
|
||||
}
|
||||
|
||||
void TransiteTo(Context &context, CooperateState state);
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
|
||||
private:
|
||||
void TransiteTo(Context &context, CooperateState state) override;
|
||||
void AddHandler(CooperateEventType event, void (StateMachine::*handler)(Context&, const CooperateEvent&));
|
||||
void AddHandler(CooperateEventType event, std::function<void(Context&, const CooperateEvent&)> handler);
|
||||
void OnQuit(Context &context);
|
||||
void AddObserver(Context &context, const CooperateEvent &event);
|
||||
void RemoveObserver(Context &context, const CooperateEvent &event);
|
||||
|
@ -310,7 +310,7 @@ void Cooperate::StartWorker()
|
||||
std::lock_guard guard(lock_);
|
||||
if (!workerStarted_) {
|
||||
workerStarted_ = true;
|
||||
worker_ = std::thread(std::bind(&Cooperate::Loop, this));
|
||||
worker_ = std::thread([this] { this->Loop(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,18 @@ void CooperateFree::UnchainConnections(Context &context, const StopCooperateEven
|
||||
CooperateFree::Initial::Initial(CooperateFree &parent)
|
||||
: ICooperateStep(parent, nullptr), parent_(parent)
|
||||
{
|
||||
AddHandler(CooperateEventType::START, &CooperateFree::Initial::OnStart, this);
|
||||
AddHandler(CooperateEventType::STOP, &CooperateFree::Initial::OnStop, this);
|
||||
AddHandler(CooperateEventType::APP_CLOSED, &CooperateFree::Initial::OnAppClosed, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, &CooperateFree::Initial::OnRemoteStart, this);
|
||||
AddHandler(CooperateEventType::START, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::STOP, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnAppClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStart(&context, &event);
|
||||
});
|
||||
}
|
||||
|
||||
void CooperateFree::Initial::OnProgress(Context &context, const CooperateEvent &event)
|
||||
|
@ -84,17 +84,44 @@ void CooperateIn::Initial::RemoveChains(std::shared_ptr<Initial> self)
|
||||
CooperateIn::Initial::Initial(CooperateIn &parent)
|
||||
: ICooperateStep(parent, nullptr), parent_(parent)
|
||||
{
|
||||
AddHandler(CooperateEventType::DISABLE, &CooperateIn::Initial::OnDisable, this);
|
||||
AddHandler(CooperateEventType::START, &CooperateIn::Initial::OnStart, this);
|
||||
AddHandler(CooperateEventType::STOP, &CooperateIn::Initial::OnStop, this);
|
||||
AddHandler(CooperateEventType::APP_CLOSED, &CooperateIn::Initial::OnAppClosed, this);
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, &CooperateIn::Initial::OnPointerEvent, this);
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, &CooperateIn::Initial::OnBoardOffline, this);
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED, &CooperateIn::Initial::OnSwitchChanged, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED, &CooperateIn::Initial::OnSoftbusSessionClosed, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, &CooperateIn::Initial::OnRemoteStart, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE, &CooperateIn::Initial::OnRemoteStop, this);
|
||||
AddHandler(CooperateEventType::UPDATE_COOPERATE_FLAG, &CooperateIn::Initial::OnUpdateCooperateFlag, this);
|
||||
AddHandler(CooperateEventType::DISABLE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnDisable(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::START, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::STOP, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnAppClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnPointerEvent(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnBoardOffline(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSwitchChanged(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSessionClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::UPDATE_COOPERATE_FLAG,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnUpdateCooperateFlag(&context, &event);
|
||||
});
|
||||
}
|
||||
|
||||
void CooperateIn::Initial::OnDisable(Context &context, const CooperateEvent &event)
|
||||
@ -306,19 +333,43 @@ void CooperateIn::Initial::OnReset(Context &context, const CooperateEvent &event
|
||||
CooperateIn::RelayConfirmation::RelayConfirmation(CooperateIn &parent, std::shared_ptr<ICooperateStep> prev)
|
||||
: ICooperateStep(parent, prev), parent_(parent)
|
||||
{
|
||||
AddHandler(CooperateEventType::DISABLE, &CooperateIn::RelayConfirmation::OnDisable, this);
|
||||
AddHandler(CooperateEventType::STOP, &CooperateIn::RelayConfirmation::OnStop, this);
|
||||
AddHandler(CooperateEventType::APP_CLOSED, &CooperateIn::RelayConfirmation::OnAppClosed, this);
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, &CooperateIn::RelayConfirmation::OnPointerEvent, this);
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, &CooperateIn::RelayConfirmation::OnBoardOffline, this);
|
||||
AddHandler(CooperateEventType::DISABLE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnDisable(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::STOP, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnAppClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnPointerEvent(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnBoardOffline(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED,
|
||||
&CooperateIn::RelayConfirmation::OnSwitchChanged, this);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSwitchChanged(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED,
|
||||
&CooperateIn::RelayConfirmation::OnSoftbusSessionClosed, this);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSessionClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_RELAY_COOPERATE_FINISHED,
|
||||
&CooperateIn::RelayConfirmation::OnResponse, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, &CooperateIn::RelayConfirmation::OnRemoteStart, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE, &CooperateIn::RelayConfirmation::OnRemoteStop, this);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnResponse(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStop(&context, &event);
|
||||
});
|
||||
}
|
||||
|
||||
void CooperateIn::RelayConfirmation::OnDisable(Context &context, const CooperateEvent &event)
|
||||
|
@ -64,19 +64,51 @@ void CooperateOut::Initial::RemoveChains(std::shared_ptr<Initial> self)
|
||||
CooperateOut::Initial::Initial(CooperateOut &parent)
|
||||
: ICooperateStep(parent, nullptr), parent_(parent)
|
||||
{
|
||||
AddHandler(CooperateEventType::DISABLE, &CooperateOut::Initial::OnDisable, this);
|
||||
AddHandler(CooperateEventType::START, &CooperateOut::Initial::OnStart, this);
|
||||
AddHandler(CooperateEventType::STOP, &CooperateOut::Initial::OnStop, this);
|
||||
AddHandler(CooperateEventType::APP_CLOSED, &CooperateOut::Initial::OnAppClosed, this);
|
||||
AddHandler(CooperateEventType::INPUT_HOTPLUG_EVENT, &CooperateOut::Initial::OnHotplug, this);
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, &CooperateOut::Initial::OnPointerEvent, this);
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, &CooperateOut::Initial::OnBoardOffline, this);
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED, &CooperateOut::Initial::OnSwitchChanged, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED, &CooperateOut::Initial::OnSoftbusSessionClosed, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_COME_BACK, &CooperateOut::Initial::OnComeBack, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, &CooperateOut::Initial::OnRemoteStart, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE, &CooperateOut::Initial::OnRemoteStop, this);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_RELAY_COOPERATE, &CooperateOut::Initial::OnRelay, this);
|
||||
AddHandler(CooperateEventType::DISABLE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnDisable(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::START, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::STOP, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnAppClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_HOTPLUG_EVENT, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnHotplug(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnPointerEvent(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnBoardOffline(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSwitchChanged(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSessionClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_COME_BACK,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnComeBack(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_STOP_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStop(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_RELAY_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRelay(&context, &event);
|
||||
});
|
||||
}
|
||||
|
||||
void CooperateOut::Initial::OnDisable(Context &context, const CooperateEvent &event)
|
||||
|
@ -34,25 +34,45 @@ DSoftbusHandler::DSoftbusHandler(IContext *env)
|
||||
{
|
||||
handles_ = {
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_START_COOPERATE),
|
||||
&DSoftbusHandler::OnStartCooperate },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnStartCooperate(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_STOP_COOPERATE),
|
||||
&DSoftbusHandler::OnStopCooperate },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnStopCooperate (&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_COME_BACK),
|
||||
&DSoftbusHandler::OnComeBack },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnComeBack(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_RELAY_COOPERATE),
|
||||
&DSoftbusHandler::OnRelayCooperate },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnRelayCooperate(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_RELAY_COOPERATE_FINISHED),
|
||||
&DSoftbusHandler::OnRelayCooperateFinish },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnRelayCooperateFinish(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_SUBSCRIBE_MOUSE_LOCATION),
|
||||
&DSoftbusHandler::OnSubscribeMouseLocation },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnSubscribeMouseLocation(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_UNSUBSCRIBE_MOUSE_LOCATION),
|
||||
&DSoftbusHandler::OnUnSubscribeMouseLocation },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnUnSubscribeMouseLocation(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_REPLY_SUBSCRIBE_MOUSE_LOCATION),
|
||||
&DSoftbusHandler::OnReplySubscribeLocation },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnReplySubscribeLocation(&networKId, &packet);
|
||||
},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_REPLY_UNSUBSCRIBE_MOUSE_LOCATION),
|
||||
&DSoftbusHandler::OnReplyUnSubscribeLocation },
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnReplyUnSubscribeLocation(&networKId, &packet);
|
||||
}},
|
||||
{ static_cast<int32_t>(MessageId::DSOFTBUS_MOUSE_LOCATION),
|
||||
&DSoftbusHandler::OnRemoteMouseLocation }
|
||||
[](DSoftbusHandler *self, const std::string &networkId, NetPacket &packet) {
|
||||
self->OnRemoteMouseLocation(&networKId, &packet);
|
||||
}}
|
||||
};
|
||||
observer_ = std::make_shared<DSoftbusObserver>(*this);
|
||||
CHKPV(env_);
|
||||
@ -212,7 +232,7 @@ bool DSoftbusHandler::OnPacket(const std::string &networkId, NetPacket &packet)
|
||||
int32_t messageId = static_cast<int32_t>(packet.GetMsgId());
|
||||
auto it = handles_.find(messageId);
|
||||
if (it != handles_.end()) {
|
||||
(this->*(it->second))(networkId, packet);
|
||||
(it->second)(this, networkId, packet);
|
||||
return true;
|
||||
}
|
||||
FI_HILOGD("Unsupported messageId: %{public}d from %{public}s", messageId,
|
||||
|
@ -58,8 +58,8 @@ void InputEventInterceptor::Enable(Context &context)
|
||||
remoteNetworkId_ = context.Peer();
|
||||
sender_ = context.Sender();
|
||||
interceptorId_ = env_->GetInput().AddInterceptor(
|
||||
std::bind(&InputEventInterceptor::OnPointerEvent, this, std::placeholders::_1),
|
||||
std::bind(&InputEventInterceptor::OnKeyEvent, this, std::placeholders::_1));
|
||||
[this](std::shared_ptr<MMI::PointerEvent> pointerEvent) { this->OnPointerEvent(PointerEvent); },
|
||||
[this](std::shared_ptr<MMI::KeyEvent> keyEvent) { this->OnKeyEvent(keyEvent); });
|
||||
if (interceptorId_ < 0) {
|
||||
FI_HILOGE("Input::AddInterceptor fail");
|
||||
}
|
||||
|
@ -69,36 +69,104 @@ StateMachine::StateMachine(IContext *env)
|
||||
states_[COOPERATE_STATE_OUT] = std::make_shared<CooperateOut>(*this, env);
|
||||
states_[COOPERATE_STATE_IN] = std::make_shared<CooperateIn>(*this, env);
|
||||
|
||||
AddHandler(CooperateEventType::ADD_OBSERVER, &StateMachine::AddObserver);
|
||||
AddHandler(CooperateEventType::REMOVE_OBSERVER, &StateMachine::RemoveObserver);
|
||||
AddHandler(CooperateEventType::REGISTER_LISTENER, &StateMachine::RegisterListener);
|
||||
AddHandler(CooperateEventType::UNREGISTER_LISTENER, &StateMachine::UnregisterListener);
|
||||
AddHandler(CooperateEventType::REGISTER_HOTAREA_LISTENER, &StateMachine::RegisterHotAreaListener);
|
||||
AddHandler(CooperateEventType::UNREGISTER_HOTAREA_LISTENER, &StateMachine::UnregisterHotAreaListener);
|
||||
AddHandler(CooperateEventType::ENABLE, &StateMachine::EnableCooperate);
|
||||
AddHandler(CooperateEventType::DISABLE, &StateMachine::DisableCooperate);
|
||||
AddHandler(CooperateEventType::START, &StateMachine::StartCooperate);
|
||||
AddHandler(CooperateEventType::GET_COOPERATE_STATE, &StateMachine::GetCooperateState);
|
||||
AddHandler(CooperateEventType::REGISTER_EVENT_LISTENER, &StateMachine::RegisterEventListener);
|
||||
AddHandler(CooperateEventType::UNREGISTER_EVENT_LISTENER, &StateMachine::UnregisterEventListener);
|
||||
AddHandler(CooperateEventType::DDM_BOARD_ONLINE, &StateMachine::OnBoardOnline);
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE, &StateMachine::OnBoardOffline);
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED, &StateMachine::OnProfileChanged);
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT, &StateMachine::OnPointerEvent);
|
||||
AddHandler(CooperateEventType::APP_CLOSED, &StateMachine::OnProcessClientDied);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_OPENED, &StateMachine::OnSoftbusSessionOpened);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED, &StateMachine::OnSoftbusSessionClosed);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SUBSCRIBE_MOUSE_LOCATION, &StateMachine::OnSoftbusSubscribeMouseLocation);
|
||||
AddHandler(CooperateEventType::ADD_OBSERVER, [this](Context &context, const CooperateEvent &event) {
|
||||
this->AddObserver(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::REMOVE_OBSERVER, [this](Context &context, const CooperateEvent &event) {
|
||||
this->RemoveObserver(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::REGISTER_LISTENER, [this](Context &context, const CooperateEvent &event) {
|
||||
this->RegisterListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::UNREGISTER_LISTENER, [this](Context &context, const CooperateEvent &event) {
|
||||
this->UnregisterListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::REGISTER_HOTAREA_LISTENER, [this](Context &context, const CooperateEvent &event) {
|
||||
this->RegisterHotAreaListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::UNREGISTER_HOTAREA_LISTENER,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->UnregisterHotAreaListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::ENABLE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->EnableCooperate(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DISABLE, [this](Context &context, const CooperateEvent &event) {
|
||||
this->DisableCooperate(&context, &event);
|
||||
});
|
||||
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::REGISTER_EVENT_LISTENER,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->RegisterEventListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::UNREGISTER_EVENT_LISTENER,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->UnregisterEventListener(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDM_BOARD_ONLINE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnBoardOnline(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDM_BOARD_OFFLINE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnBoardOffline(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DDP_COOPERATE_SWITCH_CHANGED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnProfileChanged(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_POINTER_EVENT,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnPointerEvent(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::APP_CLOSED, [this](Context &context, const CooperateEvent &event) {
|
||||
this->OnProcessClientDied(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_OPENED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSessionOpened(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SESSION_CLOSED,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSessionClosed(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_SUBSCRIBE_MOUSE_LOCATION,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusSubscribeMouseLocation(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_UNSUBSCRIBE_MOUSE_LOCATION,
|
||||
&StateMachine::OnSoftbusUnSubscribeMouseLocation);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusUnSubscribeMouseLocation(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_REPLY_SUBSCRIBE_MOUSE_LOCATION,
|
||||
&StateMachine::OnSoftbusReplySubscribeMouseLocation);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusReplySubscribeMouseLocation(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_REPLY_UNSUBSCRIBE_MOUSE_LOCATION,
|
||||
&StateMachine::OnSoftbusReplyUnSubscribeMouseLocation);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_MOUSE_LOCATION, &StateMachine::OnSoftbusMouseLocation);
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE, &StateMachine::OnRemoteStart);
|
||||
AddHandler(CooperateEventType::INPUT_HOTPLUG_EVENT, &StateMachine::OnHotPlugEvent);
|
||||
AddHandler(CooperateEventType::REMOTE_HOTPLUG_EVENT, &StateMachine::OnRemoteHotPlug);
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusReplyUnSubscribeMouseLocation(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_MOUSE_LOCATION,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnSoftbusMouseLocation(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::DSOFTBUS_START_COOPERATE,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteStart(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::INPUT_HOTPLUG_EVENT,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnHotPlugEvent(&context, &event);
|
||||
});
|
||||
AddHandler(CooperateEventType::REMOTE_HOTPLUG_EVENT,
|
||||
[this](Context &context, const CooperateEvent &event) {
|
||||
this->OnRemoteHotPlug(&context, &event);
|
||||
});
|
||||
}
|
||||
|
||||
void StateMachine::OnEvent(Context &context, const CooperateEvent &event)
|
||||
@ -123,10 +191,9 @@ void StateMachine::TransiteTo(Context &context, CooperateState state)
|
||||
}
|
||||
}
|
||||
|
||||
void StateMachine::AddHandler(CooperateEventType event,
|
||||
void (StateMachine::*handler)(Context&, const CooperateEvent&))
|
||||
void StateMachine::AddHandler(CooperateEventType event,std::function<void(Context&, const CooperateEvent&)> handler)
|
||||
{
|
||||
handlers_.emplace(event, std::bind(handler, this, std::placeholders::_1, std::placeholders::_2));
|
||||
handlers_.emplace(event, handler);
|
||||
}
|
||||
|
||||
void StateMachine::OnQuit(Context &context)
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "default_params.h"
|
||||
#include "drag_params.h"
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_func_callback.h"
|
||||
#include "proto.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "display_manager.h"
|
||||
|
||||
#include "devicestatus_define.h"
|
||||
#include "devicestatus_func_callback.h"
|
||||
#include "drag_data.h"
|
||||
|
||||
#undef LOG_TAG
|
||||
@ -61,25 +60,35 @@ void IntentionManager::InitMsgHandler()
|
||||
CALL_DEBUG_ENTER;
|
||||
std::map<MessageId, std::function<int32_t(const StreamClient&, NetPacket&)>> funs {
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
{MessageId::COORDINATION_ADD_LISTENER,
|
||||
MsgCallbackBind2(&CooperateClient::OnCoordinationListener, &cooperate_)},
|
||||
{MessageId::COORDINATION_MESSAGE,
|
||||
MsgCallbackBind2(&CooperateClient::OnCoordinationMessage, &cooperate_)},
|
||||
{MessageId::COORDINATION_GET_STATE,
|
||||
MsgCallbackBind2(&CooperateClient::OnCoordinationState, &cooperate_)},
|
||||
{MessageId::HOT_AREA_ADD_LISTENER,
|
||||
MsgCallbackBind2(&CooperateClient::OnHotAreaListener, &cooperate_)},
|
||||
{MessageId::MOUSE_LOCATION_ADD_LISTENER,
|
||||
MsgCallbackBind2(&CooperateClient::OnMouseLocationListener, &cooperate_)},
|
||||
{MessageId::COORDINATION_ADD_LISTENER, [&cooperate_](const StreamClient &client, NetPacket &pkt) {
|
||||
return cooperate_->OnCoordinationListener(&client, &pkt);
|
||||
}},
|
||||
{MessageId::COORDINATION_MESSAGE, [&cooperate_](const StreamClient &client, NetPacket &pkt) {
|
||||
return cooperate_->OnCoordinationMessage(&client, &pkt);
|
||||
}},
|
||||
{MessageId::COORDINATION_GET_STATE, [&cooperate_](const StreamClient &client, NetPacket &pkt) {
|
||||
return cooperate_->OnCoordinationState(&client, &pkt);
|
||||
},
|
||||
{MessageId::HOT_AREA_ADD_LISTENER, [&cooperate_](const StreamClient &client, NetPacket &pkt) {
|
||||
return cooperate_->OnHotAreaListener(&client, &pkt);
|
||||
}},
|
||||
{MessageId::MOUSE_LOCATION_ADD_LISTENER, [&cooperate_](const StreamClient &client, NetPacket &pkt) {
|
||||
return cooperate_->OnMouseLocationListener(&client, &pkt);
|
||||
}},
|
||||
#endif // OHOS_BUILD_ENABLE_COORDINATION
|
||||
{MessageId::DRAG_NOTIFY_RESULT,
|
||||
MsgCallbackBind2(&DragClient::OnNotifyResult, &drag_)},
|
||||
{MessageId::DRAG_STATE_LISTENER,
|
||||
MsgCallbackBind2(&DragClient::OnStateChangedMessage, &drag_)},
|
||||
{MessageId::DRAG_NOTIFY_HIDE_ICON,
|
||||
MsgCallbackBind2(&DragClient::OnNotifyHideIcon, &drag_)},
|
||||
{MessageId::DRAG_STYLE_LISTENER,
|
||||
MsgCallbackBind2(&DragClient::OnDragStyleChangedMessage, &drag_)}
|
||||
|
||||
{MessageId::DRAG_NOTIFY_RESULT, [&drag_](const StreamClient &client, NetPacket &pkt) {
|
||||
return drag_->OnNotifyResult(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_STATE_LISTENER, [&drag_](const StreamClient &client, NetPacket &pkt) {
|
||||
return drag_->OnStateChangedMessage(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_NOTIFY_HIDE_ICON, [&drag_](const StreamClient &client, NetPacket &pkt) {
|
||||
return drag_->OnNotifyHideIcon(&client, &pkt);
|
||||
}},
|
||||
{MessageId::DRAG_STYLE_LISTENER, [&drag_](const StreamClient &client, NetPacket &pkt) {
|
||||
return drag_->OnDragStyleChangedMessage(&client, &pkt);
|
||||
}}
|
||||
};
|
||||
CHKPV(client_);
|
||||
for (auto &[id, cb] : funs) {
|
||||
|
@ -62,9 +62,9 @@ bool SocketClient::Connect()
|
||||
return true;
|
||||
}
|
||||
auto socket = SocketConnection::Connect(
|
||||
std::bind(&SocketClient::Socket, this),
|
||||
std::bind(&SocketClient::OnPacket, this, std::placeholders::_1),
|
||||
std::bind(&SocketClient::OnDisconnected, this));
|
||||
[this] { this->Socket(); },
|
||||
[this](NetPacket &pkt) { this->OnPacket(pkt); },
|
||||
[this] { this->OnDisconnected(); });
|
||||
CHKPF(socket);
|
||||
CHKPF(eventHandler_);
|
||||
auto errCode = eventHandler_->AddFileDescriptorListener(socket->GetFd(),
|
||||
@ -111,7 +111,7 @@ void SocketClient::OnDisconnected()
|
||||
eventHandler_->RemoveAllEvents();
|
||||
socket_.reset();
|
||||
}
|
||||
if (!eventHandler_->PostTask(std::bind(&SocketClient::Reconnect, this), CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
if (!eventHandler_->PostTask([this] { this->Reconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
FI_HILOGE("Failed to post reconnection task");
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ void SocketClient::Reconnect()
|
||||
if (Connect()) {
|
||||
return;
|
||||
}
|
||||
if (!eventHandler_->PostTask(std::bind(&SocketClient::Reconnect, this), CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
if (!eventHandler_->PostTask([this] { this->Reconnect(); }, CLIENT_RECONNECT_COOLING_TIME)) {
|
||||
FI_HILOGE("Failed to post reconnection task");
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ int32_t TimerManager::OnInit(IContext *context)
|
||||
int32_t TimerManager::Init(IContext *context)
|
||||
{
|
||||
CHKPR(context, RET_ERR);
|
||||
return context->GetDelegateTasks().PostSyncTask(std::bind(&TimerManager::OnInit, this, context));
|
||||
return context->GetDelegateTasks().PostSyncTask([this, context] {
|
||||
return this->OnInit(context);
|
||||
});
|
||||
}
|
||||
|
||||
int32_t TimerManager::OnAddTimer(int32_t intervalMs, int32_t repeatCount, std::function<void()> callback)
|
||||
@ -68,8 +70,9 @@ int32_t TimerManager::AddTimer(int32_t intervalMs, int32_t repeatCount, std::fun
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPR(context_, RET_ERR);
|
||||
return context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&TimerManager::OnAddTimer, this, intervalMs, repeatCount, callback));
|
||||
return context_->GetDelegateTasks().PostSyncTask([this, intervalMs, repeatCount, callback] {
|
||||
return this->OnAddTimer(intervalMs, repeatCount, callback);
|
||||
});
|
||||
}
|
||||
|
||||
int32_t TimerManager::OnRemoveTimer(int32_t timerId)
|
||||
@ -85,7 +88,9 @@ int32_t TimerManager::RemoveTimer(int32_t timerId)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPR(context_, RET_ERR);
|
||||
return context_->GetDelegateTasks().PostSyncTask(std::bind(&TimerManager::OnRemoveTimer, this, timerId));
|
||||
return context_->GetDelegateTasks().PostSyncTask([this, timerId] {
|
||||
return this->OnRemoveTimer(timerId);
|
||||
});
|
||||
}
|
||||
|
||||
int32_t TimerManager::OnResetTimer(int32_t timerId)
|
||||
@ -99,7 +104,9 @@ int32_t TimerManager::ResetTimer(int32_t timerId)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPR(context_, RET_ERR);
|
||||
return context_->GetDelegateTasks().PostSyncTask(std::bind(&TimerManager::OnResetTimer, this, timerId));
|
||||
return context_->GetDelegateTasks().PostSyncTask([this, timerId] {
|
||||
return this->OnResetTimer(timerId);
|
||||
});
|
||||
}
|
||||
|
||||
bool TimerManager::OnIsExist(int32_t timerId) const
|
||||
@ -115,11 +122,14 @@ bool TimerManager::OnIsExist(int32_t timerId) const
|
||||
bool TimerManager::IsExist(int32_t timerId) const
|
||||
{
|
||||
CHKPR(context_, false);
|
||||
std::packaged_task<bool(int32_t)> task { std::bind(&TimerManager::OnIsExist, this, std::placeholders::_1) };
|
||||
std::packaged_task<bool(int32_t)> task { [this](int32_t timerId) {
|
||||
return this->OnIsExist(timerId);
|
||||
} };
|
||||
auto fu = task.get_future();
|
||||
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&TimerManager::RunIsExist, this, std::ref(task), timerId));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this, task, timerId] {
|
||||
return this->RunIsExist(std::ref(task), timerId);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post task failed");
|
||||
return false;
|
||||
@ -138,7 +148,9 @@ void TimerManager::ProcessTimers()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPV(context_);
|
||||
context_->GetDelegateTasks().PostAsyncTask(std::bind(&TimerManager::OnProcessTimers, this));
|
||||
context_->GetDelegateTasks().PostAsyncTask([this] {
|
||||
return this->OnProcessTimers();
|
||||
});
|
||||
}
|
||||
|
||||
int32_t TimerManager::RunIsExist(std::packaged_task<bool(int32_t)> &task, int32_t timerId) const
|
||||
|
@ -64,8 +64,9 @@ int32_t DeviceManager::Init(IContext *context)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPR(context, RET_ERR);
|
||||
int32_t ret = context->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnInit, this, context));
|
||||
int32_t ret = context->GetDelegateTasks().PostSyncTask([this, context] {
|
||||
return this->OnInit(context);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post sync task failed");
|
||||
}
|
||||
@ -86,8 +87,9 @@ int32_t DeviceManager::Enable()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPR(context_, RET_ERR);
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnEnable, this));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this] {
|
||||
return this->OnEnable();
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post sync task failed");
|
||||
}
|
||||
@ -125,8 +127,9 @@ int32_t DeviceManager::Disable()
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPR(context_, RET_ERR);
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnDisable, this));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this] {
|
||||
return this->OnDisable();
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("PostSyncTask failed");
|
||||
}
|
||||
@ -270,8 +273,9 @@ void DeviceManager::Dispatch(const struct epoll_event &ev)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&DeviceManager::OnEpollDispatch, this, ev.events));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this, ev] {
|
||||
return this->OnEpollDispatch(ev.events);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("PostAsyncTask failed");
|
||||
}
|
||||
@ -291,12 +295,14 @@ int32_t DeviceManager::OnEpollDispatch(uint32_t events)
|
||||
std::shared_ptr<IDevice> DeviceManager::GetDevice(int32_t id) const
|
||||
{
|
||||
CHKPP(context_);
|
||||
std::packaged_task<std::shared_ptr<IDevice>(int32_t)> task {
|
||||
std::bind(&DeviceManager::OnGetDevice, this, std::placeholders::_1) };
|
||||
std::packaged_task<std::shared_ptr<IDevice>(int32_t)> task {[this](int32_t id) {
|
||||
return this->OnGetDevice(id);
|
||||
}};
|
||||
auto fu = task.get_future();
|
||||
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::RunGetDevice, this, std::ref(task), id));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this, task, id] {
|
||||
return this->RunGetDevice(std::ref(task), id);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post task failed");
|
||||
return nullptr;
|
||||
@ -324,8 +330,9 @@ void DeviceManager::RetriggerHotplug(std::weak_ptr<IDeviceObserver> observer)
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnRetriggerHotplug, this, observer));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this, observer] {
|
||||
return this->OnRetriggerHotplug(observer);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post task failed");
|
||||
}
|
||||
@ -350,8 +357,9 @@ int32_t DeviceManager::AddDeviceObserver(std::weak_ptr<IDeviceObserver> observer
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPR(context_, RET_ERR);
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnAddDeviceObserver, this, observer));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this, observer] {
|
||||
return this->OnAddDeviceObserver(observer);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post task failed");
|
||||
}
|
||||
@ -373,8 +381,9 @@ void DeviceManager::RemoveDeviceObserver(std::weak_ptr<IDeviceObserver> observer
|
||||
{
|
||||
CALL_INFO_TRACE;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask(
|
||||
std::bind(&DeviceManager::OnRemoveDeviceObserver, this, observer));
|
||||
int32_t ret = context_->GetDelegateTasks().PostSyncTask([this, observer] {
|
||||
return this->OnRemoveDeviceObserver(observer);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post task failed");
|
||||
}
|
||||
|
@ -28,7 +28,9 @@ namespace DeviceStatus {
|
||||
bool AlgoAbsoluteStill::Init(Type type)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
algoCallback_ = std::bind(&AlgoAbsoluteStill::StartAlgorithm, this, std::placeholders::_1, std::placeholders::_2);
|
||||
algoCallback_ = [this](int32_t sensorTypeId, AccelData* sensorData) {
|
||||
retuern this->StartAlgorithm(sensorTypeId, sensorData);
|
||||
};
|
||||
if (algoCallback_ == nullptr) {
|
||||
FI_HILOGE("algoCallback is nullptr");
|
||||
return false;
|
||||
|
@ -28,7 +28,9 @@ namespace DeviceStatus {
|
||||
bool AlgoHorizontal::Init(Type type)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
algoCallback_ = std::bind(&AlgoHorizontal::StartAlgorithm, this, std::placeholders::_1, std::placeholders::_2);
|
||||
algoCallback_ = [this](int32_t sensorTypeId, AccelData* sensorData) {
|
||||
retuern this->StartAlgorithm(sensorTypeId, sensorData);
|
||||
};
|
||||
CHKPF(algoCallback_);
|
||||
SENSOR_DATA_CB.SubscribeSensorEvent(type, algoCallback_);
|
||||
return true;
|
||||
|
@ -31,7 +31,9 @@ constexpr float JUDGE_FLOAT { 1e-6 };
|
||||
bool AlgoVertical::Init(Type type)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
algoCallback_ = std::bind(&AlgoVertical::StartAlgorithm, this, std::placeholders::_1, std::placeholders::_2);
|
||||
algoCallback_ = [this](int32_t sensorTypeId, AccelData* sensorData) {
|
||||
retuern this->StartAlgorithm(sensorTypeId, sensorData);
|
||||
};
|
||||
CHKPF(algoCallback_);
|
||||
SENSOR_DATA_CB.SubscribeSensorEvent(type, algoCallback_);
|
||||
return true;
|
||||
|
@ -231,7 +231,7 @@ void DeviceStatusMsdpMock::StartThread()
|
||||
CALL_DEBUG_ENTER;
|
||||
if (!alive_) {
|
||||
alive_ = true;
|
||||
thread_ = std::thread(std::bind(&DeviceStatusMsdpMock::LoopingThreadEntry, this));
|
||||
thread_ = std::thread([this] { this->LoopingThreadEntry(); });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef DEVICESTATUS_SRV_STUB_H
|
||||
#define DEVICESTATUS_SRV_STUB_H
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
||||
#include <iremote_stub.h>
|
||||
@ -30,8 +31,6 @@ namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
class DeviceStatusSrvStub : public IRemoteStub<Idevicestatus> {
|
||||
public:
|
||||
using ConnFunc = int32_t (DeviceStatusSrvStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
DeviceStatusSrvStub();
|
||||
DISALLOW_COPY_AND_MOVE(DeviceStatusSrvStub);
|
||||
virtual ~DeviceStatusSrvStub() = default;
|
||||
@ -89,7 +88,7 @@ private:
|
||||
int32_t EraseMouseIconStub(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
private:
|
||||
std::map<uint32_t, ConnFunc> connFuncs_;
|
||||
std::map<uint32_t, std::function<int32_t(MessageParcel &data, MessageParcel &reply)>> connFuncs_;
|
||||
};
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
|
@ -52,49 +52,93 @@ void DeviceStatusSrvStub::InitCoordination()
|
||||
CALL_DEBUG_ENTER;
|
||||
connFuncs_ = {
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_SUBSCRIBE),
|
||||
&DeviceStatusSrvStub::SubscribeStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->SubscribeStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_UNSUBSCRIBE),
|
||||
&DeviceStatusSrvStub::UnsubscribeStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UnsubscribeStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_GETCACHE),
|
||||
&DeviceStatusSrvStub::GetLatestDeviceStatusDataStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetLatestDeviceStatusDataStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
|
||||
&DeviceStatusSrvStub::RegisterCoordinationMonitorStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->RegisterCoordinationMonitorStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COORDINATION_MONITOR),
|
||||
&DeviceStatusSrvStub::UnregisterCoordinationMonitorStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UnregisterCoordinationMonitorStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COORDINATION),
|
||||
&DeviceStatusSrvStub::PrepareCoordinationStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->PrepareCoordinationStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COORDINATION),
|
||||
&DeviceStatusSrvStub::UnPrepareCoordinationStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UnPrepareCoordinationStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::START_COORDINATION),
|
||||
&DeviceStatusSrvStub::ActivateCoordinationStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->ActivateCoordinationStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::STOP_COORDINATION),
|
||||
&DeviceStatusSrvStub::DeactivateCoordinationStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->DeactivateCoordinationStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE),
|
||||
&DeviceStatusSrvStub::GetCoordinationStateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetCoordinationStateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE_SYNC),
|
||||
&DeviceStatusSrvStub::GetCoordinationStateSyncStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetCoordinationStateSyncStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::ADD_HOT_AREA_MONITOR),
|
||||
&DeviceStatusSrvStub::AddHotAreaListenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->AddHotAreaListenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::REMOVE_HOT_AREA_MONITOR),
|
||||
&DeviceStatusSrvStub::RemoveHotAreaListenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->RemoveHotAreaListenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_SUBSCRIPT_MONITOR),
|
||||
&DeviceStatusSrvStub::AddSubscriptListenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->AddSubscriptListenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_SUBSCRIPT_MONITOR),
|
||||
&DeviceStatusSrvStub::RemoveSubscriptListenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->RemoveSubscriptListenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COOPERATE_MONITOR),
|
||||
&DeviceStatusSrvStub::RegisterCooperateMonitorStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->RegisterCooperateMonitorStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COOPERATE_MONITOR),
|
||||
&DeviceStatusSrvStub::UnregisterCooperateMonitorStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UnregisterCooperateMonitorStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COOPERATE),
|
||||
&DeviceStatusSrvStub::PrepareCooperateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->PrepareCooperateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COOPERATE),
|
||||
&DeviceStatusSrvStub::UnPrepareCooperateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UnPrepareCooperateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::START_COOPERATE),
|
||||
&DeviceStatusSrvStub::ActivateCooperateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->ActivateCooperateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::STOP_COOPERATE),
|
||||
&DeviceStatusSrvStub::DeactivateCooperateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->DeactivateCooperateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_COOPERATE_STATE),
|
||||
&DeviceStatusSrvStub::GetCooperateStateStub }
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetCooperateStateStub(&data, &reply);
|
||||
} }
|
||||
};
|
||||
}
|
||||
|
||||
@ -103,47 +147,89 @@ void DeviceStatusSrvStub::InitDrag()
|
||||
CALL_DEBUG_ENTER;
|
||||
std::map<uint32_t, ConnFunc> dragFuncs = {
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
|
||||
&DeviceStatusSrvStub::HandleAllocSocketFdStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->HandleAllocSocketFdStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
|
||||
&DeviceStatusSrvStub::StartDragStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->StartDragStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::STOP_DRAG),
|
||||
&DeviceStatusSrvStub::StopDragStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->StopDragStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UPDATED_DRAG_STYLE),
|
||||
&DeviceStatusSrvStub::UpdateDragStyleStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UpdateDragStyleStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_PID),
|
||||
&DeviceStatusSrvStub::GetDragTargetPidStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetDragTargetPidStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_UDKEY),
|
||||
&DeviceStatusSrvStub::GetUdKeyStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetUdKeyStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_DRAG_MONITOR),
|
||||
&DeviceStatusSrvStub::AddDraglistenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->AddDraglistenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_DRAG_MONITOR),
|
||||
&DeviceStatusSrvStub::RemoveDraglistenerStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->RemoveDraglistenerStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::SET_DRAG_WINDOW_VISIBLE),
|
||||
&DeviceStatusSrvStub::SetDragWindowVisibleStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->SetDragWindowVisibleStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_SHADOW_OFFSET),
|
||||
&DeviceStatusSrvStub::GetShadowOffsetStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetShadowOffsetStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_SHADOW_PIC),
|
||||
&DeviceStatusSrvStub::UpdateShadowPicStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UpdateShadowPicStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_DATA),
|
||||
&DeviceStatusSrvStub::GetDragDataStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetDragDataStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_STATE),
|
||||
&DeviceStatusSrvStub::GetDragStateStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetDragStateStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_SUMMARY),
|
||||
&DeviceStatusSrvStub::GetDragSummaryStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetDragSummaryStub(&data, &reply);
|
||||
} },
|
||||
{ static_cast<uint32_t>(DeviceInterfaceCode::ENTER_TEXT_EDITOR_AREA),
|
||||
&DeviceStatusSrvStub::EnterTextEditorAreaStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->EnterTextEditorAreaStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_EXTRAINFO),
|
||||
&DeviceStatusSrvStub::GetExtraInfoStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetExtraInfoStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_ACTION),
|
||||
&DeviceStatusSrvStub::GetDragActionStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->GetDragActionStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_PREVIEW_STYLE),
|
||||
&DeviceStatusSrvStub::UpdatePreviewStyleStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UpdatePreviewStyleStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_PREVIEW_STYLE_WITH_ANIMATION),
|
||||
&DeviceStatusSrvStub::UpdatePreviewStyleWithAnimationStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->UpdatePreviewStyleWithAnimationStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::ADD_PRIVILEGE),
|
||||
&DeviceStatusSrvStub::AddPrivilegeStub },
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->AddPrivilegeStub(&data, &reply);
|
||||
} },
|
||||
{static_cast<uint32_t>(DeviceInterfaceCode::ERASE_MOUSE_ICON),
|
||||
&DeviceStatusSrvStub::EraseMouseIconStub }
|
||||
[this](MessageParcel &data, MessageParcel &reply) {
|
||||
return this->EraseMouseIconStub(&data, &reply);
|
||||
} }
|
||||
};
|
||||
connFuncs_.insert(dragFuncs.begin(), dragFuncs.end());
|
||||
}
|
||||
|
@ -48,8 +48,9 @@ void DisplayChangeEventListener::OnChange(Rosen::DisplayId displayId)
|
||||
}
|
||||
lastRotation_ = Rosen::Rotation::ROTATION_0;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&IDragManager::RotateDragWindow, &context_->GetDragManager(), Rosen::Rotation::ROTATION_0));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this] {
|
||||
return this->context_->GetDragManager().RotateDragWindow(Rosen::Rotation::ROTATION_0);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
@ -71,8 +72,9 @@ void DisplayChangeEventListener::OnChange(Rosen::DisplayId displayId)
|
||||
}
|
||||
lastRotation_ = currentRotation;
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&IDragManager::RotateDragWindow, &context_->GetDragManager(), currentRotation));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this] {
|
||||
return this->context_->GetDragManager().RotateDragWindow(Rosen::currentRotation);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
|
@ -584,7 +584,8 @@ void DragDrawing::OnStartDrag(const DragAnimationData &dragAnimationData,
|
||||
return;
|
||||
}
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
if (!GetSuperHubHandler()->PostTask(std::bind(dragDropStartExtFunc, g_dragData))) {
|
||||
if (!GetSuperHubHandler()->PostTask([dragDropStartExtFunc] {
|
||||
return dragDropStartExtFunc(g_dragData); })) {
|
||||
FI_HILOGE("Start style animation failed");
|
||||
}
|
||||
#endif // OHOS_DRAG_ENABLE_ANIMATION
|
||||
@ -608,7 +609,8 @@ void DragDrawing::NotifyDragInfo(const std::string &sourceName, const std::strin
|
||||
struct DragEventInfo dragEventInfo;
|
||||
dragEventInfo.sourcePkgName = sourceName;
|
||||
dragEventInfo.targetPkgName = targetName;
|
||||
if (!GetSuperHubHandler()->PostTask(std::bind(dragDropExtFunc, dragEventInfo))) {
|
||||
if (!GetSuperHubHandler()->PostTask([dragDropStartExtFunc, dragEventInfo] {
|
||||
return dragDropStartExtFunc(dragEventInfo); })) {
|
||||
FI_HILOGE("notify drag info failed");
|
||||
}
|
||||
}
|
||||
@ -787,7 +789,7 @@ void DragDrawing::OnDragStyleAnimation()
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
}
|
||||
CheckStyleNodeModifier(dragStyleNode);
|
||||
handler_->PostTask(std::bind(&DragDrawing::ChangeStyleAnimation, this));
|
||||
handler_->PostTask([this] { this->ChangeStyleAnimation(); });
|
||||
FI_HILOGD("leave");
|
||||
}
|
||||
|
||||
@ -807,7 +809,7 @@ void DragDrawing::OnDragStyle(std::shared_ptr<Rosen::RSCanvasNode> dragStyleNode
|
||||
dragStyleNode->RemoveModifier(drawSVGModifier_);
|
||||
drawSVGModifier_ = nullptr;
|
||||
}
|
||||
if (!handler_->PostTask(std::bind(&DragDrawing::OnDragStyleAnimation, this))) {
|
||||
if (!handler_->PostTask([this] { this->OnDragStyleAnimation(); })) {
|
||||
FI_HILOGE("Drag style animation failed");
|
||||
DrawStyle(dragStyleNode, stylePixelMap);
|
||||
}
|
||||
@ -871,13 +873,13 @@ void DragDrawing::OnStopDragSuccess(std::shared_ptr<Rosen::RSCanvasNode> shadowN
|
||||
std::shared_ptr<Rosen::RSCanvasNode> dragStyleNode)
|
||||
{
|
||||
FI_HILOGD("enter");
|
||||
auto animateCb = std::bind(&DragDrawing::InitVSync, this, END_ALPHA, END_SCALE_SUCCESS);
|
||||
auto animateCb = [this] { this->InitVSync(END_ALPHA, END_SCALE_SUCCESS); };
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
ResetAnimationParameter();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPV(runner);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
if (!handler_->PostTask(std::bind(&DragDrawing::OnStopAnimationSuccess, this))) {
|
||||
if (!handler_->PostTask([this] { this->OnStopAnimationSuccess(); })) {
|
||||
FI_HILOGE("Failed to stop style animation");
|
||||
RunAnimation(animateCb);
|
||||
}
|
||||
@ -935,13 +937,13 @@ void DragDrawing::OnStopDragFail(std::shared_ptr<Rosen::RSSurfaceNode> surfaceNo
|
||||
std::shared_ptr<Rosen::RSNode> rootNode)
|
||||
{
|
||||
FI_HILOGD("enter");
|
||||
auto animateCb = std::bind(&DragDrawing::InitVSync, this, END_ALPHA, END_SCALE_FAIL);
|
||||
auto animateCb = [this] { this->InitVSync(END_ALPHA, END_SCALE_FAIL); };
|
||||
#ifdef OHOS_DRAG_ENABLE_ANIMATION
|
||||
ResetAnimationParameter();
|
||||
auto runner = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHKPV(runner);
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(std::move(runner));
|
||||
if (!handler_->PostTask(std::bind(&DragDrawing::OnStopAnimationFail, this))) {
|
||||
if (!handler_->PostTask([this] { this->OnStopAnimationFail(); })) {
|
||||
FI_HILOGE("Failed to stop style animation");
|
||||
RunAnimation(animateCb);
|
||||
}
|
||||
@ -1044,8 +1046,9 @@ void DragDrawing::OnDragMove(int32_t displayId, int32_t displayX, int32_t displa
|
||||
};
|
||||
dragSmoothProcessor_.InsertEvent(event);
|
||||
if (frameCallback_ == nullptr) {
|
||||
frameCallback_ = std::make_shared<DragFrameCallback>(
|
||||
std::bind(&DragDrawing::FlushDragPosition, this, std::placeholders::_1));
|
||||
frameCallback_ = std::make_shared<DragFrameCallback>([this](uint64_t nanoTimestamp) {
|
||||
this->FlushDragPosition(nanoTimestamp);
|
||||
});
|
||||
}
|
||||
vSyncStation_.RequestFrame(TYPE_FLUSH_DRAG_POSITION, frameCallback_);
|
||||
}
|
||||
@ -1106,7 +1109,7 @@ int32_t DragDrawing::StartVsync()
|
||||
}
|
||||
Rosen::VSyncReceiver::FrameCallback fcb = {
|
||||
.userData_ = this,
|
||||
.callback_ = std::bind(&DragDrawing::OnVsync, this)
|
||||
.callback_ = [this](int64_t parm1, void *parm2) { this->OnVsync(); }
|
||||
};
|
||||
ret = receiver_->RequestNextVSync(fcb);
|
||||
if (ret != RET_OK) {
|
||||
@ -1133,7 +1136,7 @@ void DragDrawing::OnVsync()
|
||||
}
|
||||
Rosen::VSyncReceiver::FrameCallback fcb = {
|
||||
.userData_ = this,
|
||||
.callback_ = std::bind(&DragDrawing::OnVsync, this)
|
||||
.callback_ = [this](int64_t parm1, void *parm2) { this->OnVsync(); }
|
||||
};
|
||||
CHKPV(receiver_);
|
||||
int32_t ret = receiver_->RequestNextVSync(fcb);
|
||||
@ -2009,7 +2012,9 @@ int32_t DragDrawing::EnterTextEditorArea(bool enable)
|
||||
DRAG_DATA_MGR.SetPixelMapLocation({ g_drawingInfo.pixelMapX, g_drawingInfo.pixelMapY });
|
||||
int32_t positionX = g_drawingInfo.displayX + g_drawingInfo.pixelMapX;
|
||||
int32_t positionY = g_drawingInfo.displayY + g_drawingInfo.pixelMapY - TWELVE_SIZE * GetScaling();
|
||||
if (RunAnimation(std::bind(&DragDrawing::SetNodesLocation, this, positionX, positionY)) != RET_OK) {
|
||||
if (RunAnimation([this, positionX, positionY] {
|
||||
return this->SetNodesLocation(positionX, positionY);
|
||||
}) != RET_OK) {
|
||||
FI_HILOGE("RunAnimation to SetNodesLocation failed");
|
||||
return RET_ERR;
|
||||
}
|
||||
|
@ -116,7 +116,8 @@ int32_t DragManager::AddListener(int32_t pid)
|
||||
info->msgType = MessageType::NOTIFY_STATE;
|
||||
stateNotify_.AddNotifyMsg(info);
|
||||
context_->GetSocketSessionManager().AddSessionDeletedCallback(pid,
|
||||
std::bind(&DragManager::OnSessionLost, this, std::placeholders::_1));
|
||||
[this](SocketSessionPtr session) { this->OnSessionLost(session);
|
||||
});
|
||||
FI_HILOGI("leave");
|
||||
return RET_OK;
|
||||
}
|
||||
@ -201,7 +202,8 @@ int32_t DragManager::StartDrag(const DragData &dragData, int32_t pid)
|
||||
dragOutSession_ = context_->GetSocketSessionManager().FindSessionByPid(pid);
|
||||
if (dragOutSession_ != nullptr) {
|
||||
context_->GetSocketSessionManager().AddSessionDeletedCallback(pid,
|
||||
std::bind(&DragManager::OnSessionLost, this, std::placeholders::_1));
|
||||
[this](SocketSessionPtr session) { this->OnSessionLost(session);
|
||||
});
|
||||
}
|
||||
packageName = (pid == -1) ? "Cross-device drag" : dragOutSession_->GetProgramName();
|
||||
PrintDragData(dragData, packageName);
|
||||
@ -413,8 +415,9 @@ void DragManager::DragCallback(std::shared_ptr<MMI::PointerEvent> pointerEvent)
|
||||
FI_HILOGI("DragCallback, pointerAction:%{public}d", pointerAction);
|
||||
if (pointerAction == MMI::PointerEvent::POINTER_ACTION_PULL_UP) {
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&DragManager::OnDragUp, this, pointerEvent));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this, pointerEvent] {
|
||||
return this->OnDragUp(pointerEvent);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
@ -680,15 +683,18 @@ int32_t DragManager::AddPointerEventHandler(uint32_t deviceTags)
|
||||
{
|
||||
FI_HILOGI("enter");
|
||||
#ifdef OHOS_DRAG_ENABLE_MONITOR
|
||||
auto monitor = std::make_shared<MonitorConsumer>(std::bind(&DragManager::DragCallback, this,
|
||||
std::placeholders::_1));
|
||||
auto monitor = std::make_shared<MonitorConsumer>([this](std::shared_ptr<MMI::PointerEvent> pointerEvent) {
|
||||
return this->DragCallback(pointerEvent);
|
||||
});
|
||||
pointerEventMonitorId_ = MMI::InputManager::GetInstance()->AddMonitor(monitor);
|
||||
if (pointerEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add pointer event monitor");
|
||||
return RET_ERR;
|
||||
}
|
||||
#else
|
||||
auto callback = std::bind(&DragManager::DragCallback, this, std::placeholders::_1);
|
||||
auto callback = [this](std::shared_ptr<MMI::PointerEvent> pointerEvent) {
|
||||
return this->DragCallback(pointerEvent);
|
||||
};
|
||||
auto interceptor = std::make_shared<InterceptorConsumer>(callback);
|
||||
pointerEventInterceptorId_ = MMI::InputManager::GetInstance()->AddInterceptor(
|
||||
interceptor, DRAG_PRIORITY, deviceTags);
|
||||
@ -705,7 +711,9 @@ int32_t DragManager::AddKeyEventMonitor()
|
||||
{
|
||||
FI_HILOGI("enter");
|
||||
keyEventMonitorId_ = MMI::InputManager::GetInstance()->AddMonitor(
|
||||
std::bind(&DragManager::DragKeyEventCallback, this, std::placeholders::_1));
|
||||
[this](std::shared_ptr<MMI::PointerEvent> pointerEvent) {
|
||||
return this->DragCallback(pointerEvent);
|
||||
});
|
||||
if (keyEventMonitorId_ <= 0) {
|
||||
FI_HILOGE("Failed to add key event monitor");
|
||||
return RET_ERR;
|
||||
@ -1065,8 +1073,9 @@ void DragManager::HandleCtrlKeyEvent(DragCursorStyle style, DragAction action)
|
||||
return;
|
||||
}
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&DragDrawing::UpdateDragStyle, &dragDrawing_, style));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([dragDrawing_, style] {
|
||||
return dragDrawing_->UpdateDragStyle(pointerEvent, style);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
@ -1160,8 +1169,9 @@ void DragManager::CtrlKeyStyleChangedNotify(DragCursorStyle style, DragAction ac
|
||||
return;
|
||||
}
|
||||
CHKPV(context_);
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(
|
||||
std::bind(&StateChangeNotify::StyleChangedNotify, &stateNotify_, style));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([stateNotify_, style] {
|
||||
stateNotify_->StyleChangedNotify(style);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
|
@ -86,7 +86,9 @@ void EventHub::OnReceiveEvent(const EventFwk::CommonEventData &event)
|
||||
}
|
||||
return RET_OK;
|
||||
};
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask(std::bind(fun, context_));
|
||||
int32_t ret = context_->GetDelegateTasks().PostAsyncTask([this, &fun] {
|
||||
return fun(this->context_);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Post async task failed");
|
||||
}
|
||||
|
@ -113,8 +113,9 @@ int32_t DeviceStatusManager::InitDataCallback()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
CHKPF(msdpImpl_);
|
||||
DeviceStatusMsdpClientImpl::CallbackManager callback =
|
||||
std::bind(&DeviceStatusManager::MsdpDataCallback, this, std::placeholders::_1);
|
||||
DeviceStatusMsdpClientImpl::CallbackManager callback = [this](const Data &data) {
|
||||
return this->MsdpDataCallback(&data);
|
||||
};
|
||||
if (msdpImpl_->RegisterImpl(callback) == RET_ERR) {
|
||||
FI_HILOGE("Register impl failed");
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void DeviceStatusService::OnStart()
|
||||
}
|
||||
state_ = ServiceRunningState::STATE_RUNNING;
|
||||
ready_ = true;
|
||||
worker_ = std::thread(std::bind(&DeviceStatusService::OnThread, this));
|
||||
worker_ = std::thread([this] { this->OnThread(); });
|
||||
}
|
||||
|
||||
void DeviceStatusService::OnStop()
|
||||
@ -182,7 +182,7 @@ void DeviceStatusService::EnableDSoftbus()
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to enable dsoftbus, try again later");
|
||||
int32_t timerId = timerMgr_.AddTimer(DEFAULT_WAIT_TIME_MS, WAIT_FOR_ONCE,
|
||||
std::bind(&DeviceStatusService::EnableDSoftbus, this));
|
||||
[this] { this->EnableDSoftbus(); });
|
||||
if (timerId < 0) {
|
||||
FI_HILOGE("AddTimer failed, Failed to enable dsoftbus");
|
||||
}
|
||||
@ -359,8 +359,11 @@ int32_t DeviceStatusService::AllocSocketFd(const std::string &programName, int32
|
||||
int32_t serverFd = -1;
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t uid = GetCallingUid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(std::bind(&StreamServer::AddSocketPairInfo, this,
|
||||
programName, moduleType, uid, pid, serverFd, std::ref(toReturnClientFd), tokenType));
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
[this, programName, moduleType, uid, pid, serverFd, toReturnClientFd, tokenType] {
|
||||
return this->AddSocketPairInfo(programName, moduleType, uid, pid, serverFd,
|
||||
std::ref(toReturnClientFd), tokenType);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Call Add socket pair info failed, return:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -561,7 +564,7 @@ int32_t DeviceStatusService::EnableDevMgr(int32_t nRetries)
|
||||
FI_HILOGE("Failed to enable device manager");
|
||||
if (nRetries > 0) {
|
||||
timerId = timerMgr_.AddTimer(DEFAULT_WAIT_TIME_MS, WAIT_FOR_ONCE,
|
||||
std::bind(&DeviceStatusService::EnableDevMgr, this, nRetries - 1));
|
||||
[this, nRetries - 1] { return this->EnableDevMgr(nRetries - 1); });
|
||||
if (timerId < 0) {
|
||||
FI_HILOGE("AddTimer failed, Failed to enable device manager");
|
||||
}
|
||||
@ -592,7 +595,7 @@ int32_t DeviceStatusService::RegisterCoordinationListener(bool isCompatible)
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnRegisterCoordinationListener, this, pid));
|
||||
[this, pid] { return this->OnRegisterCoordinationListener(pid); });
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On register coordination listener failed, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -610,7 +613,7 @@ int32_t DeviceStatusService::UnregisterCoordinationListener(bool isCompatible)
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnUnregisterCoordinationListener, this, pid));
|
||||
[this, pid] { return this->OnUnregisterCoordinationListener(pid); });
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On unregister coordination listener failed, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -628,7 +631,7 @@ int32_t DeviceStatusService::PrepareCoordination(int32_t userData, bool isCompat
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnPrepareCoordination, this, pid, userData));
|
||||
[this, pid, userData] { return this->OnPrepareCoordination(pid, userData); });
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On prepare coordination failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -648,7 +651,7 @@ int32_t DeviceStatusService::UnprepareCoordination(int32_t userData, bool isComp
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnUnprepareCoordination, this, pid, userData));
|
||||
[this, pid, userData] { return this->OnUnprepareCoordination(pid, userData); });
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("OnUnprepareCoordination failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -668,9 +671,8 @@ int32_t DeviceStatusService::ActivateCoordination(int32_t userData,
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnActivateCoordination,
|
||||
this, pid, userData, remoteNetworkId, startDeviceId));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, pid, userData, remoteNetworkId, startDeviceId] {
|
||||
return this->OnActivateCoordination(pid, userData, remoteNetworkId, startDeviceId); });
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On activate coordination failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -692,8 +694,9 @@ int32_t DeviceStatusService::DeactivateCoordination(int32_t userData, bool isUnc
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnDeactivateCoordination, this, pid, userData, isUnchained));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, pid, userData, isUnchained] {
|
||||
return this->OnDeactivateCoordination(pid, userData, isUnchained);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On deactivate coordination failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -714,8 +717,9 @@ int32_t DeviceStatusService::GetCoordinationState(int32_t userData, const std::s
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnGetCoordinationState, this, pid, userData, networkId));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, pid, userData, networkId] {
|
||||
return this->OnGetCoordinationState(pid, userData, networkId);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("OnGetCoordinationState failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -734,8 +738,9 @@ int32_t DeviceStatusService::GetCoordinationState(const std::string &udId, bool
|
||||
CALL_DEBUG_ENTER;
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnGetCoordinationStateSync, this, udId, std::ref(state)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, udId, state] {
|
||||
return this->OnGetCoordinationStateSync(pid, udId, std::ref(state));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("OnGetCoordinationStateSync failed, ret:%{public}d", ret);
|
||||
return ret;
|
||||
@ -752,8 +757,9 @@ int32_t DeviceStatusService::AddDraglistener()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t session = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::AddListener, &dragMgr_, session));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, session] {
|
||||
return dragMgr_->AddListener(session);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("AddListener failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -764,8 +770,9 @@ int32_t DeviceStatusService::RemoveDraglistener()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t session = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::RemoveListener, &dragMgr_, session));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, session] {
|
||||
return dragMgr_->RemoveListener(session);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Remove listener failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -776,8 +783,9 @@ int32_t DeviceStatusService::AddSubscriptListener()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t session = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::AddSubscriptListener, &dragMgr_, session));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, session] {
|
||||
return dragMgr_->AddSubscriptListener(session);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("AddListener failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -788,8 +796,9 @@ int32_t DeviceStatusService::RemoveSubscriptListener()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t session = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::RemoveSubscriptListener, &dragMgr_, session));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, session] {
|
||||
return dragMgr_->RemoveSubscriptListener(session);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("AddListener failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -800,8 +809,9 @@ int32_t DeviceStatusService::StartDrag(const DragData &dragData)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t session = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::StartDrag, &dragMgr_, std::cref(dragData), session));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, dragData, session] {
|
||||
return dragMgr_->StartDrag(std::cref(dragData), session);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("StartDrag failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -811,8 +821,9 @@ int32_t DeviceStatusService::StartDrag(const DragData &dragData)
|
||||
int32_t DeviceStatusService::StopDrag(const DragDropResult &dropResult)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::StopDrag, &dragMgr_, dropResult, std::string()));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, dropResult] {
|
||||
return dragMgr_->StopDrag(dropResult, std::string());
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("StopDrag failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -822,8 +833,9 @@ int32_t DeviceStatusService::StopDrag(const DragDropResult &dropResult)
|
||||
int32_t DeviceStatusService::SetDragWindowVisible(bool visible, bool isForce)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::OnSetDragWindowVisible, &dragMgr_, visible, isForce));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, visible, isForce] {
|
||||
return dragMgr_->OnSetDragWindowVisible(visible, isForce);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("On set drag window visible failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -833,8 +845,9 @@ int32_t DeviceStatusService::SetDragWindowVisible(bool visible, bool isForce)
|
||||
int32_t DeviceStatusService::EnterTextEditorArea(bool enable)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::EnterTextEditorArea, &dragMgr_, enable));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, enable] {
|
||||
return dragMgr_->EnterTextEditorArea(enable);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Enter Text Editor Area failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -844,8 +857,9 @@ int32_t DeviceStatusService::EnterTextEditorArea(bool enable)
|
||||
int32_t DeviceStatusService::GetShadowOffset(ShadowOffset &shadowOffset)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(std::bind(&DragManager::OnGetShadowOffset,
|
||||
&dragMgr_, std::ref(shadowOffset)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, shadowOffset] {
|
||||
return dragMgr_->OnGetShadowOffset(std::ref(shadowOffset));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get shadow offset failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -855,8 +869,9 @@ int32_t DeviceStatusService::GetShadowOffset(ShadowOffset &shadowOffset)
|
||||
int32_t DeviceStatusService::UpdateShadowPic(const ShadowInfo &shadowInfo)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::UpdateShadowPic, &dragMgr_, std::cref(shadowInfo)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, shadowInfo] {
|
||||
return dragMgr_->UpdateShadowPic(std::cref(shadowInfo));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Update shadow picture failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -866,8 +881,9 @@ int32_t DeviceStatusService::UpdateShadowPic(const ShadowInfo &shadowInfo)
|
||||
int32_t DeviceStatusService::GetDragData(DragData &dragData)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetDragData, &dragMgr_, std::ref(dragData)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, dragData] {
|
||||
return dragMgr_->GetDragData(dragData);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get drag data failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -877,9 +893,11 @@ int32_t DeviceStatusService::GetDragData(DragData &dragData)
|
||||
int32_t DeviceStatusService::GetDragState(DragState &dragState)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(static_cast<int32_t(DragManager::*)(DragState&)>(&DragManager::GetDragState),
|
||||
&dragMgr_, std::ref(dragState)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, dragState] {
|
||||
return dragMgr_->GetDragState(std::ref(dragState));
|
||||
});
|
||||
//std::bind(static_cast<int32_t(DragManager::*)(DragState&)>(&DragManager::GetDragState),
|
||||
// &dragMgr_, std::ref(dragState)));
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get drag state failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -891,8 +909,9 @@ int32_t DeviceStatusService::UpdateDragStyle(DragCursorStyle style)
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t tid = static_cast<int32_t>(GetCallingTokenID());
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::UpdateDragStyle, &dragMgr_, style, pid, tid));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, style, pid, tid] {
|
||||
return dragMgr_->UpdateDragStyle(style, pid, tid);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Update drag style failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -902,8 +921,9 @@ int32_t DeviceStatusService::UpdateDragStyle(DragCursorStyle style)
|
||||
int32_t DeviceStatusService::GetUdKey(std::string &udKey)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetUdKey, &dragMgr_, std::ref(udKey)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, udKey] {
|
||||
return dragMgr_->GetUdKey(std::ref(udKey));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get udkey failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -913,8 +933,9 @@ int32_t DeviceStatusService::GetUdKey(std::string &udKey)
|
||||
int32_t DeviceStatusService::GetDragTargetPid()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetDragTargetPid, &dragMgr_));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_] {
|
||||
return dragMgr_->GetDragTargetPid();
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get drag target pid failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -923,8 +944,9 @@ int32_t DeviceStatusService::GetDragTargetPid()
|
||||
|
||||
int32_t DeviceStatusService::GetDragAction(DragAction &dragAction)
|
||||
{
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetDragAction, &dragMgr_, std::ref(dragAction)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragAction] {
|
||||
return dragMgr_->GetDragAction(std::ref(dragAction));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get drag action failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -933,8 +955,9 @@ int32_t DeviceStatusService::GetDragAction(DragAction &dragAction)
|
||||
|
||||
int32_t DeviceStatusService::GetExtraInfo(std::string &extraInfo)
|
||||
{
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetExtraInfo, &dragMgr_, std::ref(extraInfo)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_, extraInfo] {
|
||||
return dragMgr_->GetExtraInfo(std::ref(extraInfo));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Get extraInfo failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -1090,8 +1113,9 @@ int32_t DeviceStatusService::AddHotAreaListener()
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnAddHotAreaListener, this, pid));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, pid] {
|
||||
return this->OnAddHotAreaListener(pid);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to add hot area listener, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -1107,8 +1131,9 @@ int32_t DeviceStatusService::RemoveHotAreaListener()
|
||||
#ifdef OHOS_BUILD_ENABLE_COORDINATION
|
||||
#ifndef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
|
||||
int32_t pid = GetCallingPid();
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DeviceStatusService::OnRemoveHotAreaListener, this, pid));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, pid] {
|
||||
return this->OnRemoveHotAreaListener(pid);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to remove hot area listener, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -1121,8 +1146,9 @@ int32_t DeviceStatusService::RemoveHotAreaListener()
|
||||
int32_t DeviceStatusService::UpdatePreviewStyle(const PreviewStyle &previewStyle)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::UpdatePreviewStyle, &dragMgr_, previewStyle));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, previewStyle] {
|
||||
return this->UpdatePreviewStyle(previewStyle);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("UpdatePreviewStyle failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -1133,8 +1159,9 @@ int32_t DeviceStatusService::UpdatePreviewStyleWithAnimation(const PreviewStyle
|
||||
const PreviewAnimation &animation)
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::UpdatePreviewStyleWithAnimation, &dragMgr_, previewStyle, animation));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, previewStyle, animation] {
|
||||
return this->UpdatePreviewStyleWithAnimation(previewStyle, animation);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("UpdatePreviewStyleWithAnimation failed, ret:%{public}d", ret);
|
||||
}
|
||||
@ -1143,8 +1170,9 @@ int32_t DeviceStatusService::UpdatePreviewStyleWithAnimation(const PreviewStyle
|
||||
|
||||
int32_t DeviceStatusService::GetDragSummary(std::map<std::string, int64_t> &summarys)
|
||||
{
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::GetDragSummary, &dragMgr_, std::ref(summarys)));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, summarys] {
|
||||
return this->GetDragSummary(std::ref(summarys));
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to get drag summarys, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -1156,8 +1184,9 @@ int32_t DeviceStatusService::AddPrivilege()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t tokenId = static_cast<int32_t>(GetCallingTokenID());
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::AddPrivilege, &dragMgr_, tokenId));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([this, tokenId] {
|
||||
return this->OnGetCoordinationState(tokenId);
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to add privilege, ret:%{public}d", ret);
|
||||
return RET_ERR;
|
||||
@ -1168,8 +1197,9 @@ int32_t DeviceStatusService::AddPrivilege()
|
||||
int32_t DeviceStatusService::EraseMouseIcon()
|
||||
{
|
||||
CALL_DEBUG_ENTER;
|
||||
int32_t ret = delegateTasks_.PostSyncTask(
|
||||
std::bind(&DragManager::EraseMouseIcon, &dragMgr_));
|
||||
int32_t ret = delegateTasks_.PostSyncTask([dragMgr_] {
|
||||
return dragMgr_->EraseMouseIcon();
|
||||
});
|
||||
if (ret != RET_OK) {
|
||||
FI_HILOGE("Failed to erase mouse, ret:%{public}d", ret);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void StreamServer::OnEpollRecv(int32_t fd, epoll_event &ev)
|
||||
if (!buf.Write(szBuf, size)) {
|
||||
FI_HILOGW("Write data failed, size:%{public}zd", size);
|
||||
}
|
||||
OnReadPackets(buf, std::bind(&StreamServer::OnPacket, this, fd, std::placeholders::_1));
|
||||
OnReadPackets(buf, [this, fd](NetPacket &pkt) { this->OnPacket(pkt); });
|
||||
} else if (size < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK) {
|
||||
FI_HILOGD("Continue for errno EAGAIN|EINTR|EWOULDBLOCK size:%{public}zd errno:%{public}d",
|
||||
|
@ -205,15 +205,16 @@ EXIT:
|
||||
void VirtualDeviceBuilder::SetSupportedEvents()
|
||||
{
|
||||
static const std::map<int32_t, std::function<std::vector<uint32_t>()>> uinputTypes { { UI_SET_EVBIT,
|
||||
std::bind(&VirtualDeviceBuilder::GetEventTypes, this) },
|
||||
{ UI_SET_KEYBIT, std::bind(&VirtualDeviceBuilder::GetKeys, this) },
|
||||
{ UI_SET_PROPBIT, std::bind(&VirtualDeviceBuilder::GetProperties, this) },
|
||||
{ UI_SET_ABSBIT, std::bind(&VirtualDeviceBuilder::GetAbs, this) },
|
||||
{ UI_SET_RELBIT, std::bind(&VirtualDeviceBuilder::GetRelBits, this) },
|
||||
{ UI_SET_MSCBIT, std::bind(&VirtualDeviceBuilder::GetMiscellaneous, this) },
|
||||
{ UI_SET_LEDBIT, std::bind(&VirtualDeviceBuilder::GetLeds, this) },
|
||||
{ UI_SET_SWBIT, std::bind(&VirtualDeviceBuilder::GetSwitches, this) },
|
||||
{ UI_SET_FFBIT, std::bind(&VirtualDeviceBuilder::GetRepeats, this) } };
|
||||
[this] { this->GetEventTypes(); } },
|
||||
{ UI_SET_KEYBIT, [this] { this->GetKeys(); } },
|
||||
{ UI_SET_PROPBIT, [this] { this->GetProperties(); } },
|
||||
{ UI_SET_ABSBIT, [this] { this->GetAbs(); } },
|
||||
{ UI_SET_RELBIT, [this] { this->GetRelBits(); } },
|
||||
{ UI_SET_MSCBIT, [this] { this->GetMiscellaneous(); } },
|
||||
{ UI_SET_LEDBIT, [this] { this->GetLeds(); } },
|
||||
{ UI_SET_SWBIT, [this] { this->GetSwitches(); } },
|
||||
{ UI_SET_FFBIT, [this] { this->GetRepeats(); } }
|
||||
};
|
||||
|
||||
for (const auto &setEvents : uinputTypes) {
|
||||
const auto &events = setEvents.second();
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DEVICESTATUS_FUNC_CALLBACK_H
|
||||
#define DEVICESTATUS_FUNC_CALLBACK_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Msdp {
|
||||
namespace DeviceStatus {
|
||||
template<class MemberFunType, class ClassType>
|
||||
auto MsgCallbackBind2(MemberFunType func, ClassType* obj)
|
||||
{
|
||||
return std::bind(func, obj, std::placeholders::_1, std::placeholders::_2);
|
||||
}
|
||||
|
||||
template<class MemberFunType, class ClassType>
|
||||
auto MsgCallbackBind1(MemberFunType func, ClassType* obj)
|
||||
{
|
||||
return std::bind(func, obj, std::placeholders::_1);
|
||||
}
|
||||
} // namespace DeviceStatus
|
||||
} // namespace Msdp
|
||||
} // namespace OHOS
|
||||
#endif // DEVICESTATUS_FUNC_CALLBACK_H
|
@ -47,11 +47,21 @@ std::unordered_map<std::string, RosenCurveType> AnimationCurve::specialCurveMap_
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, AnimationCurve::CurveCreator> AnimationCurve::curveMap_ = {
|
||||
{ "cubic-bezier", std::bind(&AnimationCurve::CreateCubicCurve, std::placeholders::_1) },
|
||||
{ "spring", std::bind(&AnimationCurve::CreateSpringCurve, std::placeholders::_1) },
|
||||
{ "interpolating-spring", std::bind(&AnimationCurve::CreateInterpolatingSpring, std::placeholders::_1) },
|
||||
{ "responsive-spring-motion", std::bind(&AnimationCurve::CreateResponseSpring, std::placeholders::_1) },
|
||||
{ "steps", std::bind(&AnimationCurve::CreateStepsCurve, std::placeholders::_1) }
|
||||
{ "cubic-bezier", [](const std::vector<float> &curve) {
|
||||
return AnimationCurve::CreateCubicCurve(curve);
|
||||
} },
|
||||
{ "spring", [](const std::vector<float> &curve) {
|
||||
return AnimationCurve::CreateSpringCurve(curve);
|
||||
} },
|
||||
{ "interpolating-spring", [](const std::vector<float> &curve) {
|
||||
return AnimationCurve::CreateInterpolatingSpring(curve);
|
||||
} },
|
||||
{ "responsive-spring-motion", [](const std::vector<float> &curve) {
|
||||
return AnimationCurve::CreateResponseSpring(curve);
|
||||
} },
|
||||
{ "steps", [](const std::vector<float> &curve) {
|
||||
return AnimationCurve::CreateStepsCurve(curve);
|
||||
} }
|
||||
};
|
||||
|
||||
RosenCurveType AnimationCurve::CreateCurve(const std::string &curveName, const std::vector<float> &curve)
|
||||
|
Loading…
Reference in New Issue
Block a user