197 Commits

Author SHA1 Message Date
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
874c1e9aa5 Use O_CLOEXEC when opening input device.
Change-Id: I931614ef4fe2143c9e124c3239d74a4a2ce3816c
2012-01-19 14:32:47 -08:00
Jeff Brown
e22afbedc1 Add basic support for new suspend-block ioctls.
The new ioctls will enable the system to be more selective about
which evdev devices should hold wake-locks when their queue is
non-empty.

For now, we enable this behavior for all configured input devices,
which is more or less the status quo.  This change is mainly about
ensuring that the system still works correctly when combined with
a newer kernel that supports the suspend-block ioctls.  We can
tweak this behavior later.

Change-Id: I8ff69aa5198903f7e2998772a339313df17c0f24
2012-01-19 14:27:05 -08:00
Jeff Brown
214f459b2c Remove no longer needed EventHub usleep() optimization.
This optimization is no longer needed now that the kernel evdev
driver's poll() implementation only wakes up the poll after
the final sync.

Change-Id: If237776861df9cfac3086e744d3bbf3484d4c53b
2012-01-19 14:16:09 -08:00
Jeff Brown
4130554b45 Fix line wrapping.
Change-Id: I41199d1145d2435eee046a7e5006dcdce0986821
2012-01-19 14:08:48 -08:00
Jeff Brown
c0cb3dc2c1 Fix a few memory leaks in the input dispatcher.
Bug: 5862398
Change-Id: Iae3284a223b8307f541a7987f90f5b28e70b9244
2012-01-12 18:30:12 -08:00
Steve Block
ec193dec4d Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE
See https://android-git.corp.google.com/g/157519

Bug: 5449033
Change-Id: I8ceb2dba1b031a0fd68d15d146960d9ced62bbf3
2012-01-09 21:36:22 +00: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
Jeff Brown
fa7fa9a5ba am 944c985b: am e0e9fd98: Merge "Fix system hotkey handling." into ics-mr1
* commit '944c985b4199e6e029568ea87004c9727e469cc0':
  Fix system hotkey handling.
2011-12-09 14:25:38 -08:00
Jeff Brown
68b909d8ac Fix system hotkey handling.
Fixed a problem where the key up for the ALT or META key was not
delivered to the task switcher dialog because it was deemed
to be inconsistent with the window's observed state.  Consequently
the dialog would not be dismissed when the key was released.

Moved global hotkey handling for META+* shortcuts and ALT/META-TAB
into the window manager policy's interceptKeyBeforeDispatching
method.  This change prevents applications from hijacking these
keys.

The original idea was that these shortcuts would be handled only
if the application did not handle them itself.  That way certain
applications, such as remote desktop tools, could deliberately
override some of these less important system shortcuts.
Unfortunately, that does make the behavior inconsistent across
applications.  What's more, bugs in the onKeyDown handler of
applications can cause the shortcuts to not work at all, for
no good reason.

Perhaps we can add an opt-in feature later to enable specific
applications to repurpose these keys when it makes sense.

Bug: 5720358
Change-Id: I22bf17606d12dbea6549c60d20763e6608576cf7
2011-12-07 21:37:16 -08:00
Jeff Brown
221096fdd6 am 4c0e0dd2: am 3e7497b4: Merge "Eliminate hw.keyboards system properties." into ics-mr1
* commit '4c0e0dd29dcce33e7521b11d01d21d9431f3b264':
  Eliminate hw.keyboards system properties.
2011-11-15 19:43:35 -08:00
Jeff Brown
1e08fe90df Eliminate hw.keyboards system properties.
Stop using system properties to publish information about
the key character map path.  Instead, we can retrieve it
on demand by asking the window manager.

It was possible to exhaust the supply of system properties
when repeatedly adding and removing input devices.

Bug: 5532806
Change-Id: Idd361a24ad7db2edc185c8546db7fb05f9c28669
2011-11-15 18:00:10 -08:00
David Deephanphongs
fbca596721 Modify getState to prefer AKEY_STATE_DOWN and AKEY_STATE_UP over AKEY_STATE_UNKNOWN.
For the getState() routines that operate on multiple devices / mappers:
Return AKEY_STATE_DOWN (or AKEY_STATE_VIRTUAL) if any of the devices/mappers
have the key down.
Otherwise, return AKEY_STATE_UP if at least one device/mapper returns AKEY_STATE_UP.
Otherwise, return AKEY_STATE_UNKNOWN.

Change-Id: I1ef6251d73af916b51f408a41c5e4adf5bdc237a
2011-11-15 11:10:07 -08:00
Jeff Brown
a965f083d0 Delete dead code.
Change-Id: Ia78e338a363ab82f9c0b45ce324c2a7cfa8d8246
2011-11-08 20:24:21 -08:00
Steve Block
71f2cf116a Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/143865

Bug: 5449033
Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
2011-10-26 09:57:54 +01:00
Jeff Brown
905805ad7c Improve screenshot chord debouncing.
Bug: 5011907

Introduce a 150ms delay in handling volume down keys
while waiting to see if a power key will follow.

Don't trigger the screenshot chord if both volume up and
volume down are pressed together.

Don't trigger the long-press power menu if volume keys are
also pressed.

Require the user to press both keys in the chord within
the debounce time and continue long-pressing them in order
to trigger the screenshot action.

Change-Id: I248968d37b73c09d6d08e7f62667c443eba32da0
2011-10-12 14:34:23 -07:00
Dima Zavin
e8b7f4a20c eventhub: print debugginf info when removing device
Change-Id: I40bbbd3867e8c7ac7d6fb38e1c72432bb4963316
Signed-off-by: Dima Zavin <dima@android.com>
2011-09-29 11:28:17 -07:00
Jeff Brown
bfcb60ab0f Adjust layers for system overlays.
Prevent system overlays from showing above the notification bar.

Allow secure system overlays to be fullscreen, for the pointer
location view.

Show the drag layer above the notification bar.

Change-Id: Ic8d663792a243cca2cd9952d241d001e0357d551
2011-09-08 18:53:42 -07:00
Jeff Brown
3cdfc4d94f Merge "Support composite touch / joystick devices better." 2011-08-31 15:18:59 -07:00
Jeff Brown
9d4bc852ea Merge "Fix input channel leak. Bug: 5156144" 2011-08-31 13:01:16 -07:00
Jeff Brown
9ee285afe7 Support composite touch / joystick devices better.
This change enables the joystick input mapper to handle any axes
that are not claimed by the touch input mapper, which makes
auxiliary controls such as wheels / knobs accessible.

Change-Id: I01ee7f342ac91acfcb4ccb6676fd52b3d5bf31a0
2011-08-31 12:56:34 -07:00
Jeff Brown
cc4f7db698 Fix input channel leak.
Bug: 5156144

Input channels could leak or simply live longer than they should
in some cases.

1. Monitor channels (used by the pointer location overlay) are never
   unregistered, so they would leak.

   Added code to handle failures in the receive callback by closing
   the input channel.

2. The DragState held onto its input window and application handles
   even after the input channel was disposed.

   Added code to null these handles out when they are no longer needed.

3. Input channels previously used as input event targets would stick
   around until the targets were cleared (usually on the next
   event).

   Added code to detect when the input dispatcher is in
   an idle state and to proactively clear the targets then
   to ensure that resources are released promptly.

4. Native input window handles held onto the input channel even
   after the input window was removed from the input dispatcher.
   Consequently, the input channel would not be disposed until
   the input window handle itself was freed.  Since the input
   window handle is held from managed code, this meant that the
   window's input channel could stick around until the next GC.

   Refactored the input window handle to separate the properties
   (info) and identify (handle) state into different objects.
   Then modified the dispatcher to release the properties (info)
   when no longer needed, including the input channel.

7. The pointer location overlay does not actually use its
   standard input channel, only the monitor input channel.

   Added INPUT_FEATURE_NO_INPUT_CHANNEL to allow windows to
   request that they not be provided with an input channel
   at all.

Improved some of the error handling logic to emit the status
code as part of the exception message.

Change-Id: I01988d4391a70c6678c8b0e936ca051af680b1a5
2011-08-30 21:40:28 -07:00
Max Braun
e81056f350 Pick up device configuration "device.internal = 0". Before, only "device.internal = 1" had an effect.
Change-Id: Ie88ed66e0841418c147bed2e23806405bdd17ad6
2011-08-30 14:40:43 -07:00
Jeff Brown
8d3feb6292 Merge "Add a "show touches" option for demos and presentations. Bug: 4569045" 2011-08-29 14:04:31 -07:00
Jeff Brown
deffe07c22 Prioritize INPUT_PROP_DIRECT first.
If the device tells us it's really direct, then it's direct.

Change-Id: I83875cf47e865ff6f0def149ad0c68db24d9dc4a
2011-08-26 18:38:46 -07:00