Commit Graph

209 Commits

Author SHA1 Message Date
Jeff Brown
d1de37fdab am 265cf2e7: Merge "Fix getSwitchState."
* commit '265cf2e76bef9ee369a7d43d567a22a0c39355ef':
  Fix getSwitchState.
2011-01-22 21:32:58 -08:00
Jeff Brown
cb203b228b Fix getSwitchState.
InputReader::getSwitchState always returns AKEY_STATE_UNKNOWN
because SwitchInputMapper::getSources() returns 0 which cannot
match any source mask including AINPUT_SOURCE_ANY.  As a result
initial lid switch detection is broken.

This change adds a new source constant AINPUT_SOURCE_SWITCH
that indicates that the source has switches.

Change-Id: I5321ecf0ce84f1c2b4535f6c163d3f4dcf9b7a9b
2011-01-19 20:35:47 -08:00
Jeff Brown
98e88a7d7a am 41395459: Merge "Filter virtual keys after touches. (DO NOT MERGE)" into gingerbread
* commit '41395459e676cf9ab4059e08446656f145662c2d':
  Filter virtual keys after touches.  (DO NOT MERGE)
2011-01-18 14:38:27 -08:00
Jeff Brown
7bfdb29e53 Filter virtual keys after touches. (DO NOT MERGE)
Adds a new virtualKeyQuietTimeMillis configuration resource that sets
the duration for which virtual keys will be dropped after recent touches
on screen.  The default value is 0; it is intended to be overridden
per device using a resource overlay.

This change is designed to help in two cases:

1. Swipes from touchscreen into virtual key area.
2. Accidental taps in virtual key area while using on-screen keyboard.

Bug: 3089163
Change-Id: Id6733c83c2e2bc8d9553aa0e5c1fd74b741bec6e
2011-01-11 20:56:04 -08:00
Mathias Agopian
e4f81090c2 am a2977c38: Merge changes Ie03796ae,Ide3e980a into gingerbread
* commit 'a2977c383d363e1e88a5b36230b1fa4c312807d2':
  [3171580] SurfaceFlinger Bypass mode. (DO NOT MERGE)
  [3171580] Add transform field to native buffers. (DO NOT MERGE)
2010-12-07 14:22:56 -08:00
Mathias Agopian
372c56e98b am 4153bf3a: Merge "[3171580] don\'t automatically log GraphicBuffer allocation failures" into gingerbread
* commit '4153bf3a259624a2f2dc497b77b225a1fb517abc':
  [3171580] don't automatically log GraphicBuffer allocation failures
2010-12-07 14:20:09 -08:00
Mathias Agopian
30eb1b1803 [3171580] Add transform field to native buffers. (DO NOT MERGE)
This field indicate how the content of the buffer
needs to be transformed.

Change-Id: Ide3e980a90599e931406135693231276626adbbb
2010-12-03 17:35:07 -08:00
Mathias Agopian
678bdd6349 [3171580] don't automatically log GraphicBuffer allocation failures
some of these failures are not fatal and even expected in some cases
so they should not emit a dump in the log in those cases.

Change-Id: Idcfa252e3bfa9d74e27fe4ad8f8623aa01aa9c5e
2010-12-03 17:33:09 -08:00
Jean-Baptiste Queru
af10976583 am a15e4886: Merge "Framebuffer: Support variable number of framebuffers in the UI"
* commit 'a15e4886de8f75f3cb137f51743d330414c910e8':
  Framebuffer: Support variable number of framebuffers in the UI
2010-11-17 17:29:48 -08:00
Rodrigo Obregon
71484f2f76 Framebuffer: Support variable number of framebuffers in the UI
This change defines a macro NUM_FRAME_BUFFERS to set
the desired number of framebuffers to be used by the UI,
instead of hard-coding 2 framebuffers.

Aditional logic has been  added to handle the initialization
and destruction of NUM_FRAME_BUFFERS buffers.

Change-Id: I3a4bfec3e0f453432f2ffebf084c00f574d3be46
Signed-off-by: Rodrigo Obregon <robregon@ti.com>
2010-11-03 15:16:18 -05:00
Jeff Brown
fef5b04203 Drop all dispatcher state when dispatcher is disabled.
This patch makes the dispatcher drop all of its state when it is
disabled (when the screen turns off).  This ensures that the dispatcher
does not get stuck thinking a pointer is still down if the screen
turned off while the user was touching the display (such as a fat touch
while hitting the power button).

Bug: 3098344
Change-Id: If50ef5804870aa1acd3179fd4b40e3cda58dd39d
2010-10-27 18:43:51 -07:00
Jeff Brown
3c3cc62e24 Add unit tests for native input and fix bugs identified.
Fixed a bug where we would lose the first touch point when swiping out of
the virtual key area.

Fixed a bug where we would not send an ACTION_MOVE event in cases where
individual pointers went down/up and the remaining pointers actually moved.
This is important since many applications do not handle pointer movements
during ACTION_POINTER_DOWN or ACTION_POINTER_UP.  In the case of
ACTION_POINTER_UP the movement was completely lost since all pointers were
dispatched using their old location rather than the new location.

Improved motion event validation to check for duplicate pointer ids.

Added an input source constant that was missing from the NDK api but
defined in the framework api.

Added a timestamp when reporting added/removed devices in EventHub.

Bug: 3070082
Change-Id: I3206a030f43b7616e2f48006e5a9d522c4d92e56
2010-10-23 03:52:57 -07:00
Jeff Brown
ef3a823482 Fix bug where home presses were not poking user activity.
We now poke user activity twice: once upon dequeueing an event
for dispatch and then again just before we dispatch it.  The second
poke is to compensate for the fact that it can take a few seconds to
identify the dispatch target (if the application is responding slowly)
but we want to keep the display from going to sleep for X amount of time
after the app gets a chance to actually receive the event.  This mirrors
pre-Gingerbread behavior.

Removed some unnecessary code that filters user activity pokes when sending
events to KeyGuard.  We don't need this because KeyGuard already tells the
power manager to disable user activity.

Bug: 3101397
Change-Id: I8c3a77601fdef8f584e84cfdd11aa79da0ff51db
2010-10-18 14:50:13 -07:00
Jeff Brown
d9dd44d867 Add support for secure system overlays. (DO NOT MERGE)
This change adds a new window type for secure system overlays
created by the system itself from non-secure system overlays that
might be created by applications that have the system alert permission.
Secure views ignore the presence of secure system overlays.

Bug: 3098519
Change-Id: I8f8398f4fdeb0469e5d71124c21bedf121bd8c07
2010-10-15 16:03:35 -07:00
Jeff Brown
6b337e74f0 Improve input device calibration format.
Added support for calibrating touch size for devices that report
size as an area measurement rather than as a width.
Fixed some bugs.

Bug: 3096045
Change-Id: I30a12e73752883516ed054f8af407204bca45814
2010-10-14 21:44:16 -07:00
Jeff Brown
1fe6dec097 Fix an event injection bug when the policy is bypassed.
Added the concept of a "trusted" event to distinguish between events from
attached input devices or trusted injectors vs. other applications.
This change enables us to move certain policy decisions out of the
dispatcher and into the policy itself where they can be handled more
systematically.

Change-Id: I4d56fdcdd31aaa675d452088af39a70c4e039970
2010-10-11 16:26:13 -07:00
Jeff Brown
90f0cee685 Added more robust tracking and cancelation of events.
This change fixes several issues where events would be dropped in the
input dispatch pipeline in such a way that the dispatcher could not
accurately track the state of the input device.

Given more robust tracking, we can now also provide robust cancelation
of input events in cases where an application might otherwise become
out of sync with the event stream due to ANR, app switch, policy decisions,
or forced focus transitions.

Pruned some of the input dispatcher log output.

Moved the responsibility for calling intercept*BeforeQueueing into
the input dispatcher instead of the input reader and added support for
early interception of injected events for events coming from trusted
sources.  This enables behaviors like injection of media keys while
the screen is off, haptic feedback of injected virtual keys, so injected
events become more "first class" in a way.

Change-Id: Iec6ff1dd21e5f3c7feb80ea4feb5382bd090dbd9
2010-10-10 14:45:51 -07:00
Jeff Brown
35cf0e9854 Make secure views tolerate IME overlays.
Change-Id: I3cf09b9d91045f4d9c558b4aace482a7b0bbd3d8
2010-10-05 12:26:23 -07:00
Mathias Agopian
19957553cb fix [2835280] Add support for cancelling buffers to ANativeWindow
There is a new ANativeWindow::cancelBuffer() API that can be used to
cancel any dequeued buffer, BEFORE it's been enqueued. The buffer is
returned to the list of availlable buffers. dequeue and cancel are not
mutually thread safe, they must be called from the same thread or
external synchronization must be used.

Change-Id: I86cc7985bace8b6a93ad2c75d2bef5c3c2cb4d61
2010-10-04 20:10:11 -07:00
Jeff Brown
1ad00e96fe Wait for initial device scan to finish before updating config.
This change narrows the opportunity for a race condition setting the
resource Configuration while devices are being updated.

Change-Id: I58efa563f4129ab0fce7108511d16a99dff7e451
2010-10-01 18:55:43 -07:00
Jeff Brown
2806e381cf Minor logging changes to input dispatcher to help with debugging.
Added dumpsys reporting to EventHub.
Made the formatting a bit clearer.
Added 'Locked' suffix to some internal methods of EventHub.

Change-Id: Ic449560bcce378f6361895d27c66854e9724abb0
2010-10-01 18:05:13 -07:00
Jeff Brown
956c0fb238 Support haptic feedback for virtual keys defined in key layout.
Change-Id: I83e4108a87332692e03791dc066206becbc7941f
2010-10-01 15:08:56 -07:00
Jeff Brown
26c94ff615 Move verbose logging of device capabilities to dumpsys.
Change-Id: I5d55eaebfdf049bd1ac1e7bab2758886cfefc9d7
2010-09-30 15:34:48 -07:00
Jeff Brown
d1b0a2bfe5 Add suuport for splitting touch events across windows.
This feature is currently used to enable dragging the start and end
selection handles of a TextView at the same time.  Could be used for
other things later.

Deleted some dead code in ArrowKeyMovementMethod and CursorControllers.

Change-Id: I930accd97ca1ca1917aab8a807db2c950fc7b409
2010-09-26 22:20:12 -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
Jeff Brown
128e33421b Merge "Input API review." into gingerbread 2010-09-16 12:57:56 -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
Mathias Agopian
6a3de9a424 fix a typo where the eventtags code were wrong
Change-Id: I517112a1475c10b71009a0aa9c3894c76a1f270f
2010-09-15 12:46:59 -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
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
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
Jeff Brown
542412c8c9 Add support for throttling motion events.
Change-Id: I24b3a17753e91ecda60a60fe5cd2e6b3260e033d
2010-08-18 16:58:27 -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
b183fbd646 Enhanced VelocityTracker for > 5 pointers and fixed bugs.
Improved PointerLocation tool to use VelocityTracker more efficiently
and correctly when multiple pointers are down.

Fixed a bug in TouchInputMapper where it was not correctly copying
the id to index map in the last touch data.  This could cause strange
behavior on secondary pointer up events.

Also added finished callback pooling in InputQueue.

Change-Id: Ia85e52ac2fb7350960ea1d7edfbe81a1b3e8267b
2010-07-30 20:08:29 -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
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
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