Merge "libhardware_headers: vendor modules on host" into main
diff --git a/OWNERS b/OWNERS
index 53e5f73..98ec162 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,3 @@
-zachoverflow@google.com
elaurent@google.com
jpawlowski@google.com
malchev@google.com
diff --git a/include_all/hardware/sensors.h b/include_all/hardware/sensors.h
index 5f490b5..9b3e333 100644
--- a/include_all/hardware/sensors.h
+++ b/include_all/hardware/sensors.h
@@ -97,6 +97,11 @@
#define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS"
/*
+ * The permission to use for reading heart rate sensors.
+ */
+#define SENSOR_PERMISSION_READ_HEART_RATE "android.permission.health.READ_HEART_RATE"
+
+/*
* sensor flags legacy names
*
* please use SENSOR_FLAG_* directly for new implementation.
diff --git a/modules/sensors/dynamic_sensor/Android.bp b/modules/sensors/dynamic_sensor/Android.bp
index dbb3d93..00de46d 100644
--- a/modules/sensors/dynamic_sensor/Android.bp
+++ b/modules/sensors/dynamic_sensor/Android.bp
@@ -143,7 +143,9 @@
cc_binary_host {
name: "hidrawsensor_host_test",
defaults: ["dynamic_sensor_defaults"],
-
+ static_libs: [
+ "libutils_binder",
+ ],
srcs: [
"HidRawSensor.cpp",
"BaseSensorObject.cpp",
@@ -159,7 +161,9 @@
cc_binary_host {
name: "hidrawdevice_host_test",
defaults: ["dynamic_sensor_defaults"],
-
+ static_libs: [
+ "libutils_binder",
+ ],
srcs: [
"HidRawDevice.cpp",
"HidRawSensor.cpp",
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..d9c1e66 100644
--- a/modules/sensors/dynamic_sensor/HidRawSensor.cpp
+++ b/modules/sensors/dynamic_sensor/HidRawSensor.cpp
@@ -18,6 +18,7 @@
#include <android-base/properties.h>
#include <utils/Errors.h>
+#include <utils/Unicode.h>
#include <com_android_libhardware_dynamic_sensors_flags.h>
#include "HidLog.h"
@@ -421,7 +422,14 @@
void HidRawSensor::initFeatureValueFromHidDeviceInfo(
FeatureValue *featureValue, const HidDevice::HidDeviceInfo &info) {
- featureValue->name = info.name;
+ const uint8_t *str8 = (uint8_t *)info.name.c_str();
+ const ssize_t len16 = utf8_to_utf16_length(str8, info.name.size());
+ if (len16 != -1) {
+ featureValue->name = info.name;
+ } else {
+ LOG_E << "Received an invalid sensor name" << LOG_ENDL;
+ featureValue->name = "Invalid sensor name";
+ }
std::ostringstream ss;
ss << info.busType << " "
@@ -988,12 +996,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 +1011,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 +1056,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 +1079,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 +1103,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 +1142,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;
}
}