Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _UI_INPUT_DISPATCHER_H
|
|
|
|
#define _UI_INPUT_DISPATCHER_H
|
|
|
|
|
|
|
|
#include <ui/Input.h>
|
|
|
|
#include <ui/InputTransport.h>
|
|
|
|
#include <utils/KeyedVector.h>
|
|
|
|
#include <utils/Vector.h>
|
|
|
|
#include <utils/threads.h>
|
|
|
|
#include <utils/Timers.h>
|
|
|
|
#include <utils/RefBase.h>
|
|
|
|
#include <utils/String8.h>
|
|
|
|
#include <utils/PollLoop.h>
|
|
|
|
#include <utils/Pool.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
/*
|
|
|
|
* Constants used to report the outcome of input event injection.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/* (INTERNAL USE ONLY) Specifies that injection is pending and its outcome is unknown. */
|
|
|
|
INPUT_EVENT_INJECTION_PENDING = -1,
|
|
|
|
|
|
|
|
/* Injection succeeded. */
|
|
|
|
INPUT_EVENT_INJECTION_SUCCEEDED = 0,
|
|
|
|
|
|
|
|
/* Injection failed because the injector did not have permission to inject
|
|
|
|
* into the application with input focus. */
|
|
|
|
INPUT_EVENT_INJECTION_PERMISSION_DENIED = 1,
|
|
|
|
|
|
|
|
/* Injection failed because there were no available input targets. */
|
|
|
|
INPUT_EVENT_INJECTION_FAILED = 2,
|
|
|
|
|
|
|
|
/* Injection failed due to a timeout. */
|
|
|
|
INPUT_EVENT_INJECTION_TIMED_OUT = 3
|
|
|
|
};
|
|
|
|
|
2010-07-28 22:48:59 +00:00
|
|
|
/*
|
|
|
|
* Constants used to determine the input event injection synchronization mode.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/* Injection is asynchronous and is assumed always to be successful. */
|
|
|
|
INPUT_EVENT_INJECTION_SYNC_NONE = 0,
|
|
|
|
|
|
|
|
/* Waits for previous events to be dispatched so that the input dispatcher can determine
|
|
|
|
* whether input event injection willbe permitted based on the current input focus.
|
|
|
|
* Does not wait for the input event to finish processing. */
|
|
|
|
INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT = 1,
|
|
|
|
|
|
|
|
/* Waits for the input event to be completely processed. */
|
|
|
|
INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISHED = 2,
|
|
|
|
};
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
/*
|
|
|
|
* An input target specifies how an input event is to be dispatched to a particular window
|
|
|
|
* including the window's input channel, control flags, a timeout, and an X / Y offset to
|
|
|
|
* be added to input event coordinates to compensate for the absolute position of the
|
|
|
|
* window area.
|
|
|
|
*/
|
|
|
|
struct InputTarget {
|
|
|
|
enum {
|
|
|
|
/* This flag indicates that subsequent event delivery should be held until the
|
|
|
|
* current event is delivered to this target or a timeout occurs. */
|
|
|
|
FLAG_SYNC = 0x01,
|
|
|
|
|
2010-09-02 00:01:00 +00:00
|
|
|
/* This flag indicates that a MotionEvent with AMOTION_EVENT_ACTION_DOWN falls outside
|
|
|
|
* of the area of this target and so should instead be delivered as an
|
|
|
|
* AMOTION_EVENT_ACTION_OUTSIDE to this target. */
|
2010-06-15 08:31:58 +00:00
|
|
|
FLAG_OUTSIDE = 0x02,
|
|
|
|
|
|
|
|
/* This flag indicates that a KeyEvent or MotionEvent is being canceled.
|
2010-09-02 00:01:00 +00:00
|
|
|
* In the case of a key event, it should be delivered with flag
|
|
|
|
* AKEY_EVENT_FLAG_CANCELED set.
|
|
|
|
* In the case of a motion event, it should be delivered with action
|
|
|
|
* AMOTION_EVENT_ACTION_CANCEL instead. */
|
|
|
|
FLAG_CANCEL = 0x04,
|
|
|
|
|
|
|
|
/* This flag indicates that the target of a MotionEvent is partly or wholly
|
|
|
|
* obscured by another visible window above it. The motion event should be
|
|
|
|
* delivered with flag AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED. */
|
|
|
|
FLAG_WINDOW_IS_OBSCURED = 0x08,
|
2010-06-15 08:31:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// The input channel to be targeted.
|
|
|
|
sp<InputChannel> inputChannel;
|
|
|
|
|
|
|
|
// Flags for the input target.
|
|
|
|
int32_t flags;
|
|
|
|
|
|
|
|
// The timeout for event delivery to this target in nanoseconds. Or -1 if none.
|
|
|
|
nsecs_t timeout;
|
|
|
|
|
|
|
|
// The x and y offset to add to a MotionEvent as it is delivered.
|
|
|
|
// (ignored for KeyEvents)
|
|
|
|
float xOffset, yOffset;
|
|
|
|
};
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
/*
|
|
|
|
* Input dispatcher policy interface.
|
|
|
|
*
|
|
|
|
* The input reader policy is used by the input reader to interact with the Window Manager
|
|
|
|
* and other system components.
|
|
|
|
*
|
|
|
|
* The actual implementation is partially supported by callbacks into the DVM
|
|
|
|
* via JNI. This interface is also mocked in the unit tests.
|
|
|
|
*/
|
|
|
|
class InputDispatcherPolicyInterface : public virtual RefBase {
|
|
|
|
protected:
|
|
|
|
InputDispatcherPolicyInterface() { }
|
|
|
|
virtual ~InputDispatcherPolicyInterface() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
/* Notifies the system that a configuration change has occurred. */
|
|
|
|
virtual void notifyConfigurationChanged(nsecs_t when) = 0;
|
|
|
|
|
|
|
|
/* Notifies the system that an input channel is unrecoverably broken. */
|
|
|
|
virtual void notifyInputChannelBroken(const sp<InputChannel>& inputChannel) = 0;
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
/* Notifies the system that an input channel is not responding.
|
|
|
|
* Returns true and a new timeout value if the dispatcher should keep waiting.
|
|
|
|
* Otherwise returns false. */
|
|
|
|
virtual bool notifyInputChannelANR(const sp<InputChannel>& inputChannel,
|
|
|
|
nsecs_t& outNewTimeout) = 0;
|
2010-06-15 08:31:58 +00:00
|
|
|
|
|
|
|
/* Notifies the system that an input channel recovered from ANR. */
|
|
|
|
virtual void notifyInputChannelRecoveredFromANR(const sp<InputChannel>& inputChannel) = 0;
|
|
|
|
|
2010-09-07 17:44:57 +00:00
|
|
|
/* Gets the key repeat initial timeout or -1 if automatic key repeating is disabled. */
|
2010-06-15 08:31:58 +00:00
|
|
|
virtual nsecs_t getKeyRepeatTimeout() = 0;
|
|
|
|
|
2010-09-07 17:44:57 +00:00
|
|
|
/* Gets the key repeat inter-key delay. */
|
|
|
|
virtual nsecs_t getKeyRepeatDelay() = 0;
|
|
|
|
|
2010-06-22 08:27:15 +00:00
|
|
|
/* Waits for key event input targets to become available.
|
2010-06-18 03:52:56 +00:00
|
|
|
* If the event is being injected, injectorPid and injectorUid should specify the
|
|
|
|
* process id and used id of the injecting application, otherwise they should both
|
|
|
|
* be -1.
|
|
|
|
* Returns one of the INPUT_EVENT_INJECTION_XXX constants. */
|
2010-06-22 08:27:15 +00:00
|
|
|
virtual int32_t waitForKeyEventTargets(KeyEvent* keyEvent, uint32_t policyFlags,
|
2010-06-18 03:52:56 +00:00
|
|
|
int32_t injectorPid, int32_t injectorUid,
|
2010-06-15 08:31:58 +00:00
|
|
|
Vector<InputTarget>& outTargets) = 0;
|
|
|
|
|
2010-06-22 08:27:15 +00:00
|
|
|
/* Waits for motion event targets to become available.
|
2010-06-18 03:52:56 +00:00
|
|
|
* If the event is being injected, injectorPid and injectorUid should specify the
|
|
|
|
* process id and used id of the injecting application, otherwise they should both
|
|
|
|
* be -1.
|
|
|
|
* Returns one of the INPUT_EVENT_INJECTION_XXX constants. */
|
2010-06-22 08:27:15 +00:00
|
|
|
virtual int32_t waitForMotionEventTargets(MotionEvent* motionEvent, uint32_t policyFlags,
|
2010-06-18 03:52:56 +00:00
|
|
|
int32_t injectorPid, int32_t injectorUid,
|
2010-06-15 08:31:58 +00:00
|
|
|
Vector<InputTarget>& outTargets) = 0;
|
2010-08-18 22:51:08 +00:00
|
|
|
|
|
|
|
/* Gets the maximum suggested event delivery rate per second.
|
|
|
|
* This value is used to throttle motion event movement actions on a per-device
|
|
|
|
* basis. It is not intended to be a hard limit.
|
|
|
|
*/
|
|
|
|
virtual int32_t getMaxEventsPerSecond() = 0;
|
2010-06-15 08:31:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
/* Notifies the system about input events generated by the input reader.
|
|
|
|
* The dispatcher is expected to be mostly asynchronous. */
|
|
|
|
class InputDispatcherInterface : public virtual RefBase {
|
|
|
|
protected:
|
|
|
|
InputDispatcherInterface() { }
|
|
|
|
virtual ~InputDispatcherInterface() { }
|
|
|
|
|
|
|
|
public:
|
|
|
|
/* Runs a single iteration of the dispatch loop.
|
|
|
|
* Nominally processes one queued event, a timeout, or a response from an input consumer.
|
|
|
|
*
|
|
|
|
* This method should only be called on the input dispatcher thread.
|
|
|
|
*/
|
|
|
|
virtual void dispatchOnce() = 0;
|
|
|
|
|
|
|
|
/* Notifies the dispatcher about new events.
|
|
|
|
*
|
|
|
|
* These methods should only be called on the input reader thread.
|
|
|
|
*/
|
2010-06-15 08:31:58 +00:00
|
|
|
virtual void notifyConfigurationChanged(nsecs_t eventTime) = 0;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
virtual void notifyAppSwitchComing(nsecs_t eventTime) = 0;
|
2010-07-15 01:48:53 +00:00
|
|
|
virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode,
|
|
|
|
int32_t scanCode, int32_t metaState, nsecs_t downTime) = 0;
|
2010-07-15 01:48:53 +00:00
|
|
|
virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
|
2010-09-02 00:01:00 +00:00
|
|
|
uint32_t policyFlags, int32_t action, int32_t flags,
|
|
|
|
int32_t metaState, int32_t edgeFlags,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
|
|
|
|
float xPrecision, float yPrecision, nsecs_t downTime) = 0;
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
/* Injects an input event and optionally waits for sync.
|
2010-07-28 22:48:59 +00:00
|
|
|
* The synchronization mode determines whether the method blocks while waiting for
|
|
|
|
* input injection to proceed.
|
2010-06-18 03:52:56 +00:00
|
|
|
* Returns one of the INPUT_EVENT_INJECTION_XXX constants.
|
|
|
|
*
|
|
|
|
* This method may be called on any thread (usually by the input manager).
|
|
|
|
*/
|
|
|
|
virtual int32_t injectInputEvent(const InputEvent* event,
|
2010-07-28 22:48:59 +00:00
|
|
|
int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis) = 0;
|
2010-06-18 03:52:56 +00:00
|
|
|
|
2010-06-22 08:27:15 +00:00
|
|
|
/* Preempts input dispatch in progress by making pending synchronous
|
|
|
|
* dispatches asynchronous instead. This method is generally called during a focus
|
|
|
|
* transition from one application to the next so as to enable the new application
|
|
|
|
* to start receiving input as soon as possible without having to wait for the
|
|
|
|
* old application to finish up.
|
|
|
|
*
|
|
|
|
* This method may be called on any thread (usually by the input manager).
|
|
|
|
*/
|
|
|
|
virtual void preemptInputDispatch() = 0;
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
/* Registers or unregister input channels that may be used as targets for input events.
|
|
|
|
*
|
|
|
|
* These methods may be called on any thread (usually by the input manager).
|
|
|
|
*/
|
|
|
|
virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel) = 0;
|
|
|
|
virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel) = 0;
|
|
|
|
};
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
/* Dispatches events to input targets. Some functions of the input dispatcher, such as
|
|
|
|
* identifying input targets, are controlled by a separate policy object.
|
|
|
|
*
|
|
|
|
* IMPORTANT INVARIANT:
|
|
|
|
* Because the policy can potentially block or cause re-entrance into the input dispatcher,
|
|
|
|
* the input dispatcher never calls into the policy while holding its internal locks.
|
|
|
|
* The implementation is also carefully designed to recover from scenarios such as an
|
|
|
|
* input channel becoming unregistered while identifying input targets or processing timeouts.
|
|
|
|
*
|
|
|
|
* Methods marked 'Locked' must be called with the lock acquired.
|
|
|
|
*
|
|
|
|
* Methods marked 'LockedInterruptible' must be called with the lock acquired but
|
|
|
|
* may during the course of their execution release the lock, call into the policy, and
|
|
|
|
* then reacquire the lock. The caller is responsible for recovering gracefully.
|
|
|
|
*
|
|
|
|
* A 'LockedInterruptible' method may called a 'Locked' method, but NOT vice-versa.
|
|
|
|
*/
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
class InputDispatcher : public InputDispatcherInterface {
|
|
|
|
protected:
|
|
|
|
virtual ~InputDispatcher();
|
|
|
|
|
|
|
|
public:
|
2010-06-15 08:31:58 +00:00
|
|
|
explicit InputDispatcher(const sp<InputDispatcherPolicyInterface>& policy);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
virtual void dispatchOnce();
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
virtual void notifyConfigurationChanged(nsecs_t eventTime);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
virtual void notifyAppSwitchComing(nsecs_t eventTime);
|
2010-07-15 01:48:53 +00:00
|
|
|
virtual void notifyKey(nsecs_t eventTime, int32_t deviceId, int32_t source,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t policyFlags, int32_t action, int32_t flags, int32_t keyCode,
|
|
|
|
int32_t scanCode, int32_t metaState, nsecs_t downTime);
|
2010-07-15 01:48:53 +00:00
|
|
|
virtual void notifyMotion(nsecs_t eventTime, int32_t deviceId, int32_t source,
|
2010-09-02 00:01:00 +00:00
|
|
|
uint32_t policyFlags, int32_t action, int32_t flags,
|
|
|
|
int32_t metaState, int32_t edgeFlags,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t pointerCount, const int32_t* pointerIds, const PointerCoords* pointerCoords,
|
|
|
|
float xPrecision, float yPrecision, nsecs_t downTime);
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
virtual int32_t injectInputEvent(const InputEvent* event,
|
2010-07-28 22:48:59 +00:00
|
|
|
int32_t injectorPid, int32_t injectorUid, int32_t syncMode, int32_t timeoutMillis);
|
2010-06-18 03:52:56 +00:00
|
|
|
|
2010-06-22 08:27:15 +00:00
|
|
|
virtual void preemptInputDispatch();
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
virtual status_t registerInputChannel(const sp<InputChannel>& inputChannel);
|
|
|
|
virtual status_t unregisterInputChannel(const sp<InputChannel>& inputChannel);
|
|
|
|
|
|
|
|
private:
|
|
|
|
template <typename T>
|
|
|
|
struct Link {
|
|
|
|
T* next;
|
|
|
|
T* prev;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EventEntry : Link<EventEntry> {
|
|
|
|
enum {
|
|
|
|
TYPE_SENTINEL,
|
|
|
|
TYPE_CONFIGURATION_CHANGED,
|
|
|
|
TYPE_KEY,
|
|
|
|
TYPE_MOTION
|
|
|
|
};
|
|
|
|
|
|
|
|
int32_t refCount;
|
|
|
|
int32_t type;
|
|
|
|
nsecs_t eventTime;
|
2010-06-15 08:31:58 +00:00
|
|
|
|
2010-07-28 22:48:59 +00:00
|
|
|
int32_t injectionResult; // initially INPUT_EVENT_INJECTION_PENDING
|
|
|
|
bool injectionIsAsync; // set to true if injection is not waiting for the result
|
|
|
|
int32_t injectorPid; // -1 if not injected
|
|
|
|
int32_t injectorUid; // -1 if not injected
|
2010-06-18 03:52:56 +00:00
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
bool dispatchInProgress; // initially false, set to true while dispatching
|
2010-07-28 22:48:59 +00:00
|
|
|
int32_t pendingSyncDispatches; // the number of synchronous dispatches in progress
|
2010-06-18 03:52:56 +00:00
|
|
|
|
|
|
|
inline bool isInjected() { return injectorPid >= 0; }
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ConfigurationChangedEntry : EventEntry {
|
|
|
|
};
|
|
|
|
|
|
|
|
struct KeyEntry : EventEntry {
|
|
|
|
int32_t deviceId;
|
2010-07-15 01:48:53 +00:00
|
|
|
int32_t source;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t policyFlags;
|
|
|
|
int32_t action;
|
|
|
|
int32_t flags;
|
|
|
|
int32_t keyCode;
|
|
|
|
int32_t scanCode;
|
|
|
|
int32_t metaState;
|
|
|
|
int32_t repeatCount;
|
|
|
|
nsecs_t downTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MotionSample {
|
|
|
|
MotionSample* next;
|
|
|
|
|
|
|
|
nsecs_t eventTime;
|
|
|
|
PointerCoords pointerCoords[MAX_POINTERS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MotionEntry : EventEntry {
|
|
|
|
int32_t deviceId;
|
2010-07-15 01:48:53 +00:00
|
|
|
int32_t source;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
uint32_t policyFlags;
|
|
|
|
int32_t action;
|
2010-09-02 00:01:00 +00:00
|
|
|
int32_t flags;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
int32_t metaState;
|
|
|
|
int32_t edgeFlags;
|
|
|
|
float xPrecision;
|
|
|
|
float yPrecision;
|
|
|
|
nsecs_t downTime;
|
|
|
|
uint32_t pointerCount;
|
|
|
|
int32_t pointerIds[MAX_POINTERS];
|
|
|
|
|
|
|
|
// Linked list of motion samples associated with this motion event.
|
|
|
|
MotionSample firstSample;
|
|
|
|
MotionSample* lastSample;
|
2010-08-18 22:51:08 +00:00
|
|
|
|
|
|
|
uint32_t countSamples() const;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
// Tracks the progress of dispatching a particular event to a particular connection.
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
struct DispatchEntry : Link<DispatchEntry> {
|
|
|
|
EventEntry* eventEntry; // the event to dispatch
|
|
|
|
int32_t targetFlags;
|
|
|
|
float xOffset;
|
|
|
|
float yOffset;
|
|
|
|
nsecs_t timeout;
|
|
|
|
|
|
|
|
// True if dispatch has started.
|
|
|
|
bool inProgress;
|
|
|
|
|
|
|
|
// For motion events:
|
|
|
|
// Pointer to the first motion sample to dispatch in this cycle.
|
|
|
|
// Usually NULL to indicate that the list of motion samples begins at
|
|
|
|
// MotionEntry::firstSample. Otherwise, some samples were dispatched in a previous
|
|
|
|
// cycle and this pointer indicates the location of the first remainining sample
|
|
|
|
// to dispatch during the current cycle.
|
|
|
|
MotionSample* headMotionSample;
|
|
|
|
// Pointer to a motion sample to dispatch in the next cycle if the dispatcher was
|
|
|
|
// unable to send all motion samples during this cycle. On the next cycle,
|
|
|
|
// headMotionSample will be initialized to tailMotionSample and tailMotionSample
|
|
|
|
// will be set to NULL.
|
|
|
|
MotionSample* tailMotionSample;
|
2010-07-28 22:48:59 +00:00
|
|
|
|
|
|
|
inline bool isSyncTarget() {
|
|
|
|
return targetFlags & InputTarget::FLAG_SYNC;
|
|
|
|
}
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
// A command entry captures state and behavior for an action to be performed in the
|
|
|
|
// dispatch loop after the initial processing has taken place. It is essentially
|
|
|
|
// a kind of continuation used to postpone sensitive policy interactions to a point
|
|
|
|
// in the dispatch loop where it is safe to release the lock (generally after finishing
|
|
|
|
// the critical parts of the dispatch cycle).
|
|
|
|
//
|
|
|
|
// The special thing about commands is that they can voluntarily release and reacquire
|
|
|
|
// the dispatcher lock at will. Initially when the command starts running, the
|
|
|
|
// dispatcher lock is held. However, if the command needs to call into the policy to
|
|
|
|
// do some work, it can release the lock, do the work, then reacquire the lock again
|
|
|
|
// before returning.
|
|
|
|
//
|
|
|
|
// This mechanism is a bit clunky but it helps to preserve the invariant that the dispatch
|
|
|
|
// never calls into the policy while holding its lock.
|
|
|
|
//
|
|
|
|
// Commands are implicitly 'LockedInterruptible'.
|
|
|
|
struct CommandEntry;
|
|
|
|
typedef void (InputDispatcher::*Command)(CommandEntry* commandEntry);
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
class Connection;
|
2010-06-15 08:31:58 +00:00
|
|
|
struct CommandEntry : Link<CommandEntry> {
|
|
|
|
CommandEntry();
|
|
|
|
~CommandEntry();
|
|
|
|
|
|
|
|
Command command;
|
|
|
|
|
|
|
|
// parameters for the command (usage varies by command)
|
2010-06-18 03:52:56 +00:00
|
|
|
sp<Connection> connection;
|
2010-06-15 08:31:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Generic queue implementation.
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
template <typename T>
|
|
|
|
struct Queue {
|
|
|
|
T head;
|
|
|
|
T tail;
|
|
|
|
|
|
|
|
inline Queue() {
|
|
|
|
head.prev = NULL;
|
|
|
|
head.next = & tail;
|
|
|
|
tail.prev = & head;
|
|
|
|
tail.next = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool isEmpty() {
|
|
|
|
return head.next == & tail;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void enqueueAtTail(T* entry) {
|
|
|
|
T* last = tail.prev;
|
|
|
|
last->next = entry;
|
|
|
|
entry->prev = last;
|
|
|
|
entry->next = & tail;
|
|
|
|
tail.prev = entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void enqueueAtHead(T* entry) {
|
|
|
|
T* first = head.next;
|
|
|
|
head.next = entry;
|
|
|
|
entry->prev = & head;
|
|
|
|
entry->next = first;
|
|
|
|
first->prev = entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void dequeue(T* entry) {
|
|
|
|
entry->prev->next = entry->next;
|
|
|
|
entry->next->prev = entry->prev;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline T* dequeueAtHead() {
|
|
|
|
T* first = head.next;
|
|
|
|
dequeue(first);
|
|
|
|
return first;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Allocates queue entries and performs reference counting as needed. */
|
|
|
|
class Allocator {
|
|
|
|
public:
|
|
|
|
Allocator();
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
ConfigurationChangedEntry* obtainConfigurationChangedEntry(nsecs_t eventTime);
|
|
|
|
KeyEntry* obtainKeyEntry(nsecs_t eventTime,
|
2010-07-15 01:48:53 +00:00
|
|
|
int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
|
2010-06-18 03:52:56 +00:00
|
|
|
int32_t flags, int32_t keyCode, int32_t scanCode, int32_t metaState,
|
|
|
|
int32_t repeatCount, nsecs_t downTime);
|
|
|
|
MotionEntry* obtainMotionEntry(nsecs_t eventTime,
|
2010-07-15 01:48:53 +00:00
|
|
|
int32_t deviceId, int32_t source, uint32_t policyFlags, int32_t action,
|
2010-09-02 00:01:00 +00:00
|
|
|
int32_t flags, int32_t metaState, int32_t edgeFlags,
|
|
|
|
float xPrecision, float yPrecision,
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t downTime, uint32_t pointerCount,
|
|
|
|
const int32_t* pointerIds, const PointerCoords* pointerCoords);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
DispatchEntry* obtainDispatchEntry(EventEntry* eventEntry);
|
2010-06-15 08:31:58 +00:00
|
|
|
CommandEntry* obtainCommandEntry(Command command);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
void releaseEventEntry(EventEntry* entry);
|
|
|
|
void releaseConfigurationChangedEntry(ConfigurationChangedEntry* entry);
|
|
|
|
void releaseKeyEntry(KeyEntry* entry);
|
|
|
|
void releaseMotionEntry(MotionEntry* entry);
|
|
|
|
void releaseDispatchEntry(DispatchEntry* entry);
|
2010-06-15 08:31:58 +00:00
|
|
|
void releaseCommandEntry(CommandEntry* entry);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
void appendMotionSample(MotionEntry* motionEntry,
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t eventTime, const PointerCoords* pointerCoords);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Pool<ConfigurationChangedEntry> mConfigurationChangeEntryPool;
|
|
|
|
Pool<KeyEntry> mKeyEntryPool;
|
|
|
|
Pool<MotionEntry> mMotionEntryPool;
|
|
|
|
Pool<MotionSample> mMotionSamplePool;
|
|
|
|
Pool<DispatchEntry> mDispatchEntryPool;
|
2010-06-15 08:31:58 +00:00
|
|
|
Pool<CommandEntry> mCommandEntryPool;
|
2010-06-18 03:52:56 +00:00
|
|
|
|
|
|
|
void initializeEventEntry(EventEntry* entry, int32_t type, nsecs_t eventTime);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Manages the dispatch state associated with a single input channel. */
|
|
|
|
class Connection : public RefBase {
|
|
|
|
protected:
|
|
|
|
virtual ~Connection();
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Status {
|
|
|
|
// Everything is peachy.
|
|
|
|
STATUS_NORMAL,
|
|
|
|
// An unrecoverable communication error has occurred.
|
|
|
|
STATUS_BROKEN,
|
|
|
|
// The client is not responding.
|
|
|
|
STATUS_NOT_RESPONDING,
|
|
|
|
// The input channel has been unregistered.
|
|
|
|
STATUS_ZOMBIE
|
|
|
|
};
|
|
|
|
|
|
|
|
Status status;
|
|
|
|
sp<InputChannel> inputChannel;
|
|
|
|
InputPublisher inputPublisher;
|
|
|
|
Queue<DispatchEntry> outboundQueue;
|
|
|
|
nsecs_t nextTimeoutTime; // next timeout time (LONG_LONG_MAX if none)
|
|
|
|
|
|
|
|
nsecs_t lastEventTime; // the time when the event was originally captured
|
|
|
|
nsecs_t lastDispatchTime; // the time when the last event was dispatched
|
|
|
|
nsecs_t lastANRTime; // the time when the last ANR was recorded
|
|
|
|
|
|
|
|
explicit Connection(const sp<InputChannel>& inputChannel);
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
inline const char* getInputChannelName() const { return inputChannel->getName().string(); }
|
|
|
|
|
|
|
|
const char* getStatusLabel() const;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
// Finds a DispatchEntry in the outbound queue associated with the specified event.
|
|
|
|
// Returns NULL if not found.
|
|
|
|
DispatchEntry* findQueuedDispatchEntryForEvent(const EventEntry* eventEntry) const;
|
|
|
|
|
|
|
|
// Determine whether this connection has a pending synchronous dispatch target.
|
|
|
|
// Since there can only ever be at most one such target at a time, if there is one,
|
|
|
|
// it must be at the tail because nothing else can be enqueued after it.
|
|
|
|
inline bool hasPendingSyncTarget() {
|
2010-07-28 22:48:59 +00:00
|
|
|
return ! outboundQueue.isEmpty() && outboundQueue.tail.prev->isSyncTarget();
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Gets the time since the current event was originally obtained from the input driver.
|
|
|
|
inline double getEventLatencyMillis(nsecs_t currentTime) {
|
|
|
|
return (currentTime - lastEventTime) / 1000000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gets the time since the current event entered the outbound dispatch queue.
|
|
|
|
inline double getDispatchLatencyMillis(nsecs_t currentTime) {
|
|
|
|
return (currentTime - lastDispatchTime) / 1000000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gets the time since the current event ANR was declared, if applicable.
|
|
|
|
inline double getANRLatencyMillis(nsecs_t currentTime) {
|
|
|
|
return (currentTime - lastANRTime) / 1000000.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t initialize();
|
2010-06-18 03:52:56 +00:00
|
|
|
|
|
|
|
void setNextTimeoutTime(nsecs_t currentTime, nsecs_t timeout);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
sp<InputDispatcherPolicyInterface> mPolicy;
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
Mutex mLock;
|
|
|
|
|
|
|
|
Allocator mAllocator;
|
|
|
|
sp<PollLoop> mPollLoop;
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
Queue<EventEntry> mInboundQueue;
|
|
|
|
Queue<CommandEntry> mCommandQueue;
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
// All registered connections mapped by receive pipe file descriptor.
|
|
|
|
KeyedVector<int, sp<Connection> > mConnectionsByReceiveFd;
|
|
|
|
|
2010-08-17 22:59:26 +00:00
|
|
|
ssize_t getConnectionIndex(const sp<InputChannel>& inputChannel);
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
// Active connections are connections that have a non-empty outbound queue.
|
2010-06-18 03:52:56 +00:00
|
|
|
// We don't use a ref-counted pointer here because we explicitly abort connections
|
|
|
|
// during unregistration which causes the connection's outbound queue to be cleared
|
|
|
|
// and the connection itself to be deactivated.
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
Vector<Connection*> mActiveConnections;
|
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
// List of connections that have timed out. Only used by dispatchOnce()
|
|
|
|
// We don't use a ref-counted pointer here because it is not possible for a connection
|
|
|
|
// to be unregistered while processing timed out connections since we hold the lock for
|
|
|
|
// the duration.
|
|
|
|
Vector<Connection*> mTimedOutConnections;
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
// Preallocated key and motion event objects used only to ask the input dispatcher policy
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
// for the targets of an event that is to be dispatched.
|
|
|
|
KeyEvent mReusableKeyEvent;
|
|
|
|
MotionEvent mReusableMotionEvent;
|
|
|
|
|
|
|
|
// The input targets that were most recently identified for dispatch.
|
|
|
|
// If there is a synchronous event dispatch in progress, the current input targets will
|
|
|
|
// remain unchanged until the dispatch has completed or been aborted.
|
|
|
|
Vector<InputTarget> mCurrentInputTargets;
|
2010-06-15 08:31:58 +00:00
|
|
|
bool mCurrentInputTargetsValid; // false while targets are being recomputed
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
// Event injection and synchronization.
|
|
|
|
Condition mInjectionResultAvailableCondition;
|
|
|
|
EventEntry* createEntryFromInputEventLocked(const InputEvent* event);
|
|
|
|
void setInjectionResultLocked(EventEntry* entry, int32_t injectionResult);
|
|
|
|
|
2010-07-28 22:48:59 +00:00
|
|
|
Condition mInjectionSyncFinishedCondition;
|
|
|
|
void decrementPendingSyncDispatchesLocked(EventEntry* entry);
|
|
|
|
|
2010-08-18 22:51:08 +00:00
|
|
|
// Throttling state.
|
|
|
|
struct ThrottleState {
|
|
|
|
nsecs_t minTimeBetweenEvents;
|
|
|
|
|
|
|
|
nsecs_t lastEventTime;
|
|
|
|
int32_t lastDeviceId;
|
|
|
|
uint32_t lastSource;
|
|
|
|
|
|
|
|
uint32_t originalSampleCount; // only collected during debugging
|
|
|
|
} mThrottleState;
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
// Key repeat tracking.
|
|
|
|
// XXX Move this up to the input reader instead.
|
|
|
|
struct KeyRepeatState {
|
|
|
|
KeyEntry* lastKeyEntry; // or null if no repeat
|
|
|
|
nsecs_t nextRepeatTime;
|
|
|
|
} mKeyRepeatState;
|
|
|
|
|
|
|
|
void resetKeyRepeatLocked();
|
|
|
|
|
2010-06-15 08:31:58 +00:00
|
|
|
// Deferred command processing.
|
|
|
|
bool runCommandsLockedInterruptible();
|
|
|
|
CommandEntry* postCommandLocked(Command command);
|
|
|
|
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
// Process events that have just been dequeued from the head of the input queue.
|
2010-06-15 08:31:58 +00:00
|
|
|
void processConfigurationChangedLockedInterruptible(
|
|
|
|
nsecs_t currentTime, ConfigurationChangedEntry* entry);
|
|
|
|
void processKeyLockedInterruptible(
|
|
|
|
nsecs_t currentTime, KeyEntry* entry, nsecs_t keyRepeatTimeout);
|
|
|
|
void processKeyRepeatLockedInterruptible(
|
|
|
|
nsecs_t currentTime, nsecs_t keyRepeatTimeout);
|
|
|
|
void processMotionLockedInterruptible(
|
|
|
|
nsecs_t currentTime, MotionEntry* entry);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
// Identify input targets for an event and dispatch to them.
|
2010-06-15 08:31:58 +00:00
|
|
|
void identifyInputTargetsAndDispatchKeyLockedInterruptible(
|
|
|
|
nsecs_t currentTime, KeyEntry* entry);
|
|
|
|
void identifyInputTargetsAndDispatchMotionLockedInterruptible(
|
|
|
|
nsecs_t currentTime, MotionEntry* entry);
|
|
|
|
void dispatchEventToCurrentInputTargetsLocked(
|
|
|
|
nsecs_t currentTime, EventEntry* entry, bool resumeWithAppendedMotionSample);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
|
|
|
|
// Manage the dispatch cycle for a single connection.
|
2010-06-18 03:52:56 +00:00
|
|
|
// These methods are deliberately not Interruptible because doing all of the work
|
|
|
|
// with the mutex held makes it easier to ensure that connection invariants are maintained.
|
|
|
|
// If needed, the methods post commands to run later once the critical bits are done.
|
|
|
|
void prepareDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
EventEntry* eventEntry, const InputTarget* inputTarget,
|
|
|
|
bool resumeWithAppendedMotionSample);
|
2010-06-18 03:52:56 +00:00
|
|
|
void startDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection);
|
|
|
|
void finishDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection);
|
|
|
|
void timeoutDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection);
|
|
|
|
void resumeAfterTimeoutDispatchCycleLocked(nsecs_t currentTime,
|
|
|
|
const sp<Connection>& connection, nsecs_t newTimeout);
|
|
|
|
void abortDispatchCycleLocked(nsecs_t currentTime, const sp<Connection>& connection,
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
bool broken);
|
|
|
|
static bool handleReceiveCallback(int receiveFd, int events, void* data);
|
|
|
|
|
|
|
|
// Add or remove a connection to the mActiveConnections vector.
|
|
|
|
void activateConnectionLocked(Connection* connection);
|
|
|
|
void deactivateConnectionLocked(Connection* connection);
|
|
|
|
|
|
|
|
// Interesting events that we might like to log or tell the framework about.
|
2010-06-15 08:31:58 +00:00
|
|
|
void onDispatchCycleStartedLocked(
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t currentTime, const sp<Connection>& connection);
|
2010-06-15 08:31:58 +00:00
|
|
|
void onDispatchCycleFinishedLocked(
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t currentTime, const sp<Connection>& connection, bool recoveredFromANR);
|
2010-06-15 08:31:58 +00:00
|
|
|
void onDispatchCycleANRLocked(
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t currentTime, const sp<Connection>& connection);
|
2010-06-15 08:31:58 +00:00
|
|
|
void onDispatchCycleBrokenLocked(
|
2010-06-18 03:52:56 +00:00
|
|
|
nsecs_t currentTime, const sp<Connection>& connection);
|
2010-06-15 08:31:58 +00:00
|
|
|
|
2010-06-18 03:52:56 +00:00
|
|
|
// Outbound policy interactions.
|
2010-06-15 08:31:58 +00:00
|
|
|
void doNotifyInputChannelBrokenLockedInterruptible(CommandEntry* commandEntry);
|
|
|
|
void doNotifyInputChannelANRLockedInterruptible(CommandEntry* commandEntry);
|
|
|
|
void doNotifyInputChannelRecoveredFromANRLockedInterruptible(CommandEntry* commandEntry);
|
Native input dispatch rewrite work in progress.
The old dispatch mechanism has been left in place and continues to
be used by default for now. To enable native input dispatch,
edit the ENABLE_NATIVE_DISPATCH constant in WindowManagerPolicy.
Includes part of the new input event NDK API. Some details TBD.
To wire up input dispatch, as the ViewRoot adds a window to the
window session it receives an InputChannel object as an output
argument. The InputChannel encapsulates the file descriptors for a
shared memory region and two pipe end-points. The ViewRoot then
provides the InputChannel to the InputQueue. Behind the
scenes, InputQueue simply attaches handlers to the native PollLoop object
that underlies the MessageQueue. This way MessageQueue doesn't need
to know anything about input dispatch per-se, it just exposes (in native
code) a PollLoop that other components can use to monitor file descriptor
state changes.
There can be zero or more targets for any given input event. Each
input target is specified by its input channel and some parameters
including flags, an X/Y coordinate offset, and the dispatch timeout.
An input target can request either synchronous dispatch (for foreground apps)
or asynchronous dispatch (fire-and-forget for wallpapers and "outside"
targets). Currently, finding the appropriate input targets for an event
requires a call back into the WindowManagerServer from native code.
In the future this will be refactored to avoid most of these callbacks
except as required to handle pending focus transitions.
End-to-end event dispatch mostly works!
To do: event injection, rate limiting, ANRs, testing, optimization, etc.
Change-Id: I8c36b2b9e0a2d27392040ecda0f51b636456de25
2010-04-23 01:58:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Enqueues and dispatches input events, endlessly. */
|
|
|
|
class InputDispatcherThread : public Thread {
|
|
|
|
public:
|
|
|
|
explicit InputDispatcherThread(const sp<InputDispatcherInterface>& dispatcher);
|
|
|
|
~InputDispatcherThread();
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool threadLoop();
|
|
|
|
|
|
|
|
sp<InputDispatcherInterface> mDispatcher;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace android
|
|
|
|
|
|
|
|
#endif // _UI_INPUT_DISPATCHER_PRIV_H
|