libbinder: waitForVintfService
Services in the VINTF interface are registered by type. This is a
convenient function to avoid needing to know and reproduce the format
when registering a service.
Bug: 136027762
Test: using the function
Change-Id: I2b2b10385525937e1b82c94858a13dafa0c4b1d2
diff --git a/libs/binder/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h
index 4a44c5a..bd77567 100644
--- a/libs/binder/include/binder/IServiceManager.h
+++ b/libs/binder/include/binder/IServiceManager.h
@@ -114,6 +114,13 @@
}
template<typename INTERFACE>
+sp<INTERFACE> waitForVintfService(
+ const String16& instance = String16("default")) {
+ return waitForDeclaredService<INTERFACE>(
+ INTERFACE::descriptor + String16("/") + instance);
+}
+
+template<typename INTERFACE>
status_t getService(const String16& name, sp<INTERFACE>* outService)
{
const sp<IServiceManager> sm = defaultServiceManager();