add ue dot

Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
dengxiaoyu 2024-07-10 18:16:29 +08:00
parent afe84eee73
commit f5cbc49604
8 changed files with 357 additions and 1 deletions

View File

@ -125,6 +125,7 @@ ohos_shared_library("distributedschedsvr") {
"src/distributed_sched_proxy.cpp", "src/distributed_sched_proxy.cpp",
"src/distributed_sched_service.cpp", "src/distributed_sched_service.cpp",
"src/distributed_sched_stub.cpp", "src/distributed_sched_stub.cpp",
"src/distributed_ue.cpp",
"src/dms_callback_task.cpp", "src/dms_callback_task.cpp",
"src/dms_free_install_callback.cpp", "src/dms_free_install_callback.cpp",
"src/dms_free_install_callback_proxy.cpp", "src/dms_free_install_callback_proxy.cpp",

View File

@ -96,6 +96,8 @@ public:
void AppendInfo(); void AppendInfo();
void ShowInfo(std::string& result); void ShowInfo(std::string& result);
int64_t GetTotalTime();
private: private:
bool isPull_; bool isPull_;
std::list<std::string> timeInfoList_; std::list<std::string> timeInfoList_;

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_DISTRIBUTED_UE_H
#define OHOS_DISTRIBUTED_UE_H
#include <cstdint>
#include <chrono>
#include <string>
#include <vector>
#include "dsched_continue.h"
#include "dtbschedmgr_device_info_storage.h"
#include "dtbschedmgr_log.h"
#include "single_instance.h"
namespace OHOS {
namespace DistributedSchedule {
const std::string CONTINUATION_BEHAVIOR = "CONTINUATION_BEHAVIOR";
const std::string ERROR_CODE_UE = "ERROR_CODE_UE";
const std::string PNAMEID = "PNAMEID";
const std::string PVERSIONID = "PVERSIONID";
const std::string BUNDLE_NAME = "BUNDLE_NAME";
const std::string ABILITY_NAME = "ABILITY_NAME";
const std::string SOURCE_DEVICE_TYPE = "SOURCE_DEVICE_TYPE";
const std::string CONTINUATION_STATE = "CONTINUATION_STATE";
const std::string FAILED_EXTRAINFO = "FAILED_EXTRAINFO";
const std::string CONTINUATION_DURATION = "CONTINUATION_DURATION";
const std::string SWITCH_STATE = "SWITCH_STATE";
const std::string SHOW_CONTINUATION_ICON = "SHOW_CONTINUATION_ICON";
const std::string CLICK_CONTINUATION_ICON = "CLICK_CONTINUATION_ICON";
const std::string COMPLETE_OF_CONTINUATION = "COMPLETE_OF_CONTINUATION";
const std::string ORIGINAL_SWITCH_STATE = "ORIGINAL_SWITCH_STATE";
const std::string CHANGED_SWITCH_STATE = "CHANGED_SWITCH_STATE";
constexpr char CONTINUATION_DOMAIN[] = "CONTINUATION_UE";
enum class continuationState : int32_t {
CONTINUATION_SUCC = 0;
CONTINUATION_FAIL = -1;
};
class DmsUE {
DECLARE_SINGLE_INSTANCE(DmsUE);
public:
bool NotifyDockShowIcon(const std::string& bundleName, const std::string& abilityName,
const std::string& networkId, int32_t errCode);
bool TriggerDmsContinue(const std::string& bundleName, const std::string& abilityName,
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);
int32_t GetDeviceTypeByNetworkId(std::string networkId);
std::string ConvertErrCodeToStr(int32_t errorCode);
};
} // namespace DistributedSchedule
} // namespace OHOS
#endif // OHOS_DISTRIBUTED_UE_H

View File

@ -29,6 +29,7 @@
#include "distributed_sched_permission.h" #include "distributed_sched_permission.h"
#include "distributed_sched_service.h" #include "distributed_sched_service.h"
#include "distributed_sched_utils.h" #include "distributed_sched_utils.h"
#include "distributed_ue.h"
#include "dsched_continue_event.h" #include "dsched_continue_event.h"
#include "dsched_continue_manager.h" #include "dsched_continue_manager.h"
#include "dsched_data_buffer.h" #include "dsched_data_buffer.h"
@ -454,6 +455,9 @@ int32_t DSchedContinue::ExecuteContinueReq(std::shared_ptr<DistributedWantParams
std::string peerUdid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(peerDeviceId); std::string peerUdid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(peerDeviceId);
DmsRadar::GetInstance().ClickIconDmsContinue("ContinueMission", ERR_OK, peerUdid); DmsRadar::GetInstance().ClickIconDmsContinue("ContinueMission", ERR_OK, peerUdid);
DmsUE::GetInstance().TriggerDmsContinue(continueInfo_.sinkBundleName_, continueInfo_.sinkAbilityName_,
continueInfo_.sourceDeviceId_, ERR_OK)
if (subServiceType_ == CONTINUE_PULL && CheckQuickStartConfiguration()) { if (subServiceType_ == CONTINUE_PULL && CheckQuickStartConfiguration()) {
QuickStartAbility(); QuickStartAbility();
} }
@ -1061,6 +1065,9 @@ int32_t DSchedContinue::ExecuteContinueEnd(int32_t result)
NotifyDSchedEventResult(result); NotifyDSchedEventResult(result);
DurationDumperComplete(result); DurationDumperComplete(result);
DmsUE::GetInstance().DmsContinueComplete(continueInfo_.sourceBundleName_, continueInfo_.sinkAbilityName_,
continueInfo_.sourceDeviceId_, result);
DSchedContinueManager::GetInstance().OnContinueEnd(continueInfo_); DSchedContinueManager::GetInstance().OnContinueEnd(continueInfo_);
HILOGI("ExecuteContinueEnd end"); HILOGI("ExecuteContinueEnd end");
return ERR_OK; return ERR_OK;

View File

@ -415,5 +415,10 @@ void DmsContinueTime::ShowInfo(std::string& result)
nIdx++; nIdx++;
} }
} }
int64_t DmsContinueTime::GetTotalTime()
{
return durationInfo_[DMSDURATION_TOTALTIME].GetDurationTime();
}
} }
} }

View File

@ -51,6 +51,7 @@
#include "distributed_sched_dumper.h" #include "distributed_sched_dumper.h"
#include "distributed_sched_permission.h" #include "distributed_sched_permission.h"
#include "distributed_sched_utils.h" #include "distributed_sched_utils.h"
#include "distributed_ue.h"
#include "dms_callback_task.h" #include "dms_callback_task.h"
#include "dms_constant.h" #include "dms_constant.h"
#include "dms_free_install_callback.h" #include "dms_free_install_callback.h"
@ -334,7 +335,8 @@ void DistributedSchedService::InitDataShareManager()
HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId); HILOGW("GetCurrentMissionId failed, init end. ret: %{public}d", missionId);
return; return;
} }
std::string switchState = IsContinueSwitchOn ? "1" : "0";
DmsUE::GetInstance().ChangedSwitchState(switchState, ERR_OK);
if (IsContinueSwitchOn) { if (IsContinueSwitchOn) {
DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT); DMSContinueSendMgr::GetInstance().NotifyMissionFocused(missionId, FocusedReason::INIT);
DSchedContinueManager::GetInstance().Init(); DSchedContinueManager::GetInstance().Init();
@ -345,6 +347,8 @@ void DistributedSchedService::InitDataShareManager()
}; };
}; };
dataShareManager_.RegisterObserver(CONTINUE_SWITCH_STATUS_KEY, observerCallback); dataShareManager_.RegisterObserver(CONTINUE_SWITCH_STATUS_KEY, observerCallback);
std::string switchState = SwitchStatusDependency::GetInstance().IsContinueSwitchOn() ? "1" : "0";
DmsUE::GetInstance().OriginalSwitchState(switchState, ERR_OK);
HILOGI("Init data share manager, register observer end."); HILOGI("Init data share manager, register observer end.");
} }
@ -898,6 +902,18 @@ int32_t DistributedSchedService::ContinueRemoteMission(const std::string& srcDev
} }
std::string peerUdid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(srcDeviceId); std::string peerUdid = DtbschedmgrDeviceInfoStorage::GetInstance().GetUdidByNetworkId(srcDeviceId);
DmsRadar::GetInstance().ClickIconDmsContinue("ContinueMission", ERR_OK, peerUdid); DmsRadar::GetInstance().ClickIconDmsContinue("ContinueMission", ERR_OK, peerUdid);
MissionInfo missionInfo;
int32_t ret AAFwk::AbilityManagerClient::GetInstance()->GetMissionInfo("", missionId, missionInfo);
if (ret != ERR_OK) {
HILOGE("GeGetMissionInfo failed %{public}d", ret);
return ret;
}
std::string bundleName = missionInfo.want.GetElement().GetBundleName();
std::string abilityName = missionInfo.want.GetElement().GetAbilityName();
HILOGD("bundlename: %{public}s, ability is %{public}s", bundleName.c_str(), abilityName.c_str());
DmsUE::GetInstance().TriggerDmsContinue(bundleName, abilityName, srcDeviceId, ERR_OK);
int32_t result = remoteDms->ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams); int32_t result = remoteDms->ContinueMission(srcDeviceId, dstDeviceId, missionId, callback, wantParams);
HILOGI("ContinueRemoteMission result: %{public}d!", result); HILOGI("ContinueRemoteMission result: %{public}d!", result);
return result; return result;
@ -1199,6 +1215,10 @@ void DistributedSchedService::NotifyCompleteContinuation(const std::u16string& d
} }
int dSchedEventResult = dschedContinuation_->NotifyDSchedEventResult(ERR_OK); int dSchedEventResult = dschedContinuation_->NotifyDSchedEventResult(ERR_OK);
HILOGD("NotifyDSchedEventResult result:%{public}d", dSchedEventResult); 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); remoteDms->NotifyContinuationResultFromRemote(sessionId, isSuccess, dstInfo);
dschedContinuation_->continueInfo_.srcNetworkId_ = ""; dschedContinuation_->continueInfo_.srcNetworkId_ = "";
dschedContinuation_->continueInfo_.dstNetworkId_ = ""; dschedContinuation_->continueInfo_.dstNetworkId_ = "";

View File

@ -0,0 +1,238 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "dfx/dms_continue_time_dumper.h"
#include "distributed_ue.h"
#include "dms_constant.h"
#include "hisysevent.h"
namespace OHOS {
namespace DistributedSchedule {
namespace {
const std::string TAG = "DmsUE";
const std::string NO_FAILED_EXTRAINFO = "NULL";
constexpr int32_t DEVICE_TYPE_UNKNOWN = 0;
}
IMPLEMENT_SINGLE_INSTANCE(DmsUE);
bool DmsUE::NotifyDockShowIcon(const std::string& bundleName, const std::string& abilityName,
const std::string& networkId, int32_t errCode)
{
int32_t res = ERR_OK;
if(errCode == ERR_OK) {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
SHOW_CONTINUATION_ICON,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId));
} else {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
SHOW_CONTINUATION_ICON,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId)
ERROR_CODE_UE, errCode);
}
if (res != ERR_OK) {
HILOGE("NotifyDockShowIcon error, res:%{public}d", res);
return false;
}
return true;
}
bool DmsUE::TriggerDmsContinue(const std::string& bundleName, const std::string& abilityName,
const std::string& networkId, int32_t errCode)
{
int32_t res = ERR_OK;
if (errCode == ERR_OK) {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
CLICK_CONTINUATION_ICON,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId));
} else {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
CLICK_CONTINUATION_ICON,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId),
ERROR_CODE, errCode);
}
if (res != ERR_OK) {
HILOGE("TriggerDmsContinue error, res:%{public}d", res);
return false;
}
return true;
}
bool DmsUE::DmsContinueComplete(const std::string& bundleName, const std::string& abilityName,
const std::string& networkId, int32_t errCode)
{
int32_t res = ERR_OK;
if (errCode == ERR_OK) {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
COMPLETE_OF_CONTINUATION,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId),
CONTINUATION_STATE, static_cast<int32_t>(continuationState::CONTINUATION_SUCC),
FAILED_EXTRAINFO, NO_FAILED_EXTRAINFO,
CONTINUATION_DURATION, DmsContinueTime::GetInstance().GetTotalTime());
} else {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
COMPLETE_OF_CONTINUATION,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
BUNDLE_NAME, bundleName,
ABILITY_NAME, abilityName,
SOURCE_DEVICE_TYPE, GetDeviceTypeByNetworkId(networkId),
CONTINUATION_STATE, static_cast<int32_t>(continuationState::CONTINUATION_FAIL),
FAILED_EXTRAINFO, ConvertErrCodeToStr(errCode),
CONTINUATION_DURATION, DmsContinueTime::GetInstance().GetTotalTime(),
ERROR_CODE, errCode);
}
if (res != ERR_OK) {
HILOGE("DmsContinueComplete error, res:%{public}d", res);
return false;
}
return true;
}
bool DmsUE::OriginalSwitchState(const std::string& switchState, int32_t errCode)
{
int32_t res = ERR_OK;
if (errCode == ERR_OK) {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
ORIGINAL_SWITCH_STATE,
HiviewDFX::HiSysEvent::EventType::STATISTIC,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
SWITCH_STATE, switchState);
} else {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
ORIGINAL_SWITCH_STATE,
HiviewDFX::HiSysEvent::EventType::STATISTIC,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
SWITCH_STATE, switchState,
ERROR_CODE, errCode);
}
if (res != ERR_OK) {
HILOGE("OriginalSwitchState error, res:%{public}d", res);
return false;
}
return true;
}
bool DmsUE::ChangedSwitchState(const std::string& switchState, int32_t errCode)
{
int32_t res = ERR_OK;
if (errCode == ERR_OK) {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
CHANGED_SWITCH_STATE,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
SWITCH_STATE, switchState);
} else {
res = HiSysEventWrite(
CONTINUATION_DOMAIN,
CHANGED_SWITCH_STATE,
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
PNAMEID, CONTINUATION_DOMAIN,
PVERSIONID, Constants::DMS_VERSION,
SWITCH_STATE, switchState,
ERROR_CODE, errCode);
}
if (res != ERR_OK) {
HILOGE("ChangedSwitchState error, res:%{public}d", res);
return false;
}
return true;
}
int32_t DmsUE::GetDeviceTypeByNetworkId(int32_t networkId)
{
auto deviceInfo = DtbschedmgrDeviceInfoStorage::GetInstance().GetDeviceInfoById(networkId);
if (deviceInfo == nullptr) {
return DEVICE_TYPE_UNKNOWN;
}
return deviceInfo->GetDeviceType();
}
std::string DmsUE::ConvertErrCodeToStr(int32_t errorCode)
{
switch(errorCode) {
case INVALID_PARAMETERS_ERR:
return "invalid parameters";
case INVALID_REMOTE_PARAMETERS_ERR:
return "remote invalid parameters";
case DMS_START_CONTROL_PERMISSION_DENIED:
return "start control permission check failed";
case NO_MISSION_INFO_FOR_MISSION_ID:
return "failed to get the missionInfo of the specified missionId";
case OPERATION_DEVICE_NOT_INITIATOR_OR_TARGET:
return "the operation device must be the target device to be continued";
case CONTINUE_ALREADY_IN_PROGRESS:
return "the local continuation task is already in progress";
case MISSION_FOR_CONTINUING_IS_NOT_ALIVE:
return "the mission for continuing is not alive, try again after restart mission.";
case CONTINUE_SEND_EVENT_FAILED:
return "sending event failed during continuation";
case CONTINUE_STATE_MACHINE_INVALID_STATE:
return "state machine receving invalid state code";
case CONTINUE_SESSION_SHUTDOWN:
return "session shutdown during continuation";
case CONTINUE_CALL_CONTINUE_ABILITY_FAILED:
return "calling ContinueAbility failed during continuation";
case CONTINUE_CALL_START_ABILITY_FAILED:
return "calling StartAbility failed during continuation";
case CONTINUE_SINK_ABILITY_TERMINATED:
return "sink Ability abnormal termination during continuation";
case DMS_CONNECT_APPLY_REJECT_FAILED:
return "all connect manager reject connect apply";
default:
return "internal error";
}
}
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -24,6 +24,7 @@
#include "distributed_sched_adapter.h" #include "distributed_sched_adapter.h"
#include "dtbschedmgr_device_info_storage.h" #include "dtbschedmgr_device_info_storage.h"
#include "dtbschedmgr_log.h" #include "dtbschedmgr_log.h"
#include "distributed_ue.h"
#include "parcel_helper.h" #include "parcel_helper.h"
#include "softbus_adapter/softbus_adapter.h" #include "softbus_adapter/softbus_adapter.h"
#include "switch_status_dependency.h" #include "switch_status_dependency.h"
@ -331,6 +332,13 @@ void DMSContinueRecvMgr::NotifyRecvBroadcast(const sptr<IRemoteObject>& obj,
if (!res) { if (!res) {
HILOGE("%{public}s failed", (state == INACTIVE) ? "NotifyDockUnfocused" : "NotifyDockFocused"); HILOGE("%{public}s failed", (state == INACTIVE) ? "NotifyDockUnfocused" : "NotifyDockFocused");
} }
if (state != INACTIVE) {
std::string bName = bundleName;
std::string cType = continueType;
std::string abilityName = BundleDistributedManager::GetInstance().GetAbilityName(netwokId,
bName, cType)
DmsUE::GetInstance().NotifyDockShowIcon(bundleName, abilityName, networkId, error);
}
if (error != ERR_NONE) { if (error != ERR_NONE) {
HILOGE("NotifyRecvBroadcast fail, error: %{public}d", error); HILOGE("NotifyRecvBroadcast fail, error: %{public}d", error);
return; return;