Regsiter BT HAL services if they are declared
Since finder/ranging/lmp_event HAL services are new and their interfaces
are not frozen yet, they can't register services in -next-
configuration.
Bug: 322204309
Bug: 319155748
Test: run CF in -next- build
Change-Id: I4729d8763842c719682ce0124bbaaed86164a7d5
diff --git a/bluetooth/finder/aidl/default/service.cpp b/bluetooth/finder/aidl/default/service.cpp
index a117df8..fe8904b 100644
--- a/bluetooth/finder/aidl/default/service.cpp
+++ b/bluetooth/finder/aidl/default/service.cpp
@@ -35,12 +35,16 @@
ndk::SharedRefBase::make<BluetoothFinder>();
std::string instance =
std::string() + BluetoothFinder::descriptor + "/default";
- auto result =
- AServiceManager_addService(service->asBinder().get(), instance.c_str());
- if (result == STATUS_OK) {
- ABinderProcess_joinThreadPool();
+ if (AServiceManager_isDeclared(instance.c_str())) {
+ auto result =
+ AServiceManager_addService(service->asBinder().get(), instance.c_str());
+ if (result != STATUS_OK) {
+ ALOGE("Could not register as a service!");
+ }
} else {
- ALOGE("Could not register as a service!");
+ ALOGE("Could not register as a service because it's not declared.");
}
+ // Keep running
+ ABinderProcess_joinThreadPool();
return 0;
}