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

Commit 5a42361d authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "servicemanager: guaranteeClient on wait register" am: 0206fed4 am:...

Merge "servicemanager: guaranteeClient on wait register" am: 0206fed4 am: 89d9dc74 am: 9c14937a

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2628342



Change-Id: I6e111a8627419abba4d1841d131dba975000c022
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0135b631 9c14937a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -404,14 +404,13 @@ Status ServiceManager::addService(const std::string& name, const sp<IBinder>& bi
            .allowIsolated = allowIsolated,
            .dumpPriority = dumpPriority,
            .hasClients = prevClients, // see b/279898063, matters if existing callbacks
            .guaranteeClient = false,  // handled below
            .guaranteeClient = false,
            .ctx = ctx,
    };

    if (auto it = mNameToRegistrationCallback.find(name); it != mNameToRegistrationCallback.end()) {
        // TODO: this is only needed once
        // See also getService - handles case where client never gets the service,
        // we want the service to quit.
        // If someone is currently waiting on the service, notify the service that
        // we're waiting and flush it to the service.
        mNameToService[name].guaranteeClient = true;
        CHECK(handleServiceClientCallback(2 /* sm + transaction */, name, false));
        mNameToService[name].guaranteeClient = true;
@@ -724,6 +723,11 @@ Status ServiceManager::registerClientCallback(const std::string& name, const sp<

    mNameToClientCallback[name].push_back(cb);

    // Flush updated info to client callbacks (especially if guaranteeClient
    // and !hasClient, see b/285202885). We may or may not have clients at
    // this point, so ignore the return value.
    (void)handleServiceClientCallback(2 /* sm + transaction */, name, false);

    return Status::ok();
}