summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2023-04-13 20:29:33 +0000
committer Steven Moreland <smoreland@google.com> 2023-04-14 01:26:57 +0000
commit9c8646077a6ae0e11a0ae90f64a5a084756cbd73 (patch)
tree16a40d507aea3b137218593ff6c557d09aa963b2
parent7bb4ab864585475690b4ef73ee1cc691c85231e5 (diff)
lazy AIDL services: test multiple callbacks
In order to test multiple lazy callbacks, an additional API is exposed from LazyServiceRegistrar. Bug: 278038751 Test: aidl_lazy_test Change-Id: I3cb102a9727b5f126703d389fb416969fccae26d
-rw-r--r--libs/binder/LazyServiceRegistrar.cpp4
-rw-r--r--libs/binder/include/binder/LazyServiceRegistrar.h12
2 files changed, 15 insertions, 1 deletions
diff --git a/libs/binder/LazyServiceRegistrar.cpp b/libs/binder/LazyServiceRegistrar.cpp
index f66993f926..7644806e2b 100644
--- a/libs/binder/LazyServiceRegistrar.cpp
+++ b/libs/binder/LazyServiceRegistrar.cpp
@@ -324,6 +324,10 @@ LazyServiceRegistrar& LazyServiceRegistrar::getInstance() {
return *registrarInstance;
}
+LazyServiceRegistrar LazyServiceRegistrar::createExtraTestInstance() {
+ return LazyServiceRegistrar();
+}
+
status_t LazyServiceRegistrar::registerService(const sp<IBinder>& service, const std::string& name,
bool allowIsolated, int dumpFlags) {
if (!mClientCC->registerService(service, name, allowIsolated, dumpFlags)) {
diff --git a/libs/binder/include/binder/LazyServiceRegistrar.h b/libs/binder/include/binder/LazyServiceRegistrar.h
index 2e22b84ff0..bda3d19ee1 100644
--- a/libs/binder/include/binder/LazyServiceRegistrar.h
+++ b/libs/binder/include/binder/LazyServiceRegistrar.h
@@ -93,7 +93,17 @@ class LazyServiceRegistrar {
*/
void reRegister();
- private:
+ /**
+ * Create a second instance of lazy service registrar.
+ *
+ * WARNING: dangerous! DO NOT USE THIS - LazyServiceRegistrar
+ * should be single-instanced, so that the service will only
+ * shut down when all services are unused. A separate instance
+ * is only used to test race conditions.
+ */
+ static LazyServiceRegistrar createExtraTestInstance();
+
+ private:
std::shared_ptr<internal::ClientCounterCallback> mClientCC;
LazyServiceRegistrar();
};