diff --git a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h index 730b6f7e1e197cfcf41046700cd2a7a85480e74c..5c6145ec70ce41f595cb8244de198a886984393d 100644 --- a/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h +++ b/services/distributedhardwarefwkservice/include/componentmanager/component_manager.h @@ -94,8 +94,7 @@ public: const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid); int32_t ForceDisableSink(const DHDescriptor &dhDescriptor); int32_t ForceDisableSource(const std::string &networkId, const DHDescriptor &dhDescriptor); - int32_t CheckIdenticalAccount(const std::string &networkId, - const std::string &uuid, const DHDescriptor &dhDescriptor); + int32_t CheckIdenticalAccount(const std::string &networkId); class ComponentManagerEventHandler : public AppExecFwk::EventHandler { public: diff --git a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp index 86285c9e9223ab9f317039b4b0a39395f37a2228..47adca01cb7be38a3e984703635498f718761b44 100644 --- a/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp +++ b/services/distributedhardwarefwkservice/src/componentmanager/component_manager.cpp @@ -1008,6 +1008,8 @@ int32_t ComponentManager::DisableSink(const DHDescriptor &dhDescriptor, int32_t int32_t ComponentManager::EnableSource(const std::string &networkId, const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) { + DHLOGI("Begin enable source, networkId: %{public}s, dhType: %{public}#X.", + GetAnonyString(networkId).c_str(), dhDescriptor.dhType); sptr listener; int32_t ret = EnableSourceInternal(networkId, dhDescriptor, callingUid, callingPid, listener); if (ret == DH_FWK_SUCCESS) { @@ -1016,12 +1018,16 @@ int32_t ComponentManager::EnableSource(const std::string &networkId, DHLOGI("Callback business source OnEnable."); } } + DHLOGI("End enable source, networkId: %{public}s, dhType: %{public}#X.", + GetAnonyString(networkId).c_str(), dhDescriptor.dhType); return ret; } int32_t ComponentManager::DisableSource(const std::string &networkId, const DHDescriptor &dhDescriptor, int32_t callingUid, int32_t callingPid) { + DHLOGI("Begin disable source, networkId: %{public}s, dhType: %{public}#X.", + GetAnonyString(networkId).c_str(), dhDescriptor.dhType); sptr listener; int32_t ret = DisableSourceInternal(networkId, dhDescriptor, callingUid, callingPid, listener); if (ret == DH_FWK_SUCCESS) { @@ -1030,6 +1036,8 @@ int32_t ComponentManager::DisableSource(const std::string &networkId, DHLOGI("Callback business source OnDisable."); } } + DHLOGI("End disable source, networkId: %{public}s, dhType: %{public}#X.", + GetAnonyString(networkId).c_str(), dhDescriptor.dhType); return ret; } @@ -1059,24 +1067,14 @@ int32_t ComponentManager::ForceDisableSource(const std::string &networkId, const return ret; } -int32_t ComponentManager::CheckIdenticalAccount(const std::string &networkId, - const std::string &uuid, const DHDescriptor &dhDescriptor) +int32_t ComponentManager::CheckIdenticalAccount(const std::string &networkId) { - EnableParam param; - auto ret = GetEnableParam(networkId, uuid, dhDescriptor.id, dhDescriptor.dhType, param); - if (ret != DH_FWK_SUCCESS) { - DHLOGE("GetEnableParam failed, uuid = %{public}s, dhId = %{public}s, errCode = %{public}d", - GetAnonyString(uuid).c_str(), GetAnonyString(dhDescriptor.id).c_str(), ret); - if (ComponentManager::GetInstance().RetryGetEnableParam( - networkId, uuid, dhDescriptor.id, dhDescriptor.dhType, param) != DH_FWK_SUCCESS) { - return ret; - } - } - ret = CheckSubtypeResource(param.subtype, networkId); - if (ret != DH_FWK_SUCCESS) { - DHLOGE("CheckSubtypeResource failed, ret = %{public}d.", ret); - return ret; +#ifdef DHARDWARE_CHECK_RESOURCE + if (!IsIdenticalAccount(networkId)) { + DHLOGE("Enable resources must be logged in with the same account."); + return ERR_DH_FWK_COMPONENT_ENABLE_FAILED; } +#endif return DH_FWK_SUCCESS; } diff --git a/services/distributedhardwarefwkservice/src/task/offline_task.cpp b/services/distributedhardwarefwkservice/src/task/offline_task.cpp index 5b9c0c9058ad9cbe0ab126b211cc34d64460630f..105966ea7b7790a79b9a87dafa6205627fd6583c 100644 --- a/services/distributedhardwarefwkservice/src/task/offline_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/offline_task.cpp @@ -22,6 +22,7 @@ #include "anonymous_string.h" #include "capability_info_manager.h" +#include "component_manager.h" #include "constants.h" #include "device_manager.h" #include "dh_context.h" @@ -108,6 +109,10 @@ void OffLineTask::CreateDisableTask() { DHLOGI("networkId = %{public}s, uuid = %{public}s", GetAnonyString(GetNetworkId()).c_str(), GetAnonyString(GetUUID()).c_str()); + if (ComponentManager::GetInstance().CheckIdenticalAccount(GetNetworkId()) != DH_FWK_SUCCESS) { + DHLOGE("Check identical account failed, networkId: %{public}s.", GetAnonyString(GetNetworkId()).c_str()); + return; + } std::string deviceId = GetDeviceIdByUUID(GetUUID()); std::vector> devDhInfos; std::vector> capabilityInfos; diff --git a/services/distributedhardwarefwkservice/src/task/online_task.cpp b/services/distributedhardwarefwkservice/src/task/online_task.cpp index e044b8170981d08396db55cfe3386703876e594b..5cf51bf50b83d9ec52b0c15822c7bfea171b6548 100644 --- a/services/distributedhardwarefwkservice/src/task/online_task.cpp +++ b/services/distributedhardwarefwkservice/src/task/online_task.cpp @@ -17,6 +17,7 @@ #include "anonymous_string.h" #include "capability_info_manager.h" +#include "component_manager.h" #include "device_manager.h" #include "dh_utils_tool.h" #include "distributed_hardware_errno.h" @@ -105,6 +106,10 @@ void OnLineTask::CreateEnableTask() { DHLOGI("CreateEnableTask, networkId: %{public}s, uuid: %{public}s, udid: %{public}s", GetAnonyString(GetNetworkId()).c_str(), GetAnonyString(GetUUID()).c_str(), GetAnonyString(GetUDID()).c_str()); + if (ComponentManager::GetInstance().CheckIdenticalAccount(GetNetworkId()) != DH_FWK_SUCCESS) { + DHLOGE("Check identical account failed, networkId: %{public}s.", GetAnonyString(GetNetworkId()).c_str()); + return; + } std::string deviceId = GetDeviceIdByUUID(GetUUID()); std::vector> devDhInfos; std::vector> capabilityInfos;