mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
5aee5b8d03
@ -209,6 +209,8 @@ private:
|
|||||||
void UpdateState(DSchedContinueStateType stateType);
|
void UpdateState(DSchedContinueStateType stateType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr int32_t INVALID_SESSION_ID = -1;
|
||||||
|
|
||||||
std::shared_ptr<DSchedContinueStateMachine> stateMachine_;
|
std::shared_ptr<DSchedContinueStateMachine> stateMachine_;
|
||||||
std::shared_ptr<DSchedContinueEventHandler> eventHandler_;
|
std::shared_ptr<DSchedContinueEventHandler> eventHandler_;
|
||||||
std::condition_variable eventCon_;
|
std::condition_variable eventCon_;
|
||||||
@ -221,7 +223,7 @@ private:
|
|||||||
int32_t direction_ = 0;
|
int32_t direction_ = 0;
|
||||||
DSchedContinueInfo continueInfo_;
|
DSchedContinueInfo continueInfo_;
|
||||||
bool isSourceExit_ = true;
|
bool isSourceExit_ = true;
|
||||||
int32_t softbusSessionId_ = 0;
|
int32_t softbusSessionId_ = INVALID_SESSION_ID;
|
||||||
sptr<IRemoteObject> callback_ = nullptr;
|
sptr<IRemoteObject> callback_ = nullptr;
|
||||||
EventNotify eventData_;
|
EventNotify eventData_;
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@ class DSchedTransportSoftbusAdapter {
|
|||||||
DECLARE_SINGLE_INSTANCE_BASE(DSchedTransportSoftbusAdapter);
|
DECLARE_SINGLE_INSTANCE_BASE(DSchedTransportSoftbusAdapter);
|
||||||
public:
|
public:
|
||||||
int32_t InitChannel();
|
int32_t InitChannel();
|
||||||
int32_t ConnectDevice(const std::string &peerDeviceId);
|
int32_t ConnectDevice(const std::string &peerDeviceId, int32_t &sessionId);
|
||||||
void DisconnectDevice(const std::string &peerDeviceId);
|
void DisconnectDevice(const std::string &peerDeviceId);
|
||||||
int32_t ReleaseChannel();
|
int32_t ReleaseChannel();
|
||||||
int32_t SendData(int32_t sessionId, int32_t dataType, std::shared_ptr<DSchedDataBuffer> dataBuffer);
|
int32_t SendData(int32_t sessionId, int32_t dataType, std::shared_ptr<DSchedDataBuffer> dataBuffer);
|
||||||
|
@ -462,17 +462,17 @@ int32_t DSchedContinue::ExecuteContinueReq(std::shared_ptr<DistributedWantParams
|
|||||||
QuickStartAbility();
|
QuickStartAbility();
|
||||||
}
|
}
|
||||||
|
|
||||||
softbusSessionId_ = DSchedTransportSoftbusAdapter::GetInstance().ConnectDevice(peerDeviceId);
|
int32_t ret = DSchedTransportSoftbusAdapter::GetInstance().ConnectDevice(peerDeviceId, softbusSessionId_);
|
||||||
if (softbusSessionId_ <= 0) {
|
if (ret != ERR_OK) {
|
||||||
HILOGE("ExecuteContinueReq connect peer device %{public}s failed, ret %{public}d",
|
HILOGE("ExecuteContinueReq connect peer device %{public}s failed, ret %{public}d",
|
||||||
GetAnonymStr(peerDeviceId).c_str(), softbusSessionId_);
|
GetAnonymStr(peerDeviceId).c_str(), ret);
|
||||||
return softbusSessionId_;
|
return ret;
|
||||||
}
|
}
|
||||||
HILOGI("ExecuteContinueReq peer %{public}s connected, sessionId %{public}d",
|
HILOGI("ExecuteContinueReq peer %{public}s connected, sessionId %{public}d",
|
||||||
GetAnonymStr(peerDeviceId).c_str(), softbusSessionId_);
|
GetAnonymStr(peerDeviceId).c_str(), softbusSessionId_);
|
||||||
|
|
||||||
auto startCmd = std::make_shared<DSchedContinueStartCmd>();
|
auto startCmd = std::make_shared<DSchedContinueStartCmd>();
|
||||||
int32_t ret = PackStartCmd(startCmd, wantParams);
|
ret = PackStartCmd(startCmd, wantParams);
|
||||||
if (ret != ERR_OK) {
|
if (ret != ERR_OK) {
|
||||||
HILOGE("ExecuteContinueReq pack start cmd failed, ret %{public}d", ret);
|
HILOGE("ExecuteContinueReq pack start cmd failed, ret %{public}d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -109,7 +109,7 @@ int32_t DSchedTransportSoftbusAdapter::CreateServerSocket()
|
|||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDeviceId)
|
int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDeviceId, int32_t &sessionId)
|
||||||
{
|
{
|
||||||
HILOGI("try to connect peer: %{public}s.", GetAnonymStr(peerDeviceId).c_str());
|
HILOGI("try to connect peer: %{public}s.", GetAnonymStr(peerDeviceId).c_str());
|
||||||
{
|
{
|
||||||
@ -119,7 +119,8 @@ int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDevi
|
|||||||
if (iter->second != nullptr && peerDeviceId == iter->second->GetPeerDeviceId()) {
|
if (iter->second != nullptr && peerDeviceId == iter->second->GetPeerDeviceId()) {
|
||||||
HILOGI("peer device already connected");
|
HILOGI("peer device already connected");
|
||||||
iter->second->OnConnect();
|
iter->second->OnConnect();
|
||||||
return iter->first;
|
sessionId = iter->first;
|
||||||
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +133,8 @@ int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDevi
|
|||||||
ret = DSchedAllConnectManager::GetInstance().ApplyAdvanceResource(peerDeviceId, reqInfoSets);
|
ret = DSchedAllConnectManager::GetInstance().ApplyAdvanceResource(peerDeviceId, reqInfoSets);
|
||||||
if (ret != ERR_OK) {
|
if (ret != ERR_OK) {
|
||||||
HILOGE("Apply advance resource fail, ret: %{public}d.", ret);
|
HILOGE("Apply advance resource fail, ret: %{public}d.", ret);
|
||||||
return INVALID_SESSION_ID;
|
sessionId = INVALID_SESSION_ID;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = DSchedAllConnectManager::GetInstance().PublishServiceState(peerDeviceId, "", SCM_PREPARE);
|
ret = DSchedAllConnectManager::GetInstance().PublishServiceState(peerDeviceId, "", SCM_PREPARE);
|
||||||
@ -142,12 +144,11 @@ int32_t DSchedTransportSoftbusAdapter::ConnectDevice(const std::string &peerDevi
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t sessionId = INVALID_SESSION_ID;
|
|
||||||
ret = AddNewPeerSession(peerDeviceId, sessionId);
|
ret = AddNewPeerSession(peerDeviceId, sessionId);
|
||||||
if (ret != ERR_OK || sessionId <= 0) {
|
if (ret != ERR_OK || sessionId <= 0) {
|
||||||
HILOGE("Add new peer connect session fail, ret: %{public}d, sessionId: %{public}d.", ret, sessionId);
|
HILOGE("Add new peer connect session fail, ret: %{public}d, sessionId: %{public}d.", ret, sessionId);
|
||||||
}
|
}
|
||||||
return sessionId;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t DSchedTransportSoftbusAdapter::AddNewPeerSession(const std::string &peerDeviceId, int32_t &sessionId)
|
int32_t DSchedTransportSoftbusAdapter::AddNewPeerSession(const std::string &peerDeviceId, int32_t &sessionId)
|
||||||
|
Loading…
Reference in New Issue
Block a user