diff options
author | Steven Moreland <smoreland@google.com> | 2019-11-06 16:39:16 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-11-06 16:39:16 -0800 |
commit | 1f678c2408148246a8a28273c9c6016ddf3868f3 (patch) | |
tree | 64fe0c116ab1099626bf2cc9f7d008f7f7f369f1 | |
parent | 2f78d9df0ef144092270c851f07dd0a988b18970 (diff) | |
parent | 0b5ac42f5bd65fbe76fbc4b01dec7d8c5144ea7e (diff) | |
download | native-1f678c2408148246a8a28273c9c6016ddf3868f3.tar.gz |
Merge "libbinder: checkVintfService"
am: 0b5ac42f5b
Change-Id: I07c694a6c7b967de8c72189b7f23d300cb9b330b
-rw-r--r-- | libs/binder/include/binder/IServiceManager.h | 14 |
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(); |