From 3eedf6a7303cb14a762dc6716a9ab95239fafd15 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Thu, 10 Oct 2024 16:40:47 +0800 Subject: [PATCH 01/11] code check Signed-off-by: dengxiaoyu --- interfaces/innerkits/distributed_event/src/dms_sa_client.cpp | 1 + .../dtbschedmgr/src/mission/dms_continue_send_manager.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp index 5e59042d..134b87a7 100644 --- a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp +++ b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp @@ -26,6 +26,7 @@ DmsSaClient &DmsSaClient::GetInstance() bool DmsSaClient::SubscribeDmsSA() { HILOGD("called."); + std::lock_guard lock(saMgrMutex_); if (!saMgrProxy_) { HILOGE("saMgrProxy_ is null."); return false; diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index ba4888bc..2a0e3ced 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -240,6 +240,10 @@ int32_t DMSContinueSendMgr::SendSoftbusEvent(uint16_t bundleNameId, uint8_t cont HILOGD("SendSoftbusEvent start, bundleNameId: %{public}u, continueTypeId: %{public}u", bundleNameId, continueTypeId); std::shared_ptr buffer = std::make_shared(DMS_SEND_LEN); + if (buffer->Data() == nullptr) { + HILOGE("Failed to initialize DSchedDataBuffer"); + return INVALID_PARAMETERS_ERR; + } buffer->Data()[0] = (type << CONTINUE_SHIFT_04) | DMS_DATA_LEN; buffer->Data()[1] = (bundleNameId >> CONTINUE_SHIFT_08) & DMS_0XFF; buffer->Data()[INDEX_2] = bundleNameId & DMS_0XFF; From 7455d7a6ceb5f85059431ab93780bc6feb7b9fd2 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Thu, 10 Oct 2024 20:57:47 +0800 Subject: [PATCH 02/11] code check Signed-off-by: dengxiaoyu --- interfaces/innerkits/distributed_event/src/dms_sa_client.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp index 134b87a7..5e59042d 100644 --- a/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp +++ b/interfaces/innerkits/distributed_event/src/dms_sa_client.cpp @@ -26,7 +26,6 @@ DmsSaClient &DmsSaClient::GetInstance() bool DmsSaClient::SubscribeDmsSA() { HILOGD("called."); - std::lock_guard lock(saMgrMutex_); if (!saMgrProxy_) { HILOGE("saMgrProxy_ is null."); return false; From fd622edd89b1ac60563f48e0df40b8f683da6d01 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 11 Oct 2024 19:22:22 +0800 Subject: [PATCH 03/11] optimize log Signed-off-by: dengxiaoyu --- common/include/dtbschedmgr_log.h | 20 ++++++++++ .../include/distributed_sched_permission.h | 2 +- .../src/continue/dsched_continue.cpp | 2 +- .../src/distributed_sched_permission.cpp | 38 ++++++++++--------- .../src/mission/dms_continue_send_manager.cpp | 7 ++-- 5 files changed, 47 insertions(+), 22 deletions(-) diff --git a/common/include/dtbschedmgr_log.h b/common/include/dtbschedmgr_log.h index c405cbdc..2035f4fb 100644 --- a/common/include/dtbschedmgr_log.h +++ b/common/include/dtbschedmgr_log.h @@ -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 diff --git a/services/dtbschedmgr/include/distributed_sched_permission.h b/services/dtbschedmgr/include/distributed_sched_permission.h index e5f099ea..436063ba 100644 --- a/services/dtbschedmgr/include/distributed_sched_permission.h +++ b/services/dtbschedmgr/include/distributed_sched_permission.h @@ -70,7 +70,7 @@ private: AccountInfo& accountInfo); bool ParseGroupInfos(const std::string& returnGroupStr, std::vector& 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; diff --git a/services/dtbschedmgr/src/continue/dsched_continue.cpp b/services/dtbschedmgr/src/continue/dsched_continue.cpp index 9c1cb5ad..b72ae217 100644 --- a/services/dtbschedmgr/src/continue/dsched_continue.cpp +++ b/services/dtbschedmgr/src/continue/dsched_continue.cpp @@ -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; } diff --git a/services/dtbschedmgr/src/distributed_sched_permission.cpp b/services/dtbschedmgr/src/distributed_sched_permission.cpp index 7fddc20b..58bcfcf7 100644 --- a/services/dtbschedmgr/src/distributed_sched_permission.cpp +++ b/services/dtbschedmgr/src/distributed_sched_permission.cpp @@ -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, diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index 2a0e3ced..d26e8081 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -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 buffer = std::make_shared(DMS_SEND_LEN); - if (buffer->Data() == nullptr) { - HILOGE("Failed to initialize DSchedDataBuffer"); + if (buffer->Data() == nullptr || buffer->Size()Size(), DMS_SEND_LEN); return INVALID_PARAMETERS_ERR; } buffer->Data()[0] = (type << CONTINUE_SHIFT_04) | DMS_DATA_LEN; From d86ef81d0a6b3e4da5db6c07237ccd6b780e1c11 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Fri, 11 Oct 2024 22:00:35 +0800 Subject: [PATCH 04/11] optimize log Signed-off-by: dengxiaoyu --- services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index d26e8081..ccbdc891 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -241,8 +241,7 @@ int32_t DMSContinueSendMgr::SendSoftbusEvent(uint16_t bundleNameId, uint8_t cont bundleNameId, continueTypeId); std::shared_ptr buffer = std::make_shared(DMS_SEND_LEN); if (buffer->Data() == nullptr || buffer->Size()Size(), DMS_SEND_LEN); + HILOGE("Failed to initialize DSchedDataBuffer."); return INVALID_PARAMETERS_ERR; } buffer->Data()[0] = (type << CONTINUE_SHIFT_04) | DMS_DATA_LEN; From b1ab4bfee24bbf3ac50261e01bf857bc86c73cfd Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 09:20:12 +0800 Subject: [PATCH 05/11] optimize log Signed-off-by: dengxiaoyu --- services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index ccbdc891..51f4a420 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -240,7 +240,7 @@ int32_t DMSContinueSendMgr::SendSoftbusEvent(uint16_t bundleNameId, uint8_t cont HILOGD("SendSoftbusEvent start, bundleNameId: %{public}u, continueTypeId: %{public}u", bundleNameId, continueTypeId); std::shared_ptr buffer = std::make_shared(DMS_SEND_LEN); - if (buffer->Data() == nullptr || buffer->Size()Data() == nullptr || buffer->Size() < DMS_SEND_LEN) { HILOGE("Failed to initialize DSchedDataBuffer."); return INVALID_PARAMETERS_ERR; } From c0dbec613fb76d31a4496331b4ad548e5ff588ca Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 12:06:49 +0800 Subject: [PATCH 06/11] optimize log Signed-off-by: dengxiaoyu --- services/dtbschedmgr/src/dfx/distributed_radar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/dtbschedmgr/src/dfx/distributed_radar.cpp b/services/dtbschedmgr/src/dfx/distributed_radar.cpp index c4a5082d..850dc1da 100644 --- a/services/dtbschedmgr/src/dfx/distributed_radar.cpp +++ b/services/dtbschedmgr/src/dfx/distributed_radar.cpp @@ -810,7 +810,8 @@ bool DmsRadar::ClickIconDmsStartAbility(const std::string& func, int32_t errCode bool DmsRadar::ClickIconDmsRecvOver(const std::string& func, int32_t errCode) { int32_t res = ERR_OK; - StageRes stageRes = (errCode == ERR_OK) ? StageRes::STAGE_SUCC : StageRes::STAGE_FAIL; + StageRes stageRes = (errCode == ERR_OK || errCode == MISSION_NOT_FOCUSED || + errCode == MISSION_NOT_CONTINUE_ACTIVE) ? StageRes::STAGE_SUCC : StageRes::STAGE_FAIL; if (stageRes == StageRes::STAGE_SUCC) { res = HiSysEventWrite( APP_CONTINUE_DOMAIN, From e6822025a0d2c314b4532f6b93dc5c4779e3fc06 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 15:34:12 +0800 Subject: [PATCH 07/11] optimize log Signed-off-by: dengxiaoyu --- services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp index 51f4a420..749ce4aa 100644 --- a/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp +++ b/services/dtbschedmgr/src/mission/dms_continue_send_manager.cpp @@ -241,7 +241,7 @@ int32_t DMSContinueSendMgr::SendSoftbusEvent(uint16_t bundleNameId, uint8_t cont bundleNameId, continueTypeId); std::shared_ptr buffer = std::make_shared(DMS_SEND_LEN); if (buffer->Data() == nullptr || buffer->Size() < DMS_SEND_LEN) { - HILOGE("Failed to initialize DSchedDataBuffer."); + HILOGE("Failed to initialize DSchedDataBuffer"); return INVALID_PARAMETERS_ERR; } buffer->Data()[0] = (type << CONTINUE_SHIFT_04) | DMS_DATA_LEN; From 3d251babd4f3640441c952b2889a8b715df44d67 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 17:14:43 +0800 Subject: [PATCH 08/11] optimize log Signed-off-by: dengxiaoyu --- .../src/distributed_sched_permission.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/services/dtbschedmgr/src/distributed_sched_permission.cpp b/services/dtbschedmgr/src/distributed_sched_permission.cpp index 58bcfcf7..f95ff629 100644 --- a/services/dtbschedmgr/src/distributed_sched_permission.cpp +++ b/services/dtbschedmgr/src/distributed_sched_permission.cpp @@ -519,18 +519,22 @@ int32_t DistributedSchedPermission::CheckAccountAccessPermission(const CallerInf } HILOGI("check same account by DM fail, will try check access Group by hichain"); #endif - + int32_t result = ERR_OK; if (!DistributedSchedAdapter::GetInstance().CheckAccessToGroup(udid, targetBundleName)) { HILOGE("CheckAccessToGroup by HiChain failed."); - return CHECK_ACCESS_FAILED_BY_HICHAIN; - } + result = 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)) { - HILOGE("Check different account ACL by DM failed, CheckAccessControl failed."); - return CHECK_ACCESS_FAILED_BY_DM; + HILOGI("Check access Group by hichain fail, will try check different account ACL by DM."); + if (!DeviceManager::GetInstance().CheckAccessControl(dmSrcCaller, dmDstCallee)) { + HILOGE("Check different account ACL by DM failed, CheckAccessControl failed."); + result = CHECK_ACCESS_FAILED_BY_DM; + } else { + HILOGI("Check different account ACL by DM success"); + result = ERR_OK; + } } - return ERR_OK; + HILOGI("CheckAccessToGroup by HiChain success."); + return result; } bool DistributedSchedPermission::CheckComponentAccessPermission(const AppExecFwk::AbilityInfo& targetAbility, From d6202b891a70807a6820733aaf2771f6e0e21590 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 17:36:17 +0800 Subject: [PATCH 09/11] optimize log Signed-off-by: dengxiaoyu --- .../include/distributed_sched_permission.h | 2 +- .../src/distributed_sched_permission.cpp | 43 ++++++++----------- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/services/dtbschedmgr/include/distributed_sched_permission.h b/services/dtbschedmgr/include/distributed_sched_permission.h index 436063ba..e5f099ea 100644 --- a/services/dtbschedmgr/include/distributed_sched_permission.h +++ b/services/dtbschedmgr/include/distributed_sched_permission.h @@ -70,7 +70,7 @@ private: AccountInfo& accountInfo); bool ParseGroupInfos(const std::string& returnGroupStr, std::vector& groupInfos); bool VerifyPermission(uint32_t accessToken, const std::string& permissionName) const; - int32_t CheckAccountAccessPermission(const CallerInfo& callerInfo, + bool 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; diff --git a/services/dtbschedmgr/src/distributed_sched_permission.cpp b/services/dtbschedmgr/src/distributed_sched_permission.cpp index f95ff629..1e42c714 100644 --- a/services/dtbschedmgr/src/distributed_sched_permission.cpp +++ b/services/dtbschedmgr/src/distributed_sched_permission.cpp @@ -111,10 +111,9 @@ int32_t DistributedSchedPermission::CheckSendResultPermission(const AAFwk::Want& const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility) { // 1.check account access permission in no account networking environment. - int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName); - if (ret != ERR_OK) { + if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) { HILOGE("CheckAccountAccessPermission denied or failed!"); - return ret; + return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED; } // 2.check component access permission, when the ability is not visible. if (!CheckComponentAccessPermission(targetAbility, callerInfo, accountInfo, want)) { @@ -129,10 +128,9 @@ 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. - int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName); - if (ret != ERR_OK) { + if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) { HILOGE("CheckAccountAccessPermission denied or failed!"); - return ret; + return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED; } // 2.check start control permissions. if (!CheckStartControlPermission(targetAbility, callerInfo, want, isSameBundle)) { @@ -341,10 +339,9 @@ int32_t DistributedSchedPermission::CheckGetCallerPermission(const AAFwk::Want& const AccountInfo& accountInfo, AppExecFwk::AbilityInfo& targetAbility) { // 1.check account access permission in no account networking environment. - int32_t ret = CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName); - if (ret != ERR_OK) { + if (!CheckAccountAccessPermission(callerInfo, accountInfo, targetAbility.bundleName)) { HILOGE("CheckAccountAccessPermission denied or failed!"); - return ret; + return DMS_ACCOUNT_ACCESS_PERMISSION_DENIED; } // 2. check call with same appid if (!BundleManagerInternal::IsSameAppId(callerInfo.callerAppId, targetAbility.bundleName)) { @@ -487,14 +484,14 @@ bool DistributedSchedPermission::VerifyPermission(uint32_t accessToken, const st return true; } -int32_t DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo& callerInfo, +bool 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 GET_LOCAL_DEVICE_ERR; + return false; } DmAccessCaller dmSrcCaller = { .accountId = accountInfo.activeAccountId, @@ -519,22 +516,18 @@ int32_t DistributedSchedPermission::CheckAccountAccessPermission(const CallerInf } HILOGI("check same account by DM fail, will try check access Group by hichain"); #endif - int32_t result = ERR_OK; - if (!DistributedSchedAdapter::GetInstance().CheckAccessToGroup(udid, targetBundleName)) { - HILOGE("CheckAccessToGroup by HiChain failed."); - result = 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)) { - HILOGE("Check different account ACL by DM failed, CheckAccessControl failed."); - result = CHECK_ACCESS_FAILED_BY_DM; - } else { - HILOGI("Check different account ACL by DM success"); - result = ERR_OK; - } + if (DistributedSchedAdapter::GetInstance().CheckAccessToGroup(udid, targetBundleName)) { + return true; } - HILOGI("CheckAccessToGroup by HiChain success."); - return result; + + HILOGI("Check access Group by hichain fail, will try check different account ACL by DM."); + if (DeviceManager::GetInstance().CheckAccessControl(dmSrcCaller, dmDstCallee)) { + return true; + } + + HILOGE("Check different account ACL by DM fail."); + return false; } bool DistributedSchedPermission::CheckComponentAccessPermission(const AppExecFwk::AbilityInfo& targetAbility, From 3e88a87f92bcd33ccee047a0153bb66e3f07abc5 Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 17:44:09 +0800 Subject: [PATCH 10/11] optimize log Signed-off-by: dengxiaoyu --- common/include/dtbschedmgr_log.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/common/include/dtbschedmgr_log.h b/common/include/dtbschedmgr_log.h index 2035f4fb..2d9e3e58 100644 --- a/common/include/dtbschedmgr_log.h +++ b/common/include/dtbschedmgr_log.h @@ -513,18 +513,6 @@ enum { * 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 From fe57a82a64e91ca4d902409474ed24b6cb3e417e Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Sat, 12 Oct 2024 17:46:33 +0800 Subject: [PATCH 11/11] optimize log Signed-off-by: dengxiaoyu --- services/dtbschedmgr/src/distributed_sched_permission.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/services/dtbschedmgr/src/distributed_sched_permission.cpp b/services/dtbschedmgr/src/distributed_sched_permission.cpp index 1e42c714..7fddc20b 100644 --- a/services/dtbschedmgr/src/distributed_sched_permission.cpp +++ b/services/dtbschedmgr/src/distributed_sched_permission.cpp @@ -510,9 +510,8 @@ bool DistributedSchedPermission::CheckAccountAccessPermission(const CallerInfo& dmSrcCaller.pkgName.c_str(), GetAnonymStr(dmDstCallee.networkId).c_str()); #ifdef DMSFWK_SAME_ACCOUNT - if (!DeviceManager::GetInstance().CheckIsSameAccount(dmSrcCaller, dmDstCallee)) { - HILOGE("Check same account ACL by DM fail."); - return ACCOUNT_NOT_SAME_BY_DM; + if (DeviceManager::GetInstance().CheckIsSameAccount(dmSrcCaller, dmDstCallee)) { + return true; } HILOGI("check same account by DM fail, will try check access Group by hichain"); #endif