Merge "ServiceManager: Check guaranteeClient before unregistering services"
diff --git a/cmds/servicemanager/ServiceManager.cpp b/cmds/servicemanager/ServiceManager.cpp
index 1e88aaf..cbbea12 100644
--- a/cmds/servicemanager/ServiceManager.cpp
+++ b/cmds/servicemanager/ServiceManager.cpp
@@ -522,6 +522,11 @@
return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
}
+ if (serviceIt->second.guaranteeClient) {
+ LOG(INFO) << "Tried to unregister " << name << ", but there is about to be a client.";
+ return Status::fromExceptionCode(Status::EX_ILLEGAL_STATE);
+ }
+
int clients = handleServiceClientCallback(name, false);
// clients < 0: feature not implemented or other error. Assume clients.