summaryrefslogtreecommitdiff
path: root/vibrator/aidl/default/main.cpp
diff options
context:
space:
mode:
authorLais Andrade <lsandrade@google.com>2020-10-12 18:44:40 +0000
committerLais Andrade <lsandrade@google.com>2020-11-16 14:29:29 +0000
commit80b1861b20ad521da43f695ff6acb74d2ee9b0a9 (patch)
treee5d110b5f59f3097654ff55822951c21813fd0d7 /vibrator/aidl/default/main.cpp
parent9bb4eb02730d2f64fd40362ac9de181821a6e008 (diff)
Introduce IVibratorManager.aidl
Introduce interface for vibrator manager HAL. A default implementation is made available to the existing android.hardware.vibrator-service.example, which now provides a top level devault IVibrator and a top level IVibratorManager with a different vibrator in it. VTS tests were also introduced for the new manager, and existing tests for IVibrator where changed to run in all top level and managed HAL instances found on a device. Bug: 166586119 Test: atest VtsHalVibratorTargetTest atest VtsHalVibratorManagerTargetTest Change-Id: Iec9175167e795bc03c4f3d873e2ac6682ed52512
Diffstat (limited to 'vibrator/aidl/default/main.cpp')
-rw-r--r--vibrator/aidl/default/main.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/vibrator/aidl/default/main.cpp b/vibrator/aidl/default/main.cpp
index ebb0905a3a..bd834d2a21 100644
--- a/vibrator/aidl/default/main.cpp
+++ b/vibrator/aidl/default/main.cpp
@@ -15,19 +15,29 @@
*/
#include "vibrator-impl/Vibrator.h"
+#include "vibrator-impl/VibratorManager.h"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using aidl::android::hardware::vibrator::Vibrator;
+using aidl::android::hardware::vibrator::VibratorManager;
int main() {
ABinderProcess_setThreadPoolMaxThreadCount(0);
- std::shared_ptr<Vibrator> vib = ndk::SharedRefBase::make<Vibrator>();
- const std::string instance = std::string() + Vibrator::descriptor + "/default";
- binder_status_t status = AServiceManager_addService(vib->asBinder().get(), instance.c_str());
+ // make a default vibrator service
+ auto vib = ndk::SharedRefBase::make<Vibrator>();
+ const std::string vibName = std::string() + Vibrator::descriptor + "/default";
+ binder_status_t status = AServiceManager_addService(vib->asBinder().get(), vibName.c_str());
+ CHECK(status == STATUS_OK);
+
+ // make the vibrator manager service with a different vibrator
+ auto managedVib = ndk::SharedRefBase::make<Vibrator>();
+ auto vibManager = ndk::SharedRefBase::make<VibratorManager>(std::move(managedVib));
+ const std::string vibManagerName = std::string() + VibratorManager::descriptor + "/default";
+ status = AServiceManager_addService(vibManager->asBinder().get(), vibManagerName.c_str());
CHECK(status == STATUS_OK);
ABinderProcess_joinThreadPool();