Merge "Regsiter BT HAL services if they are declared" into main
This commit is contained in:
commit
9dec1ab884
3 changed files with 24 additions and 15 deletions
|
@ -35,12 +35,16 @@ int main(int /* argc */, char** /* argv */) {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -41,10 +41,11 @@ fn main() {
|
|||
let lmp_event_service = lmp_event::LmpEvent::new();
|
||||
let lmp_event_service_binder = BnBluetoothLmpEvent::new_binder(lmp_event_service, BinderFeatures::default());
|
||||
|
||||
binder::add_service(
|
||||
&format!("{}/default", lmp_event::LmpEvent::get_descriptor()),
|
||||
lmp_event_service_binder.as_binder(),
|
||||
).expect("Failed to register service");
|
||||
|
||||
let descriptor = format!("{}/default", lmp_event::LmpEvent::get_descriptor());
|
||||
if binder::is_declared(&descriptor).expect("Failed to check if declared") {
|
||||
binder::add_service(&descriptor, lmp_event_service_binder.as_binder()).expect("Failed to register service");
|
||||
} else {
|
||||
info!("{LOG_TAG}: Failed to register service. Not declared.");
|
||||
}
|
||||
binder::ProcessState::join_thread_pool()
|
||||
}
|
||||
|
|
|
@ -37,12 +37,16 @@ int main(int /* argc */, char** /* argv */) {
|
|||
ndk::SharedRefBase::make<BluetoothChannelSounding>();
|
||||
std::string instance =
|
||||
std::string() + BluetoothChannelSounding::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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue