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

Commit 718470ee authored by Jon Spivack's avatar Jon Spivack
Browse files

LazyServiceRegistrar: Use defaultServiceManager

This is cleaner and more robust than partially reimplementing IServiceManager's code.

Bug: N/A
Test: aidl_lazy_test
Change-Id: I0fb696f5fb7c7d905ceb803d4cab898099aaaead
parent 6a1aed6f
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -64,8 +64,7 @@ private:

bool ClientCounterCallback::registerService(const sp<IBinder>& service, const std::string& name,
                                            bool allowIsolated, int dumpFlags) {
    auto manager = interface_cast<AidlServiceManager>(
                    ProcessState::self()->getContextObject(nullptr));
    auto manager = interface_cast<AidlServiceManager>(asBinder(defaultServiceManager()));

    bool reRegister = mRegisteredServices.count(name) > 0;
    std::string regStr = (reRegister) ? "Re-registering" : "Registering";
@@ -114,9 +113,7 @@ Status ClientCounterCallback::onClients(const sp<IBinder>& service, bool clients
void ClientCounterCallback::tryShutdown() {
    ALOGI("Trying to shut down the service. No clients in use for any service in process.");

    // This makes the same assumption as IServiceManager.cpp. Could dedupe if used in more places.
    auto manager = interface_cast<AidlServiceManager>(
            ProcessState::self()->getContextObject(nullptr));
    auto manager = interface_cast<AidlServiceManager>(asBinder(defaultServiceManager()));

    auto unRegisterIt = mRegisteredServices.begin();
    for (; unRegisterIt != mRegisteredServices.end(); ++unRegisterIt) {