Bugfix: bring source error code to sink

Signed-off-by: z00838083 <zhuhuixuan@huawei.com>
This commit is contained in:
z00838083 2024-07-18 16:19:03 +08:00
parent d26d9f3bb9
commit ec5fdca674
16 changed files with 263 additions and 75 deletions

View File

@ -180,7 +180,7 @@ private:
int32_t PackDataCmd(std::shared_ptr<DSchedContinueDataCmd>& cmd, const OHOS::AAFwk::Want& want,
const AppExecFwk::AbilityInfo& abilityInfo, const CallerInfo& callerInfo,
const AccountInfo& accountInfo);
int32_t PackEndCmd(std::shared_ptr<DSchedContinueEndCmd> cmd, bool result);
int32_t PackEndCmd(std::shared_ptr<DSchedContinueEndCmd> cmd, int32_t result);
int32_t PackReplyCmd(std::shared_ptr<DSchedContinueReplyCmd> cmd, int32_t replyCmd, int32_t appVersion,
int32_t result, const std::string reason);
int32_t SendCommand(std::shared_ptr<DSchedContinueCmdBase> cmd);

View File

@ -33,6 +33,8 @@ public:
private:
int32_t DoContinueDataTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);

View File

@ -35,6 +35,8 @@ private:
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueAbilityTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);

View File

@ -33,6 +33,8 @@ public:
private:
int32_t DoContinueSendTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);

View File

@ -35,6 +35,8 @@ private:
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinuePushReqTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);
int32_t DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event);

View File

@ -613,7 +613,7 @@ int32_t DSchedContinue::PackStartCmd(std::shared_ptr<DSchedContinueStartCmd>& cm
int32_t DSchedContinue::ExecuteContinueAbility(int32_t appVersion)
{
HILOGI("ExecuteContinueAbility start");
HILOGI("ExecuteContinueAbility start, appVersion: %{public}d", appVersion);
DmsRadar::GetInstance().SaveDataDmsContinue("ContinueAbility", ERR_OK);
int32_t result = GetMissionIdByBundleName();
@ -949,23 +949,24 @@ int32_t DSchedContinue::StartAbility(const OHOS::AAFwk::Want& want, int32_t requ
{
int32_t ret = AAFwk::AbilityManagerClient::GetInstance()->Connect();
if (ret != ERR_OK) {
HILOGE("ExecuteContinueData connect ability server failed %{public}d", ret);
HILOGE("connect ability server failed %{public}d", ret);
return ret;
}
int32_t activeAccountId = 0;
ret = DistributedSchedService::GetInstance().QueryOsAccount(activeAccountId);
if (ret != ERR_OK) {
HILOGE("ExecuteContinueData QueryOsAccount failed %{public}d", ret);
HILOGE("QueryOsAccount failed %{public}d", ret);
return ret;
}
HILOGI("ExecuteContinueData StartAbility start, flag is %{public}d", want.GetFlags());
DmsRadar::GetInstance().ClickIconDmsStartAbility("StartAbility", ret);
continueInfo_.sinkAbilityName_ = want.GetElement().GetAbilityName();
DmsRadar::GetInstance().ClickIconDmsStartAbility("StartAbility", ret);
HILOGI("call StartAbility start, flag is %{public}d", want.GetFlags());
ret = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, DEFAULT_REQUEST_CODE, activeAccountId);
if (ret != ERR_OK) {
HILOGE("StartAbility failed %{public}d", ret);
HILOGE("failed %{public}d", ret);
return ret;
}
return ret;
@ -973,7 +974,7 @@ int32_t DSchedContinue::StartAbility(const OHOS::AAFwk::Want& want, int32_t requ
int32_t DSchedContinue::ExecuteNotifyComplete(int32_t result)
{
HILOGI("ExecuteNotifyComplete start, continueInfo: %{public}s", continueInfo_.toString().c_str());
HILOGI("ExecuteNotifyComplete start, result %{public}d", result);
DmsContinueTime::GetInstance().SetDurationEnd(CONTINUE_START_ABILITY_TIME, GetTickCount());
int32_t ret = 0;
@ -1036,12 +1037,11 @@ int32_t DSchedContinue::PackReplyCmd(std::shared_ptr<DSchedContinueReplyCmd> cmd
int32_t DSchedContinue::ExecuteContinueEnd(int32_t result)
{
HILOGI("ExecuteContinueEnd start, continueInfo: %{public}s", continueInfo_.toString().c_str());
HILOGI("ExecuteContinueEnd start, result %{public}d", result);
std::string peerDeviceId = (direction_ == CONTINUE_SOURCE) ?
continueInfo_.sinkDeviceId_ : continueInfo_.sourceDeviceId_;
if (result != ERR_OK ||
(subServiceType_ == CONTINUE_PULL && direction_ == CONTINUE_SINK) ||
if ((subServiceType_ == CONTINUE_PULL && direction_ == CONTINUE_SINK) ||
(subServiceType_ == CONTINUE_PUSH && direction_ == CONTINUE_SOURCE)) {
HILOGI("ExecuteContinueEnd disconnect peer device %{public}s", GetAnonymStr(peerDeviceId).c_str());
DSchedTransportSoftbusAdapter::GetInstance().DisconnectDevice(peerDeviceId);
@ -1123,16 +1123,16 @@ int32_t DSchedContinue::ExecuteContinueError(int32_t result)
PackEndCmd(cmd, result);
SendCommand(cmd);
if (direction_ == CONTINUE_SOURCE) {
UpdateState(DSCHED_CONTINUE_SINK_END_STATE);
} else {
UpdateState(DSCHED_CONTINUE_SOURCE_END_STATE);
} else {
UpdateState(DSCHED_CONTINUE_SINK_END_STATE);
}
OnContinueEnd(result);
HILOGI("ExecuteNotifyComplete end");
return ERR_OK;
}
int32_t DSchedContinue::PackEndCmd(std::shared_ptr<DSchedContinueEndCmd> cmd, bool result)
int32_t DSchedContinue::PackEndCmd(std::shared_ptr<DSchedContinueEndCmd> cmd, int32_t result)
{
if (cmd == nullptr) {
HILOGE("cmd is null");

View File

@ -28,7 +28,8 @@ DSchedContinueDataState::DSchedContinueDataState(std::shared_ptr<DSchedContinueS
: stateMachine_(stateMachine)
{
memberFuncMap_[DSCHED_CONTINUE_DATA_EVENT] = &DSchedContinueDataState::DoContinueDataTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueDataState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_COMPLETE_EVENT] = &DSchedContinueDataState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueDataState::DoContinueErrorTask;
}
DSchedContinueDataState::~DSchedContinueDataState()
@ -38,9 +39,13 @@ DSchedContinueDataState::~DSchedContinueDataState()
int32_t DSchedContinueDataState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueDataState execute %{public}d in wrong state", event->GetInnerEventId());
HILOGE("DSchedContinueDataState execute %{public}d in wrong state", event->GetInnerEventId());
return CONTINUE_STATE_MACHINE_INVALID_STATE;
}
@ -60,8 +65,8 @@ DSchedContinueStateType DSchedContinueDataState::GetStateType()
int32_t DSchedContinueDataState::DoContinueDataTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<DSchedContinueDataCmd>();
@ -72,11 +77,11 @@ int32_t DSchedContinueDataState::DoContinueDataTask(std::shared_ptr<DSchedContin
return ret;
}
int32_t DSchedContinueDataState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
int32_t DSchedContinueDataState::DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -86,5 +91,20 @@ int32_t DSchedContinueDataState::DoContinueEndTask(std::shared_ptr<DSchedContinu
}
return ret;
}
int32_t DSchedContinueDataState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
int32_t ret = dContinue->ExecuteContinueEnd(*syncContinueData);
if (ret != ERR_OK) {
HILOGE("DSchedContinueDataState ExecuteContinueSend failed, ret: %{public}d", ret);
}
return ret;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -37,6 +37,10 @@ DSchedContinueSinkEndState::~DSchedContinueSinkEndState()
int32_t DSchedContinueSinkEndState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueSinkEndState execute %{public}d in wrong state", event->GetInnerEventId());
@ -60,8 +64,8 @@ DSchedContinueStateType DSchedContinueSinkEndState::GetStateType()
int32_t DSchedContinueSinkEndState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();

View File

@ -29,7 +29,8 @@ DSchedContinueSinkStartState::DSchedContinueSinkStartState(std::shared_ptr<DSche
{
memberFuncMap_[DSCHED_CONTINUE_REQ_PULL_EVENT] = &DSchedContinueSinkStartState::DoContinuePullReqTask;
memberFuncMap_[DSHCED_CONTINUE_ABILITY_EVENT] = &DSchedContinueSinkStartState::DoContinueAbilityTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueSinkStartState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_COMPLETE_EVENT] = &DSchedContinueSinkStartState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueSinkStartState::DoContinueErrorTask;
}
DSchedContinueSinkStartState::~DSchedContinueSinkStartState()
@ -39,6 +40,10 @@ DSchedContinueSinkStartState::~DSchedContinueSinkStartState()
int32_t DSchedContinueSinkStartState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueSinkStartState execute %{public}d in wrong state", event->GetInnerEventId());
@ -62,8 +67,8 @@ DSchedContinueStateType DSchedContinueSinkStartState::GetStateType()
int32_t DSchedContinueSinkStartState::DoContinuePullReqTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<DistributedWantParams>();
@ -77,18 +82,18 @@ int32_t DSchedContinueSinkStartState::DoContinuePullReqTask(std::shared_ptr<DSch
int32_t DSchedContinueSinkStartState::DoContinueAbilityTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
return dContinue->ExecuteContinueReply();
}
int32_t DSchedContinueSinkStartState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
int32_t DSchedContinueSinkStartState::DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -98,5 +103,20 @@ int32_t DSchedContinueSinkStartState::DoContinueEndTask(std::shared_ptr<DSchedCo
}
return ret;
}
int32_t DSchedContinueSinkStartState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
int32_t ret = dContinue->ExecuteContinueEnd(*syncContinueData);
if (ret != ERR_OK) {
HILOGE("DSchedContinueSinkStartState ExecuteContinueSend failed, ret: %{public}d", ret);
}
return ret;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -38,6 +38,10 @@ DSchedContinueSinkWaitEndState::~DSchedContinueSinkWaitEndState()
int32_t DSchedContinueSinkWaitEndState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueSinkWaitEndState execute %{public}d in wrong state", event->GetInnerEventId());
@ -61,8 +65,8 @@ DSchedContinueStateType DSchedContinueSinkWaitEndState::GetStateType()
int32_t DSchedContinueSinkWaitEndState::DoNotifyCompleteTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -76,8 +80,8 @@ int32_t DSchedContinueSinkWaitEndState::DoNotifyCompleteTask(std::shared_ptr<DSc
int32_t DSchedContinueSinkWaitEndState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();

View File

@ -28,7 +28,8 @@ DSchedContinueAbilityState::DSchedContinueAbilityState(std::shared_ptr<DSchedCon
: stateMachine_(stateMachine)
{
memberFuncMap_[DSHCED_CONTINUE_SEND_DATA_EVENT] = &DSchedContinueAbilityState::DoContinueSendTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueAbilityState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_COMPLETE_EVENT] = &DSchedContinueAbilityState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueAbilityState::DoContinueErrorTask;
}
DSchedContinueAbilityState::~DSchedContinueAbilityState()
@ -38,6 +39,10 @@ DSchedContinueAbilityState::~DSchedContinueAbilityState()
int32_t DSchedContinueAbilityState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueAbilityState execute %{public}d in wrong state", event->GetInnerEventId());
@ -61,8 +66,8 @@ DSchedContinueStateType DSchedContinueAbilityState::GetStateType()
int32_t DSchedContinueAbilityState::DoContinueSendTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<ContinueAbilityData>();
@ -73,11 +78,11 @@ int32_t DSchedContinueAbilityState::DoContinueSendTask(std::shared_ptr<DSchedCon
return ret;
}
int32_t DSchedContinueAbilityState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
int32_t DSchedContinueAbilityState::DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -87,5 +92,20 @@ int32_t DSchedContinueAbilityState::DoContinueEndTask(std::shared_ptr<DSchedCont
}
return ret;
}
int32_t DSchedContinueAbilityState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
int32_t ret = dContinue->ExecuteContinueEnd(*syncContinueData);
if (ret != ERR_OK) {
HILOGE("DSchedContinueAbilityState ExecuteContinueEnd failed, ret: %{public}d", ret);
}
return ret;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -37,6 +37,10 @@ DSchedContinueEndState::~DSchedContinueEndState()
int32_t DSchedContinueEndState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueEndState execute %{public}d in wrong state", event->GetInnerEventId());
@ -59,8 +63,8 @@ DSchedContinueStateType DSchedContinueEndState::GetStateType()
int32_t DSchedContinueEndState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();

View File

@ -29,7 +29,8 @@ DSchedContinueSourceStartState::DSchedContinueSourceStartState(std::shared_ptr<D
{
memberFuncMap_[DSHCED_CONTINUE_REQ_PUSH_EVENT] = &DSchedContinueSourceStartState::DoContinuePushReqTask;
memberFuncMap_[DSHCED_CONTINUE_ABILITY_EVENT] = &DSchedContinueSourceStartState::DoContinueAbilityTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueSourceStartState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_COMPLETE_EVENT] = &DSchedContinueSourceStartState::DoContinueEndTask;
memberFuncMap_[DSCHED_CONTINUE_END_EVENT] = &DSchedContinueSourceStartState::DoContinueErrorTask;
}
DSchedContinueSourceStartState::~DSchedContinueSourceStartState()
@ -39,6 +40,10 @@ DSchedContinueSourceStartState::~DSchedContinueSourceStartState()
int32_t DSchedContinueSourceStartState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueSourceStartState execute %{public}d in wrong state", event->GetInnerEventId());
@ -62,8 +67,8 @@ DSchedContinueStateType DSchedContinueSourceStartState::GetStateType()
int32_t DSchedContinueSourceStartState::DoContinuePushReqTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<DistributedWantParams>();
@ -77,8 +82,8 @@ int32_t DSchedContinueSourceStartState::DoContinuePushReqTask(std::shared_ptr<DS
int32_t DSchedContinueSourceStartState::DoContinueAbilityTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -89,11 +94,11 @@ int32_t DSchedContinueSourceStartState::DoContinueAbilityTask(std::shared_ptr<DS
return ret;
}
int32_t DSchedContinueSourceStartState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
int32_t DSchedContinueSourceStartState::DoContinueErrorTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -103,5 +108,20 @@ int32_t DSchedContinueSourceStartState::DoContinueEndTask(std::shared_ptr<DSched
}
return ret;
}
int32_t DSchedContinueSourceStartState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
int32_t ret = dContinue->ExecuteContinueEnd(*syncContinueData);
if (ret != ERR_OK) {
HILOGE("DSchedContinueSourceStartState ExecuteContinueError failed, ret: %{public}d", ret);
}
return ret;
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -38,6 +38,10 @@ DSchedContinueWaitEndState::~DSchedContinueWaitEndState()
int32_t DSchedContinueWaitEndState::Execute(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (event == nullptr) {
HILOGE("event is null");
return INVALID_PARAMETERS_ERR;
}
auto iterFunc = memberFuncMap_.find(event->GetInnerEventId());
if (iterFunc == memberFuncMap_.end()) {
HILOGI("DSchedContinueWaitEndState execute %{public}d in wrong state", event->GetInnerEventId());
@ -61,8 +65,8 @@ DSchedContinueStateType DSchedContinueWaitEndState::GetStateType()
int32_t DSchedContinueWaitEndState::DoNotifyCompleteTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();
@ -76,8 +80,8 @@ int32_t DSchedContinueWaitEndState::DoNotifyCompleteTask(std::shared_ptr<DSchedC
int32_t DSchedContinueWaitEndState::DoContinueEndTask(std::shared_ptr<DSchedContinue> dContinue,
const AppExecFwk::InnerEvent::Pointer &event)
{
if (dContinue == nullptr) {
HILOGE("dContinue is null");
if (dContinue == nullptr || event == nullptr) {
HILOGE("dContinue or event is null");
return INVALID_PARAMETERS_ERR;
}
auto syncContinueData = event->GetSharedObject<int32_t>();

View File

@ -463,7 +463,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueDataTask001, TestSize.Level3
ASSERT_NE(dataStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -485,7 +485,7 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueEndTask001, TestSize.Level3)
ASSERT_NE(dataStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -496,6 +496,28 @@ HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueEndTask001, TestSize.Level3)
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueEndTask001 end" << std::endl;
}
/**
* @tc.name: SinkDoContinueErrorTask001
* @tc.desc: DoContinueErrorTask
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueDataStateTest, SinkDoContinueErrorTask001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueErrorTask001 begin" << std::endl;
ASSERT_NE(dataStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = dataStateTest_->DoContinueErrorTask(nullptr, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueDataStateTest SinkDoContinueErrorTask001 end" << std::endl;
}
/**
* @tc.name: TestSinkExecute001
* @tc.desc: Execute
@ -565,7 +587,7 @@ HWTEST_F(DSchedContinueSinkEndStateTest, TestSinkDoContinueEndTask001, TestSize.
ASSERT_NE(sinkEndStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -645,7 +667,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinuePullReqTaskTest_001, Te
ASSERT_NE(sinkStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -668,7 +690,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueAbilityTaskTest_001, Te
ASSERT_NE(sinkStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -691,7 +713,7 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueEndTaskTest_001, TestSi
ASSERT_NE(sinkStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -703,6 +725,28 @@ HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueEndTaskTest_001, TestSi
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkDoContinueEndTaskTest_001 end" << std::endl;
}
/**
* @tc.name: SinkDoContinueErrorTask001
* @tc.desc: DoContinueErrorTask
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSinkStartStateTest, SinkDoContinueErrorTask001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkDoContinueErrorTask001 begin" << std::endl;
ASSERT_NE(sinkStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = sinkStartStateTest_->DoContinueErrorTask(nullptr, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSinkStartStateTest SinkDoContinueErrorTask001 end" << std::endl;
}
/**
* @tc.name: SinkExecute001
* @tc.desc: Execute
@ -773,7 +817,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoNotifyCompleteTask001, TestSi
ASSERT_NE(sinkWaitEndTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -796,7 +840,7 @@ HWTEST_F(DSchedContinueSinkWaitEndStateTest, SinkDoContinueEndTask001, TestSize.
ASSERT_NE(sinkWaitEndTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -877,7 +921,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueSendTask001, TestSize.Leve
ASSERT_NE(abilityStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -899,7 +943,7 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueEndTask001, TestSize.Level
ASSERT_NE(abilityStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -910,6 +954,28 @@ HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueEndTask001, TestSize.Level
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueEndTask001 end" << std::endl;
}
/**
* @tc.name: SrcDoContinueErrorTask001
* @tc.desc: DoContinueErrorTask
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueAbilityStateTest, SrcDoContinueErrorTask001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueErrorTask001 begin" << std::endl;
ASSERT_NE(abilityStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = abilityStateTest_->DoContinueErrorTask(nullptr, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueAbilityStateTest SrcDoContinueErrorTask001 end" << std::endl;
}
/**
* @tc.name: SrcExecuteTest001
* @tc.desc: Execute
@ -979,7 +1045,7 @@ HWTEST_F(DSchedContinueEndStateTest, SrcDoContinueEndTaskTest001, TestSize.Level
ASSERT_NE(srcEndStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -1059,7 +1125,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinuePushReqTaskTest_001, T
ASSERT_NE(srcStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -1082,7 +1148,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueAbilityTaskTest_001, T
ASSERT_NE(srcStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -1105,7 +1171,7 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueEndTaskTest_001, TestS
ASSERT_NE(srcStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -1117,6 +1183,28 @@ HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueEndTaskTest_001, TestS
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueEndTaskTest_001 end" << std::endl;
}
/**
* @tc.name: SrcDoContinueErrorTask001
* @tc.desc: DoContinueErrorTask
* @tc.type: FUNC
*/
HWTEST_F(DSchedContinueSourceStartStateTest, SrcDoContinueErrorTask001, TestSize.Level3)
{
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueErrorTask001 begin" << std::endl;
ASSERT_NE(srcStartStateTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
}
};
int32_t ret = srcStartStateTest_->DoContinueErrorTask(nullptr, AppExecFwk::InnerEvent::Pointer(event, destructor));
EXPECT_NE(ret, ERR_OK);
DTEST_LOG << "DSchedContinueSourceStartStateTest SrcDoContinueErrorTask001 end" << std::endl;
}
/**
* @tc.name: SrcExecute_001
* @tc.desc: Execute
@ -1186,7 +1274,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoNotifyCompleteTask_001, TestSize.L
ASSERT_NE(srcWaitEndTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;
@ -1209,7 +1297,7 @@ HWTEST_F(DSchedContinueWaitEndStateTest, SrcDoContinueEndTask_001, TestSize.Leve
ASSERT_NE(srcWaitEndTest_, nullptr);
AppExecFwk::InnerEvent *event = new AppExecFwk::InnerEvent();
ASSERT_NE(event, nullptr);
event->innerEventId_ = static_cast<uint32_t>(-1);;
event->innerEventId_ = static_cast<uint32_t>(-1);
auto destructor = [](AppExecFwk::InnerEvent *event) {
if (event != nullptr) {
delete event;

View File

@ -79,10 +79,6 @@ HWTEST_F(SwitchStatusDependencyTest, IsCreateDataShareHelper_001, TestSize.Level
defaultValue = CONTINUE_SWITCH_ON;
EXPECT_EQ(CONTINUE_SWITCH_ON,
SwitchStatusDependency::GetInstance().GetSwitchStatus(key, defaultValue));
key = CONTINUE_SWITCH_STATUS_KEY;
defaultValue = CONTINUE_SWITCH_OFF;
EXPECT_EQ(CONTINUE_SWITCH_OFF,
SwitchStatusDependency::GetInstance().GetSwitchStatus(key, defaultValue));
DTEST_LOG << "SwitchStatusDependencyTest IsCreateDataShareHelper_001 end" << std::endl;
}
}