replicant-frameworks_native/include/ui
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
..
egl Introduce official public NativeWindow type. 2010-06-30 15:32:04 -07:00
android_native_buffer.h Add incStrong and decStrong methods to android_native_{window,buffer}_t. 2010-05-10 17:33:32 -07:00
DisplayInfo.h auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
EGLNativeSurface.h auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
EGLUtils.h added EGLUtils::strerror 2009-08-07 16:37:21 -07:00
EventHub.h Refactor input reader to support new device types more easily. 2010-07-28 14:16:15 -07:00
FramebufferNativeWindow.h Introduce official public NativeWindow type. 2010-06-30 15:32:04 -07:00
GraphicBuffer.h split surface management from surface's buffers management 2010-06-04 18:57:41 -07:00
GraphicBufferAllocator.h when a zero dimension buffer is allocated, turn the allocation into 2010-04-15 15:23:25 -07:00
GraphicBufferMapper.h fix [2167050] glTexImage2D code path buggy in SurfaceFlinger 2009-10-06 17:00:25 -07:00
Input.h Refactor input reader to support new device types more easily. 2010-07-28 14:16:15 -07:00
InputDispatcher.h Fix possible race conditions during channel unregistration. 2010-08-17 17:03:42 -07:00
InputManager.h DO NOT MERGE: Fix input event injection ANRs on UI thread. 2010-07-29 12:54:27 -07:00
InputReader.h Fix safe mode and KeyEvent.getMaxKeyCode(). 2010-08-10 16:28:03 -07:00
InputTransport.h Add support for new input sources. 2010-07-15 18:32:33 -07:00
IOverlay.h move libbinder's header files under includes/binder 2009-05-20 12:55:03 -07:00
KeyCharacterMap.h auto import from //depot/cupcake/@135843 2009-03-03 19:31:44 -08:00
KeycodeLabels.h Add initial gamepad support. 2010-07-13 17:04:57 -07:00
Overlay.h Adding resizeInput and setAttributes for overlay 2009-07-29 17:53:38 -07:00
PixelFormat.h fix a bug I introduced recently where YUV formats would crash the system 2010-02-16 20:43:39 -08:00
Point.h minor clean-up to Rect and Point. 2009-05-26 17:47:39 -07:00
Rect.h Add ANativeWindow API for directly drawing to the surface bits. 2010-07-09 16:58:19 -07:00
Region.h Remove a dependency of Region (libui) on Parcel (libbinder). 2010-02-17 20:26:47 -08:00