IServiceManager: Improve getService responsiveness in absence of service
Now blocks for 4 seconds worst case instead of 5 seconds.
Some android devices may not have all the normal android phone services.
Test: Wear device on feldspar-dev
Bug: 33086228
Change-Id: Id83fc8cd6b657b53ef78823a460d5fba4a522ab4
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 2062b3b..3aeff2e 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -135,10 +135,12 @@
{
unsigned n;
for (n = 0; n < 5; n++){
+ if (n > 0) {
+ ALOGI("Waiting for service %s...", String8(name).string());
+ sleep(1);
+ }
sp<IBinder> svc = checkService(name);
if (svc != NULL) return svc;
- ALOGI("Waiting for service %s...\n", String8(name).string());
- sleep(1);
}
return NULL;
}