Lines Matching refs:name
40 static bool isVintfDeclared(const std::string& name) { in isVintfDeclared() argument
41 size_t firstSlash = name.find('/'); in isVintfDeclared()
42 size_t lastDot = name.rfind('.', firstSlash); in isVintfDeclared()
45 << "some.package.foo.IFoo/default) but got: " << name; in isVintfDeclared()
48 const std::string package = name.substr(0, lastDot); in isVintfDeclared()
49 const std::string iface = name.substr(lastDot+1, firstSlash-lastDot-1); in isVintfDeclared()
50 const std::string instance = name.substr(firstSlash+1); in isVintfDeclared()
67 LOG(INFO) << "Found " << name << " in " << mwd.description << " VINTF manifest."; in isVintfDeclared()
79 static bool meetsDeclarationRequirements(const sp<IBinder>& binder, const std::string& name) { in meetsDeclarationRequirements() argument
84 return isVintfDeclared(name); in meetsDeclarationRequirements()
107 for (const auto& [name, callbacks] : mNameToRegistrationCallback) { in ~ServiceManager()
108 CHECK(!callbacks.empty()) << name; in ~ServiceManager()
110 CHECK(callback != nullptr) << name; in ~ServiceManager()
114 for (const auto& [name, service] : mNameToService) { in ~ServiceManager()
115 CHECK(service.binder != nullptr) << name; in ~ServiceManager()
119 Status ServiceManager::getService(const std::string& name, sp<IBinder>* outBinder) { in getService() argument
120 *outBinder = tryGetService(name, true); in getService()
125 Status ServiceManager::checkService(const std::string& name, sp<IBinder>* outBinder) { in checkService() argument
126 *outBinder = tryGetService(name, false); in checkService()
131 sp<IBinder> ServiceManager::tryGetService(const std::string& name, bool startIfNotFound) { in tryGetService() argument
136 if (auto it = mNameToService.find(name); it != mNameToService.end()) { in tryGetService()
150 if (!mAccess->canFind(ctx, name)) { in tryGetService()
155 tryStartService(name); in tryGetService()
167 bool isValidServiceName(const std::string& name) { in isValidServiceName() argument
168 if (name.size() == 0) return false; in isValidServiceName()
169 if (name.size() > 127) return false; in isValidServiceName()
171 for (char c : name) { in isValidServiceName()
182 Status ServiceManager::addService(const std::string& name, const sp<IBinder>& binder, bool allowIso… in addService() argument
190 if (!mAccess->canAdd(ctx, name)) { in addService()
198 if (!isValidServiceName(name)) { in addService()
199 LOG(ERROR) << "Invalid service name: " << name; in addService()
204 if (!meetsDeclarationRequirements(binder, name)) { in addService()
212 LOG(ERROR) << "Could not linkToDeath when adding " << name; in addService()
216 auto entry = mNameToService.emplace(name, Service { in addService()
223 auto it = mNameToRegistrationCallback.find(name); in addService()
228 cb->onRegistration(name, binder); in addService()
241 for (auto const& [name, service] : mNameToService) { in listServices()
242 (void) name; in listServices()
250 for (auto const& [name, service] : mNameToService) { in listServices()
254 outList->push_back(name); in listServices()
262 const std::string& name, const sp<IServiceCallback>& callback) { in registerForNotifications() argument
265 if (!mAccess->canFind(ctx, name)) { in registerForNotifications()
269 if (!isValidServiceName(name)) { in registerForNotifications()
270 LOG(ERROR) << "Invalid service name: " << name; in registerForNotifications()
279 LOG(ERROR) << "Could not linkToDeath when adding " << name; in registerForNotifications()
283 mNameToRegistrationCallback[name].push_back(callback); in registerForNotifications()
285 if (auto it = mNameToService.find(name); it != mNameToService.end()) { in registerForNotifications()
289 CHECK(binder != nullptr) << name; in registerForNotifications()
290 callback->onRegistration(name, binder); in registerForNotifications()
296 const std::string& name, const sp<IServiceCallback>& callback) { in unregisterForNotifications() argument
299 if (!mAccess->canFind(ctx, name)) { in unregisterForNotifications()
305 auto it = mNameToRegistrationCallback.find(name); in unregisterForNotifications()
311 LOG(ERROR) << "Trying to unregister callback, but none exists " << name; in unregisterForNotifications()
318 Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) { in isDeclared() argument
321 if (!mAccess->canFind(ctx, name)) { in isDeclared()
328 *outReturn = isVintfDeclared(name); in isDeclared()
372 void ServiceManager::tryStartService(const std::string& name) { in tryStartService() argument
374 name.c_str()); in tryStartService()
377 (void)base::SetProperty("ctl.interface_start", "aidl/" + name); in tryStartService()
381 Status ServiceManager::registerClientCallback(const std::string& name, const sp<IBinder>& service, in registerClientCallback() argument
388 if (!mAccess->canAdd(ctx, name)) { in registerClientCallback()
392 auto serviceIt = mNameToService.find(name); in registerClientCallback()
394 LOG(ERROR) << "Could not add callback for nonexistent service: " << name; in registerClientCallback()
399 LOG(WARNING) << "Only a server can register for client callbacks (for " << name << ")"; in registerClientCallback()
404 LOG(WARNING) << "Tried to register client callback for " << name in registerClientCallback()
410 LOG(ERROR) << "Could not linkToDeath when adding client callback for " << name; in registerClientCallback()
414 mNameToClientCallback[name].push_back(cb); in registerClientCallback()
446 for (const auto& [name, service] : mNameToService) { in handleClientCallbacks()
447 handleServiceClientCallback(name, true); in handleClientCallbacks()
516 Status ServiceManager::tryUnregisterService(const std::string& name, const sp<IBinder>& binder) { in tryUnregisterService() argument
522 if (!mAccess->canAdd(ctx, name)) { in tryUnregisterService()
526 auto serviceIt = mNameToService.find(name); in tryUnregisterService()
528 LOG(WARNING) << "Tried to unregister " << name in tryUnregisterService()
534 LOG(WARNING) << "Only a server can unregister itself (for " << name << ")"; in tryUnregisterService()
541 LOG(WARNING) << "Tried to unregister " << name in tryUnregisterService()
547 LOG(INFO) << "Tried to unregister " << name << ", but there is about to be a client."; in tryUnregisterService()
551 int clients = handleServiceClientCallback(name, false); in tryUnregisterService()
560 LOG(INFO) << "Tried to unregister " << name << ", but there are clients: " << clients; in tryUnregisterService()
566 mNameToService.erase(name); in tryUnregisterService()