Steven Moreland | d44007e | 2019-10-24 18:12:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
Steven Moreland | 8ba8c03 | 2019-11-18 16:23:39 -0800 | [diff] [blame] | 17 | #include "vibrator-impl/Vibrator.h" |
Lais Andrade | 80b1861 | 2020-10-12 18:44:40 +0000 | [diff] [blame] | 18 | #include "vibrator-impl/VibratorManager.h" |
Steven Moreland | d44007e | 2019-10-24 18:12:46 -0700 | [diff] [blame] | 19 | |
| 20 | #include <android-base/logging.h> |
| 21 | #include <android/binder_manager.h> |
| 22 | #include <android/binder_process.h> |
| 23 | |
| 24 | using aidl::android::hardware::vibrator::Vibrator; |
Lais Andrade | 80b1861 | 2020-10-12 18:44:40 +0000 | [diff] [blame] | 25 | using aidl::android::hardware::vibrator::VibratorManager; |
Steven Moreland | d44007e | 2019-10-24 18:12:46 -0700 | [diff] [blame] | 26 | |
| 27 | int main() { |
| 28 | ABinderProcess_setThreadPoolMaxThreadCount(0); |
Steven Moreland | d44007e | 2019-10-24 18:12:46 -0700 | [diff] [blame] | 29 | |
Lais Andrade | 80b1861 | 2020-10-12 18:44:40 +0000 | [diff] [blame] | 30 | // make a default vibrator service |
| 31 | auto vib = ndk::SharedRefBase::make<Vibrator>(); |
| 32 | const std::string vibName = std::string() + Vibrator::descriptor + "/default"; |
| 33 | binder_status_t status = AServiceManager_addService(vib->asBinder().get(), vibName.c_str()); |
Steven Moreland | ffb0399 | 2021-12-14 01:45:47 +0000 | [diff] [blame] | 34 | CHECK_EQ(status, STATUS_OK); |
Lais Andrade | 80b1861 | 2020-10-12 18:44:40 +0000 | [diff] [blame] | 35 | |
| 36 | // make the vibrator manager service with a different vibrator |
| 37 | auto managedVib = ndk::SharedRefBase::make<Vibrator>(); |
| 38 | auto vibManager = ndk::SharedRefBase::make<VibratorManager>(std::move(managedVib)); |
| 39 | const std::string vibManagerName = std::string() + VibratorManager::descriptor + "/default"; |
| 40 | status = AServiceManager_addService(vibManager->asBinder().get(), vibManagerName.c_str()); |
Steven Moreland | ffb0399 | 2021-12-14 01:45:47 +0000 | [diff] [blame] | 41 | CHECK_EQ(status, STATUS_OK); |
Steven Moreland | d44007e | 2019-10-24 18:12:46 -0700 | [diff] [blame] | 42 | |
| 43 | ABinderProcess_joinThreadPool(); |
| 44 | return EXIT_FAILURE; // should not reach |
| 45 | } |