diff options
author | Nikita Putikhin <nputikhin@google.com> | 2023-12-15 09:47:35 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-12-15 09:47:35 +0000 |
commit | c315f49b2ee6b88ad0883346a6a999971326b425 (patch) | |
tree | 009d777191ba178478bfafb00cf5681740a3b057 | |
parent | 53f0ce5f59166a566701718860f39ac468b10f2e (diff) | |
parent | 3ff648d5ffb150b43b0fd155af577ad0fe2613d1 (diff) | |
download | libhardware_legacy-c315f49b2ee6b88ad0883346a6a999971326b425.tar.gz |
Merge "Check that ISystemSuspend is declared before acquiring a wake lock" into main
-rw-r--r-- | power.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -40,8 +40,15 @@ static std::unordered_map<std::string, std::shared_ptr<IWakeLock>> gWakeLockMap; static const std::shared_ptr<ISystemSuspend> getSystemSuspendServiceOnce() { static std::shared_ptr<ISystemSuspend> suspendService = - ISystemSuspend::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService( - (ISystemSuspend::descriptor + std::string("/default")).c_str()))); + []() -> std::shared_ptr<ISystemSuspend> { + std::string suspendServiceName = + ISystemSuspend::descriptor + std::string("/default"); + if (!AServiceManager_isDeclared(suspendServiceName.c_str())) { + return nullptr; + } + return ISystemSuspend::fromBinder(ndk::SpAIBinder( + AServiceManager_waitForService(suspendServiceName.c_str()))); + }(); return suspendService; } |