diff options
| author | 2022-03-18 18:15:20 +0000 | |
|---|---|---|
| committer | 2022-03-18 18:18:07 +0000 | |
| commit | ac2d2857a1a56bc020917c6b6ba4d063050de4c4 (patch) | |
| tree | 7dad718c3f0eff210102c61642d6ff24a6e07af6 /cmds/servicemanager/ServiceManager.cpp | |
| parent | 4fe07911ea6b870ea31e39c8efd7e26fd45f3662 (diff) | |
servicemanager: explicit addService errors
We return these codes, but not more information before. This was a bit
confusing because some error codes are used for multiple things.
Bug: 224955557
Test: servicemanager_test
Change-Id: I5132b6882253a945dccbdefd4888892ed79e73af
Diffstat (limited to 'cmds/servicemanager/ServiceManager.cpp')
| -rw-r--r-- | cmds/servicemanager/ServiceManager.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp index 555be1ed7e..3cfe5297ca 100644 --- a/cmds/servicemanager/ServiceManager.cpp +++ b/cmds/servicemanager/ServiceManager.cpp @@ -295,28 +295,27 @@ bool isValidServiceName(const std::string& name) { Status ServiceManager::addService(const std::string& name, const sp<IBinder>& binder, bool allowIsolated, int32_t dumpPriority) { auto ctx = mAccess->getCallingContext(); - // apps cannot add services if (multiuser_get_app_id(ctx.uid) >= AID_APP) { - return Status::fromExceptionCode(Status::EX_SECURITY); + return Status::fromExceptionCode(Status::EX_SECURITY, "App UIDs cannot add services"); } if (!mAccess->canAdd(ctx, name)) { - return Status::fromExceptionCode(Status::EX_SECURITY); + return Status::fromExceptionCode(Status::EX_SECURITY, "SELinux denial"); } if (binder == nullptr) { - return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT); + return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Null binder"); } if (!isValidServiceName(name)) { LOG(ERROR) << "Invalid service name: " << name; - return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT); + return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "Invalid service name"); } #ifndef VENDORSERVICEMANAGER if (!meetsDeclarationRequirements(binder, name)) { // already logged - return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT); + return Status::fromExceptionCode(Status::EX_ILLEGAL_ARGUMENT, "VINTF declaration error"); } #endif // !VENDORSERVICEMANAGER @@ -324,7 +323,7 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi if (binder->remoteBinder() != nullptr && binder->linkToDeath(sp<ServiceManager>::fromExisting(this)) != OK) { LOG(ERROR) << "Could not linkToDeath when adding " << name; - return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE); + return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE, "linkToDeath failure"); } // Overwrite the old service if it exists |