Myles Watson | 6d5e772 | 2022-09-30 06:22:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "aidl.android.hardware.bluetooth.service.default" |
| 18 | |
| 19 | #include <aidl/android/hardware/bluetooth/IBluetoothHci.h> |
| 20 | #include <android/binder_manager.h> |
| 21 | #include <android/binder_process.h> |
| 22 | #include <hidl/HidlSupport.h> |
| 23 | #include <hidl/HidlTransportSupport.h> |
| 24 | |
| 25 | #include "BluetoothHci.h" |
| 26 | |
| 27 | using ::aidl::android::hardware::bluetooth::impl::BluetoothHci; |
| 28 | using ::android::hardware::configureRpcThreadpool; |
| 29 | using ::android::hardware::joinRpcThreadpool; |
| 30 | |
| 31 | int main(int /* argc */, char** /* argv */) { |
| 32 | ALOGI("Bluetooth HAL starting"); |
Myles Watson | 18bd409 | 2023-04-18 15:42:39 -0700 | [diff] [blame] | 33 | if (!ABinderProcess_setThreadPoolMaxThreadCount(0)) { |
Myles Watson | 6d5e772 | 2022-09-30 06:22:43 -0700 | [diff] [blame] | 34 | ALOGI("failed to set thread pool max thread count"); |
| 35 | return 1; |
| 36 | } |
| 37 | |
| 38 | std::shared_ptr<BluetoothHci> service = |
| 39 | ndk::SharedRefBase::make<BluetoothHci>(); |
| 40 | std::string instance = std::string() + BluetoothHci::descriptor + "/default"; |
| 41 | auto result = |
| 42 | AServiceManager_addService(service->asBinder().get(), instance.c_str()); |
| 43 | if (result == STATUS_OK) { |
| 44 | ABinderProcess_joinThreadPool(); |
| 45 | } else { |
| 46 | ALOGE("Could not register as a service!"); |
| 47 | } |
| 48 | return 0; |
| 49 | } |