diff --git a/services/dtbschedmgr/include/distributed_ue.h b/services/dtbschedmgr/include/distributed_ue.h index a951e138..f040f382 100644 --- a/services/dtbschedmgr/include/distributed_ue.h +++ b/services/dtbschedmgr/include/distributed_ue.h @@ -64,8 +64,8 @@ public: const std::string& networkId, int32_t errCode); bool DmsContinueComplete(const std::string& bundleName, const std::string& abilityName, const std::string& networkId, int32_t errCode); - bool OriginalSwitchState(const std::string& switchState, int32_t errCode); - bool ChangedSwitchState(const std::string& switchState, int32_t errCode); + bool OriginalSwitchState(bool isContinueSwitchOn, int32_t errCode); + bool ChangedSwitchState(bool isContinueSwitchOn, int32_t errCode); int32_t GetDeviceTypeByNetworkId(std::string networkId); std::string ConvertErrCodeToStr(int32_t errorCode); diff --git a/services/dtbschedmgr/src/continue/dsched_continue.cpp b/services/dtbschedmgr/src/continue/dsched_continue.cpp index f23c43f8..ae15ed91 100644 --- a/services/dtbschedmgr/src/continue/dsched_continue.cpp +++ b/services/dtbschedmgr/src/continue/dsched_continue.cpp @@ -1065,9 +1065,6 @@ int32_t DSchedContinue::ExecuteContinueEnd(int32_t result) NotifyDSchedEventResult(result); DurationDumperComplete(result); - DmsUE::GetInstance().DmsContinueComplete(continueInfo_.sourceBundleName_, continueInfo_.sinkAbilityName_, - continueInfo_.sourceDeviceId_, result); - DSchedContinueManager::GetInstance().OnContinueEnd(continueInfo_); HILOGI("ExecuteContinueEnd end"); return ERR_OK; @@ -1113,6 +1110,8 @@ void DSchedContinue::DurationDumperComplete(int32_t result) std::string strEndTime = DmsContinueTime::GetInstance().GetCurrentTime(); DmsContinueTime::GetInstance().SetDurationEnd(CONTINUE_TOTAL_TIME, GetTickCount()); DmsContinueTime::GetInstance().SetDurationStrTime(CONTINUE_END_TIME, strEndTime); + DmsUE::GetInstance().DmsContinueComplete(continueInfo_.sourceBundleName_, continueInfo_.sinkAbilityName_, + continueInfo_.sourceDeviceId_, result); DmsContinueTime::GetInstance().AppendInfo(); DmsContinueTime::GetInstance().SetPull(false); } diff --git a/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp b/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp index 35850857..873b31dd 100644 --- a/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp +++ b/services/dtbschedmgr/src/dfx/dms_continue_time_dumper.cpp @@ -46,7 +46,7 @@ constexpr int32_t DMSDURATION_DSTTOSRCRPCTIME = 3; constexpr int32_t DMSDURATION_SAVETIME = 4; constexpr int32_t DMSDURATION_SRCTODSTRPCTIME = 5; constexpr int32_t DMSDURATION_STARTABILITY = 6; -constexpr int32_t DMSDURATION_INFOISEMPTY = 0; +constexpr int32_t DMSDURATION_EMPTY_TIME = 0; } IMPLEMENT_SINGLE_INSTANCE(DmsContinueTime); @@ -419,12 +419,12 @@ void DmsContinueTime::ShowInfo(std::string& result) int64_t DmsContinueTime::GetTotalTime() { - int32_t totalTime = durationInfo_[DMSDURATION_TOTALTIME].GetDurationTime(); - if (!totalTime) { - HILOGE("totalTime is empty"); - return DMSDURATION_INFOISEMPTY; + HILOGD("GetTotalTime start, durationInfo_.size is %{public}lu", durationInfo_.size()); + if (durationInfo_.empty() || durationInfo_.size() < DMSDURATION_TOTALTIME) { + HILOGE("totalTime is not exist."); + return DMSDURATION_EMPTY_TIME; } - return totalTime; + return durationInfo_[DMSDURATION_TOTALTIME].GetEndTime() - durationInfo_[DMSDURATION_TOTALTIME].GetBeginTime(); } } } \ No newline at end of file diff --git a/services/dtbschedmgr/src/distributed_sched_service.cpp b/services/dtbschedmgr/src/distributed_sched_service.cpp index 361b790c..ec4ee509 100644 --- a/services/dtbschedmgr/src/distributed_sched_service.cpp +++ b/services/dtbschedmgr/src/distributed_sched_service.cpp @@ -335,8 +335,7 @@ void DistributedSchedService::InitDataShareManager() HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId); return; } - std::string switchState = IsContinueSwitchOn ? "1" : "0"; - DmsUE::GetInstance().ChangedSwitchState(switchState, ERR_OK); + DmsUE::GetInstance().ChangedSwitchState(IsContinueSwitchOn, ERR_OK); if (IsContinueSwitchOn) { DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT); DSchedContinueManager::GetInstance().Init(); @@ -347,8 +346,7 @@ void DistributedSchedService::InitDataShareManager() }; }; dataShareManager_.RegisterObserver(CONTINUE_SWITCH_STATUS_KEY, observerCallback); - std::string switchState = SwitchStatusDependency::GetInstance().IsContinueSwitchOn() ? "1" : "0"; - DmsUE::GetInstance().OriginalSwitchState(switchState, ERR_OK); + DmsUE::GetInstance().OriginalSwitchState(SwitchStatusDependency::GetInstance().IsContinueSwitchOn(), ERR_OK); HILOGI("Init data share manager, register observer end."); } @@ -1200,6 +1198,9 @@ void DistributedSchedService::NotifyCompleteContinuation(const std::u16string& d HILOGE("continuation object null!"); return; } + int dSchedEventResult = dschedContinuation_->NotifyDSchedEventResult(ERR_OK); + HILOGD("NotifyDSchedEventResult result:%{public}d", dSchedEventResult); + std::string dstInfo(""); if (DmsContinueTime::GetInstance().GetPull()) { int64_t end = GetTickCount(); @@ -1207,18 +1208,19 @@ void DistributedSchedService::NotifyCompleteContinuation(const std::u16string& d DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_STARTABILITY, end); DmsContinueTime::GetInstance().SetDurationEnd(DMSDURATION_TOTALTIME, end); DmsContinueTime::GetInstance().SetDurationStrTime(DMSDURATION_ENDTIME, strEndTime); + + std::string bundleName = DmsContinueTime::GetInstance().GetDstInfo().bundleName; + std::string abilityName = DmsContinueTime::GetInstance().GetDstInfo().abilityName; + std::string srcNetworkId = dschedContinuation_->continueInfo_.srcNetworkId_; + DmsUE::GetInstance().DmsContinueComplete(bundleName, abilityName, srcNetworkId, dSchedEventResult); + DmsContinueTime::GetInstance().AppendInfo(); DmsContinueTime::GetInstance().SetPull(false); } else { dstInfo = DmsContinueTime::GetInstance().WriteDstInfo(DmsContinueTime::GetInstance().GetDstInfo().bundleName, DmsContinueTime::GetInstance().GetDstInfo().abilityName); } - int dSchedEventResult = dschedContinuation_->NotifyDSchedEventResult(ERR_OK); - HILOGD("NotifyDSchedEventResult result:%{public}d", dSchedEventResult); - std::string bundleName = DmsContinueTime::GetInstance().GetDstInfo().bundleName; - std::string abilityName = DmsContinueTime::GetInstance().GetDstInfo().abilityName; - std::string srcNetworkId = dschedContinuation_->continueInfo_.srcNetworkId_; - DmsUE::GetInstance().DmsContinueComplete(bundleName, abilityName, srcNetworkId, dSchedEventResult); + remoteDms->NotifyContinuationResultFromRemote(sessionId, isSuccess, dstInfo); dschedContinuation_->continueInfo_.srcNetworkId_ = ""; dschedContinuation_->continueInfo_.dstNetworkId_ = ""; diff --git a/services/dtbschedmgr/src/distributed_ue.cpp b/services/dtbschedmgr/src/distributed_ue.cpp index 25902a7f..4f47dd8d 100644 --- a/services/dtbschedmgr/src/distributed_ue.cpp +++ b/services/dtbschedmgr/src/distributed_ue.cpp @@ -134,9 +134,10 @@ bool DmsUE::DmsContinueComplete(const std::string& bundleName, const std::string return true; } -bool DmsUE::OriginalSwitchState(const std::string& switchState, int32_t errCode) +bool DmsUE::OriginalSwitchState(bool isContinueSwitchOn, int32_t errCode) { int32_t res = ERR_OK; + std::string switchState = isContinueSwitchOn ? "1" : "0"; if (errCode == ERR_OK) { res = HiSysEventWrite( CONTINUATION_DOMAIN, @@ -162,9 +163,10 @@ bool DmsUE::OriginalSwitchState(const std::string& switchState, int32_t errCode) return true; } -bool DmsUE::ChangedSwitchState(const std::string& switchState, int32_t errCode) +bool DmsUE::ChangedSwitchState(bool isContinueSwitchOn, int32_t errCode) { int32_t res = ERR_OK; + std::string switchState = isContinueSwitchOn ? "1" : "0"; if (errCode == ERR_OK) { res = HiSysEventWrite( CONTINUATION_DOMAIN,