OSDN Git Service

Fix enforcement of sensor's slowest rate
authorJim Kaye <jameskaye@google.com>
Mon, 8 May 2017 16:07:27 +0000 (09:07 -0700)
committerJim Kaye <jameskaye@google.com>
Mon, 8 May 2017 16:31:52 +0000 (16:31 +0000)
commit663720b29f412756b8599897df9f8e32eb930be2
tree7b36230ffd8c01d058fa8c36c30b909c2225067e
parent584bc3cebf3f23d378fc7ed06e71c5d1722373dd
Fix enforcement of sensor's slowest rate

This code calculates a sensor's maximum sample
period in nanoseconds. This is stored as a 64-bit
value, as required for periods greater than ~2.1
seconds.

The calculation was done with 32-bit arithmetic,
sometimes resulting in overflow. This caused the
sensor to run at its maximum rate.

(The requested period is first clipped to the maximum
period. When the maximum period appears negative, it
is always used. The now-negative period is then clipped
to the minimum period, resulting in the sensor's maximum
supported rate.)

Bug: 37465457

Test: Verified correct operation with Goldfish accelerometer,
which has a 60-second maximum period.

Change-Id: Ic75a9dc7c4e7c9ca690eafbfa51ee50540ca5aaf
services/sensorservice/SensorService.cpp