diff --git a/vibrator/common/HardwareBase.cpp b/vibrator/common/HardwareBase.cpp index 329293a..583caaa 100644 --- a/vibrator/common/HardwareBase.cpp +++ b/vibrator/common/HardwareBase.cpp @@ -69,6 +69,7 @@ HwCalBase::HwCalBase() { std::ifstream calfile; std::ifstream calfile_dual; auto propertyPrefix = std::getenv("PROPERTY_PREFIX"); + auto calPath = std::getenv("CALIBRATION_FILEPATH"); if (propertyPrefix != NULL) { mPropertyPrefix = std::string(propertyPrefix); @@ -76,6 +77,14 @@ HwCalBase::HwCalBase() { ALOGE("Failed get property prefix!"); } + // Keep the cal file path for the current HwCalBase instance. + if (calPath != NULL) { + mCalPath = std::string(calPath); + } else { + ALOGE("Failed get the calibration file path!"); + } + + // Read the cal data for the current instance. utils::fileFromEnv("CALIBRATION_FILEPATH", &calfile); for (std::string line; std::getline(calfile, line);) { @@ -89,6 +98,7 @@ HwCalBase::HwCalBase() { } } + // Read the cal data for the other instance. utils::fileFromEnv("CALIBRATION_FILEPATH_DUAL", &calfile_dual); for (std::string line; std::getline(calfile_dual, line);) { @@ -106,7 +116,6 @@ HwCalBase::HwCalBase() { void HwCalBase::debug(int fd) { std::ifstream stream; - std::string path; std::string line; struct context { HwCalBase *obj; @@ -133,9 +142,8 @@ void HwCalBase::debug(int fd) { dprintf(fd, "Persist:\n"); - utils::fileFromEnv("CALIBRATION_FILEPATH", &stream, &path); - - dprintf(fd, " %s:\n", path.c_str()); + utils::openNoCreate(mCalPath, &stream); + dprintf(fd, " %s:\n", mCalPath.c_str()); while (std::getline(stream, line)) { dprintf(fd, " %s\n", line.c_str()); } diff --git a/vibrator/common/HardwareBase.h b/vibrator/common/HardwareBase.h index f09fada..0296390 100644 --- a/vibrator/common/HardwareBase.h +++ b/vibrator/common/HardwareBase.h @@ -208,6 +208,7 @@ class HwCalBase { private: std::string mPropertyPrefix; + std::string mCalPath; std::map mCalData; }; diff --git a/vibrator/cs40l26/Vibrator.cpp b/vibrator/cs40l26/Vibrator.cpp index 8543bf0..e091571 100644 --- a/vibrator/cs40l26/Vibrator.cpp +++ b/vibrator/cs40l26/Vibrator.cpp @@ -1081,7 +1081,7 @@ ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, const if (mIsDual) { mHwApiDual->getOwtFreeSpace(&freeBytes); if (ch-> size() > freeBytes) { - ALOGE("Invalid OWT length in flip: Effect %d: %d > %d!", effectIndex, + ALOGE("Invalid OWT length in flip: Effect %d: %zu > %d!", effectIndex, ch-> size(), freeBytes); return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); } @@ -1619,12 +1619,16 @@ binder_status_t Vibrator::dump(int fd, const char **args, uint32_t numArgs) { verFile.close(); } + dprintf(fd, "\n"); + mHwApiDef->debug(fd); dprintf(fd, "\n"); mHwCalDef->debug(fd); + dprintf(fd, "\n"); + if (mIsDual) { mHwApiDual->debug(fd); dprintf(fd, "\n");