51 Commits

Author SHA1 Message Date
Mathias Agopian
89c30a5486 usea socketpair instead of a pipe in BitTube
Bug: 6252830
Change-Id: I363cc7e9f73a5b7d8bbccee312c6d8938c84e99a
2012-04-02 18:38:02 -07:00
Steve Block
3762c31172 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-01-08 13:19:13 +00:00
Steve Block
8564c8da81 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-01-06 10:07:54 +00:00
Steve Block
6215d3ff4b Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/156801

Bug: 5449033
Change-Id: Ib08fe86d23db91ee153e9f91a99a35c42b9208ea
2012-01-04 20:05:49 +00:00
Steve Block
5baa3a62a9 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-01-03 22:38:27 +00:00
Mathias Agopian
c925a654b1 am e1d50e0c: am 785fd368: Merge "handle EINTR when calling sensor HAL\'s poll function" into ics-mr1
* commit 'e1d50e0ccb95f06d1d60aa83822b486828148483':
  handle EINTR when calling sensor HAL's poll function
2011-11-10 19:39:53 +00:00
Mathias Agopian
37d95f6f91 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
2011-11-09 17:53:14 -08:00
Mathias Agopian
e6b5e2452c am 64370354: am 393e2c1f: Merge "SensorService now always clamps the requested rate" into ics-mr1
* commit '6437035400ae63a6f3eb2e375cb979bdd0037ba0':
  SensorService now always clamps the requested rate
2011-11-09 21:51:23 +00:00
Mathias Agopian
eed2373321 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
2011-11-07 21:21:47 -08:00
Mathias Agopian
5f43c96a71 am 515c6b44: Merge "fix an issue where SensorService could request an invalid sensor delay" into ics-mr1
* commit '515c6b44d57b829792267594a355cd2831582197':
  fix an issue where SensorService could request an invalid sensor delay
2011-11-05 19:33:18 +00:00
Mathias Agopian
f61acdac57 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
2011-11-01 19:09:41 -07:00
Mathias Agopian
12cdf5116c Rename SensorChannel to BitTube 2011-10-20 18:42:02 -07:00
Mathias Agopian
6f4f8e790e improve sensorservice dumpsys
Change-Id: I8b53d5cab884c3aca16d95df5fbf288368d52e8b
2011-09-14 16:43:34 -07:00
Mathias Agopian
8c2733527a improve sensorservice_test output
Change-Id: I6248b6f1f001fedec1bddcddfcd2b381d9bb4bf4
2011-09-12 22:16:01 -07:00
Mathias Agopian
3a3fca3dce Fix a few style issues and remove LOG spam
Change-Id: I6b6f75373f4ac28f98dea6a6f1c2567a6aa02243
2011-08-24 18:40:33 -07:00
Michael Johnson
f5cfea78b0 More error checks to avoid div by zero.
Change-Id: I18e5b72d02bf5420c14334d3a03f18fa40572d31
2011-08-24 18:34:49 -07:00
Max Braun
3d41ecd9bd Fix occasional fusion divergence by detecting it and resetting the fusion.
Change-Id: I51186e12fb9b2316e3671e3908174f4495df89a0
2011-08-19 09:16:23 -07:00
Mathias Agopian
88b14c5d6d have the sensorsevice test print the delay of the first received event
Change-Id: I89d63122574c3f8790f00512c76d59b463acf18f
2011-08-15 17:10:23 -07:00
Mathias Agopian
f9a4b1366e silence sensorservice when it's dropping events
Change-Id: Ib05862e545aa780821aa605e45ab189f530494b7
2011-07-20 18:51:15 -07:00
Mathias Agopian
29c176f043 sensorservice: be more robust when there are no sensor h/w
Bug: 5030108
Change-Id: I45b85b3c492b9268cb0ae44d2e5fc8c708b6e66e
2011-07-14 16:39:46 -07:00
Jeff Brown
bd882b1c87 Remove the simulator target from all makefiles.
Bug: 5010576

Change-Id: I04d722f258951a3078fe07899f5bbe8aac02a8e8
2011-07-11 22:12:16 -07:00
Mathias Agopian
0dd593f223 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
2011-06-27 17:42:15 -07:00
Mathias Agopian
451e825847 cleanup Kalman filter parameters, add/fix comments/units
Change-Id: Iedcae7164af8f7ea0e048ea7c72d0f35d16d739f
2011-06-13 18:47:17 -07:00
Mathias Agopian
f8a6737f3d 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
2011-06-08 20:06:50 -07:00
Mathias Agopian
6043e5329c 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
2011-06-02 21:11:50 -07:00
Mathias Agopian
73e0bc805a 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
2011-05-27 17:04:55 -07:00
Mathias Agopian
9ff73de08f Fix a few issues with sensors reference-counting 2011-05-27 16:36:58 -07:00
Mathias Agopian
057f625cd9 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
2011-05-19 16:21:32 -07:00
Iliyan Malchev
3070af0882 frameworks/base: remove LOCAL_PRELINK_MODULE
Change-Id: I54dd62ebef47e7690afa5a858f3cad941b135481
Signed-off-by: Iliyan Malchev <malchev@google.com>
2011-03-14 14:25:59 -07:00
Mathias Agopian
8d94d82a6d 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
2011-03-10 15:23:28 -08:00
Mathias Agopian
f0aec213ec 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
2011-02-03 14:52:47 -08:00
Mathias Agopian
0bcd713977 fix [3369027] Sensor.TYPE_ROTATION_VECTOR is unstable and returns NaNs when running slowly
The cut-off frequency of the lowpass filter was too high
for the sampling rate used by DELAY_NORMAL.

Now we use the same filters used for the gravity vector
(cascaded biquad at 1.5 Hz)

Change-Id: I319dc4f449a3abd553d61b196a9ddcf7782f912d
2011-01-19 18:20:06 -08:00
Mathias Agopian
b483d5cd13 fix [3237242] sensormanager sensor active count gets out of sync
whether a physical sensor needed to be active or not was managed by
a simpe reference counter; unfortunatelly nothing prevented it to
get out of sync if a sensor was disabled more than once.

sensorservice already maintainted a list of all the "clients"
connected to a physical sensor; we now use that list to determine if
a sensor should be enabled. This can never be "out-of-sync" since
this is the only data structure linking a sensor to a user of that
sensor.

also removed the isEnabled() method, which was never used and
implemented wrongly (since it didn't take into account that a sensor
could be disabled for a client but not of another).

Change-Id: I789affb877728ca957e99f7ba749def37c4db1c7
2010-11-30 15:41:16 -08:00
Mathias Agopian
186b68b744 Merge "allow rotation-vector to have 4 components" into gingerbread 2010-11-30 15:38:38 -08:00
Mathias Agopian
6038db3dda Uses 4-th order low-pass for extracting gravity.
Most accelerometers have 8-bits accuracy so we beed to
reject 48dB in thestop-band, which requires a 4-th order
filter at the cut-off frequency we're using.

Change-Id: Ic00421d38d751641f86b1f3ad7663e6b44a91198
2010-11-30 14:07:28 -08:00
Mathias Agopian
7badd2c402 allow rotation-vector to have 4 components
- upadte documentation for rotation vector
- update method dealing with rotation vector to deal with 4 components
- virtual rotation-vector sensor reports all four components
- improve SensorManager documentation layout

Whent he 4-th component of the rotation-vector is present, we can save
a square-root when computing the quaternion or rotation matrix from it.

Change-Id: Ia84d278dd5f0909fab1c5ba050f8df2679e2c7c8
2010-11-30 14:07:09 -08:00
Mathias Agopian
5d45c33eb8 don't attempt to normalize the rotation vector
indeed, by construction of the rotation matrix, it is
guaranteed to have a length of 1.

moreover, the normalization code was missing a square-root,
fortunatelly, since the length is 1, this didn't cause any
damage (since sqrt(1) = 1).

Change-Id: I9facd668caaf5bb3bfccb139ab872f2bb2066365
2010-11-22 01:04:09 -08:00
Mathias Agopian
671a6ff4be 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
2010-11-18 15:29:05 -08:00
Mathias Agopian
f33a6e9645 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
2010-11-14 20:55:25 -08:00
Mathias Agopian
3a9223ebf8 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
2010-11-10 17:50:28 -08:00
Mathias Agopian
94c4f5c1b2 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
2010-11-08 13:51:53 -08:00
Jeff Brown
4fe6c3e51b 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
2010-09-14 01:59:45 -07:00
Mathias Agopian
32123fde1b Report sensor events to BatteryStats service
Change-Id: I9b83aa709887aa658bc474391573f2d45b6c4eb2
2010-07-23 16:55:24 -07:00
Mathias Agopian
aea786f42c SensorService handles last known state properly
SensorService now correctly sends the last known
state of a sensor as soon as a new connection is made.
This fixes the issue where, for instance, an application
could wait a long time before getting the light or proximity
sensor initial state.

Change-Id: Ic41392f3626e26c4f15746c7e17c7ecd44bbb10b
2010-07-22 21:24:39 -07:00
Mathias Agopian
efba8bf53a filter sensor event by connection
we now don't send events down to a connection that has not
registered for this event.

Change-Id: I3fe507974d3e99293749bfec2ef871e8a0ee9600
2010-07-22 16:18:10 -07:00
Mathias Agopian
d865351844 propagate sensor event rate properly to the sensor HAL
Change-Id: I1abe4c0fcce423caab79208353fded4d57398227
2010-07-21 21:45:57 -07:00
Mathias Agopian
23e8de26b7 propagate sensor event rate properly
Change-Id: I32e67d30e4295285a6827956cc8161b2025d70bc
2010-07-21 16:09:39 -07:00
Mathias Agopian
5df13ef30e SensorService doesn't crash if correct HAL is not present
Change-Id: I83700b1a1b43390f5830e1056572bfb16e58e8e4
2010-07-21 16:09:39 -07:00
Mathias Agopian
42e1b39ac5 Better dumpsys logs
Change-Id: Iae65a8547ee5815cc4c3b74d2c9ef17bed7f565d
2010-07-19 17:57:29 -07:00
Mathias Agopian
6f8b4d28d4 Added partial support for repporting sensor activity to IBatteryStats
Change-Id: I2af319d89e49b0f2349ec9d8b0fccac80e9bc047
2010-07-19 17:57:29 -07:00