Commit Graph

58 Commits

Author SHA1 Message Date
Mark Salyzyn 993146092f am d4dabf87: am cdbf28b3: Merge "native frameworks: 64-bit compile issues"
* commit 'd4dabf872ac0a12e12aebae9032f7d62762c2aeb':
  native frameworks: 64-bit compile issues
2014-03-13 23:12:09 +00:00
Mark Salyzyn d4dabf872a am cdbf28b3: Merge "native frameworks: 64-bit compile issues"
* commit 'cdbf28b3f7f5327f4cb0eb95b8326bf4c24c87ba':
  native frameworks: 64-bit compile issues
2014-03-13 15:26:10 +00:00
Mark Salyzyn 92dc3fc52c native frameworks: 64-bit compile issues
- Fix format (print/scanf)
- Suppress unused argument warning messages (bonus)

Change-Id: I05c7724d2aba6da1e82a86000e11f3a8fef4e728
2014-03-12 13:12:44 -07:00
Aravind Akella 35348dc712 am e7643e43: am 8ae7c02e: am ffac23b2: am 4b84704b: Ignore flush complete events when recording last value for a sensor.
* commit 'e7643e431abc2d1b42ab1d68913ec22d0b180554':
  Ignore flush complete events when recording last value for a sensor.
2014-03-06 02:57:23 +00:00
Aravind Akella 4b84704b97 Ignore flush complete events when recording last value for a sensor.
Bug: 11822806
Change-Id: I1402d6684ed71ed413aef6a7be3aad945b331ec2
2014-03-06 00:48:59 +00:00
Patrick Tjin eefced119b Add uid to sensorservice's dump of active connections
Change-Id: I1c365157bcd28a93635dbde4a8d91c79750e03ae
2014-02-05 15:06:03 -08:00
Aravind Akella b4099e77ec Bug fixes for SensorService
i) Emulate Flush for AOSP Fusion Sesnsors on newer HALs that support batching.
ii) Early return if there are no events for the current SensorEventConnection.

Bug: 11325707, 11376538

Change-Id: Idb856302463649a99d3d5d0c965bb06ba06b8e1d
2013-10-25 13:58:58 -07:00
Aravind Akella c551eac5b1 SensorService Flush API bug fix.
SensorService is dead locking itself when flush is called on older devices which don't support batching. mConnectionLock is acquired twice.

Change-Id: I5c25585bfb2b396df4b05826a9cba1da7997a3ee
2013-10-14 17:09:19 -07:00
Aravind Akella 701166d9f6 Change API from flush(handle) to flush(). Call flush on all active sensors in the given SensorEventConnection.
Change-Id: I4ef2bec80406c517903ab9782dc9eaf3fa8b7f36
2013-10-09 17:26:01 -07:00
Aravind Akella 4c8b951f8d Sensor Batching Bug fixes.
i) SensorService dropping events. Increase SOCKET_BUFFER_SIZE in BitTube ctor.
ii) Call flush before every activate.
iii) Emulate flush for older devices. Add a trivial flush complete event when flush is called.

Bug: 10641596
Change-Id: I30d0f3948e830457143f16e157b6ad81908687ce
2013-09-16 14:43:02 -07:00
Mathias Agopian 90ed3e8d78 fix a few problems with BitTube
BitTube used to send objects one at a time and didn't
handle errors properly.

We now send all the objects in one call, which means they
have to be read as a single batch as well. This changes the
BitTube API.

Update SensorService to the new API.

Also added an API to set the size of the send buffer.

Bug: 10641596
Change-Id: I77c70d35e351fdba0416fae4b7ca3b1d56272251
2013-09-10 21:10:53 -07:00
Aravind Akella 724d91d778 Sensor batching. Changes to the native code.
Bug: 10109508
Change-Id: I7333f3aac76125a8226a4c99c901fb904588df04
2013-09-03 17:04:36 -07:00
Mathias Agopian cdd7d8bc14 resolved conflicts for merge of 00aea5c5 to master
Change-Id: Ie1769be863ee2d411eae451907a928db57882e14
2013-07-12 14:19:10 -07:00
Mathias Agopian ac9a96da65 fix a dead-lock in sensorservice
sensorservice would deadlock if for some reason
a sensor failed to enable.

simplifed the code a bit, and made it behave a little
closer to mr1.1 -- I couldn't convince myself that
some changes in how locks were used were correct.

Bug: 9794362
Change-Id: I6110f5dbb67e543f1c71d127de2299232badb36a
2013-07-12 02:08:06 -07:00
Mathias Agopian ba02cd2f6c improve sensorservice's dumpsys
it now displays the reported trigger mode properly, as well as
the number and type of the last received data

Change-Id: I2ff64b32ab71f1332bc2e09671c8c02bb9550490
2013-07-08 15:44:41 -07:00
Mathias Agopian 7438fd1a01 simplify some unnecessary complex code
getSensorType() ran in O(n) instead of O(1). fix that.

Change-Id: Idcf29e46fc34db32604a0d8e5a9156486783b74f
2013-07-08 12:50:39 -07:00
Mathias Agopian 0319306670 various fixes to the sensorservice
1) "google" sensors are now reporting AOSP as the vendor string
2) don't expose the system's sensor fusion if the HAL provides it
3) use uncalibrated gyro if availble for the system's sensor fusion

Change-Id: I25140436cdb29d55e39fd6fbbf8c44a410a83d5c
2013-05-16 18:47:21 -07:00
Jaikumar Ganesh 4c01b1ad80 Fix activation issue with auto disabled sensors.
Auto disabled sensors get auto disabled after trigger.
An activation after this wasn't working because the
state was not being reset.

b/8609561

Change-Id: If72c9f27345e91671d7ad0a7a066f6dc3d255b78
2013-04-17 14:58:22 -07:00
Jaikumar Ganesh 4342fdf14f Sensor changes.
1. Some sensors can wake up the AP. Add wakelocks.
2. Handle backward compatibility for rotation vector
   heading accuracy.
3. Cleanup auto disabled sensors.
4. Fix race condition between enable and dispatch.

Change-Id: I39dddf12e208d83cd288201986ee994312555820
2013-04-12 09:34:44 -07:00
Mathias Agopian 787ac1b388 improve sensor battery usage tracking
until now we were tracking when a sensors was
physically enabled or disabled and we were reporting
that to the BattaryService.

this wasn incorrect because we could have several different
apps enabling the same sensor, so the accounting by the
battery service would be incorrect in that case (depending
on the order in which these apps disabled said sensor).

BatteryService tracks sensors per uid, however SensorService
does this per binder connection, so we could have several
binder connections for the same uid, to solve this we keep
a list of sensor/uid -> count, which is the bulk of this
change.

Bug: 6661604
Change-Id: I561c198c42ba1736a8671bdacda4c76d72b9dd6f
2012-09-18 23:33:36 -07:00
Mathias Agopian 5307d17fe3 track UID with connections
Change-Id: Id4865f3cd27a95acdbbfdff1f2bb4123f312a13b
2012-09-18 23:33:36 -07:00
Mathias Agopian a5b8e8bfa9 fix a typo in SensorService
It shouldn't have caused much harm though.
Also log a warning when enabling a sensor
for a connection that is already enabled.

Change-Id: Ia4a052381e79183cd4cb1bedc7ba08e5228d7a38
2012-09-18 17:19:04 -07:00
Mathias Agopian 33264868ba add a way to enable debugging sensors at runtime
if debug.sensors is true, extra debugging
sensors are enabled and HAL provided sensor fusion
is disabled

Change-Id: I9b093424edb8c5363d1337237cdf6abe4ab266f9
2012-06-28 19:46:54 -07:00
Mathias Agopian 8dd4fe8dd3 fix a potential buffer overflow in sensorservice
Bug: 6580560
Change-Id: Icf6cafbca09174515a964a7cd69d8cc589ad52de
2012-06-27 17:07:56 -07:00
Mathias Agopian d1920ffede Fix a stack corruption in sensorservice
Bug: 6576732
Change-Id: If0f2fb0d0c35b932fb77cd262e676042145b28f9
2012-06-27 17:07:56 -07:00
Mathias Agopian a5c106a4f0 fix a typo causing sensor event to be sorted in reverse chronological order
Change-Id: I041c64616d88ed1abb5efc90ed9eb0d9baeb4832
2012-06-27 17:07:56 -07:00
Mathias Agopian 907103bf18 usea socketpair instead of a pipe in BitTube
Bug: 6252830
Change-Id: I363cc7e9f73a5b7d8bbccee312c6d8938c84e99a
2012-06-27 17:07:56 -07:00
Steve Block f5a1230d32 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2012-06-27 17:07:56 -07:00
Steve Block 3c20fbed7f Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
2012-06-27 17:07:56 -07:00
Steve Block a551237de1 Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156016

Bug: 5449033
Change-Id: I4c4e33bb9df3e39e11cd985e193e6fbab4635298
2012-06-27 17:07:56 -07:00
Mathias Agopian 1a62301fc5 handle EINTR when calling sensor HAL's poll function
some sensor HALs don't handle EINTR, make sure to catch it in the
sensorservice.

also if we ever encounter an error that we can't handle, we abort
which will restart us (or the whole system process if we're running
in it)

Bug: 5511741
Change-Id: I7051882b06980f778736b53d6cd021a99b5ca8d2
2012-06-27 17:07:56 -07:00
Mathias Agopian 62569ecf52 SensorService now always clamps the requested rate
Requested rate will be clamped to the minimum rate and then
to 1ms. Previously we would return an error if a lower
rate was asked. The SensorManager documentation wording
allows this change.

We do this to get more consistancy between all the sensor
drivers / HALs

Change-Id: I199f76486fb76ccbb11e7280460a03726c767e84
2012-06-27 17:07:56 -07:00
Mathias Agopian ae09d65f5b fix an issue where SensorService could request an invalid sensor delay
When the app requests "fastest", the java layer encodes this as a
delay of 0. SensorService was passing this unchanged to the HAL.
However the HAL is required to reject delays lower that the
advertised lower delay.

Change-Id: I92be77acd3af62ffeb49e4b31e24ddcd203510e2
2012-06-27 17:07:56 -07:00
Mathias Agopian b3989276d1 Rename SensorChannel to BitTube 2012-06-27 17:07:55 -07:00
Mathias Agopian 16c3e4ae72 silence sensorservice when it's dropping events
Change-Id: Ib05862e545aa780821aa605e45ab189f530494b7
2012-06-27 17:07:55 -07:00
Mathias Agopian 7b2b32f2e7 sensorservice: be more robust when there are no sensor h/w
Bug: 5030108
Change-Id: I45b85b3c492b9268cb0ae44d2e5fc8c708b6e66e
2012-06-27 17:07:55 -07:00
Mathias Agopian 1cb13461a8 PermissionCache caches permission checks
This is intended to absorb the cost of the IPC
to the permission controller.
Cached permission checks cost about 3us, while
full blown ones are two orders of magnitude slower.

CAVEAT: PermissionCache can only handle system
permissions safely for now, because the cache is
not purged upon global permission changes.

Change-Id: I8b8a5e71e191e3c01e8f792f253c379190eee62e
2012-06-27 17:07:55 -07:00
Mathias Agopian 010e422301 improve orientation sensor with gyro data
when we do our own sensor fusion, we also export an
improved orientation sensor and hide the HAL sensor.
The fused orientation sensor is much more precise, fast
and smooth.

Change-Id: I0ea843b47ad9d12f6b22cce51f8629852d423126
2012-06-27 17:07:55 -07:00
Mathias Agopian 3301542828 use quaternions instead of MRPs
also use correct time propagation equation
disable the fused sensors when gyro is not present since
they were unusable in practice.

Change-Id: Iad797425784e67dc6c5690e97c71c583418cc5b5
2012-06-27 17:07:55 -07:00
Mathias Agopian 984826cc15 9-axis sensor fusion with Kalman filter
Add support for 9-axis gravity and linear-acceleration sensors
virtual orientation sensor using 9-axis fusion

Change-Id: I6717539373fce781c10e97b6fa59f68a831a592f
2012-06-27 17:07:54 -07:00
Mathias Agopian a1b7db95b6 Fix a few issues with sensors reference-counting 2012-06-27 17:07:54 -07:00
Mathias Agopian e04a63b305 Fix a crasher in SensorService
SensorService main thread wasn't java-enabled. however, in
some situations we end-up calling into the BatteryService from
that thread which causes a crash.

Change-Id: Iffba90e4c4b743dba84d62f1342001a9db31916d
2012-06-27 17:07:54 -07:00
Mathias Agopian 3f2f891611 fix [4025681] continuous sensors should not try to send an event as soon as they're activated
Make sure to send an event down only for sensors that report a value only on data
change. Other sensors, will naturally send an event when the next event is available.

Bug: 4025681
Change-Id: I6d444deda388b6bc9a33e3371e09d390f1566ec5
2012-06-27 17:07:54 -07:00
Mathias Agopian db5b4bce9e fix [3421350] Killing a game that uses the accelerometer renders the device unable to sleep
when an app dies, make sure to disable all sensors that process
is connected to, regardless of wether this was the LAST connection
to this sensor.

Change-Id: I9c72b1792eee03815304674d5c2f25b5270e4748
2012-06-27 17:07:54 -07:00
Mathias Agopian f001c92436 Add support for virtual sensors.
Rework sensorservice to allow "virtual sensors", that is
sensors that report a synthetized value based on real sensors.

the main change to sensorservice is around managing which real
sensor need to be activated and which rate to use.

The logic for all this has been moved into SensorDevice, which
essentially wraps the sensor HAL but adds two features to it:
- it keeps track of which sensors need to be activated
- it keeps track of what rate needs to be used

For this purpose an "identity" is associated with each real sensor
activation, so we can track them.

On start-up we check for gravity, linear-acceleration and
rotation-vector sensors, if they're not present in the HAL, we
synthetize them in sensor-service.

Change-Id: I841db2c1b37ef127ed571efa21732ecc5adf1800
2012-06-27 17:07:54 -07:00
Mathias Agopian 71d7a5c289 Fix a race condition in sensormanager
the per-connection state assumed the main sensorservice
lock was held during access. This is however not true while
pre-processing the events just before sending them to clients.
Therefore, there was a small window during which this state
could be modified while being used.

we now have an internal lock that protects this state.

Change-Id: I594680f20f09d6a4f1f38f093a1d3f650dcef1be
2012-06-27 17:07:54 -07:00
Mathias Agopian 94e8f6813f record the last event received regardless of having clients or not
We only recorded the last received event (which is needed when a sensor
is activated on a connection) when there was some connection active.
This should fix an issue where sometimes the light sensor doesn't
return an event whent activated.

we also didn't need to hold the main lock while dispatching events
to clients.

Change-Id: I6c6386c040051ce205e3c0516c678e0603fa45e1
2012-06-27 17:07:54 -07:00
Mathias Agopian 24d72350f3 improve sensorservice dumpsys and increase the max sensor rate to 1 ms (1000Hz)
the increased maximum rate is needed for proper gyro integration, current gyro
parts can sample at up to 800Hz

Change-Id: Ide75f6d5bc7a0fdafeb2dafd72db39e7afb9e794
2012-06-27 17:07:54 -07:00
Jeff Brown 1e0b1e8491 Replace epoll() with poll() and rename PollLoop to Looper.
As part of this change, consolidated and cleaned up the Looper API so
that there are fewer distinctions between the NDK and non-NDK declarations
(no need for two callback types, etc.).

Removed the dependence on specific constants from sys/poll.h such as
POLLIN.  Instead looper.h defines events like LOOPER_EVENT_INPUT for
the events that it supports.  That should help make any future
under-the-hood implementation changes easier.

Fixed a couple of compiler warnings along the way.

Change-Id: I449a7ec780bf061bdd325452f823673e2b39b6ae
2012-06-27 17:07:53 -07:00
Mathias Agopian c4a930d1d5 Report sensor events to BatteryStats service
Change-Id: I9b83aa709887aa658bc474391573f2d45b6c4eb2
2012-06-27 17:07:53 -07:00