diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-05-29 15:34:26 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-05-29 15:34:26 +0000 |
commit | aec5a535ca3ead7bdbfc52e7bd9e05954e43422a (patch) | |
tree | 6e946b640080f3ea0875cc30728332403bca913d /apps | |
parent | ed6ecbb23de98058ebcdc2c6a22b02ad11bc68e5 (diff) | |
parent | 814a2d0faa812fec98559c283fc0d8486fef43a3 (diff) | |
download | chre-aec5a535ca3ead7bdbfc52e7bd9e05954e43422a.tar.gz |
Merge "cross val napp ensures sampling interval >= minInterval in CHRE" into rvc-dev
Diffstat (limited to 'apps')
-rw-r--r-- | apps/test/common/chre_cross_validator/src/chre_cross_validator_manager.cc | 47 | ||||
-rw-r--r-- | apps/test/common/proto/chre_cross_validation.proto | 4 |
2 files changed, 26 insertions, 25 deletions
diff --git a/apps/test/common/chre_cross_validator/src/chre_cross_validator_manager.cc b/apps/test/common/chre_cross_validator/src/chre_cross_validator_manager.cc index cf9d94f6..70b54bf9 100644 --- a/apps/test/common/chre_cross_validator/src/chre_cross_validator_manager.cc +++ b/apps/test/common/chre_cross_validator/src/chre_cross_validator_manager.cc @@ -16,6 +16,7 @@ #include "chre_cross_validator_manager.h" +#include <algorithm> #include <cinttypes> #include <chre.h> @@ -247,37 +248,37 @@ bool Manager::encodeProximitySensorDatapoints(pb_ostream_t *stream, bool Manager::handleStartSensorMessage( const chre_cross_validation_StartSensorCommand &startSensorCommand) { - bool success = true; + bool success = false; uint8_t sensorType = startSensorCommand.chreSensorType; - uint64_t interval = startSensorCommand.samplingIntervalInNs; - uint64_t latency = startSensorCommand.samplingMaxLatencyInNs; + uint64_t intervalFromAp = startSensorCommand.intervalInMs; + uint64_t latency = startSensorCommand.latencyInMs; bool isContinuous = startSensorCommand.isContinuous; uint32_t handle; if (!chreSensorFindDefault(sensorType, &handle)) { LOGE("Could not find default sensor for sensorType %" PRIu8, sensorType); - success = false; // TODO(b/146052784): Test other sensor configure modes } else { - // If the sensor is on-change or one-shot then the interval from host - // message will be 0 which cannot be passed to chreSensorConfigure so set - // the interval and latency to default in that case - if (!isContinuous) { - interval = CHRE_SENSOR_INTERVAL_DEFAULT; - latency = CHRE_SENSOR_LATENCY_DEFAULT; - } - // Copy hostEndpoint param from previous version of cross validator - // state - mCrossValidatorState = CrossValidatorState( - CrossValidatorType::SENSOR, sensorType, handle, chreGetTime(), - mCrossValidatorState->hostEndpoint, isContinuous); - if (!chreSensorConfigure(handle, CHRE_SENSOR_CONFIGURE_MODE_CONTINUOUS, - interval, latency)) { - LOGE("Error configuring sensor with sensorType %" PRIu8 - ", interval %" PRIu64 "ns, and latency %" PRIu64 "ns", - sensorType, interval, latency); - success = false; + chreSensorInfo sensorInfo; + if (!chreGetSensorInfo(handle, &sensorInfo)) { + LOGE("Error getting sensor info for sensor"); } else { - LOGD("Sensor with sensor type %" PRIu8 " configured", sensorType); + // TODO(b/154271547): Send minInterval to AP and have the AP decide from + // both CHRE and AP min and max interval. + uint64_t interval = std::max(intervalFromAp, sensorInfo.minInterval); + // Copy hostEndpoint param from previous version of cross validator + // state + mCrossValidatorState = CrossValidatorState( + CrossValidatorType::SENSOR, sensorType, handle, chreGetTime(), + mCrossValidatorState->hostEndpoint, isContinuous); + if (!chreSensorConfigure(handle, CHRE_SENSOR_CONFIGURE_MODE_CONTINUOUS, + interval, latency)) { + LOGE("Error configuring sensor with sensorType %" PRIu8 + ", interval %" PRIu64 "ns, and latency %" PRIu64 "ns", + sensorType, interval, latency); + } else { + LOGD("Sensor with sensor type %" PRIu8 " configured", sensorType); + success = true; + } } } return success; diff --git a/apps/test/common/proto/chre_cross_validation.proto b/apps/test/common/proto/chre_cross_validation.proto index 4e31e299..c208eaad 100644 --- a/apps/test/common/proto/chre_cross_validation.proto +++ b/apps/test/common/proto/chre_cross_validation.proto @@ -32,8 +32,8 @@ message StartCommand { */ message StartSensorCommand { optional uint32 chreSensorType = 1; - optional uint64 samplingIntervalInNs = 2; - optional uint64 samplingMaxLatencyInNs = 3; + optional uint64 intervalInMs = 2; + optional uint64 latencyInMs = 3; optional bool isContinuous = 4; } |