diff --git a/services/core/jni/com_android_server_power_PowerManagerService.cpp b/services/core/jni/com_android_server_power_PowerManagerService.cpp index 73bb579bd2740..4e0434873944b 100644 --- a/services/core/jni/com_android_server_power_PowerManagerService.cpp +++ b/services/core/jni/com_android_server_power_PowerManagerService.cpp @@ -201,13 +201,8 @@ sp getSuspendHal() { sp getSuspendControl() { static std::once_flag suspendControlFlag; std::call_once(suspendControlFlag, [](){ - while(gSuspendControl == nullptr) { - sp control = - defaultServiceManager()->getService(String16("suspend_control")); - if (control != nullptr) { - gSuspendControl = interface_cast(control); - } - } + gSuspendControl = waitForService(String16("suspend_control")); + LOG_ALWAYS_FATAL_IF(gSuspendControl == nullptr); }); return gSuspendControl; }