summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2019-11-07 00:24:57 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-11-07 00:24:57 +0000
commit0b5ac42f5bd65fbe76fbc4b01dec7d8c5144ea7e (patch)
tree589c866591259d7d8702be9e7a5902228ba3e1e9
parent8f0bd5a0900dff092fc9e613c7e6bc0d6c5d292e (diff)
parentf1b02a4ad3253d69b96e071296a5be445c24e29d (diff)
Merge "libbinder: checkVintfService"
-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();