Skip to content

Commit efc9eec

Browse files
Steven Morelandandroid-build-merger
authored andcommitted
Merge "libbinder: checkVintfService" am: 0b5ac42 am: 1f678c2
am: 7b5d159 Change-Id: I0d77c6298dc6bf8b18f756ca460aef492349dce6
2 parents 1d439cf + 7b5d159 commit efc9eec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libs/binder/include/binder/IServiceManager.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,27 @@ sp<INTERFACE> waitForDeclaredService(const String16& name) {
113113
return interface_cast<INTERFACE>(sm->waitForService(name));
114114
}
115115

116+
template <typename INTERFACE>
117+
sp<INTERFACE> checkDeclaredService(const String16& name) {
118+
const sp<IServiceManager> sm = defaultServiceManager();
119+
if (!sm->isDeclared(name)) return nullptr;
120+
return interface_cast<INTERFACE>(sm->checkService(name));
121+
}
122+
116123
template<typename INTERFACE>
117124
sp<INTERFACE> waitForVintfService(
118125
const String16& instance = String16("default")) {
119126
return waitForDeclaredService<INTERFACE>(
120127
INTERFACE::descriptor + String16("/") + instance);
121128
}
122129

130+
template<typename INTERFACE>
131+
sp<INTERFACE> checkVintfService(
132+
const String16& instance = String16("default")) {
133+
return checkDeclaredService<INTERFACE>(
134+
INTERFACE::descriptor + String16("/") + instance);
135+
}
136+
123137
template<typename INTERFACE>
124138
status_t getService(const String16& name, sp<INTERFACE>* outService)
125139
{

0 commit comments

Comments
 (0)