From 3b36bcf7035c32fafe3070c54b427779467ad416 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Tue, 6 Dec 2016 09:40:01 -0800 Subject: [PATCH] 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 (cherry picked from commit 6456e4488d59c0568a1f29dc93b7beb472236086) --- libs/binder/IServiceManager.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp index 61f24d6805..44d235f0fc 100644 --- a/libs/binder/IServiceManager.cpp +++ b/libs/binder/IServiceManager.cpp @@ -140,10 +140,12 @@ public: { unsigned n; for (n = 0; n < 5; n++){ + if (n > 0) { + ALOGI("Waiting for service %s...", String8(name).string()); + sleep(1); + } sp svc = checkService(name); if (svc != NULL) return svc; - ALOGI("Waiting for service %s...\n", String8(name).string()); - sleep(1); } return NULL; } -- 2.11.0