History log of /frameworks/base/services/input/InputDispatcher.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
074b8b7cf19d128f16e0de12bc2fc58e7438ec37 01-Nov-2012 Jeff Brown <jeffbrown@google.com> Eliminate potential reentrance from unregisterInputChannel.

Ensure that all callbacks into the window manager policy occur
on the input dispatcher thread in the right place. This fixes
a potential deadlock that may occur if the window manager
unregisters an input channel while holding its own lock.

The change is simply to defer running asynchronous commands
(usually callbacks into the policy) until the next iteration
of the dispatch looper thread.

Bug: 7382388
Change-Id: I90095580d717fcddb2209ef332df56400f837a34
/frameworks/base/services/input/InputDispatcher.h
bcc046af4ef171aa3aa3c6b64efb5cafc1e46cd3 28-Sep-2012 Jeff Brown <jeffbrown@google.com> Bundle correlated switch changes atomically.

This is a prerequisite for headset jack detection on Manta.

Bug: 6548391
Change-Id: I549a194344511c0cee578b00f6a9ab5fdbdfb99c
/frameworks/base/services/input/InputDispatcher.h
83d616a9c7b9505153d258511eb5c16b552e268d 10-Sep-2012 Jeff Brown <jeffbrown@google.com> Make input system aware of multiple displays.

The input system needs to know about the window that has
focus, even if it is on a secondary display. So now we
send it the list of all windows and indicate which display
they are on. We filter the list of windows as necessary
when delivering touch events.

To keep things simple, monitor input channels and input
filters are not supported except on the main display.
We also do not pass the display id to applications; it is
only used inside the input system for now.

Properly scale touch coordinates based on the viewport.
This will be needed to ensure that touch works on external
display as well as when the internal display is being used
to simulate a different resolution.

Change-Id: I1815579a52fcc852c519b5391fc7ab8767c2dc59
/frameworks/base/services/input/InputDispatcher.h
22aa51202652efbd55094217a046b8e5ecb7afe2 17-Jun-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
265f1ccc5128319d81eee70ee2d2ae81573efb11 12-Jun-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
fd23e3ed976b22b9a92ddb2cb3a46f9d2a0ce23f 09-May-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
f44e39493c471b5e6a0807778c7a6439ea1b8adc 20-Apr-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
481c1570dc5cdf58265b53f657801709dd05d1df 09-Mar-2012 Jeff Brown <jeffbrown@google.com> Add Java wrappers for new atrace functionality.

Instrument a few parts of the input dispatcher and the
view hierarchy.

Change-Id: I49285c9fb3502253baa1ffed60f521b8c24fccaf
/frameworks/base/services/input/InputDispatcher.h
b93a03f841d93498bfea6cc92a22faa34bce1337 18-Feb-2012 Mathias Agopian <mathias@google.com> frameworks/base refactoring.

First step. Move libui includes to their new home: androidfw.

Change-Id: Ic042b52fdba72f30edc3cc6339bf30b4c1b99662
/frameworks/base/services/input/InputDispatcher.h
0952c30ac279d5f4cdc032fcbafa372213aa6d86 13-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
072ec96a4900d4616574733646ee46311cb5d2cb 07-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
d1c48a0525d05021036d4b14e937e221c0ae1318 07-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
8b4be56030c3b8c93dfa45bccac7365f90f377ce 07-Feb-2012 Jeff Brown <jeffbrown@google.com> Delete premature optimization.

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

Bug: 5963420

Change-Id: I5c182f6e17d468bf3033125b2094b2baa5b94e81
/frameworks/base/services/input/InputDispatcher.h
28b5cf1c33df847d667b8974ba07c4157a49b48a 07-Feb-2012 Jeff Brown <jeffbrown@google.com> Delete dead code.

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

Bug: 5963420

Change-Id: I9f8b93f6a25ddd872f993366b57bab404c93bede
/frameworks/base/services/input/InputDispatcher.h
59f1ff99786e9d4a94270d6752aa3ca61e10f0a6 07-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
9831d90db8fba7e967d22b1f86eea1d6ac831541 07-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
e9bb9be9e46523ed901e38cfa83f4630f6496418 07-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
cbee6d6ede0499fb4a2c00bfc00d5db8d9ed5139 04-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
3241b6b7bd7eff64f0118ba2d636030e505a98f9 04-Feb-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
308028049a75b36d5ed525c0bcef441da850c2a5 03-Feb-2012 Jeff Brown <jeffbrown@google.com> Remove the input dispatcher throttle.

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

Bug: 5963420
Change-Id: Iab33594bc5df8aa05232ef64c64e98fc61c5bf52
/frameworks/base/services/input/InputDispatcher.h
112b5f52c5a4b6743eeb7b26a8896c7636c74455 28-Jan-2012 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
c0cb3dc2c16883f19bf1caf652b2fcdb55a1a856 13-Jan-2012 Jeff Brown <jeffbrown@google.com> Fix a few memory leaks in the input dispatcher.

Bug: 5862398
Change-Id: Iae3284a223b8307f541a7987f90f5b28e70b9244
/frameworks/base/services/input/InputDispatcher.h
905805ad7ce18a386076fff99264f821bbad9f83 12-Oct-2011 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
cc4f7db698f88b633a286d8ab1105b28a474cd09 31-Aug-2011 Jeff Brown <jeffbrown@google.com> 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
/frameworks/base/services/input/InputDispatcher.h
65fd251c3913fc921468a3dad190810db19eb9df 18-Aug-2011 Jeff Brown <jeffbrown@google.com> Input system bug fixes, particularly for stylus.
Bug: 5049148

Finished stylus support, including support for indirect stylus
and mouse tools.

Added TILT axis. When stylus tilt X/Y is available, it is transformed
into an orientation and tilt inclination which is a more convenient
representation and a simpler extension to the exiting API.

Touch devices now only report touch data using a single input
source. Previously touch devices in pointer mode would report
both absolute touch pad data and cooked pointer gestures.
Now we just pick one. The touch device switches modes as needed
when the focused application enables/disables pointer gestures.
This change greatly simplifies the code and reduces the load
on the input dispatcher.

Fixed an incorrect assumption that the value of ABS_(MT_)DISTANCE
would be zero whenever the stylus was in direct contact. It appears
that the correct way to determine whether the stylus is in direct
contact (rather than hovering) is by checking for a non-zero
reported pressure.

Added code to read the initial state of tool buttons and axis values
when the input devices are initialized or reset. This fixes
problems where the input mapper state might have the wrong initial
state.

Moved responsibility for cancelling pending inputs (keys down,
touches, etc.) to the InputDispatcher by sending it a device reset
notification. This frees the InputReader from having to synthesize
events during reset, which was cumbersome and somewhat brittle
to begin with.

Consolidated more of the common accumulator logic from
SingleTouchInputMapper and MultiTouchInputMapper into
TouchInputMapper.

Improved the PointerLocation output.

Change-Id: I595d3647f7fd7cb1e3eff8b3c76b85043b5fe2f0
/frameworks/base/services/input/InputDispatcher.h
89ef0720ee8e0ac6ae1758faa917e4d6c9606fb4 11-Aug-2011 Jeff Brown <jeffbrown@google.com> Add input system to Watchdog.
Bug: 5094994

Change-Id: I153866958efc64ac19bda8b997c1c9f6ad425ec4
/frameworks/base/services/input/InputDispatcher.h
be1aa8250cee7819c49741e819e81659d1d03823 28-Jul-2011 Jeff Brown <jeffbrown@google.com> Refactor input reader to add stylus support.
Bug: 5064702

Introduced the concept of an InputListener to further decouple
the InputReader from the InputDispatcher. The InputListener
exposes just the minimum interface that the InputReader needs
to communicate with the outside world. The InputReader
passes arguments to the InputListener by reference, which makes
it easy to queue them up.

Consolidated all of the InputReader locks into one simple global
Mutex. The reason this wasn't done before was due to potential
re-entrance in outbound calls to the InputDispatcher. To fix this,
the InputReader now queues up all of the events it wants to send
using a QueuedInputListener, then flushes them outside of the
critical section after all of the event processing is finished.
Removing all of the InputMapper locks greatly simplifies the
implementation.

Added tests for new stylus features such as buttons, tool types,
and hovering.

Added some helpers to BitSet32 to handle common code patterns
like finding the first marked bit and clearing it.

Fixed a bug in VelocityTracker where the wrong pointer trace
could get cleared when handling ACTION_POINTER_DOWN. Oops.

Changed PointerCoords so it no longer stores useless zero
axis values. Removed editAxisValue because it is not very
useful when all zero value axes are absent and therefore
cannot be edited in place.

Added dispatch of stylus hover events.

Added support for distance and tool types.

Change-Id: I4cf14d134fcb1db7d10be5f2af7b37deef8f8468
/frameworks/base/services/input/InputDispatcher.h
ac386073df2514b79a2ca169f4a89f129733002f 21-Jul-2011 Jeff Brown <jeffbrown@google.com> Remove unimplemented memory pool.

dlmalloc does such a great job that we don't need a pool anyways.

Change-Id: I105b28c4a5c491543959190c7c0a9de75a5b8052
/frameworks/base/services/input/InputDispatcher.h
9302c8796fc4dcda08d4bd1e11733848fd4fafaf 14-Jul-2011 Jeff Brown <jeffbrown@google.com> Refactor input dispatcher use of window/app handles.

This change moves the cached window and application input state
into the handle objects themselves. It simplifies the dispatcher
somewhat because it no longer needs to fix up references to
transient InputWindow objects each time the window list is updated.

This change will also make it easier to optimize setInputWindows
to avoid doing a lot of redundant data copying. In principle, only
the modified fields need to be updated. However, for now we
continue to update all fields in unison as before.

It turns out that the input dispatcher was inappropriately retaining
pointers to InputWindow objects within the mWindows InputWindow
vector. This vector is copy-on-write so it is possible and the
item pointers to change if an editing operation is performed on
the vector when it does not exclusively own the underlying
SharedBuffer. This bug was uncovered by a previous change that
replaced calls to clear() and appendVector() with a simple use
of operator= which caused the buffer to be shared. Consequently
after editItemAt was called (which it shouldn't have, actually)
the buffer was copied and the cached InputWindow pointers became
invalid. Oops. This change fixes the problem.

Change-Id: I0a259339a6015fcf9113dc4081a6875e047fd425
/frameworks/base/services/input/InputDispatcher.h
8134681b25dfff814ffeaad8ff70e84316c1869f 29-Jun-2011 Jeff Brown <jeffbrown@google.com> Improve input event consistency invariants.

Fixed some issues where inconsistent streams of events could
be generated by the dispatcher, particularly when switching from
hovering with one device to hovering with another.

Fixed a bug where the touch pad would fail to generate a new
HOVER_MOVE following a tap event. As a result, the hover event
stream would not resume until the user touched the touch pad
again.

Change-Id: I444dce84641fb12e56a0af84c931520771d6c493
/frameworks/base/services/input/InputDispatcher.h
98db5fabdad86dca379740d8050697950b9f026c 09-Jun-2011 Jeff Brown <jeffbrown@google.com> Allow touches to slide out of the navigation bar.

Change-Id: I73cabba3d62f47829bf6217700ace56a27c42b1d
/frameworks/base/services/input/InputDispatcher.h
7a9db181a64e0e752a447c6408639bbb33c412fc 03-Jun-2011 Kenny Root <kroot@google.com> No position information for outside touches

When a window registers to listen for outside touches, it doesn't need
the position information for touches that land outside of its activity
for normal use cases.

This patch uses the foreground window's UID as a filter to determine
whether to pass the position information. This will allow applications
to continue to rely on touch information for inputs that were directed
at one of its other windows.

Bug: 4541250
Change-Id: If16eb1ec8404b797d991859eef55ac0a20a355a3
/frameworks/base/services/input/InputDispatcher.h
f3b57def9345d6d3cac3604d6a970f6d48f345ec 03-Jun-2011 Dianne Hackborn <hackbod@google.com> resolved conflicts for merge of 7e193916 to master

Change-Id: If06892419319c3a2d4ab6b03dd3ceb99b83803b5
214eaf48878bba00cbd5831871bcbd82632b6e34 27-May-2011 Jeff Brown <jeffbrown@android.com> Use ViewConfiguration to seed input system configuration.

Fix bug where the pointer presentation would be updated on
any input reader timeout rather than only when a pointer gesture
is in progress.

Bug: 4124987
Change-Id: Ie9bba4a0b3228d55e45e65fa2ede5cd6ba887a08
/frameworks/base/services/input/InputDispatcher.h
5ced76a14350db56f1a80f00076f8be3d982c389 24-May-2011 Jeff Brown <jeffbrown@android.com> Coalesce input events that arrive faster than 333Hz. (DO NOT MERGE)

Some drivers report individual finger updates one at a time
instead of all at once. When 10 fingers are down, this can
cause the framework to have to handle 10 times as many events
each with 10 times as much data. Applications like
PointerLocation would get significantly bogged down by all
of the redundant samples.

This change coalesces samples that are closely spaced in time,
before they are dispatched, as part of the motion event batching
protocol.

Increased the size of the InputChannel shared memory buffer so
that applications can catch up faster if they accumulate a
backlog of samples.

Change-Id: Ibc6abf8af027d9003011ac75caa12941080caba3
/frameworks/base/services/input/InputDispatcher.h
524ee64b91bc123e1ccfc881a0f1a1e84722251d 30-Mar-2011 Jeff Brown <jeffbrown@google.com> Support chorded fallback keys. (DO NOT MERGE)

Also be more careful about canceling fallback keys during focus
transitions, when the application handles the key, or when the
policy decides to do something different.

Fixed a crash due to JNI CallObjectMethod returning an undefined
value (not null) when an exception is thrown.

Fixed a crash due to the policy trying to create a Dialog for
recent apps on the dispatcher thread. It should happen on the
policy's Looper instead.

Bug: 4187302
Change-Id: I043f82913830f411b3bb4018d6422467b6ca454f
/frameworks/base/services/input/InputDispatcher.h
fe9f8ab03a63b1037f07dd85799fbea80ec6adaa 07-May-2011 Jeff Brown <jeffbrown@google.com> Add initial API for stylus and mouse buttons.

Added the concept of pointer properties in a MotionEvent.
This is currently used to track the pointer tool type to enable
applications to distinguish finger touches from a stylus.

Button states are also reported to application as part of touch events.

There are no new actions for detecting changes in button states.
The application should instead query the button state from the
MotionEvent and take appropriate action as needed.

A good time to check the button state is on ACTION_DOWN.

As a side-effect, applications that do not support multiple buttons
will treat primary, secondary and tertiary buttons identically
for all touch events.

The back button on the mouse is mapped to KEYCODE_BACK
and the forward button is mapped to KEYCODE_FORWARD.

Added basic plumbing for the secondary mouse button to invoke
the context menu, particularly in lists.

Added clamp and split methods on MotionEvent to take care of
common filtering operations so we don't have them scattered
in multiple places across the framework.

Bug: 4260011
Change-Id: Ie992b4d4e00c8f2e76b961da0a902145b27f6d83
/frameworks/base/services/input/InputDispatcher.h
aa9d84c37e05f696ec158dac98ce38cf41e18314 10-May-2011 Dianne Hackborn <hackbod@google.com> resolved conflicts for merge of 05be6d6f to master

Change-Id: Ic6a6c5bb300f6f1d43f9ed550b284282b4f16212
e2515eebf42c763c0a2d9f873a153711778cfc17 28-Apr-2011 Dianne Hackborn <hackbod@google.com> Better compat mode part one: start scaling windows.

First step of improving app screen size compatibility mode. When
running in compat mode, an application's windows are scaled up on
the screen rather than being small with 1:1 pixels.

Currently we scale the application to fill the entire screen, so
don't use an even pixel scaling. Though this may have some
negative impact on the appearance (it looks okay to me), it has a
big benefit of allowing us to now treat these apps as normal
full-screens apps and do the normal transition animations as you
move in and out and around in them.

This introduces fun stuff in the input system to take care of
modifying pointer coordinates to account for the app window
surface scaling. The input dispatcher is told about the scale
that is being applied to each window and, when there is one,
adjusts pointer events appropriately as they are being sent
to the transport.

Also modified is CompatibilityInfo, which has been greatly
simplified to not be so insane and incomprehendible. It is
now simple -- when constructed it determines if the given app
is compatible with the current screen size and density, and
that is that.

There are new APIs on ActivityManagerService to put applications
that we would traditionally consider compatible with larger screens
in compatibility mode. This is the start of a facility to have
a UI affordance for a user to switch apps in and out of
compatibility.

To test switching of modes, there is a new variation of the "am"
command to do this: am screen-compat [on|off] [package]

This mode switching has the fundamentals of restarting activities
when it is changed, though the state still needs to be persisted
and the overall mode switch cleaned up.

For the few small apps I have tested, things mostly seem to be
working well. I know of one problem with the text selection
handles being drawn at the wrong position because at some point
the window offset is being scaled incorrectly. There are
probably other similar issues around the interaction between
two windows because the different window coordinate spaces are
done in a hacky way instead of being formally integrated into
the window manager layout process.

Change-Id: Ie038e3746b448135117bd860859d74e360938557
/frameworks/base/services/input/InputDispatcher.h
4e91a180be46c0c7c3bf398d4df4cbe2404216b5 07-Apr-2011 Jeff Brown <jeffbrown@google.com> Coalesce input events that arrive faster than 333Hz.

Some drivers report individual finger updates one at a time
instead of all at once. When 10 fingers are down, this can
cause the framework to have to handle 10 times as many events
each with 10 times as much data. Applications like
PointerLocation would get significantly bogged down by all
of the redundant samples.

This change coalesces samples that are closely spaced in time,
before they are dispatched, as part of the motion event batching
protocol.

Increased the size of the InputChannel shared memory buffer so
that applications can catch up faster if they accumulate a
backlog of samples.

Added logging code to help measure input dispatch and drawing
latency issues in the view hierarchy. See ViewDebug.DEBUG_LATENCY.

Change-Id: Ia5898f781f19901d2225c529a910c32bdf4f504f
/frameworks/base/services/input/InputDispatcher.h
0029c66203ab9ded4342976bf7a17bb63af8c44a 30-Mar-2011 Jeff Brown <jeffbrown@google.com> Add input filter mechanism for accessibility.

This patch adds a mechanism for capturing, filtering, transforming
and injecting input events at a very low level before the input
dispatcher attempts to deliver them to applications. At this time,
the mechanism is only intended to be used by the accessibility
system to implement built-in system-level accessibility affordances.

The accessibility input filter is currently just a stub.
It logs the input events receives and reinjects them unchanged,
except that it transforms KEYCODE_Q into KEYCODE_Z.

Currently, the accessibility input filter is installed whenever
accessibility is enabled. We'll probably want to change that
so it only enables the input filter when a screen reader is
installed and we want touch exploration.

Change-Id: I35764fdf75522b69d09ebd78c9766eb7593c1afe
/frameworks/base/services/input/InputDispatcher.h
da3d5a91b6b311ed77f2707d4456c1f18b84d73b 30-Mar-2011 Jeff Brown <jeffbrown@google.com> Support chorded fallback keys.

Also be more careful about canceling fallback keys during focus
transitions, when the application handles the key, or when the
policy decides to do something different.

Fixed a crash due to JNI CallObjectMethod returning an undefined
value (not null) when an exception is thrown.

Fixed a crash due to the policy trying to create a Dialog for
recent apps on the dispatcher thread. It should happen on the
policy's Looper instead.

Bug: 4187302
Change-Id: I659a3fd1bd2325ed36d965f9beb75dacb89790c9
/frameworks/base/services/input/InputDispatcher.h
a032cc008618b83ecbbede537517d1e7998e3264 08-Mar-2011 Jeff Brown <jeffbrown@google.com> Add MotionEvent.HOVER_ENTER and HOVER_EXIT.

The input dispatcher sends a HOVER_ENTER to a window before dispatching
it any HOVER_MOVE events. For compatibility reasons, the window will
*also* receive the HOVER_MOVE. When the pointer moves into a different
window or the pointer goes down or when events are canceled for some reason,
the input dispatcher sends a HOVER_EXIT to the previously hovered window.

The view hierarchy behavior is similar. All views under the pointer
receive onHoverEvent with HOVER_ENTER followed by any number of HOVER_MOVE
events. When the pointer leaves a view, the view receives HOVER_EXIT.
Similarly, if a parent view decides to capture hover by returning true
from onHoverEvent, the hovered descendants will receive HOVER_EXIT.

The default behavior of onHoverEvent is to update the view's hovered
state by calling setHovered(true/false). Views can query their current
hovered state using isHovered().

For testing purposes, the hovered state is mapped to the pressed
drawable state. This will change in a subsequent commit with the
introduction of a new hovered drawable state.

Change-Id: Ib76a7a90236c8f2c7336e55773acade6346cacbe
/frameworks/base/services/input/InputDispatcher.h
56194ebec6212e229f4ccdaa4b187166d20013ef 03-Mar-2011 Jeff Brown <jeffbrown@google.com> Wake screen from external HID peripherals.

Added some plumbing to enable the policy to intercept motion
events when the screen is off to handle wakeup if needed.

Added a basic concept of an external device to limit the scope
of the wakeup policy to external devices only. The wakeup policy
for internal devices should be based on explicit rules such as
policy flags in key layout files.

Moved isTouchEvent to native.

Ensure the dispatcher sends the right event type to userActivity
for non-touch pointer events like HOVER_MOVE and SCROLL.

Bug: 3193114
Change-Id: I15dbd48a16810dfaf226ff7ad117d46908ca4f86
/frameworks/base/services/input/InputDispatcher.h
bfaf3b91709ef35e0d5901b186edd7c2a9729161 23-Feb-2011 Jeff Brown <jeffbrown@google.com> Be more precise about tracking fallback keys.

Only initiate fallback key handling if the first key down was
not handled and there is no other fallback key already in progress.
This prevents spurious fallbacks from being generated when
applications handle the initial down but not repeated downs or the up.

Change-Id: I8a513896cf96b16dc502cd72291926d5532aa2ab
/frameworks/base/services/input/InputDispatcher.h
cc0c159e9b3dd4e0f48da0ce3e33d2c68a651413 19-Feb-2011 Jeff Brown <jeffbrown@google.com> Add new hover move action and scroll wheel plumbing.

Added support for tracking the mouse position even when the mouse button
is not pressed. To avoid confusing existing applications, mouse movements
are reported using the new ACTION_HOVER_MOVE action when the mouse button
is not pressed.

Added some more plumbing for the scroll wheel axes. The values are
reported to Views but they are not yet handled by the framework.

Change-Id: I1706be850d25cf34e5adf880bbed5cc3265cf4b1
/frameworks/base/services/input/InputDispatcher.h
58a2da843f2f22f406df8df1f011738eb8b7fcb1 26-Jan-2011 Jeff Brown <jeffbrown@google.com> Fix crashes caused by some input devices.

The touch screen sometimes reports more than 10 pointers even though that's
all we asked for. When this happens, we start dropping events with more
than 10 pointers. This confuses applications and causes them to crash.
Raised the limit to 16 pointers.
Bug: 3331247

The default behavior was to identify all touch devices as touch screens.
External devices that are plugged in are more likely to be touch pads
not attached to a screen. Changed the default to be a touch pad
and renamed some internal constants to avoid confusion.

A certain mouse happens to also behave like a touch pad. That caused
problems because we would see multiple concurrent traces of motion events
coming from the same input device so we would batch them up.
Added code to ensure that we don't batch events unless they come from
the same *source* in addition to coming from the same *device*.

Due to batching or misbehaving drivers, it's possible for the set of
pointer ids to be different from what we expect when it comes time to
split motion events across windows. As a result, we can generate motion
events with 0 pointers. When we try to deliver those events, we cause
an error in the InputTransport so we tear down the InputChannel and kill
the application.
Added code to check out assumption about pointer ids and drop the
event gracefully instead.

Patched up the tests to take into account the change in default behavior
for identifying touch screens and touch pads.

Change-Id: Ic364bd4cb4cc6335d4a1213a26d6bdadc7e33505
/frameworks/base/services/input/InputDispatcher.h
928e054931d357326613c78e62f4d850b7c442ff 10-Jan-2011 Jeff Brown <jeffbrown@google.com> Prevent events from getting backlogged.

This change implements two heuristics.

1. When events are older than 10 seconds, they are dropped.

2. If the application is currently busy processing an event and
the user touches a window belonging to a different application
then we drop the currently queued events so the other application
can start processing the gesture immediately.

Note that the system takes care of synthesizing cancelation events
automatically for any events that it drops.

Added some new handle types to allow the native dispatcher to
indirectly refer to the WindowManager's window state and app window
token. This was done to enable the dispatcher to identify the
application to which each window belongs but it also eliminates
some lookup tables and linear searches through the window list
on each key press.

Bug: 3224911
Change-Id: I9dae8dfe23d195d76865f97011fe2f1d351e2940
/frameworks/base/services/input/InputDispatcher.h
95712850665492af670824abdba77f0944d984d1 05-Jan-2011 Jeff Brown <jeffbrown@google.com> Only allow touch events from one device at a time.

Reject movements from other devices when one device is already down.
This fixes jittery behavior when the user moves the mouse and touches
the screen at the same time.

Change-Id: I99151c8f2596a3139720f776bcbc559d4b314878
/frameworks/base/services/input/InputDispatcher.h
b4ff35df5c04aec71fce7e90a6d6f9ef7180c2ad 03-Jan-2011 Jeff Brown <jeffbrown@google.com> Mouse pointer integration.

Added support for loading the pointer icon from a resource.

Moved the system server related bits of the input manager out
of libui and into libinput since they do not need to be linked into
applications.

Change-Id: Iec11e0725b3add2b905c51f8ea2c3b4b0d1a2d67
/frameworks/base/services/input/InputDispatcher.h