Don't retry getting binderized services without servicemanager.
Bug: 32257169
Test: StartVibratorService took to complete: 20ms
Change-Id: Ie48d358b050a5ad7aa4d64e1432e4186e08e0b11
diff --git a/include/hidl/HidlSupport.h b/include/hidl/HidlSupport.h
index c3ec8f5..d5df337 100644
--- a/include/hidl/HidlSupport.h
+++ b/include/hidl/HidlSupport.h
@@ -536,15 +536,13 @@
sp<I##INTERFACE> iface; \
const struct timespec DELAY {1,0}; \
unsigned retries = 3; \
- if (!getStub) { \
+ const sp<IServiceManager> sm = defaultServiceManager(); \
+ if (sm != nullptr && !getStub) { \
do { \
- const sp<IServiceManager> sm = defaultServiceManager(); \
- if (sm != nullptr) { \
- sp<IBinder> binderIface = \
- sm->checkService(String16(serviceName.c_str()), \
- I##INTERFACE::version); \
- iface = IHw##INTERFACE::asInterface(binderIface); \
- } \
+ sp<IBinder> binderIface = \
+ sm->checkService(String16(serviceName.c_str()), \
+ I##INTERFACE::version); \
+ iface = IHw##INTERFACE::asInterface(binderIface); \
if (iface != nullptr) { \
return iface; \
} \