diff options
| author | 2020-01-25 16:05:10 -0800 | |
|---|---|---|
| committer | 2020-01-25 16:05:10 -0800 | |
| commit | af05567b2cfb41b51a4f988c7adb9a0773d72519 (patch) | |
| tree | 2e06b7e2d875ed2772faacd7204123da7f0a9653 /libs | |
| parent | b4931c59dd31bc06ed6b2e2937e2077cdb8a0adb (diff) | |
| parent | 37f70cc1029e8e984e60f485db59d6e6889cbb1b (diff) | |
Revert "Dynamically stop services with multiple interfaces"
am: 37f70cc102
Change-Id: I2abcb3d8142e4e089069afa7bc4647169a7f7149
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/binder/LazyServiceRegistrar.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/libs/binder/LazyServiceRegistrar.cpp b/libs/binder/LazyServiceRegistrar.cpp index f064bd77ce..dc9482c536 100644 --- a/libs/binder/LazyServiceRegistrar.cpp +++ b/libs/binder/LazyServiceRegistrar.cpp @@ -53,13 +53,14 @@ private: struct Service { sp<IBinder> service; + std::string name; bool allowIsolated; int dumpFlags; }; /** - * Map of registered names and services + * Number of services that have been registered. */ - std::map<std::string, Service> mRegisteredServices; + std::vector<Service> mRegisteredServices; }; bool ClientCounterCallback::registerService(const sp<IBinder>& service, const std::string& name, @@ -67,24 +68,20 @@ bool ClientCounterCallback::registerService(const sp<IBinder>& service, const st auto manager = interface_cast<AidlServiceManager>( ProcessState::self()->getContextObject(nullptr)); - bool reRegister = mRegisteredServices.count(name) > 0; - std::string regStr = (reRegister) ? "Re-registering" : "Registering"; - ALOGI("%s service %s", regStr.c_str(), name.c_str()); + ALOGI("Registering service %s", name.c_str()); if (!manager->addService(name.c_str(), service, allowIsolated, dumpFlags).isOk()) { ALOGE("Failed to register service %s", name.c_str()); return false; } - if (!manager->registerClientCallback(name, service, this).isOk()) { - ALOGE("Failed to add client callback for service %s", name.c_str()); - return false; + if (!manager->registerClientCallback(name, service, this).isOk()) + { + ALOGE("Failed to add client callback for service %s", name.c_str()); + return false; } - if (!reRegister) { - // Only add this when a service is added for the first time, as it is not removed - mRegisteredServices[name] = {service, allowIsolated, dumpFlags}; - } + mRegisteredServices.push_back({service, name, allowIsolated, dumpFlags}); return true; } @@ -122,11 +119,10 @@ void ClientCounterCallback::tryShutdown() { for (; unRegisterIt != mRegisteredServices.end(); ++unRegisterIt) { auto& entry = (*unRegisterIt); - bool success = manager->tryUnregisterService(entry.first, entry.second.service).isOk(); - + bool success = manager->tryUnregisterService(entry.name, entry.service).isOk(); if (!success) { - ALOGI("Failed to unregister service %s", entry.first.c_str()); + ALOGI("Failed to unregister service %s", entry.name.c_str()); break; } } @@ -141,8 +137,7 @@ void ClientCounterCallback::tryShutdown() { auto& entry = (*reRegisterIt); // re-register entry - if (!registerService(entry.second.service, entry.first, entry.second.allowIsolated, - entry.second.dumpFlags)) { + if (!registerService(entry.service, entry.name, entry.allowIsolated, entry.dumpFlags)) { // Must restart. Otherwise, clients will never be able to get a hold of this service. ALOGE("Bad state: could not re-register services"); } |