Commit Graph

216 Commits

Author SHA1 Message Date
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
Jeff Brown
774cf1baa1 Remove incomplete input device enumeration NDK API.
Change-Id: I32de74ff5fcf0e29179a2aee03ddabd22fa485bb
2010-08-31 15:24:55 -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
Mathias Agopian
385648ba93 Merge "remove unused pixel format" into gingerbread 2010-08-19 13:37:35 -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
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
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
Jeff Brown
8d4dfd25f7 Fix safe mode and KeyEvent.getMaxKeyCode().
Bug: 2901731
Change-Id: I78617c1b9dee3790fc590e5af4b5083368873184
2010-08-10 16:28:03 -07:00
Jeff Brown
b51719b9ae Improve thread safety of input mappers.
Also fixed bug where old touch screen size could be reported by
getMotionRange if an orientation change occurred but the user has not
yet touched the screen.

Bug: 2877345
Change-Id: I7878f47458f310ed6ebe6a5d1b2c9bec2c598ab9
2010-07-30 14:43:58 -07:00
Jeff Brown
82de2fcdd0 Fix touch input in landscape mode.
Change-Id: I7d47e9b02e6443ed604a6bf842028a5db934d90d
2010-07-29 13:05:52 -07:00
Jeff Brown
f67c53eee3 DO NOT MERGE: Fix input event injection ANRs on UI thread.
Added a new asynchronous injection mode and made the existing
synchronization mechanism more robust.

Change-Id: Ia4aa04fd9b75ea2461a844c5b7933c831c1027e6
2010-07-29 12:54:27 -07:00
Jeff Brown
e57e895080 Refactor input reader to support new device types more easily.
Refactored the input reader so that each raw input protocol is handled
by a separate subclass of the new InputMapper type.  This way, behaviors
pertaining to keyboard, trackballs, touchscreens, switches and other
devices are clearly distinguished for improved maintainability.

Added partial support for describing capabilities of input devices
(incomplete and untested for now, will be fleshed out in later commits).

Simplified EventHub interface somewhat since InputReader is taking over
more of the work.

Cleaned up some of the interactions between InputManager and
WindowManagerService related to reading input state.

Fixed swiping finger from screen edge into display area.

Added logging of device information to 'dumpsys window'.

Change-Id: I17faffc33e3aec3a0f33f0b37e81a70609378612
2010-07-28 14:16:15 -07:00
Jeff Brown
f26db0d6c5 Fix trackball down and movement bugs.
Bug: 2823788
Change-Id: Icb0c392b58f7e735614460b5eb87439cb73ac4f2
2010-07-16 17:46:03 -07:00
Jeff Brown
3cf1c9b844 Fix individual pointer id up/down reporting.
Fix a minor threading bug in InputManager dump.

Change-Id: Ic2eecf7df5a8dc9f40561fcb03ebe58a2c073778
2010-07-16 15:11:24 -07:00
Dianne Hackborn
0e8852766d Implement native key pre-dispatching to IMEs.
This significantly re-works the native key dispatching code to
allow events to be pre-dispatched to the current IME before
being processed by native code.  It introduces one new public
API, which must be called after retrieving an event if the app
wishes for it to be pre-dispatched.

Currently the native code will only do pre-dispatching of
system keys, to avoid significant overhead for gaming input.
This should be improved to be smarted, filtering for only
keys that the IME is interested in.  Unfortunately IMEs don't
currently provide this information. :p

Change-Id: Ic1c7aeec8b348164957f2cd88119eb5bd85c2a9f
2010-07-15 22:05:33 -07:00
Jeff Brown
5c1ed84a2d Add support for new input sources.
Added several new coordinate values to MotionEvents to capture
touch major/minor area, tool major/minor area and orientation.

Renamed NDK input constants per convention.

Added InputDevice class in Java which will eventually provide
useful information about available input devices.

Added APIs for manufacturing new MotionEvent objects with multiple
pointers and all necessary coordinate data.

Fixed a bug in the input dispatcher where it could get stuck with
a pointer down forever.

Fixed a bug in the WindowManager where the input window list could
end up containing stale removed windows.

Fixed a bug in the WindowManager where the input channel was being
removed only after the final animation transition had taken place
which caused spurious WINDOW DIED log messages to be printed.

Change-Id: Ie55084da319b20aad29b28a0499b8dd98bb5da68
2010-07-15 18:32:33 -07:00
Jeff Brown
a50ee3ecb3 Don't build framework tests for simulator target.
Change-Id: I70f29c7eb307e4f3ec5702f4eb9d97b4342e2f36
2010-07-14 22:55:02 -07:00
Mathias Agopian
48c3476371 Remove the YV16 format for simplicity's sake.
Change-Id: Iee03d100933ba0c67b13d51e0435be3b4cd953cf
2010-07-14 15:12:05 -07:00
Dianne Hackborn
ce838a265d IME events are now dispatched to native applications.
And also:

- APIs to show and hide the IME, and control its interaction with the app.
- APIs to tell the app when its window resizes and needs to be redrawn.
- API to tell the app the content rectangle of its window (to layout
  around the IME or status bar).

There is still a problem with IME interaction -- we need a way for the
app to deliver events to the IME before it handles them, so that for
example the back key will close the IME instead of finishing the app.

Change-Id: I37b75fc2ec533750ef36ca3aedd2f0cc0b5813cd
2010-07-13 18:36:46 -07:00
Jeff Brown
8575a87b0d Add initial gamepad support.
Change-Id: I0439648f6eb5405f200e4223c915eb3a418b32b9
2010-07-13 17:04:57 -07:00
Dianne Hackborn
9147d11a5f Add ANativeWindow API for directly drawing to the surface bits.
Also other cleanup and fixes:

- We now properly set the default window format to 565.
- New APIs to set the window format and flags from native code.
- Tweaked glue for simpler handling of the "destroy" message.
- Um, other stuff.

Change-Id: Id7790a21a2fa9a19b91854d225324a7c1e7c6ade
2010-07-09 16:58:19 -07:00
Dianne Hackborn
3c5d125ed7 Add new glue code for writing native apps.
This factors out the boiler-plate code from the sample
app to a common glue code that can be used for everyone
writing this style of app: a dedicated app thread that
takes care of waiting for events and processing them.

As part of doing this, ALooper has a new facility to allow
registration of fds that cause ALooper_pollOnce() to return
the fd that has data, allowing the app to drive the loop
without callbacks.  Hopefully this makes some people feel better. :)

Also do some other cleanup of the ALooper API, plus some
actual documentation.

Change-Id: Ic53bd56bdf627e3ba28a3c093faa06a92be522b8
2010-07-08 11:06:59 -07:00
Jeff Brown
f16c26dec9 More native input dispatch work.
Removed old input dispatch code.
Refactored the policy callbacks.
Pushed a tiny bit of the power manager state down to native.
Fixed long press on MENU.
Made the virtual key detection and cancelation a bit more precise.

Change-Id: I5d8c1062f7ea0ab3b54c6fadb058c4d5f5a9e02e
2010-07-03 19:23:01 -07:00
Mathias Agopian
1764c73b55 remove unused YUV formats
Change-Id: Ie84616f842c7e0329d68e67e65a65d510558004b
2010-07-01 21:17:56 -07:00
Dianne Hackborn
e12e3d7692 Merge "Introduce official public NativeWindow type." into gingerbread 2010-06-30 16:05:30 -07:00
Mathias Agopian
05dedd17ec Merge "fix live wallpapers on Droid" into gingerbread 2010-06-30 15:59:02 -07:00
Mathias Agopian
a8f3e4e53c fix live wallpapers on Droid
On omap3 h/w we force opaque formats to RGB_565 instead of RGBX_8888
because the GL driver doesn't support it. RGBX_8888 is always remapped
to RGBA_8888.

Change-Id: I0bfabeb98c8d3a399079e6797cf2a0ee95915324
2010-06-30 15:43:47 -07:00
Dianne Hackborn
4b5e91e482 Introduce official public NativeWindow type.
Not yet hooked up to anything in the NDK, but requires renaming
the existing android_native_window_t type everywhere.

Change-Id: Iffee6ea39c93b8b34e20fb69e4d2c7c837e5ea2e
2010-06-30 15:32:04 -07:00
Jeff Brown
c393eb6cf5 Fix injection of specially intercepted keys like HOME.
This change mainly unwinds a premature optimization in the
dispatch pipeline.
To test HOME injection, run 'adb shell input keyevent 3'.

Change-Id: I1c4b7377c205da7c898014b8b07fc6dc1d46e4dd
2010-06-30 14:41:59 -07:00
Dianne Hackborn
189ed23c10 Implement default key handling for native code.
The native code now maintains a list of all keys that may use
default handling.  If the app finishes one of these keys
without handling it, the key will be passed back off to Java
for default treatment.

Change-Id: I6a842a0d728eeafa4de7142fae573f8c11099e18
2010-06-30 10:49:40 -07:00
Jeff Brown
4036f7f2b4 Fix native input dispatch in the emulator.
Set a default orientation of ROTATION_0.
Added some more careful checks based on whether we have valid
absolute axis information from the driver.
Reset key repeating during configuration changes since the keyboard
device may have been removed.

Change-Id: I685960828acffcb17595fc5683309e8064a76714
2010-06-29 16:52:21 -07:00
Dianne Hackborn
9c7f8186ae Update native activity & event APIs to follow correct conventions.
Change-Id: Ie64fb3a9c68bc9c117fa5621b75d1f609e304e0e
2010-06-29 10:43:54 -07:00
Jeff Brown
50de30a523 Native input event dispatching.
Target identification is now fully native.
Fixed a couple of minor issues related to input injection.
Native input enabled by default, can be disabled by setting
WindowManagerPolicy.ENABLE_NATIVE_INPUT_DISPATCH to false.

Change-Id: I7edf66ed3e987cc9306ad4743ac57a116af452ff
2010-06-28 19:10:54 -07:00
Christopher Tate
d974e00697 Remember to initialize timestamps in the dispatch allocator
Change-Id: I83a2d353c34ff84a7d130e602c6dedc6a5541944
2010-06-23 16:51:07 -07:00
Dianne Hackborn
4d96bb6ae3 First stab at attaching native event dispatching.
Provides the basic infrastructure for a
NativeActivity's native code to get an object representing
its event stream that can be used to read input events.

Still work to do, probably some API changes, and reasonable
default key handling (so that for example back will still
work).

Change-Id: I6db891bc35dc9683181d7708eaed552b955a077e
2010-06-22 11:21:50 -07:00
Mathias Agopian
3f3a74a53a remove unused YUV formats
Change-Id: Id0ae28b1700cf771cdbe0ca27b139d32cab90b2a
2010-06-21 18:22:09 -07:00
Mathias Agopian
b16fa651dd Merge "Added support for the GL_TEXTURE_EXTERNAL target" into gingerbread 2010-06-21 15:11:18 -07:00
Jeff Brown
51d45a710e More native input event dispatching.
Added ANRs handling.
Added event injection.
Fixed a NPE ActivityManagerServer writing ANRs to the drop box.
Fixed HOME key interception.
Fixed trackball reporting.
Fixed pointer rotation in landscape mode.

Change-Id: I50340f559f22899ab924e220a78119ffc79469b7
2010-06-21 13:59:34 -07:00
Jeff Brown
f4a4ec2063 Even more native input dispatch work in progress.
Added more tests.
Fixed a regression in Vector.
Fixed bugs in pointer tracking.
Fixed a starvation issue in PollLoop when setting or removing callbacks.
Fixed a couple of policy nits.

Modified the internal representation of MotionEvent to be more
efficient and more consistent.

Added code to skip/cancel virtual key processing when there are multiple
pointers down.  This helps to better disambiguate virtual key presses
from stray touches (such as cheek presses).

Change-Id: I2a7d2cce0195afb9125b23378baa94fd2fc6671c
2010-06-17 13:27:16 -07:00
Mathias Agopian
0a91775c4d Added support for the GL_TEXTURE_EXTERNAL target
This will allow us to support YUV surfaces.

Change-Id: I2d4da75f1006a5285bdc552695d4caeecccf2183
2010-06-15 17:31:17 -07:00
Jeff Brown
c10612c77a Merge "More work in progress on native events." into gingerbread 2010-06-15 16:44:23 -07:00
Jeff Brown
54bc281639 More work in progress on native events.
Refactored the code to eliminate potential deadlocks due to re-entrant
calls from the policy into the dispatcher.  Also added some plumbing
that will be used to notify the framework about ANRs.

Change-Id: Iba7a10de0cb3c56cd7520d6ce716db52fdcc94ff
2010-06-15 16:43:18 -07:00
Jeff Brown
f69280ef72 Support for multiple tests
The build system enforces some invariants that were being ignored
before.

Change-Id: Ie7675042af7f961a507386c13b2a0b592b591af8
2010-06-14 15:46:08 -07:00