Commit Graph

865 Commits

Author SHA1 Message Date
Dianne Hackborn
67f78c4fe8 Some debugging support.
- New feature to "am monitor" to have it automatically launch
  gdbserv for you when a crash/ANR happens, and tell you how to
  run the client.

- Update dumpstate to match new location of binder debug logs

- Various commented out logs that are being used to track down
  issues.

Change-Id: Ia5dd0cd2df983a1fc6be697642a4590aa02a26a5
2010-09-24 13:11:55 -07:00
Jeff Brown
61a25b2490 Looper: use pthread_once for TLS key initialization.
Also fix a Valgrind complaint by zeroing out the entire epoll event
struct since otherwise the data field union would be partly
uninitialized (but not in a harmful way).

Change-Id: I2091ce517e87fcad7c9caf90e2c5e4854a7ca465
2010-09-21 15:26:51 -07:00
Jeff Brown
ed242de3f5 Reduce lock thrashing in native Looper.
In the common case, there is nothing interesting happening on the native
Looper besides occasional wake ups.  There is no point grabbing the
semaphore then.

Change-Id: Ib5c426d0e158dfa37891b7ff5537b6f833592fad
2010-09-17 17:01:23 -07:00
Brian Carlstrom
ce802e33d4 Merge "Fix sim-eng build on Hardy" into gingerbread 2010-09-16 23:48:53 -07:00
Mathias Agopian
2ffb24799e Fix typo which causes sensors to fail miserably
Change-Id: Ieca18fc089e2bdf7d049f213836971b54d11cd76
2010-09-16 21:41:13 -07:00
Mathias Agopian
9e110d532f Merge "part of fix for [3004226] Cannot end the call - Proximity sensor doesn't work" into gingerbread 2010-09-16 17:54:50 -07:00
Mathias Agopian
aeda9afdba part of fix for [3004226] Cannot end the call - Proximity sensor doesn't work
- In SensorEventQueue, only bail on errors from Looper::loopOnce
- Improve sensor error logging

Change-Id: Ib3cf8d5d9fdac8513a3d753155827e0feeda1662
2010-09-16 17:33:48 -07:00
Jeff Brown
3b6dda9e19 Merge "Ensure input dispatcher and native looper handles EINTR." into gingerbread 2010-09-16 17:12:31 -07:00
Jeff Brown
f67f299036 Ensure input dispatcher and native looper handles EINTR.
Change-Id: I0a42db5f273b9bfe4ab174e4ee65d5d852f9f6bc
2010-09-16 17:04:52 -07:00
Jeff Brown
d8816c3c4c Fix app switch latency optimization.
This optimization was broken due to recent changes in how ANRs are handled.

Change-Id: Ic99248a12755fadac8d4893e7d305b773e038d3d
2010-09-16 16:41:46 -07:00
Brian Carlstrom
17563f9fb3 Fix sim-eng build on Hardy
Older glibc version do not include BSD htole32 and htole64 which are
present in bionic. This worksaround a sim-eng build issue by only
using htole32/htole64 if the host is not little endian.

Change-Id: Ia8d0d36285f3c34c51a331790458e52a21c2925f
2010-09-16 16:28:13 -07:00
Jeff Brown
128e33421b Merge "Input API review." into gingerbread 2010-09-16 12:57:56 -07:00
Jeff Brown
405a1d32e9 Fix input dispatcher regression on launcher drag&drop.
Change-Id: I40e937bd712cd2ed6cceac95dfd1b8c8e070724f
2010-09-16 12:31:46 -07:00
Jeff Brown
40ad470643 Fix NPE when handling certain kinds of ANRs.
Change-Id: Iccef1852e52c84f6f49d30c491431460a10b33d3
2010-09-16 11:02:16 -07:00
Jeff Brown
53a415e6d1 Make input dispatcher only ANR for foreground windows.
Redesigned the input dispatcher's ANR timeout mechanism so it is much
closer to Froyo's policy.  ANR is only ever signalled if the dispatcher
is waiting on a window to finish processing its previous event(s) and
there is new pending input.

In the old code, we tracked the dispatch timeout separately for each
input channel.  This was somewhat complicated and also resulted in the
situation where applications could ANR long after the user had pushed
them into the background.

Change-Id: I666ecada0952d4b95f1d67b9f733842b745c7f4b
2010-09-15 18:52:08 -07:00
Jeff Brown
b5764e066c Input API review.
Drop currently unsupported input features.
Add documentation comments.

Change-Id: I407d2e1dd90c5ee82983a3ccf177430d35ee7592
2010-09-14 20:46:14 -07:00
Jeff Brown
b06cca6228 Merge "Replace epoll() with poll() and rename PollLoop to Looper." into gingerbread 2010-09-14 15:27:33 -07:00
Jeff Brown
59abe7e090 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
35b48d10bc Add logging of various important graphics events
There are 16 events logged in the event log:
SF_APP_DEQUEUE_BEFORE
SF_APP_DEQUEUE_AFTER
SF_APP_LOCK_BEFORE
SF_APP_LOCK_AFTER
SF_APP_QUEUE

SF_REPAINT
SF_COMPOSITION_COMPLETE
SF_UNLOCK_CLIENTS
SF_SWAP_BUFFERS
SF_REPAINT_DONE

SF_FB_POST_BEFORE
SF_FB_POST_AFTER
SF_FB_DEQUEUE_BEFORE
SF_FB_DEQUEUE_AFTER
SF_FB_LOCK_BEFORE
SF_FB_LOCK_AFTER

all events log the buffer conserned and a timestamp in microseconds.

by default the logging is not enabled, to turn it on:
adb shell service call SurfaceFlinger 1006 i31 1
adb shell setprop debug.graphic_log 1

The effect is immediate in SurfaceFlinger, but applications need to be
restarted.

Change-Id: Ifc2e31f7aed072d9a7dede20ff2ce59231edbec1
2010-09-13 23:16:58 -07:00
Jeff Brown
a665ca805c Input dispatcher ANR handling enhancements.
This change is essentially a rewrite of the main input dispatcher loop
with the target identification folded in.  Since the input dispatcher now
has all of the window state, it can make better decisions about
when to ANR.

Added a .5 second deadline for processing app switch keys.  This behavior
predates Gingerbread but had not previously been ported.

Fixed some timing inaccuracies in the ANR accounting that could cause
applications to ANR sooner than they should have.

Added a mechanism for tracking key and motion events that have been
dispatched to a window so that appropriate cancelation events can be
synthesized when recovering from ANR.  This change helps to keep
applications in sync so they don't end up with stuck buttons upon
recovery from ANRs.

Added more comments to describe the tricky parts of PollLoop.

Change-Id: I13dffca27acb436fc383980db536abc4d8b9e6f1
2010-09-12 16:52:03 -07:00
Dianne Hackborn
9c82c48d52 Always set the scheduling group when starting a new thread.
Change-Id: Ia33acf13fc3752707f3819928c36315e223fa1bd
2010-09-09 22:12:25 -07:00
Jeff Brown
61ce3982e1 Fix key repeat delay.
Change-Id: I6216e082324ee29bf50e37acc673350ca5417c4d
2010-09-08 12:28:43 -07:00
Jeff Brown
af30ff6020 Add support for secure views.
Added the MotionEvent.FLAG_WINDOW_IS_OBSCURED flag which is set by the
input manager whenever another visible window is partly or wholly obscured
the target of a touch event so that applications can filter touches
accordingly.

Added a "filterTouchesWhenObscured" attribute to View which can be used to
enable filtering of touches when the view's window is obscured.

Change-Id: I936d9c85013fd2d77fb296a600528d30a29027d2
2010-09-08 11:50:55 -07:00
Kenny Root
dc2d840ff7 Revert "Free created FileMap when uncompressing files"
This reverts commit 52b8235238fb4d8cf141020cc1ae33880929dc3f.

munmap() on a region that overlaps something else (e.g, the ZIP Central
Directory in this case) unmaps those other regions as well making the
ZipFileRO class unhappy. Revert this for now until we can have FileMap
deal with this craziness.
2010-09-07 19:30:22 -07:00
Dianne Hackborn
45e0acb41a Modify native ALooper to take an explicit ident.
The ALooper API now uses an explicit "identifier" for the integer
that is returned rather than implicitly using the fd.  This allows
the APIs that had the fd to be a little more sane.

Change-Id: I8507f535ad484c0bdc4a1bd016d87bb09acd7ff0
2010-09-07 15:46:55 -07:00
Dianne Hackborn
bb39b9f17b Hopefully fix the build.
Change-Id: Id8cd92c0895c9939e1386ef488bd1309a3be3568
2010-09-07 12:32:19 -07:00
Dianne Hackborn
7b0d45c346 Add system property to turn off scheduling groups.
Do this:

adb shell setprop debug.sys.noschedgroups 1

Change-Id: I6e06a74205fd45ee1526ce71fe33944465d39984
2010-09-07 11:19:11 -07:00
Kenny Root
45162448b3 Add better debug output for ResourceType errors
An error code is returned as -ESOMETHING, but the debug code was
printing out 0x%08x for these codes making -74 print out as 0xffffffb5
which is kind of silly.

Change-Id: I7d77fb3da2e146845949f121404f662b47288e61
2010-09-02 14:58:47 -07:00
Jeff Brown
774cf1baa1 Remove incomplete input device enumeration NDK API.
Change-Id: I32de74ff5fcf0e29179a2aee03ddabd22fa485bb
2010-08-31 15:24:55 -07:00
Brad Fitzpatrick
5273603e98 Don't propagate StrictMode over one-way Binder calls.
This was causing stack stitching problems where a one-way call with
violations followed by a two-way call without violations was getting
the previous one-way call's violation stack stitched on to the second
caller's stack.

The solution is a little more indirect than I would've liked
(preserving the binder's onTransact flags until enforceInterface) but
was seemingly necessary to work without changing the AIDL compiler.
It should also be sufficiently cheap, since no new calls to
thread-local IPCThreadState lookups were required.  The additional
work is just same-thread getter/setters on the existing
IPCThreadState.

Change-Id: I4b6db1d445c56e868e6d0d7be3ba6849f4ef23ae
2010-08-31 13:16:49 -07:00
Jeff Brown
38a7fabd96 Input device calibration and capabilities.
Finished the input device capability API.
Added a mechanism for calibrating touch devices to obtain more
accurate information about the touch contact area.
Improved pointer location to show new coordinates and capabilities.
Optimized pointer location display and formatting to avoid allocating large
numbers of temporary objects.  The GC churn was causing the application to
stutter very badly when more than a couple of fingers were down).
Added more diagnostics.

Change-Id: Ie25380278ed6f16c5b04cd9df848015850383498
2010-08-30 18:16:43 -07:00
Kenny Root
e96ad7bc45 Merge "Add debugging to ZipFileRO" into gingerbread 2010-08-27 12:58:00 -07:00
Kenny Root
e0573a4ad6 Add debugging to ZipFileRO
Some assets are failing to read from ZIP files. This adds a bit more
debugging to figure out what's going on.

Change-Id: Id90e10546c54c85069a34478fbc28bc2523bda5d
2010-08-27 12:47:34 -07:00
Mathias Agopian
0e7f4292c7 fix a race in SF buffer management
also remove some unused code.

Change-Id: Iae2c3309b7a08055f3e13a5b866c5c084993e352
2010-08-26 17:42:27 -07:00
Mathias Agopian
b661d66013 fix [2931513] Add support for setting the orientation of an ANativeWindow
Also implement support for cropping.

Change-Id: Iba5888dd242bf2feaac9e9ce26e404c1f404c280
2010-08-24 15:40:50 -07:00
Kenny Root
e6d429c49b Merge "Free created FileMap when uncompressing files" into gingerbread 2010-08-20 13:16:20 -07:00
Kenny Root
cd9ce313dd Free created FileMap when uncompressing files
Change-Id: Ice22c4ecb7c129b74bf60cd66ae79e110b017a4a
2010-08-19 18:39:58 -07:00
Mathias Agopian
385648ba93 Merge "remove unused pixel format" into gingerbread 2010-08-19 13:37:35 -07:00
Jeff Brown
2008e3efde Merge "Make the throttling more sensitive to end-to-end latency." into gingerbread 2010-08-19 13:27:58 -07:00
Jeff Brown
869347fc62 Make the throttling more sensitive to end-to-end latency.
The code now takes into account the time when the event was generated.
So with a 60Hz throttling rate, it ensures that a motion event will not
be delayed due to throttling by any more than 1/60th of second past
the time it was generated.

Change-Id: Iaea1d4f76e79036b4a18873485230731c3cd63c3
2010-08-19 13:26:58 -07:00
Mathias Agopian
c04cffd570 remove unused pixel format
Change-Id: I55bc3cc41385743c07f7e4de06335c922f746f73
2010-08-19 13:11:42 -07:00
Kenny Root
1068812158 Merge "Add OBB flags to support overlays" into gingerbread 2010-08-19 09:09:32 -07:00
Jeff Brown
542412c8c9 Add support for throttling motion events.
Change-Id: I24b3a17753e91ecda60a60fe5cd2e6b3260e033d
2010-08-18 16:58:27 -07:00
Sean McNeil
2e7a530242 Only monitor recognized uevent devices.
system_server can potentially monitor uevent devices that are
of no use to it. For instance, an accelerometer implementation
as uevents. This would cause the process to be busy when
unnecessary. If a device cannot be classified, don't monitor it.

Change-Id: Ib2c93105e7d746d9c1a7414bea8bab3fb8c0b70a
2010-08-18 13:53:36 -07:00
Jeff Brown
36cb115c77 Merge "Fix some input device mapping bugs with certain drivers." into gingerbread 2010-08-18 13:38:32 -07:00
Jeff Brown
d64c855821 Fix some input device mapping bugs with certain drivers.
On single-touch devices, pointer up/down is signalled by a BTN_TOUCH
key event.  Previously we handled BTN_TOUCH immediately but some drivers
may produce the sequence BTN_TOUCH, ABS_X, ABS_Y, SYN_REPORT on pointer down
which caused us to emit a bad initial pointer down location.
Now we wait for SYN_REPORT before reporting the up or down.

On multi-touch devices, pointer up can be signalled by as little as
the sequence SYN_MT_REPORT, SYN_REPORT.  This change ensures that we
handle this case.

Added support for reading ABS_MT_PRESSURE when available.
Corrected mapping of touchMajor/touchMinor on single touch devices.
Minor code cleanup.

Change-Id: Ic7ec4811241ed85a06e59b8a839ca05180d491d4
2010-08-18 13:37:45 -07:00
Jens Gulin
7dcaa58496 Keep track of remaining fd when devices are removed
Sometimes the wrong fd was accessed when the device was addressed
by device id.

The earlier implementation assumed that two arrays were in sync
but one of them was compacted when devices were removed. Instead
of that dependency the device now keeps track of it's file descriptor.

Change-Id: Ib0f320603aafb07ded354bc3687de9759c9068f2
2010-08-18 10:54:03 -07:00
Kenny Root
28e9b9f243 Add OBB flags to support overlays
* Add flags field in OBB footer to support overlays.

* Remove unused 'crypto' and 'filesystem' fields in obbtool (could
  later be supported in the "flags" field of the OBB footer).

* Add notes to document OBB classes before shipping.

Change-Id: I386b43c32c5edef55210acb5d3322639c08010ba
2010-08-18 09:34:58 -07:00
Jeff Brown
827630744a Optimize EventHub reads.
Change-Id: Id7d09c0a6e5c741c1e29becd2b6560772c5ff372
2010-08-17 19:40:26 -07:00
Jeff Brown
0cacb87f02 Fix possible race conditions during channel unregistration.
Previously, the input dispatcher assumed that the input channel's
receive pipe file descriptor was a sufficiently unique identifier for
looking up input channels in its various tables.  However, it can happen
that an input channel is disposed and then a new input channel is
immediately created that reuses the same file descriptor.  Ordinarily
this is not a problem, however there is a small opportunity for a race
to arise in InputQueue.

When InputQueue receives an input event from the dispatcher, it
generates a finishedToken that encodes the channel's receive pipe fd,
and a sequence number.  The finishedToken is used by the ViewRoot
as a handle for the event so that it can tell the InputQueue when
the event has finished being processed.

Here is the race:

1. InputQueue receives an input event, assigns a new finishedToken.
2. ViewRoot begins processing the input event.
3. During processing, ViewRoot unregisters the InputChannel.
4. A new InputChannel is created and is registered with the Input Queue.
   This InputChannel happens to have the same receive pipe fd as
   the one previously registered.
5. ViewRoot tells the InputQueue that it has finished processing the
   input event, passing along the original finishedToken.
6. InputQueue throws an exception because the finishedToken's receive
   pipe fd is registered but the sequence number is incorrect so it
   assumes that the client has called finish spuriously.

The fix is to include a unique connection id within the finishedToken so
that the InputQueue can accurately confirm that the token belongs to
the currently registered InputChannel rather than to an old one that
happened to have the same receive pipe fd.  When it notices this, it
ignores the spurious finish.

I've also made a couple of other small changes to avoid similar races
elsewhere.

This patch set also includes a fix to synthesize a finished signal
when the input channel is unregistered on the client side to
help keep the server and client in sync.

Bug: 2834068
Change-Id: I1de34a36249ab74c359c2c67a57e333543400f7b
2010-08-17 17:03:42 -07:00