158 Commits

Author SHA1 Message Date
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
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
Jeff Brown
daf4a127ba Add a "show touches" option for demos and presentations.
Bug: 4569045

Change-Id: I8726ea292dd7def790a5e40d7d7e58968974f896
2011-08-26 17:14:14 -07:00
Jeff Brown
c28306ad4a Improve input device wake heuristics.
Bug: 5205674

Only wake the device on positive interactions from the user
such as button presses, movement, initial touch down events.
In particular, do not wake the device on up events since the
driver might synthesize them on power off, causing the device
to wake up again for no good reason.

Change-Id: I767f553ea36d110e6f3a10611b324487ba7d880d
2011-08-23 21:32:42 -07:00
Jeff Brown
9cc695c579 Clean up InputDispatcher debugging.
Change-Id: I020e834bfb541a1f274e26a72705f96f4307dddf
2011-08-23 18:42:06 -07:00
Jeff Brown
ea6892e02e Support BTN_TOOL_*TAP as synonyms for BTN_TOOL_FINGER.
Bug: 5205301

Some drivers report one finger as BTN_TOOL_FINGER, two as
BTN_TOOL_DOUBLETAP, three as BTN_TOOL_TRIPLETAP and four
as BTN_TOOL_QUADTAP.  Since we care about the tool type,
we need to handle _DOUBLE/_TRIPLE/_QUAD tap in the same way
we handle _FINGER.

Change-Id: I8eb83d2a2bada9ac32d07619c7eea84e924316b8
2011-08-23 17:49:49 -07:00
Jeff Brown
a66cee134e Fix tap gesture on touch pads.
Change-Id: I92b23e5971d4b98b173aacd64fe03ce9f0755c88
2011-08-19 16:04:30 -07:00
Jeff Brown
65fd251c39 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
2011-08-19 15:02:26 -07:00
Christopher Tate
755bd67a50 Merge "Don't crash if a drag recipient throws an uncaught exception" 2011-08-16 17:03:24 -07:00
Christopher Tate
d9be36c897 Don't crash if a drag recipient throws an uncaught exception
There turn out to be two distinct bugs leading to runtime restarts.

The first, dating from at least Android 3.1, is that following certain kinds
of app crashes we properly clean up the drag-state bookkeeping, but aren't
prepared in the case of the drag-target timeout clock firing with a now-
null drag state in effect.  We now catch that edge condition and don't NPE
(and note that there was already similar code around the separate timeout
when an app is *starting* the drag process).

The second bug is that some new-in-ICS code in the input channel management
wasn't prepared for certain cases where the current touch window could have
become unusable and its input channel torn down summarily in the case of the
aforesaid app crash during drag.  The code now makes sure that there really
is an input channel that needs to be flushed / cancelled prior to attempting
that operation.

Fixes bug 5173534

Change-Id: Idaae158ecfb4b93456ab1425769b669962893c00
2011-08-16 16:09:33 -07:00
Jeff Brown
abb4d446a1 Fix blocked event handling in InputDispatcher.
Bug: 5161854

The InputDispatcher contains code to recover from ANRs more quickly
when the user touches a different application.  When triggered,
it sets mNextUnblockedEvent to the next event it should dispatch
(to the next application).  All prior events are dropped.

This change fixes a bug where mNextUnblockedEvent could potentially
never be reset back to NULL if the inbound queue was drained
for some reason.

Change-Id: I21be2f02c9fc770bd260ea414db8bb184df89ada
2011-08-15 12:55:32 -07:00
Jeff Brown
063097545e Ensure outValue is set, even when an error occurs.
Change-Id: If883f60cde28792bd0e108597ced49d69d13136e
2011-08-11 17:10:06 -07:00
Jeff Brown
8bcbbefa3b Exorcise notification panel ghosts.
Bug: 5105599

Don't clear slot data when slot is no longer in use.

The kernel will not resend absolute slot values if they are
unchanged, even if the slot was previously marked unused.

Because the protocol is stateful, this could cause problems if
evdev drops events (marked by SYN_DROPPED) since we cannot
query the initial values of the slots, but there's nothing
we can do.

Change-Id: Ie13e68097fb8ed2542c2f60338b499082cf9e77f
2011-08-11 15:54:54 -07:00
Jeff Brown
a1f89ceec0 Improve touch device configuration.
Bug: 5064702

This change improves compatibility with standard touch device
drivers.  All existing touch device IDC files will need to
be updated because the input system now assumes that the
touch device drivers implement the multitouch input
protocol correctly and use the appropriate axes.

Change-Id: I93aad0e011efea74fbc7fa3da31f7967aff8136c
2011-08-11 14:57:50 -07:00
Jeff Brown
89ef0720ee Add input system to Watchdog.
Bug: 5094994

Change-Id: I153866958efc64ac19bda8b997c1c9f6ad425ec4
2011-08-10 16:25:21 -07:00
Jeff Brown
ba421dddfd Fix getSwitchState and others to check bitmasks.
Bug: 5149443

Removed some dead code and unnecessary checks, such as checks
for non-nullity of arrays that used to be dynamically allocated
once upon a time but are now part of the Device object itself.

Change-Id: I531116e816772d7c5030d22da0c8e1d7dcfba778
2011-08-10 15:17:37 -07:00
Jeff Brown
d87c6d5fd5 Use BTN_TOUCH or BTN_TOOL_* to determine if touch active.
Bug: 5064702

Should not include stylus buttons in the condition.

Change-Id: If4d78a875b77da8bd59672d6fdbf5353004d0023
2011-08-10 14:55:59 -07:00
Jeff Brown
be1aa8250c 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
2011-07-31 15:38:09 -07:00
Ying Wang
00fd1fc9b3 Merge "Fix uses of all-subdir-makefiles" 2011-07-27 18:29:26 -07:00
Ying Wang
d84d6c7b1a Fix uses of all-subdir-makefiles
We should use all-makefiles-under instead.
all-subdir-makefiles can be used only before any "include" statement.
Before this change, both subdirs were actually not included.

Change-Id: I6bf35d07f294a5012c9322096f999ac26e37432f
2011-07-27 16:59:08 -07:00
Jeff Brown
5ea29ab7ef Reset input dispatcher targets when focus changes apps.
This fixes an issue where an ANR can occur in a newly focused
application through no fault of its own, simply because
the previous app took a little while to transfer focus to
the new app.

Bug: 4584620
Change-Id: If3227eb68d92a09a108e9de7f0afcbd9a5dbdead
2011-07-27 11:50:51 -07:00
Jeff Brown
bc68a59c02 Report the external display size to the input reader.
The input reader needs this information so that it knows how to
interpolate touches on an external touch screen.

Changed Display so that it asks the WindowManager what the real
display size is (as opposed to the raw display size).  This means
it now takes into the forced display size set by
adb shell am display-size.

Replaced all calls to getRealWidth() / getRealHeight() /
getRealMetrics() in the WindowManager and replaced them with direct
usages of the mCurDisplayWidth / mCurDisplayHeight so that the WM
doesn't end up making a reentrant Binder call into itself.

Fixed the table status bar HeightReceiver so that it updates the
height on all configuration changes since it is possible that the
display size changed independently of an external HDMI display
being plugged / unplugged.

Improved the Display class documentation to make the distinctions
betweeen the various sizes clearer.

Change-Id: I3f75de559d3ebffed532ab46c4ae52c5e7f1da2b
2011-07-25 20:10:12 -07:00
Jeff Brown
49754db5a3 Handle stylus buttons and tool types.
Added TOOL_TYPE_ERASER.

Refactored the InputReader to share more code between the
various input mappers that handle button states and to
simplify the accumulator implementations by having each
one only handle a single type of input.

Removed the concept of direct/indirect tool types from the API.
If we add it back, it should be done in a manner that is orthogonal
to the tool type itself, perhaps as a flags field on the pointer.
The device source may well provide sufficient information anyhow.

Change-Id: I811c22d95e8304269b6ee4f6d11a6b04f3cfc1b2
2011-07-25 20:04:18 -07:00
Jeff Brown
44e504e089 Drop hack for drivers that emit zero ABS_MT_TOUCH_MAJOR.
Bug: 5064702

When using Linux MT Protocol A, drivers are supposed to omit
fingers that go up and to send an empty sync with no fingers
(can be just an SYN_MT_REPORT / SYN_REPORT) when no fingers
remain.

This makes Android more compliant with the protocol standard.

Change-Id: I5775feb14ab7db015824a32b1e2c015da239385d
2011-07-25 20:04:17 -07:00
Jeff Brown
ac386073df Remove unimplemented memory pool.
dlmalloc does such a great job that we don't need a pool anyways.

Change-Id: I105b28c4a5c491543959190c7c0a9de75a5b8052
2011-07-20 15:19:50 -07:00
Jeff Brown
612891e07b Add support for orientationAware touch pads.
Bug: 5038388

Change-Id: I9c571b1542299334d2d64c5b33e456ec20ebc0ae
2011-07-15 20:54:03 -07:00
Jeff Brown
6069139356 Remove more edge flag cruft.
Change-Id: I4f9f4f4cc7c771a918aee82a941a3e86ecfe48fe
2011-07-15 19:08:26 -07:00
Jeff Brown
a6111377e1 Remove edge slop support.
The edge slop feature was added a long time ago for a specific
device that had severe non-linear touch response issues near
the edges of its touch screen.  The feature is not useful on
modern hardware that is property calibrated.

Change-Id: I26716cbc7411c31883ddb4bb4ddd981027790d0f
2011-07-14 21:48:23 -07:00
Jeff Brown
9302c8796f 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
2011-07-14 04:11:21 -07:00
Jeff Brown
023e8c72e9 Merge "Revert "fix a weird use of Vector::appendVector()"" 2011-07-13 13:00:38 -07:00
Jeff Brown
b99a82437c Revert "fix a weird use of Vector::appendVector()"
This reverts commit 198fd888add624cf9e53ce31b776568a5d069916

This change seems to have exposed some other bugs.
Bug: 5026631
2011-07-13 12:51:11 -07:00
Jeff Brown
8c55a9a57e Merge "Remove the simulator target from all makefiles. Bug: 5010576" 2011-07-12 12:15:07 -07:00
Jeff Brown
bd882b1c87 Remove the simulator target from all makefiles.
Bug: 5010576

Change-Id: I04d722f258951a3078fe07899f5bbe8aac02a8e8
2011-07-11 22:12:16 -07:00
Mathias Agopian
198fd888ad fix a weird use of Vector::appendVector()
operator= is way more efficient.

Change-Id: I61c9adb1413bed230801a77151b8f7000fd11471
2011-07-11 16:26:36 -07:00
Jeff Brown
a4d1bc5172 Drop obsolete touch screen hacks.
Change-Id: I47354c37ee2cc2b36340eb709bb5043b3ba78ed9
2011-07-01 19:23:40 -07:00
Jeff Brown
6894a2947e Workaround apps that make assumptions about pointer ids.
Modified the touch input mapper to assign pointer ids sequentially
starting from 0 instead of using the tracking id or slot index
supplied by the driver.  Applications should not depend on this
ordering but some do.  (sigh)

Bug: 4980884
Change-Id: I0dfeb3ac27c57a7102a13c960c760e2a02eb7669
2011-07-01 19:08:15 -07:00
Jeff Brown
2717eff2ac Query input device for initial slot index.
This fixes a problem where touches can get stuck because the
driver and the framework have different ideas of what the
initial slot index is.  The framework assumed it was slot 0
but it could in principle be any slot, such as slot 1.  When
that happened, the framework would start tracking the first
touch as slot 0, but it might never receive an "up" for that slot.

Change-Id: Idaffc4534b275d66b9d4360987b28dc2d0f63218
2011-07-01 02:59:26 -07:00
Jeff Brown
d640125318 Merge "Fix joystick and trackpad regression." 2011-06-29 21:20:36 -07:00
Jeff Brown
2e45fb6f95 Fix joystick and trackpad regression.
Change-Id: I33b6756f95a6b0725ffa210f341da3c98426491b
2011-06-29 21:19:05 -07:00
Mathias Agopian
439863f3b3 SF transactions are now O(1) wrt IPC instead of O(N).
Change-Id: I57669852cbf6aabae244ea86940a08a5a27ffc43
2011-06-29 15:05:41 -07:00
Jeff Brown
aba321aa6f Add some logging code to track down touch issues.
Change-Id: I9bd7af6b93f82a83c6863986d21e7a222d97e4ae
2011-06-28 20:34:40 -07:00