summaryrefslogtreecommitdiff
path: root/cmds/servicemanager/ServiceManager.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2023-06-22 00:37:07 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-06-22 00:37:07 +0000
commit9c14937a37bebc192f32266ad6aedf80af2da226 (patch)
treeca210c3bd9b430ec70bd83d36d80c98036f96fa4 /cmds/servicemanager/ServiceManager.cpp
parentaec28ea26d2c8426ff6b723b0031406cccc024f6 (diff)
parent89d9dc74d0bc60d07881281536954e991326d5b8 (diff)
Merge "servicemanager: guaranteeClient on wait register" am: 0206fed4eb am: 89d9dc74d0
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2628342 Change-Id: I2c14484b898a78a58a4e19c1af0624bdf7ffb5f2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'cmds/servicemanager/ServiceManager.cpp')
-rw-r--r--cmds/servicemanager/ServiceManager.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 98a70ed973..cae9684cc4 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -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;
@@ -714,6 +713,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();
}