diff --git a/interfaces/inner_api/src/standard/device_security_level_loader.cpp b/interfaces/inner_api/src/standard/device_security_level_loader.cpp index 70b37671b6760b6eb4ed47a41be49815e40e0ed5..b9e25faff45fcaf34b77edf979d6b0549a7942ef 100644 --- a/interfaces/inner_api/src/standard/device_security_level_loader.cpp +++ b/interfaces/inner_api/src/standard/device_security_level_loader.cpp @@ -26,6 +26,8 @@ #include "device_security_level_defines.h" #include "idevice_security_level.h" +constexpr uint32_t MAX_LOAD_TIMEOUT = 30; + namespace OHOS { namespace Security { namespace DeviceSecurityLevel { @@ -70,7 +72,13 @@ void DeviceSecurityLevelLoader::LoadCallback::OnLoadSystemAbilityFail(int32_t si sptr DeviceSecurityLevelLoader::LoadCallback::Promise() { - return promise_.get_future().get(); + std::future> future = promise_.get_future(); + if (future.wait_for(std::chrono::seconds(MAX_LOAD_TIMEOUT)) == std::future_status::timeout) { + HILOG_ERROR(LOG_CORE, "DeviceSecurityLevelLoader loadCallback timeout error."); + return nullptr; + } + + return future.get(); } } // namespace DeviceSecurityLevel } // namespace Security