summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Ishiguro <arthuri@google.com>2023-12-08 17:43:14 +0000
committerArthur Ishiguro <arthuri@google.com>2023-12-08 17:43:14 +0000
commit072d07df7f15c07f33f6f5565b0de9e1db0d677b (patch)
treeca40a60680a368ccf114024b47b68127c29b2e28
parent374655eeeaea0e54af29942f59f6e3a58828fcfb (diff)
downloadlibhardware-072d07df7f15c07f33f6f5565b0de9e1db0d677b.tar.gz
Simplify transport selection logic
Bug: 298450041 Test: Compile Change-Id: I35c7ed3c0a7ba603215b6b2c3fcfb9a7993f5c8e
-rw-r--r--modules/sensors/dynamic_sensor/HidRawSensor.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/modules/sensors/dynamic_sensor/HidRawSensor.cpp b/modules/sensors/dynamic_sensor/HidRawSensor.cpp
index 336461c7..dcf4b470 100644
--- a/modules/sensors/dynamic_sensor/HidRawSensor.cpp
+++ b/modules/sensors/dynamic_sensor/HidRawSensor.cpp
@@ -1004,9 +1004,6 @@ int HidRawSensor::enable(bool enable) {
if (device->getFeature(id, &buffer)
&& (8 * buffer.size()) >=
(mLeTransportBitOffset + mLeTransportBitSize)) {
- constexpr uint8_t kLeAclValue = 0;
- constexpr uint8_t kLeIsoValue = 1;
-
// The following property, if defined, represents a comma-separated list of
// transport preferences for the following types: le-acl or iso-[sw|hw],
// which describes the priority list of transport selections used based on the
@@ -1020,19 +1017,17 @@ int HidRawSensor::enable(bool enable) {
}
uint16_t capability = mFeatureInfo.version & 0x0000FFFF;
- uint8_t value;
+ uint8_t index;
if (capability == (kIsoBitMask | kAclBitMask)) {
if (!priorityList.empty() && priorityList[0].compare("le-acl") == 0) {
- value = kLeAclValue;
+ index = mLeTransportAclIndex;
} else {
- value = kLeIsoValue;
+ index = mLeTransportIsoIndex;
}
} else {
- value = (capability & kIsoBitMask) ? kLeIsoValue : kLeAclValue;
+ index = (capability & kIsoBitMask) ? mLeTransportIsoIndex : mLeTransportAclIndex;
}
- uint8_t index = (value == kLeAclValue) ? mLeTransportAclIndex :
- mLeTransportIsoIndex;
HidUtil::copyBits(&index, &(buffer[0]), buffer.size(), 0,
mLeTransportBitOffset, mLeTransportBitSize);
setLeAudioTransportOk = device->setFeature(id, buffer);