Merge "Check that ISystemSuspend is declared before acquiring a wake lock" into main am: c315f49b2e
Original change: https://android-review.googlesource.com/c/platform/hardware/libhardware_legacy/+/2870803 Change-Id: Ibe65e62a2ebbb8a98ffc540e7d2862e6456cdfd5 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
a39da7cb44
1 changed files with 9 additions and 2 deletions
11
power.cpp
11
power.cpp
|
@ -40,8 +40,15 @@ static std::unordered_map<std::string, std::shared_ptr<IWakeLock>> gWakeLockMap;
|
||||||
|
|
||||||
static const std::shared_ptr<ISystemSuspend> getSystemSuspendServiceOnce() {
|
static const std::shared_ptr<ISystemSuspend> getSystemSuspendServiceOnce() {
|
||||||
static std::shared_ptr<ISystemSuspend> suspendService =
|
static std::shared_ptr<ISystemSuspend> suspendService =
|
||||||
ISystemSuspend::fromBinder(ndk::SpAIBinder(AServiceManager_waitForService(
|
[]() -> std::shared_ptr<ISystemSuspend> {
|
||||||
(ISystemSuspend::descriptor + std::string("/default")).c_str())));
|
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;
|
return suspendService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue