optimize log

Signed-off-by: dengxiaoyu <dengxiaoyu6@huawei.com>
This commit is contained in:
dengxiaoyu 2024-10-11 19:22:22 +08:00
parent 7455d7a6ce
commit fd622edd89
5 changed files with 47 additions and 22 deletions

View File

@ -505,6 +505,26 @@ enum {
* Result(29360232) for all connect manager deal connect apply timeout.
*/
DMS_CONNECT_APPLY_TIMEOUT_FAILED = 29360232,
/**
* Result(29360233) for mission continue state is not active.
*/
MISSION_NOT_CONTINUE_ACTIVE = 29360233,
/**
* Result(29360234) for mission is not focused.
*/
MISSION_NOT_FOCUSED = 29360234,
/**
* Result(29360235) for check access failed by DM, account is not same.
*/
ACCOUNT_NOT_SAME_BY_DM = 29360235,
/**
* Result(29360236) for check access failed by HiChain.
*/
CHECK_ACCESS_FAILED_BY_HICHAIN = 29360236,
/**
* Result(29360237) for check access failed by DM.
*/
CHECK_ACCESS_FAILED_BY_DM = 29360237,
};
} // namespace DistributedSchedule
} // namespace OHOS

View File

@ -70,7 +70,7 @@ private:
AccountInfo& accountInfo);
bool ParseGroupInfos(const std::string& returnGroupStr, std::vector<GroupInfo>& groupInfos);
bool VerifyPermission(uint32_t accessToken, const std::string& permissionName) const;
bool CheckAccountAccessPermission(const CallerInfo& callerInfo,
int32_t CheckAccountAccessPermission(const CallerInfo& callerInfo,
const AccountInfo& accountInfo, const std::string& targetBundleName);
bool CheckComponentAccessPermission(const AppExecFwk::AbilityInfo& targetAbility,
const CallerInfo& callerInfo, const AccountInfo& accountInfo, const AAFwk::Want& want) const;

View File

@ -723,7 +723,7 @@ int32_t DSchedContinue::CheckContinueAbilityPermission()
if (missionInfo.continueState != AAFwk::ContinueState::CONTINUESTATE_ACTIVE) {
HILOGE("Mission continue state set to INACTIVE. Can't continue. Mission id: %{public}d",
continueInfo_.missionId_);
return INVALID_PARAMETERS_ERR;
return MISSION_NOT_CONTINUE_ACTIVE;
}
return ERR_OK;
}

View File

@ -111,9 +111,10 @@ int32_t DistributedSchedPermission::CheckSendResultPermission(const AAFwk::Want&
const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility)
{
// 1.check account access permission in no account networking environment.
if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) {
int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName);
if (ret != ERR_OK) {
HILOGE("CheckAccountAccessPermission denied or failed!");
return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED;
return ret;
}
// 2.check component access permission, when the ability is not visible.
if (!CheckComponentAccessPermission(targetAbility, callerInfo, accountInfo, want)) {
@ -128,9 +129,10 @@ int32_t DistributedSchedPermission::CheckStartPermission(const AAFwk::Want& want
const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility, bool isSameBundle)
{
// 1.check account access permission in no account networking environment.
if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) {
int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName);
if (ret != ERR_OK) {
HILOGE("CheckAccountAccessPermission denied or failed!");
return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED;
return ret;
}
// 2.check start control permissions.
if (!CheckStartControlPermission(targetAbility, callerInfo, want, isSameBundle)) {
@ -339,9 +341,10 @@ int32_t DistributedSchedPermission::CheckGetCallerPermission(const AAFwk::Want&
const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility)
{
// 1.check account access permission in no account networking environment.
if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) {
int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName);
if (ret != ERR_OK) {
HILOGE("CheckAccountAccessPermission denied or failed!");
return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED;
return ret;
}
// 2. check call with same appid
if (!BundleManagerInternal::IsSameAppId(callerInfo.callerAppId, targetAbility.bundleName)) {
@ -484,14 +487,14 @@ bool DistributedSchedPermission::VerifyPermission(uint32_t accessToken, const st
return true;
}
bool DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo& callerInfo,
int32_t DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo& callerInfo,
const AccountInfo& accountInfo, const std::string& targetBundleName)
{
std::string udid = DnetworkAdapter::GetInstance()->GetUdidByNetworkId(callerInfo.sourceDeviceId);
std::string dstNetworkId;
if (!DtbschedmgrDeviceInfoStorage::GetInstance().GetLocalDeviceId(dstNetworkId)) {
HILOGE("GetLocalDeviceId failed");
return false;
return GET_LOCAL_DEVICE_ERR;
}
DmAccessCaller dmSrcCaller = {
.accountId = accountInfo.activeAccountId,
@ -510,23 +513,24 @@ bool DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo&
dmSrcCaller.pkgName.c_str(), GetAnonymStr(dmDstCallee.networkId).c_str());
#ifdef DMSFWK_SAME_ACCOUNT
if (DeviceManager::GetInstance().CheckIsSameAccount(dmSrcCaller, dmDstCallee)) {
return true;
if (!DeviceManager::GetInstance().CheckIsSameAccount(dmSrcCaller, dmDstCallee)) {
HILOGE("Check same account ACL by DM fail.");
return ACCOUNT_NOT_SAME_BY_DM;
}
HILOGI("check same account by DM fail, will try check access Group by hichain");
#endif
if (DistributedSchedAdapter::GetInstance().CheckAccessToGroup(udid, targetBundleName)) {
return true;
if (!DistributedSchedAdapter::GetInstance().CheckAccessToGroup(udid, targetBundleName)) {
HILOGE("CheckAccessToGroup by HiChain failed.");
return CHECK_ACCESS_FAILED_BY_HICHAIN;
}
HILOGI("Check access Group by hichain fail, will try check different account ACL by DM.");
if (DeviceManager::GetInstance().CheckAccessControl(dmSrcCaller, dmDstCallee)) {
return true;
if (!DeviceManager::GetInstance().CheckAccessControl(dmSrcCaller, dmDstCallee)) {
HILOGE("Check different account ACL by DM failed, CheckAccessControl failed.");
return CHECK_ACCESS_FAILED_BY_DM;
}
HILOGE("Check different account ACL by DM fail.");
return false;
return ERR_OK;
}
bool DistributedSchedPermission::CheckComponentAccessPermission(const AppExecFwk::AbilityInfo& targetAbility,

View File

@ -214,7 +214,7 @@ int32_t DMSContinueSendMgr::GetMissionIdByBundleName(const std::string& bundleNa
HILOGI("get missionId end, missionId: %{public}d", missionId);
return ERR_OK;
}
return INVALID_PARAMETERS_ERR;
return MISSION_NOT_FOCUSED;
}
void DMSContinueSendMgr::StartEvent()
@ -240,8 +240,9 @@ int32_t DMSContinueSendMgr::SendSoftbusEvent(uint16_t bundleNameId, uint8_t cont
HILOGD("SendSoftbusEvent start, bundleNameId: %{public}u, continueTypeId: %{public}u",
bundleNameId, continueTypeId);
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(DMS_SEND_LEN);
if (buffer->Data() == nullptr) {
HILOGE("Failed to initialize DSchedDataBuffer");
if (buffer->Data() == nullptr || buffer->Size()<DMS_SEND_LEN) {
HILOGE("Failed to initialize DSchedDataBuffer. Initialized size: %{public}zu,
Expected size: %{public}u", buffer->Size(), DMS_SEND_LEN);
return INVALID_PARAMETERS_ERR;
}
buffer->Data()[0] = (type << CONTINUE_SHIFT_04) | DMS_DATA_LEN;