Commit Graph

46691 Commits

Author SHA1 Message Date
Mathias Agopian
50b66767f6 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
2012-06-27 17:07:54 -07:00
Mathias Agopian
87c9dbb728 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
2012-06-27 17:07:54 -07:00
Mathias Agopian
ddf1ceb647 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
2012-06-27 17:07:54 -07:00
Mathias Agopian
5c6d7ff3e6 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
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
Mathias Agopian
3560fb24b6 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
2012-06-27 17:07:53 -07:00
Mathias Agopian
cf51001dbf 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
2012-06-27 17:07:53 -07:00
Mathias Agopian
7c1c531872 propagate sensor event rate properly to the sensor HAL
Change-Id: I1abe4c0fcce423caab79208353fded4d57398227
2012-06-27 17:07:53 -07:00
Mathias Agopian
1cd7000153 propagate sensor event rate properly
Change-Id: I32e67d30e4295285a6827956cc8161b2025d70bc
2012-06-27 17:07:53 -07:00
Mathias Agopian
50df2959e5 SensorService doesn't crash if correct HAL is not present
Change-Id: I83700b1a1b43390f5830e1056572bfb16e58e8e4
2012-06-27 17:07:53 -07:00
Mathias Agopian
5d2707214d Better dumpsys logs
Change-Id: Iae65a8547ee5815cc4c3b74d2c9ef17bed7f565d
2012-06-27 17:07:53 -07:00
Mathias Agopian
451beee076 Added partial support for repporting sensor activity to IBatteryStats
Change-Id: I2af319d89e49b0f2349ec9d8b0fccac80e9bc047
2012-06-27 17:07:53 -07:00
Mathias Agopian
fc32881fcc new SensorService
remove old sensor service and implement SensorManager
on top of the new (native) SensorManger API.

Change-Id: Iddb77d498755da3e11646473a44d651f12f40281
2012-06-27 17:07:53 -07:00
John Grossman
ec44ed0758 Utils: Fix a bug in the linear transformation code.
Hand merge from ics-aah

> Utils: Fix a bug in the linear transformation code.
>
> Fix a bug where an incorrect result would be computed if you used the
> linear transformation code to do a reverse transformation (from B's
> domain into A's domain) when the scaler fraction was negative.
>
> Change-Id: I8e5f109314d235a177ab41f65d3c4cd08cff78be
> Signed-off-by: John Grossman <johngro@google.com>

Change-Id: Id90e18f685c61c1a89fd91c32adcf01363b3e8f3
Signed-off-by: John Grossman <johngro@google.com>
2012-06-27 15:34:43 -07:00
Johannes Carlsson
3443b333f1 am db1597a9: Fix shutdown sequence to avoid SIGSEGV when running am command
* commit 'db1597a98958b78dc0d8eced19ae1406382b70d6':
  Fix shutdown sequence to avoid SIGSEGV when running am command
2012-06-25 14:06:56 -07:00
Johannes Carlsson
db1597a989 Fix shutdown sequence to avoid SIGSEGV when running am command
When the app_process is shutting down the main thread will close the
binder fd while pool threads are executing an ioctl (in
IPCThreadState::stopProcess called by AppRuntime::onStarted in
app_main.c).

The binder driver will then return all pending calls in ioctl
without any error and with a command. One of the threads gets a
BR_SPAWN_LOOPER which will create a new thread (the other thread
gets a BR_NOOP). This new thread then calls
vm->AttachCurrentThread. Usually this results in a log entry with
"AndroidRuntime: NOTE: attach of thread 'Binder Thread #3' failed",
but sometimes it also causes a SIGSEGV. This depends on the timing
between the new thread an the main thread that calls DestroyJavaVM
(in AndroidRuntime::start).

If IPCThreadState.cpp is compiled with "#define LOG_NDEBUG 0" the
pool thread will loop and hit the
ALOG_ASSERT(mProcess->mDriverFD >= 0) in
IPCThreadState::talkWithDriver.

Crashes like this has been seen when running the am command and
other commands that use the app_process.

This fix makes sure that any command that is received when the driver
fd is closed are ignored and IPCThreadState::talkWithDriver instead
returns an error which will cause the pool thread to exit and detach
itself from the vm. A check to avoid calling ioctl to a fd with -1
was also added in IPCThreadState::threadDestructor.

Another solution might be to change the binder driver so that it
returns an error when the fd is closed (or atleast not a
BR_SPAWN_LOOPER command). It might also be possible to call exit(0)
which is done when System.exit(0) is called from java.

Change-Id: I3d1f0ff64896c44be2a5994b3a90f7a06d27f429
2012-06-25 13:58:47 -07:00
Jesse Hall
b7c839b110 Merge "Pass fences from BufferQueue to SurfaceTextureClient" 2012-06-22 19:58:47 -07:00
Jesse Hall
a277b7a4d7 Merge "Transfer HWC release fences to BufferQueue" 2012-06-22 19:45:10 -07:00
Jesse Hall
37815d16f6 Merge "Move remaining bits of lockBuffer to dequeueBuffer" 2012-06-22 10:15:00 -07:00
The Android Open Source Project
52aab9cbc1 am 589cdbed: Reconcile with jb-release
* commit '589cdbed556fd38a95895ab684dbcded7f4851e9':
2012-06-22 08:20:21 -07:00
The Android Open Source Project
589cdbed55 Reconcile with jb-release
Change-Id: Ic18750e72ccec1b5aad558da8959c9c4031b27f8
2012-06-22 08:17:16 -07:00
Jesse Hall
f785754009 Pass fences from BufferQueue to SurfaceTextureClient
ISurfaceTexture::dequeueBuffer now returns the buffer's fence for the
client to wait on. For BufferQueue, this means passing it through
Binder so it can be returned to the SurfaceTextureClient. Now
SurfaceTextureClient is responsible for waiting on the fence in
dequeueBuffer instead of BufferQueue: one step closer to the goal.

Change-Id: I677ae758bcd23acee2d784b8cec11b32cccc196d
2012-06-21 22:21:12 -07:00
Jesse Hall
ef19414bd8 Transfer HWC release fences to BufferQueue
After a HWC set, each SurfaceFlinger Layer retrieves the release fence
HWC returned and gives it to the layer's SurfaceTexture. The
SurfaceTexture accumulates the fences into a merged fence until the
next updateTexImage, then passes the merged fence to the BufferQueue
in releaseBuffer.

In a follow-on change, BufferQueue will return the fence along with
the buffer slot in dequeueBuffer. For now, dequeueBuffer waits for the
fence to signal before returning.

The releaseFence default value for BufferQueue::releaseBuffer() is
temporary to avoid transient build breaks with a multi-project
checkin. It'll disappear in the next change.

Change-Id: Iaa9a0d5775235585d9cbf453d3a64623d08013d9
2012-06-21 22:21:12 -07:00
Jesse Hall
a74cbc0649 Move remaining bits of lockBuffer to dequeueBuffer
FramebufferNativeWindow::dequeueBuffer now waits for the next buffer
to be non-front in addition to being free.

Change-Id: I991f154958cc6b488b1241aba83d1f95a0513b3c
2012-06-21 11:56:49 -07:00
The Android Automerger
f455c9a267 merge in jb-release history after reset to jb-dev 2012-06-21 07:02:53 -07:00
Jamie Gennis
d8e812ce6f Update ANativeWindow clients for sync
This change updates the uses of ANativeWindow to use the new ANW functions that
accept and return Sync HAL fence file descriptors.

Change-Id: I3ca648b6ac33f7360e86754f924aa072f95242f6
2012-06-20 15:48:30 -07:00
Jamie Gennis
f25e183a70 libui: add the Fence class
This change adds the Fence class to libui for to wrap the libsync
functionality.

Change-Id: I93a31baeee608b93c14da807a32013dabf783f84
2012-06-20 15:48:30 -07:00
Mathias Agopian
aa049f0d19 am 8aaf3e47: am a67e418e: Exit boot animation cleanly.
* commit '8aaf3e47a51aa0beebecc8c536504d310d07cda9':
  Exit boot animation cleanly.
2012-06-20 13:39:58 -07:00
Mathias Agopian
8aaf3e47a5 am a67e418e: Exit boot animation cleanly.
* commit 'a67e418e1fda219f6cc0a7e420bcf5cc4f9fe710':
  Exit boot animation cleanly.
2012-06-20 13:37:09 -07:00
Mathias Agopian
a67e418e1f Exit boot animation cleanly.
The desc.txt file can now mark parts as 'must finish cleanly' by using
'c' as the part line prefix rather than 'p'.  If so indicated, if the
bootanimation is asked to quit it will do so only after waiting to
finish that part.

I considered either making init.c service killing smarter or promoting
bootanim to be a bindable service with a requestExit method.  However,
these changes are probably too big/risky given our ship date.  So
I used a property as a mailbox between SurfaceFlinger and bootanim.

Bug: 6679877
Change-Id: Id7dca22caa50b450fff25ca94f7242d971034f41
2012-06-19 17:32:00 -07:00
Jesse Hall
549646d29f Merge "Add support for HWC_DEVICE_API_VERSION_1_0" 2012-06-19 08:55:12 -07:00
The Android Open Source Project
543ed967ad am fb05c7c3: Reconcile with jb-release
* commit 'fb05c7c34b45e468103b399ef60763e235dd6e06':
  SF could get stuck waiting for vsync when turning the screen off
2012-06-19 06:16:15 -07:00
The Android Open Source Project
fb05c7c34b Reconcile with jb-release
Change-Id: I6a74f5247794a5dddd6fbb75b2edbaba06674ab7
2012-06-19 06:13:43 -07:00
Mathias Agopian
5df996211d fix typo in makefile LOCAL_CFLAGS was spelled LOCAL_CLFAGS
Change-Id: I58b96d28f608ce16fcad5ed0efb887e582779e03
2012-06-18 17:27:56 -07:00
Mathias Agopian
db403e8ff0 split-up Client.h out of SurfaceFlinger.h
Change-Id: I1993bf23e417163749d886283563a93d50b361b4
2012-06-18 16:47:56 -07:00
Jeff Brown
d50fdb0209 am bbdad819: am 7c24b1d4: Merge "SF could get stuck waiting for vsync when turning the screen off" into jb-dev
* commit 'bbdad8193ea3a16e9f65f32f4469959577b400e9':
  SF could get stuck waiting for vsync when turning the screen off
2012-06-18 10:52:34 -07:00
Jeff Brown
bbdad8193e am 7c24b1d4: Merge "SF could get stuck waiting for vsync when turning the screen off" into jb-dev
* commit '7c24b1d4da5e13329d2105cb2f8285715d920787':
  SF could get stuck waiting for vsync when turning the screen off
2012-06-18 10:32:32 -07:00
The Android Automerger
9e39e5353c merge in jb-release history after reset to jb-dev 2012-06-16 07:03:06 -07:00
Mathias Agopian
1ffdccc46e SF could get stuck waiting for vsync when turning the screen off
When turning the screen off we could have 2 waiters on the
vsync condition: The main vsync waiter as well as one in
onScreenReleased(). We were only signaling the condition though,
so it it would be possible to wake onScreenReleased() without waking
the main vsync thread which would then be stuck in .wait().

We fix this by just using broadcast() when receiving a vsync event.

We also add a broadcast() to signal when the state of
mUseSoftwareVSync changes.  This is important particularly for
the transition from hardware to software vsync because the main
vsync waiter might have observed mUseSoftwareVSync == false
and decided to block indefinitely pending a hardware vsync
signal that will never arrive.

Removed a potentially deadlocking wait for a signal in
onScreenReleased().  The function was trying to wait for the last
vsync event from the hardware to be delivered to clients but there
was no guarantee that another thread would signal it to wake up
again afterwards.  (As far as I can tell, the only other other
thread that might wake it up at this point would be a client
application issuing a vsync request.)  We don't really need to wait
here anyhow.  It's enough to set the mUseSoftwareVSync flag,
wake up the thread loop and go.  If there was a pending vsync
timestamp from the hardware, then the thread loop will grab
it and use it then start software vsync on the next iteration.

Bug: 6672102
Change-Id: I7c6abc23bb021d1dfc94f101bd3ce18e3a81a73e
2012-06-15 16:17:06 -07:00
Mathias Agopian
d3076aca0f Merge "Implement SurfaceFlinger's ANW on top of BufferQueue" 2012-06-15 15:34:55 -07:00
Jeff Brown
7c24b1d4da Merge "SF could get stuck waiting for vsync when turning the screen off" into jb-dev 2012-06-15 15:30:35 -07:00
Mathias Agopian
7d88647473 SF could get stuck waiting for vsync when turning the screen off
When turning the screen off we could have 2 waiters on the
vsync condition: The main vsync waiter as well as one in
onScreenReleased(). We were only signaling the condition though,
so it it would be possible to wake onScreenReleased() without waking
the main vsync thread which would then be stuck in .wait().

We fix this by just using broadcast() when receiving a vsync event.

We also add a broadcast() to signal when the state of
mUseSoftwareVSync changes.  This is important particularly for
the transition from hardware to software vsync because the main
vsync waiter might have observed mUseSoftwareVSync == false
and decided to block indefinitely pending a hardware vsync
signal that will never arrive.

Removed a potentially deadlocking wait for a signal in
onScreenReleased().  The function was trying to wait for the last
vsync event from the hardware to be delivered to clients but there
was no guarantee that another thread would signal it to wake up
again afterwards.  (As far as I can tell, the only other other
thread that might wake it up at this point would be a client
application issuing a vsync request.)  We don't really need to wait
here anyhow.  It's enough to set the mUseSoftwareVSync flag,
wake up the thread loop and go.  If there was a pending vsync
timestamp from the hardware, then the thread loop will grab
it and use it then start software vsync on the next iteration.

Bug: 6672102
Change-Id: I7c6abc23bb021d1dfc94f101bd3ce18e3a81a73e
2012-06-15 14:59:31 -07:00
Jeff Brown
b6d00dcf3e am 0512af11: am 16272efb: Add ASSIST keycode.
* commit '0512af11f4b790fb032dc7c344dcdac527faf8ad':
  Add ASSIST keycode.
2012-06-15 12:00:28 -07:00
Jeff Brown
0512af11f4 am 16272efb: Add ASSIST keycode.
* commit '16272efb7af0692266fecdc53b2c6d995bf397b7':
  Add ASSIST keycode.
2012-06-15 11:57:37 -07:00
Jeff Brown
16272efb7a Add ASSIST keycode.
Bug: 6594275
Change-Id: I032b055207d16bfff93ee8a350c0dc52b9102926
2012-06-15 11:46:11 -07:00