From ce8931202677156d71ec378383dd2ef0c7de963c Mon Sep 17 00:00:00 2001 From: chenbingbing Date: Wed, 25 Sep 2024 20:42:54 +0800 Subject: [PATCH] cherry pick 4c1a375 from https://gitee.com/gong-guilin/systemabilitymgr_samgr/pulls/1039 remove GetSystemAbility interface last wait Signed-off-by: chenbingbing --- frameworks/native/source/system_ability_manager_proxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/native/source/system_ability_manager_proxy.cpp b/frameworks/native/source/system_ability_manager_proxy.cpp index 77d70dbf..e22da020 100644 --- a/frameworks/native/source/system_ability_manager_proxy.cpp +++ b/frameworks/native/source/system_ability_manager_proxy.cpp @@ -39,7 +39,7 @@ namespace OHOS { namespace { const int32_t MAX_TIMEOUT = 4; const int32_t MIN_TIMEOUT = 0; -const int32_t RETRY_TIME_OUT_NUMBER = 5; +const int32_t RETRY_TIME_OUT_NUMBER = 6; const int32_t SLEEP_INTERVAL_TIME = 200; const int32_t GET_SYSTEM_ABILITY_CODE = 1; const int32_t CHECK_SYSTEM_ABILITY_CODE = 2; @@ -185,8 +185,6 @@ sptr SystemAbilityManagerProxy::GetSystemAbilityWrapper(int32_t s } if (!isExist) { HILOGD("%{public}s:SA:%{public}d is not exist", __func__, systemAbilityId); - usleep(SLEEP_ONE_MILLI_SECOND_TIME * SLEEP_INTERVAL_TIME); - continue; } } else { svc = CheckSystemAbility(systemAbilityId, deviceId, errCode); @@ -199,7 +197,9 @@ sptr SystemAbilityManagerProxy::GetSystemAbilityWrapper(int32_t s if (svc != nullptr) { return svc; } - usleep(SLEEP_ONE_MILLI_SECOND_TIME * SLEEP_INTERVAL_TIME); + if (timeout > 0) { + usleep(SLEEP_ONE_MILLI_SECOND_TIME * SLEEP_INTERVAL_TIME); + } } while (timeout--); HILOGE("GetSaWrap SA:%{public}d not start", systemAbilityId); return nullptr; -- Gitee