Replace vibrator/ from git_tm-qpr-dev
Lastest commit:
2724d61 vibrator/cs40l26: Fix unsupport primitive effects test
Bug: 267926374
Bug: 264625320
Test: HAL init properly.
Change-Id: I1c01ea8c6d584ae58d8d20f21a9ac43a8977f435
diff --git a/vibrator/cs40l26/service.cpp b/vibrator/cs40l26/service.cpp
index fd76b19..605de43 100644
--- a/vibrator/cs40l26/service.cpp
+++ b/vibrator/cs40l26/service.cpp
@@ -20,34 +20,60 @@
#include <log/log.h>
#include "Hardware.h"
+#include "VibMgrHwApi.h"
#include "Vibrator.h"
-#include "VibratorSync.h"
using ::aidl::android::hardware::vibrator::HwApi;
using ::aidl::android::hardware::vibrator::HwCal;
+using ::aidl::android::hardware::vibrator::VibMgrHwApi;
using ::aidl::android::hardware::vibrator::Vibrator;
using ::android::defaultServiceManager;
using ::android::ProcessState;
using ::android::sp;
using ::android::String16;
-using ::android::hardware::vibrator::VibratorSync;
#if !defined(VIBRATOR_NAME)
#define VIBRATOR_NAME "default"
#endif
int main() {
- auto svc = ndk::SharedRefBase::make<Vibrator>(std::make_unique<HwApi>(),
- std::make_unique<HwCal>());
+ const char *hwApiPathPrefixDual = std::getenv("HWAPI_PATH_PREFIX_DUAL");
+ const char *calFilePath = std::getenv("CALIBRATION_FILEPATH");
+ const char *calFilePathDual = std::getenv("CALIBRATION_FILEPATH_DUAL");
+
+ auto hwgpio = VibMgrHwApi::Create();
+ if (!hwgpio) {
+ return EXIT_FAILURE;
+ }
+ auto hwApiDef = HwApi::Create();
+ if (!hwApiDef) {
+ return EXIT_FAILURE;
+ }
+ auto hwCalDef = HwCal::Create();
+ if (!hwCalDef) {
+ return EXIT_FAILURE;
+ }
+
+ std::shared_ptr<Vibrator> svc;
+ // Synchronize base and flip actuator F0.
+ // Replace dual cal file path to base and copy the base to dual's path.
+ if ((hwApiPathPrefixDual != nullptr) && !setenv("HWAPI_PATH_PREFIX", hwApiPathPrefixDual, 1) &&
+ (calFilePathDual != nullptr) && !setenv("CALIBRATION_FILEPATH", calFilePathDual, 1) &&
+ !setenv("CALIBRATION_FILEPATH_DUAL", calFilePath, 1)) {
+ ALOGD("Init dual HAL: %s", std::getenv("HWAPI_PATH_PREFIX"));
+ svc = ndk::SharedRefBase::make<Vibrator>(std::move(hwApiDef), std::move(hwCalDef),
+ std::make_unique<HwApi>(),
+ std::make_unique<HwCal>(), std::move(hwgpio));
+ } else {
+ ALOGD("Failed to init dual HAL");
+ svc = ndk::SharedRefBase::make<Vibrator>(std::move(hwApiDef), std::move(hwCalDef), nullptr,
+ nullptr, std::move(hwgpio));
+ }
+
const auto svcName = std::string() + svc->descriptor + "/" + VIBRATOR_NAME;
- auto ext = sp<VibratorSync>::make(svc);
- const auto extName = std::stringstream() << ext->descriptor << "/" << VIBRATOR_NAME;
-
ProcessState::initWithDriver("/dev/vndbinder");
- defaultServiceManager()->addService(String16(extName.str().c_str()), ext);
-
auto svcBinder = svc->asBinder();
binder_status_t status = AServiceManager_addService(svcBinder.get(), svcName.c_str());
LOG_ALWAYS_FATAL_IF(status != STATUS_OK);