From 9ef08eb9d9a4e9f677937df4e4416b84bdde4e63 Mon Sep 17 00:00:00 2001 From: lvyuanmin Date: Tue, 9 Aug 2022 17:16:56 +0800 Subject: [PATCH] add waitting samgr to ensure start-up sequence Signed-off-by: lvyuanmin --- frameworks/src/standard/ipc_adapt.cpp | 4 ++++ services/BUILD.gn | 2 ++ 2 files changed, 6 insertions(+) diff --git a/frameworks/src/standard/ipc_adapt.cpp b/frameworks/src/standard/ipc_adapt.cpp index f226caea..6fe6d58e 100644 --- a/frameworks/src/standard/ipc_adapt.cpp +++ b/frameworks/src/standard/ipc_adapt.cpp @@ -26,6 +26,7 @@ #include "iservice_registry.h" #include "securec.h" #include "system_ability_definition.h" +#include "parameter.h" using namespace std; using namespace OHOS; @@ -1331,6 +1332,9 @@ int32_t AddDevAuthServiceToManager(uintptr_t *serviceCtx) int32_t ret = ERR_OK; ServiceDevAuth *sPtr = nullptr; + // Wait samgr ready for up to 1 second to ensure adding service to samgr. + WaitParameter("bootevent.samgr.ready", "true", 1); + sptr sysMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); if (sysMgr == nullptr) { return HC_ERR_IPC_GET_SERVICE; diff --git a/services/BUILD.gn b/services/BUILD.gn index 03aa0ae6..cca5c161 100644 --- a/services/BUILD.gn +++ b/services/BUILD.gn @@ -229,6 +229,7 @@ if (os_level == "mini" || os_level == "small") { "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", + "init:libbegetutil", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", @@ -273,6 +274,7 @@ if (os_level == "mini" || os_level == "small") { "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", + "init:libbegetutil", "ipc:ipc_core", "samgr:samgr_proxy", ]