Merge "vibrator: correct debug() calibration file path" into main

This commit is contained in:
Treehugger Robot 2024-10-15 20:58:48 +00:00 committed by Android (Google) Code Review
commit f8f3aaf665
3 changed files with 18 additions and 5 deletions

View file

@ -69,6 +69,7 @@ HwCalBase::HwCalBase() {
std::ifstream calfile; std::ifstream calfile;
std::ifstream calfile_dual; std::ifstream calfile_dual;
auto propertyPrefix = std::getenv("PROPERTY_PREFIX"); auto propertyPrefix = std::getenv("PROPERTY_PREFIX");
auto calPath = std::getenv("CALIBRATION_FILEPATH");
if (propertyPrefix != NULL) { if (propertyPrefix != NULL) {
mPropertyPrefix = std::string(propertyPrefix); mPropertyPrefix = std::string(propertyPrefix);
@ -76,6 +77,14 @@ HwCalBase::HwCalBase() {
ALOGE("Failed get property prefix!"); 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); utils::fileFromEnv("CALIBRATION_FILEPATH", &calfile);
for (std::string line; std::getline(calfile, line);) { 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); utils::fileFromEnv("CALIBRATION_FILEPATH_DUAL", &calfile_dual);
for (std::string line; std::getline(calfile_dual, line);) { for (std::string line; std::getline(calfile_dual, line);) {
@ -106,7 +116,6 @@ HwCalBase::HwCalBase() {
void HwCalBase::debug(int fd) { void HwCalBase::debug(int fd) {
std::ifstream stream; std::ifstream stream;
std::string path;
std::string line; std::string line;
struct context { struct context {
HwCalBase *obj; HwCalBase *obj;
@ -133,9 +142,8 @@ void HwCalBase::debug(int fd) {
dprintf(fd, "Persist:\n"); dprintf(fd, "Persist:\n");
utils::fileFromEnv("CALIBRATION_FILEPATH", &stream, &path); utils::openNoCreate(mCalPath, &stream);
dprintf(fd, " %s:\n", mCalPath.c_str());
dprintf(fd, " %s:\n", path.c_str());
while (std::getline(stream, line)) { while (std::getline(stream, line)) {
dprintf(fd, " %s\n", line.c_str()); dprintf(fd, " %s\n", line.c_str());
} }

View file

@ -208,6 +208,7 @@ class HwCalBase {
private: private:
std::string mPropertyPrefix; std::string mPropertyPrefix;
std::string mCalPath;
std::map<std::string, std::string> mCalData; std::map<std::string, std::string> mCalData;
}; };

View file

@ -1081,7 +1081,7 @@ ndk::ScopedAStatus Vibrator::on(uint32_t timeoutMs, uint32_t effectIndex, const
if (mIsDual) { if (mIsDual) {
mHwApiDual->getOwtFreeSpace(&freeBytes); mHwApiDual->getOwtFreeSpace(&freeBytes);
if (ch-> size() > 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); ch-> size(), freeBytes);
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); 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(); verFile.close();
} }
dprintf(fd, "\n");
mHwApiDef->debug(fd); mHwApiDef->debug(fd);
dprintf(fd, "\n"); dprintf(fd, "\n");
mHwCalDef->debug(fd); mHwCalDef->debug(fd);
dprintf(fd, "\n");
if (mIsDual) { if (mIsDual) {
mHwApiDual->debug(fd); mHwApiDual->debug(fd);
dprintf(fd, "\n"); dprintf(fd, "\n");