From 514e9b732cd62f120134da6eb68ac57ed6e65a32 Mon Sep 17 00:00:00 2001 From: guoyi Date: Sun, 3 Nov 2024 20:51:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: guoyi --- etc/init/deviceprofile.cfg | 1 + .../core/src/distributed_device_profile_service.cpp | 3 +++ .../core/include/distributed_device_profile_service_new.h | 2 +- .../core/src/distributed_device_profile_service_new.cpp | 6 +++--- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/etc/init/deviceprofile.cfg b/etc/init/deviceprofile.cfg index 2294b983..16c085c6 100644 --- a/etc/init/deviceprofile.cfg +++ b/etc/init/deviceprofile.cfg @@ -17,6 +17,7 @@ "permission" : [ "ohos.permission.DISTRIBUTED_DATASYNC", "ohos.permission.ACCESS_SERVICE_DM", + "ohos.permission.MANAGE_LOCAL_ACCOUNTS", "ohos.permission.MONITOR_DEVICE_NETWORK_STATE" ], "permission_acls" : ["ohos.permission.MONITOR_DEVICE_NETWORK_STATE"], diff --git a/old/services/core/src/distributed_device_profile_service.cpp b/old/services/core/src/distributed_device_profile_service.cpp index 345ba48e..b16113c2 100644 --- a/old/services/core/src/distributed_device_profile_service.cpp +++ b/old/services/core/src/distributed_device_profile_service.cpp @@ -291,6 +291,9 @@ void DistributedDeviceProfileService::OnStop() void DistributedDeviceProfileService::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { HILOGI("called systemAbilityId:%{public}d", systemAbilityId); + if (systemAbilityId == SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN) { + DistributedDeviceProfile::DistributedDeviceProfileServiceNew::GetInstance().SubscribeAccountCommonEvent(); + } if (DistributedDeviceProfile::DistributedDeviceProfileServiceNew::GetInstance().IsInited()) { return; } diff --git a/services/core/include/distributed_device_profile_service_new.h b/services/core/include/distributed_device_profile_service_new.h index 3b4f1b1a..522b8622 100644 --- a/services/core/include/distributed_device_profile_service_new.h +++ b/services/core/include/distributed_device_profile_service_new.h @@ -73,6 +73,7 @@ public: int32_t Dump(int32_t fd, const std::vector& args) override; void DelayUnloadTask() override; bool IsInited() override; + void SubscribeAccountCommonEvent(); protected: void OnStart(const SystemAbilityOnDemandReason& startReason) override; @@ -89,7 +90,6 @@ private: int32_t SaveSwitchProfilesFromTempCache(); int32_t SaveDynamicProfilesFromTempCache(); int32_t NotifyDeviceProfileInited(); - void SubscribeAccountCommonEvent(); void GetDynamicProfilesFromTempCache(std::map& entries); void ClearProfileCache(); diff --git a/services/core/src/distributed_device_profile_service_new.cpp b/services/core/src/distributed_device_profile_service_new.cpp index 52bfb23f..2c13efa2 100644 --- a/services/core/src/distributed_device_profile_service_new.cpp +++ b/services/core/src/distributed_device_profile_service_new.cpp @@ -606,6 +606,9 @@ int32_t DistributedDeviceProfileServiceNew::OnIdle(const SystemAbilityOnDemandRe void DistributedDeviceProfileServiceNew::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { HILOGI("called systemAbilityId:%{public}d", systemAbilityId); + if (systemAbilityId == SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN) { + SubscribeAccountCommonEvent(); + } if (DistributedDeviceProfile::DistributedDeviceProfileServiceNew::GetInstance().IsInited()) { return; } @@ -619,9 +622,6 @@ void DistributedDeviceProfileServiceNew::OnAddSystemAbility(int32_t systemAbilit return; } } - if (systemAbilityId == SUBSYS_ACCOUNT_SYS_ABILITY_ID_BEGIN) { - SubscribeAccountCommonEvent(); - } PostInit(); }