Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46f380b9 authored by Steven Moreland's avatar Steven Moreland
Browse files

servicemanager: self-register

So that servicemanager isn't treated any differently for things like
dumpsys or other utilities that need to iterate over all services.

Bug: 136027762
Test: dumpsys -l
Change-Id: I82cc5e5261ff86d36da4fe49b434e88aa5368005
parent a1ebc66b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi
#endif  // !VENDORSERVICEMANAGER

    // implicitly unlinked when the binder is removed
    if (OK != binder->linkToDeath(this)) {
    if (binder->remoteBinder() != nullptr && binder->linkToDeath(this) != OK) {
        LOG(ERROR) << "Could not linkToDeath when adding " << name;
        return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
    }
+8 −3
Original line number Diff line number Diff line
@@ -23,11 +23,12 @@
#include "Access.h"
#include "ServiceManager.h"

using ::android::sp;
using ::android::ProcessState;
using ::android::Access;
using ::android::IPCThreadState;
using ::android::ProcessState;
using ::android::ServiceManager;
using ::android::Access;
using ::android::os::IServiceManager;
using ::android::sp;

int main(int argc, char** argv) {
    if (argc > 2) {
@@ -41,6 +42,10 @@ int main(int argc, char** argv) {
    ps->setCallRestriction(ProcessState::CallRestriction::FATAL_IF_NOT_ONEWAY);

    sp<ServiceManager> manager = new ServiceManager(std::make_unique<Access>());
    if (!manager->addService("manager", manager, false /*allowIsolated*/, IServiceManager::DUMP_FLAG_PRIORITY_DEFAULT).isOk()) {
        LOG(ERROR) << "Could not self register servicemanager";
    }

    IPCThreadState::self()->setTheContextObject(manager);
    ps->becomeContextManager(nullptr, nullptr);