diff options
| author | 2019-10-29 09:14:39 -0700 | |
|---|---|---|
| committer | 2019-10-29 09:14:39 -0700 | |
| commit | 4a44bce7ff121cc2da6a8a8cf4ee6d8a30a37630 (patch) | |
| tree | 4a843b2614c81ac6b9e1477721800f0261b1fe2e /cmds/servicemanager/ServiceManager.cpp | |
| parent | 58eb8459991ea95cf129728ba731c2d29f361825 (diff) | |
| parent | c9c2f0c8589fba44cd8f4fb589f7fe44e97c5218 (diff) | |
Merge "ServiceManager: add isDeclared"
am: c9c2f0c858
Change-Id: I1614b9605037d9cd750c08d970945def22d936e0
Diffstat (limited to 'cmds/servicemanager/ServiceManager.cpp')
| -rw-r--r-- | cmds/servicemanager/ServiceManager.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp index 934646da41..91e89ae7e8 100644 --- a/cmds/servicemanager/ServiceManager.cpp +++ b/cmds/servicemanager/ServiceManager.cpp @@ -34,11 +34,7 @@ using ::android::internal::Stability; namespace android { #ifndef VENDORSERVICEMANAGER -static bool meetsDeclarationRequirements(const sp<IBinder>& binder, const std::string& name) { - if (!Stability::requiresVintfDeclaration(binder)) { - return true; - } - +static bool isVintfDeclared(const std::string& name) { size_t firstSlash = name.find('/'); size_t lastDot = name.rfind('.', firstSlash); if (firstSlash == std::string::npos || lastDot == std::string::npos) { @@ -62,6 +58,14 @@ static bool meetsDeclarationRequirements(const sp<IBinder>& binder, const std::s << " in the VINTF manifest."; return false; } + +static bool meetsDeclarationRequirements(const sp<IBinder>& binder, const std::string& name) { + if (!Stability::requiresVintfDeclaration(binder)) { + return true; + } + + return isVintfDeclared(name); +} #endif // !VENDORSERVICEMANAGER ServiceManager::ServiceManager(std::unique_ptr<Access>&& access) : mAccess(std::move(access)) {} @@ -270,6 +274,21 @@ Status ServiceManager::unregisterForNotifications( return Status::ok(); } +Status ServiceManager::isDeclared(const std::string& name, bool* outReturn) { + auto ctx = mAccess->getCallingContext(); + + if (!mAccess->canFind(ctx, name)) { + return Status::fromExceptionCode(Status::EX_SECURITY); + } + + *outReturn = false; + +#ifndef VENDORSERVICEMANAGER + *outReturn = isVintfDeclared(name); +#endif + return Status::ok(); +} + void ServiceManager::removeCallback(const wp<IBinder>& who, CallbackMap::iterator* it, bool* found) { |