ServiceManager signals init to start lazy services
This allows services to be disabled at boot and dynamically enabled as
they are needed. When servicemanager receives a getService request,
it will check whether the service is running. If it is not,
servicemanager will attempt to start the service by signaling init with
the ctl.interface_start control message.
Bug: 138756857
Test: Manual (using mediaextractor as a test service), test_sm
Change-Id: Ic2d47d21769b936381e3fae2f2cf739d3b7501a4
diff --git a/libs/binder/IServiceManager.cpp b/libs/binder/IServiceManager.cpp
index 715a460..eefc5b1 100644
--- a/libs/binder/IServiceManager.cpp
+++ b/libs/binder/IServiceManager.cpp
@@ -232,7 +232,7 @@
const std::string name = String8(name16).c_str();
sp<IBinder> out;
- if(!mTheRealServiceManager->checkService(name, &out).isOk()) {
+ if (!mTheRealServiceManager->getService(name, &out).isOk()) {
return nullptr;
}
if(out != nullptr) return out;
@@ -256,13 +256,13 @@
// Handle race condition for lazy services. Here is what can happen:
// - the service dies (not processed by init yet).
// - sm processes death notification.
- // - sm gets checkService and calls init to start service.
+ // - sm gets getService and calls init to start service.
// - init gets the start signal, but the service already appears
// started, so it does nothing.
// - init gets death signal, but doesn't know it needs to restart
// the service
// - we need to request service again to get it to start
- if(!mTheRealServiceManager->checkService(name, &out).isOk()) {
+ if (!mTheRealServiceManager->getService(name, &out).isOk()) {
return nullptr;
}
if(out != nullptr) return out;