summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/binder/include/binder/IServiceManager.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/binder/include/binder/IServiceManager.h b/libs/binder/include/binder/IServiceManager.h
index bd77567290..2c4326393e 100644
--- a/libs/binder/include/binder/IServiceManager.h
+++ b/libs/binder/include/binder/IServiceManager.h
@@ -113,6 +113,13 @@ sp<INTERFACE> waitForDeclaredService(const String16& name) {
return interface_cast<INTERFACE>(sm->waitForService(name));
}
+template <typename INTERFACE>
+sp<INTERFACE> checkDeclaredService(const String16& name) {
+ const sp<IServiceManager> sm = defaultServiceManager();
+ if (!sm->isDeclared(name)) return nullptr;
+ return interface_cast<INTERFACE>(sm->checkService(name));
+}
+
template<typename INTERFACE>
sp<INTERFACE> waitForVintfService(
const String16& instance = String16("default")) {
@@ -121,6 +128,13 @@ sp<INTERFACE> waitForVintfService(
}
template<typename INTERFACE>
+sp<INTERFACE> checkVintfService(
+ const String16& instance = String16("default")) {
+ return checkDeclaredService<INTERFACE>(
+ INTERFACE::descriptor + String16("/") + instance);
+}
+
+template<typename INTERFACE>
status_t getService(const String16& name, sp<INTERFACE>* outService)
{
const sp<IServiceManager> sm = defaultServiceManager();