231 Commits

Author SHA1 Message Date
Jeff Brown
22aa512026 Capture input dispatcher's last ANR state in bug report.
Some ANR bugs are very difficult to localize because by the time
the bug report has been captured, the relevant information is
gone.  Work around this by capturing a log of the input dispatcher's
state at the exact time of the ANR before anything has changed
and include this information in the bug report.

Also fixed a nit related to some format strings that had
improper field widths specified.

Bug: 6680398
Change-Id: I5323bf18ec5e47a767cd053209753cc46852bf4c
2012-06-17 15:51:30 -07:00
Jeff Brown
265f1ccc51 Improve ANR diagnostics.
When an ANR occurs, log the associated reason.

When an event takes too long to process (currently more than 2 seconds)
log basic information about the event including how long it actually
took.

Dump the contents of the inbound, outbound and wait queues as part
of dumpsys input.

Bug: 6574842
Change-Id: I9ab754c320f609cb86fe266c469a61e7032dfed6
2012-06-11 18:05:31 -07:00
Jeff Brown
8249fc6183 Don't ANR on hover, scroll or if a window goes away.
Prevents ANR on hover or scroll events.

Prevents ANR in the case where one finger touches a window which
is subsequently removed then a second finger comes along and tries
to touch something.

Change-Id: I985ccb70cd86659992328f14f8a705f3f05ea2e5
2012-05-24 19:34:39 -07:00
JP Abgrall
286298896b Merge "Revert "services: input events: enable debugging in EventHub (touch screen issues)"" into jb-dev 2012-05-16 13:24:10 -07:00
JP Abgrall
25a465bb44 Revert "services: input events: enable debugging in EventHub (touch screen issues)"
This reverts commit df0a89daa8018f9dec53d8d766e5a045347ffc93

Get rid of the debugging for the release.
2012-05-16 10:33:49 -07:00
Jeff Brown
8a90e6e317 Minor refactoring before starting on velocity tracker changes.
Bug: 6413587
Change-Id: I5eba2bb57193bff78cb3740de5f87aca0b31d154
2012-05-11 12:32:56 -07:00
Jeff Brown
571d4cbeec Merge "Fix bugs in fallback key handling." into jb-dev 2012-05-09 17:35:07 -07:00
Jeff Brown
fd23e3ed97 Fix bugs in fallback key handling.
If a fallback key is generated using a key plus a modifier,
then it's possible we might get a different fallback key
generated if the modifier has changed.  PhoneWindowManager
needs to remember which fallback is last generated for a
given key code so that it can apply the same fallback action.

When generating cancellation events, it's important to have
preserved the policyFlags of the original event.  Otherwise
we may not dispatch the cancellation properly.  For example,
some actions are not performed if the POLICY_FLAG_TRUSTED
is not specified.

Remember the metaState associated with a key event so we can
include it when canceled.

Tell the policy when a fallback is being cancelled so that it
can clean up its state.

After a SEARCH shortcut is invoked, clear the flag indicating
that a shortcut is pending.  This is to prevent SEARCH from
getting stuck down in the case where we might forget to send
the up.  (Shouldn't happen anymore after the prior fixes.)

Bug: 5616255
Change-Id: I68f0a9679c7af464eaf31c099f2aa50b53fecf1f
2012-05-09 13:34:28 -07:00
JP Abgrall
956f9bd004 Merge "services: input events: enable debugging in EventHub (touch screen issues)" into jb-dev 2012-05-09 10:41:28 -07:00
JP Abgrall
df0a89daa8 services: input events: enable debugging in EventHub (touch screen issues)
Enable verbose logging, but limit the output of events to only those that
are stale by more than 1ms.
This does not overly pollute the logcat output.


Bug: 6258051
Change-Id: I32012a379ca0e97c0834975482cd91f9eeb08907
2012-05-08 16:38:33 -07:00
Jeff Brown
c042ee2acd Disable input dispatch until boot finished.
Bug: 6263070
Change-Id: I25e15e3d8af8eb3343c7b684fec345337d9f6aab
2012-05-08 13:58:32 -07:00
Jeff Brown
a75fe05b6e Use EVIOCSCLOCKID correctly.
Bug: 6382031
Change-Id: I87b0887ce867a79758bcd24e2202280270faaf8c
2012-05-01 18:41:26 -07:00
Jeff Brown
daa3753a04 Improve handling of built-in keyboard.
The window manager policy made some incorrect assumptions about the
meaning of the Configuration.keyboard field.  We need to be more
careful about distinguishing between built-in and external keyboards.

Most of this change is to move the determination of the parts of
the Configuration related to input devices into the WindowManagerService
leveraging new features of the InputManagerService to good effect.

Then we plumb through the flag that indicates whether a device
is internal or external so that we can be more particular about
how the lid switch effects changes to the Configuration.

Bug: 6424373
Change-Id: I36a1c22ade35e578955465a25940a33f227b9763
2012-05-01 16:34:20 -07:00
Dianne Hackborn
c3742a18a6 am 7086cd5c: am 5600deb7: am d26a8b73: am cda8329e: Merge "Distance max set incorrectly"
* commit '7086cd5c75073b75cd4a7d61aaa9f0529450e4e5':
  Distance max set incorrectly
2012-04-24 16:08:22 -07:00
Andreas Sandblad
8239940d0e Distance max set incorrectly
The distance max used in the MotionRange is calculated
incorrectly.

Looks like a copy-and-paste error.

Change-Id: I2b6daab088df0fb69e05682b67ca33524ff35987
2012-04-23 09:53:30 +02:00
Jeff Brown
5bbd4b4f5f Get alias for Bluetooth devices.
Bluetooth devices can be renamed by the user.  Make the
input system aware of the user-specified name and transparently
pass it down to applications.  This enables the keyboard
layout picker Settings UI to use device names that are
consistent with what the user set in the Bluetooth UI.

Bug: 6363157
Change-Id: I8eea26ce2c69c2a3f09c8de02e9e847610e0419c
2012-04-20 20:11:12 -07:00
Jeff Brown
f44e39493c When ANR happens, only remove ANR'd window.
The system bar uses input event injection to inject BACK keys
into the application.  If the receiving application ANRs, we
used to clear the touch state unconditionally.  Doing so would
prevent the system bar from receiving the ACTION_UP event so
the back button would continue to appear pressed until pressed
again.

Now we are more careful to only remove the specific ANR'd
window from the touch state.  Other windows should continue
to receive touch events as usual.

Change-Id: If86bfc323e2c7aed82ca1334bc67da649953168f
2012-04-20 11:33:27 -07:00
Jeff Brown
00710e906b Make InputDevice.SOURCE_STYLUS meaningful.
Bug: 5424551
Change-Id: I415cb1842422e050cc41b17f5a1f13b4fab17a44
2012-04-19 15:21:08 -07:00
Jeff Brown
61c0824058 Don't load keyboard layout overlay for virtual keyboard.
Bug: 6110399
Change-Id: I07c85cf991790ed8766b097acc39295a8065a5ea
2012-04-19 11:25:09 -07:00
Jeff Brown
426f905b84 Fix build.
Change-Id: I277042c91b34af59e70941fd5b458581310b1c22
2012-04-17 19:52:56 -07:00
Jeff Brown
4a3862f6b0 Add Dvorak keyboard layout.
Added support for mapping both scan codes and HID usages to
KeyLayoutMap and KeyCharacterMap.  Keyboard overlays can
now influence how key events are mapped to key codes.

Bug: 6110399
Change-Id: I6619fd2d3e1337c55928f89869dbc45b535c7ccf
2012-04-17 18:50:05 -07:00
Jeff Brown
6ec6f79e1a Support loading keyboard layout overlays from resources.
Added the concept of a keyboard layout overlay, which is
a key character map file that has "type OVERLAY".

Added support for loading keyboard layout overlays from
resources dynamically.  The layouts are reloaded whenever they
are changed in the Settings application or an application
is installed.  This is somewhat more aggressive than necessary
so we might want to optimize it later.

Before system-ready, the input system uses just the generic
keyboard layouts that are included on the device system image.
After system-ready, it considers the user's selected keyboard
layout overlay and attempts to load it as necessary.  We need to
wait until system-ready before doing this because we need to
be in a state where it is safe to start applications or access
their resources.

Bug: 6110399
Change-Id: Iae0886d3356649b0d2440aa00910a888cedd8323
2012-04-17 17:56:32 -07:00
Jeff Brown
a47425a13c Add support for input devices that have vibrators.
Added a getVibrator() method to InputDevice which returns a Vibrator
associated with that input device.  Its uses the same API as the
system vibrator which makes it easy for applications to be modified
to use one or the other.

Bug: 6334179
Change-Id: Ifc7f13dbcb778670f3f1c07ccc562334e6109d2e
2012-04-13 17:01:15 -07:00
Jeff Brown
af9e8d3818 Notify applications when input devices change.
This change allows the InputManager to keep track of what input
devices are registered with the system and when they change.
It needs to do this so that it can properly clear its cache of
input device properties (especially the key map!) when changes
occur.

Added new API so that applications can register listeners for
input device changes.

Fixed a minor bug in EventHub where it didn't handle EPOLLHUP
properly so it would spam the log about unsupposed epoll events
until inotify noticed that the device was gone and removed it.

Change-Id: I937d8c601f7185d4299038bce6a2934fe4fdd2b3
2012-04-12 18:54:54 -07:00
Jeff Brown
cc11698319 HID usage should take precedence over scan code.
Change-Id: Ibd8988e3dcc0d64f4019ffe491d9789733f9d243
2012-04-12 10:05:41 -07:00
Jeff Brown
49ccac530b Refactor key code mapping.
Added handling for EV_MSC / MSC_SCAN which typically reports
the HID usage associated with a key.  This will enable key maps
to map keys with HID usages that Linux does not natively recognize.

Removed keyCode and flags fields from EventHub RawEvent since
they don't necessarily make sense in isolation now that we
pay attention to HID usage codes too.

Removed the fallback code for mapping keys and axes.  In practice,
an input device should be self-sufficient.  We should not ever
need to look at the built-in keyboard's key map.  In fact, there
usually isn't a built-in keyboard anyhow.  This code was originally
working around a problem where we weren't loading the key map
for touch screens with virtual keys, which has long since been fixed.

Change-Id: I0a319bdec44be9514f795526347397e94d53a127
2012-04-11 20:28:09 -07:00
Jeff Brown
9f25b7fdf2 Request key maps from input manager service.
Instead of each application loading the KeyCharacterMap from
the file system, get them from the input manager service as
part of the InputDevice object.

Refactored InputManager to be a proper singleton instead of
having a bunch of static methods.

InputManager now maintains a cache of all InputDevice objects
that it has loaded.  Currently we never invalidate the cache
which can cause InputDevice to return stale motion ranges if
the device is reconfigured.  This will be fixed in a future change.

Added a fake InputDevice with ID -1 to represent the virtual keyboard.

Change-Id: If7a695839ad0972317a5aab89e9d1e42ace28eb7
2012-04-10 18:23:58 -07:00
Jeff Brown
eca3cf58c0 Use new EVIOCSCLOCKID ioctl if supported.
Bug: 6292993
Change-Id: I718f167c2cd41298ed54847dbc5de872cd4c7e4a
2012-04-09 11:00:37 -07:00
Jeff Brown
e38fdfae91 Add a unique input device descriptor.
The purpose of the input device descriptor is to make it possible
to associate persistent settings for each input device, such as the
keyboard layout.

The descriptor is a hash of the information we have about the
device, such as its vendor id, product id, unique id, name,
or location.

Bug: 6110399
Change-Id: Idb80f946819b3f0dbf4e661bb0a753dbc2b60981
2012-04-06 14:57:19 -07:00
Jeff Brown
481c1570dc Add Java wrappers for new atrace functionality.
Instrument a few parts of the input dispatcher and the
view hierarchy.

Change-Id: I49285c9fb3502253baa1ffed60f521b8c24fccaf
2012-03-09 15:43:50 -08:00
Mathias Agopian
8335f1cccc fix libgui header location
Change-Id: Iec71706cdd4f29c6904993648ce873e83ef9cafe
2012-02-27 13:03:08 -08:00
Mathias Agopian
83c64e6b62 frameworks/base refactoring
create the new libandroidfw from parts of libui and libutils

Change-Id: I1584995616fff5d527a2aba63921b682a6194d58
2012-02-20 22:38:43 -08:00
Mathias Agopian
b93a03f841 frameworks/base refactoring.
First step. Move libui includes to their new home: androidfw.

Change-Id: Ic042b52fdba72f30edc3cc6339bf30b4c1b99662
2012-02-17 15:36:10 -08:00
Jeff Brown
91e328984c Clean up InputChannel file descriptor data type.
File descriptors are ints.

Change-Id: Ie36733bf36ddfeaa9a09ef6ebd7bd2f1788f5d27
2012-02-14 15:57:59 -08:00
Jeff Brown
0952c30ac2 Don't serialize motion events.
On reflection, only key events need to be serialized.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420
Change-Id: I028b4eac97497d012036cb60ffbac4cb22d3966c
2012-02-13 14:04:24 -08:00
Jeff Brown
072ec96a49 Implement batching of input events on the consumer side.
To support this feature, the input dispatcher now allows input
events to be acknowledged out-of-order.  As a result, the
consumer can choose to defer handling an input event from one
device (because it is building a big batch) while continuing
to handle input events from other devices.

The InputEventReceiver now sends a notification when a batch
is pending.  The ViewRoot handles this notification by scheduling
a draw on the next sync.  When the draw happens, the InputEventReceiver
is instructed to consume all pending batched input events, the
input event queue is fully processed (as much as possible),
and then the ViewRoot performs traversals as usual.

With these changes in place, the input dispatch latency is
consistently less than one frame as long as the application itself
isn't stalled.  Input events are delivered to the application
as soon as possible and are handled as soon as possible.  In practice,
it is no longer possible for an application to build up a huge
backlog of touch events.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I42c01117eca78f12d66d49a736c1c122346ccd1d
2012-02-13 10:28:41 -08:00
Jeff Brown
1adee11b5e Optimize dispatcher for back-to-back finished signals.
Minor tweak to the dispatcher to handle as many finished signals
in a receive callback as possible instead of going back to
the Looper and waiting for the next poll() to hit the callback
again.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I8471107371693e21ce8ce7cca1e8d79ba4ca2351
2012-02-13 10:28:41 -08:00
Jeff Brown
d1c48a0525 Dispatch multiple touch events in parallel.
This change enables the input dispatcher to send multiple touch
events to an application without waiting for them to be acknowledged.
Essentially this is a variation on the old streaming optimization
but it is much more comprehensive.  Event dispatch will stall as
soon as 0.5sec of unacknowledged events are accumulated or a
focused event (such as a key event) needs to be delivered.

Streaming input events makes a tremendous difference in application
performance.  The next step will be to enable batching of input
events on the client side once again.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420
Change-Id: I025df90c06165d719fcca7f63eed322a5cce4a78
2012-02-13 10:28:41 -08:00
Jeff Brown
8b4be56030 Delete premature optimization.
This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I5c182f6e17d468bf3033125b2094b2baa5b94e81
2012-02-13 10:28:41 -08:00
Jeff Brown
28b5cf1c33 Delete dead code.
This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I9f8b93f6a25ddd872f993366b57bab404c93bede
2012-02-13 10:28:40 -08:00
Jeff Brown
59f1ff9978 Delete latency tracking information in the Connection.
The information gathered here will no longer be valid once we
start dispatching multiple events at a time to the same connection.
Moreover, we are more concerned with end-to-end latency, which we
can measure with sufficiently high accuracy in other ways.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I49a0c9876b64af56b40e96e0d98c45f325da2a73
2012-02-13 10:28:40 -08:00
Jeff Brown
9831d90db8 Remove active connection tracking.
The dispatcher no longer needs to track which connections are
active except perhaps for diagnostic purposes, so we might as well
remove this code.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: Ibadc830b7b792a59b9244d0a6e85f320c4947109
2012-02-13 10:28:40 -08:00
Jeff Brown
e9bb9be9e4 Simplify input target handling in the dispatcher.
Since we no longer stream events to the application, we don't need to
keep the current list of input targets around longer than it takes
to begin the dispatch cycle.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I5824b04e564c8a4dec991598292441e46c331905
2012-02-13 10:28:40 -08:00
Jeff Brown
cbee6d6ede Rewrite input transport using sockets.
Since we will not longer be modifying events in place, we don't need
to use an ashmem region for input.  Simplified the code to instead
use a socket of type SOCK_SEQPACKET.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: I05909075ed8b61b93900913e44c6db84857340d8
2012-02-13 10:28:40 -08:00
Jeff Brown
3241b6b7bd Remove batching and streaming from the input dispatcher.
Don't worry, these features will be moving to a different part of
the pipeline.  We're just getting them out of the way for now so
we can make deeper changes to how the input dispatcher works.

This is part of a series of changes to improve input system pipelining.

Bug: 5963420

Change-Id: If97de923c8165776882eef23f5204cc448dad0fc
2012-02-13 10:28:39 -08:00
Jeff Brown
308028049a Remove the input dispatcher throttle.
This is part of a series of changes to improve input system pipelining.

Bug: 5963420
Change-Id: Iab33594bc5df8aa05232ef64c64e98fc61c5bf52
2012-02-07 18:38:11 -08:00
Jeff Brown
ed73440416 Merge "Use O_CLOEXEC when opening input device." 2012-01-31 10:05:51 -08:00
Jeff Brown
dd3ba43843 Merge "Add basic support for new suspend-block ioctls." 2012-01-31 10:05:09 -08:00
Jeff Brown
112b5f52c5 Improve watchdog monitor for InputReader and InputDispatcher.
Try harder to test for liveness.  There are situations where
the lock might not be held but the input system is stuck in
a callback into the window manager policy that has hung.

Bug: 5094994
Change-Id: Iff88655512a5dc8bbb4615be65f4115e975c020b
2012-01-27 17:33:42 -08:00
Jeff Brown
06a0fb953f am 5d58eb06: Merge "Fix a few memory leaks in the input dispatcher. (DO NOT MERGE)" into ics-mr1
* commit '5d58eb06bcc8671bae72fb2389a9929e106131cc':
  Fix a few memory leaks in the input dispatcher.  (DO NOT MERGE)
2012-01-20 11:26:43 -08:00