Improve debug logs for dynamic sensor enable, batch, and getFeature
Fixes: 361140362
Test: presubmit
Change-Id: I1610f183dad78b4f51656c372715dd69fa510387
diff --git a/modules/sensors/dynamic_sensor/HidRawDevice.cpp b/modules/sensors/dynamic_sensor/HidRawDevice.cpp
index 6032ed9..ae763e1 100644
--- a/modules/sensors/dynamic_sensor/HidRawDevice.cpp
+++ b/modules/sensors/dynamic_sensor/HidRawDevice.cpp
@@ -215,7 +215,7 @@
}
if (mIoBuffer.front() != id) {
LOG_E << "HidRawDevice::getFeature: get feature " << static_cast<int>(id)
- << " result has header " << mIoBuffer.front() << LOG_ENDL;
+ << " result has header " << static_cast<int>(mIoBuffer.front()) << LOG_ENDL;
}
out->resize(size - 1);
std::copy(mIoBuffer.begin() + 1, mIoBuffer.begin() + size, out->begin());
diff --git a/modules/sensors/dynamic_sensor/HidRawSensor.cpp b/modules/sensors/dynamic_sensor/HidRawSensor.cpp
index b61185d..84baffc 100644
--- a/modules/sensors/dynamic_sensor/HidRawSensor.cpp
+++ b/modules/sensors/dynamic_sensor/HidRawSensor.cpp
@@ -988,12 +988,13 @@
SP(HidDevice) device = PROMOTE(mDevice);
if (device == nullptr) {
- LOG_E << "enable: no device" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): no device" << LOG_ENDL;
return NO_INIT;
}
if (enable == mEnabled) {
- LOG_D << "enable: already in desired state" << LOG_ENDL;
+ LOG_D << "enable(" << enable << "): already in desired state"
+ << LOG_ENDL;
return NO_ERROR;
}
@@ -1002,10 +1003,10 @@
bool setReportingOk = setReportingState(device, enable);
if (setPowerOk && setReportingOk && setLeAudioTransportOk) {
mEnabled = enable;
- LOG_I << "enable: success" << LOG_ENDL;
+ LOG_I << "enable(" << enable << "): success" << LOG_ENDL;
return NO_ERROR;
} else {
- LOG_E << "enable: set feature failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): set feature failed" << LOG_ENDL;
return INVALID_OPERATION;
}
}
@@ -1047,10 +1048,10 @@
mLeTransportBitOffset, mLeTransportBitSize);
success = device->setFeature(id, buffer);
if (!success) {
- LOG_E << "enable: setFeature VENDOR LE TRANSPORT failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): setFeature LE TRANSPORT failed" << LOG_ENDL;
}
} else {
- LOG_E << "enable: changing VENDOR LE TRANSPORT failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): changing LE TRANSPORT failed" << LOG_ENDL;
}
}
return success;
@@ -1070,10 +1071,10 @@
0, mPowerStateBitOffset, mPowerStateBitSize);
success = device->setFeature(id, buffer);
if (!success) {
- LOG_E << "enable: setFeature POWER STATE failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): setFeature POWER STATE failed" << LOG_ENDL;
}
} else {
- LOG_E << "enable: changing POWER STATE failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): changing POWER STATE failed" << LOG_ENDL;
}
}
return success;
@@ -1094,10 +1095,10 @@
mReportingStateBitOffset, mReportingStateBitSize);
success = device->setFeature(id, buffer);
if (!success) {
- LOG_E << "enable: setFeature REPORTING STATE failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): setFeature REPORTING STATE failed" << LOG_ENDL;
}
} else {
- LOG_E << "enable: changing REPORTING STATE failed" << LOG_ENDL;
+ LOG_E << "enable(" << enable << "): changing REPORTING STATE failed" << LOG_ENDL;
}
}
return success;
@@ -1133,6 +1134,13 @@
0, mReportIntervalBitOffset,
mReportIntervalBitSize);
ok = device->setFeature(id, buffer);
+ if (!ok) {
+ LOG_E << "batch(" << samplingPeriod << ", " << batchingPeriod << "): "
+ << "setFeature failed" << LOG_ENDL;
+ }
+ } else {
+ LOG_E << "batch(" << samplingPeriod << ", " << batchingPeriod << "): "
+ << "invalid getFeature result (buffer.size: " << buffer.size() << ")" << LOG_ENDL;
}
}