PowerManagerService: use waitForService.

Instead of while(true) sleep1

Bug: N/A
Test: boot
Change-Id: I6f316fd1f9634b827f003998995e6358dde15a83
This commit is contained in:
Steven Moreland
2019-08-27 18:20:05 -07:00
parent 3ffad04add
commit d9b00ae794

View File

@@ -201,13 +201,8 @@ sp<ISystemSuspend> getSuspendHal() {
sp<ISuspendControlService> getSuspendControl() {
static std::once_flag suspendControlFlag;
std::call_once(suspendControlFlag, [](){
while(gSuspendControl == nullptr) {
sp<IBinder> control =
defaultServiceManager()->getService(String16("suspend_control"));
if (control != nullptr) {
gSuspendControl = interface_cast<ISuspendControlService>(control);
}
}
gSuspendControl = waitForService<ISuspendControlService>(String16("suspend_control"));
LOG_ALWAYS_FATAL_IF(gSuspendControl == nullptr);
});
return gSuspendControl;
}