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-22 18:58:52 -07: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define LOG_TAG "InputManager-JNI"
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
//#define LOG_NDEBUG 0
|
|
|
|
|
|
|
|
// Log debug messages about InputReaderPolicy
|
2010-06-22 01:27:15 -07:00
|
|
|
#define DEBUG_INPUT_READER_POLICY 0
|
2010-06-15 01:31:58 -07:00
|
|
|
|
|
|
|
// Log debug messages about InputDispatcherPolicy
|
2010-06-22 01:27:15 -07:00
|
|
|
#define DEBUG_INPUT_DISPATCHER_POLICY 0
|
2010-06-15 01:31:58 -07:00
|
|
|
|
2010-12-23 17:50:18 -08: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-22 18:58:52 -07:00
|
|
|
#include "JNIHelp.h"
|
|
|
|
#include "jni.h"
|
2010-06-22 01:27:15 -07:00
|
|
|
#include <limits.h>
|
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-22 18:58:52 -07:00
|
|
|
#include <android_runtime/AndroidRuntime.h>
|
2011-01-02 16:37:43 -08: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-22 18:58:52 -07:00
|
|
|
#include <utils/Log.h>
|
|
|
|
#include <utils/threads.h>
|
2010-12-23 17:50:18 -08:00
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
#include <input/InputManager.h>
|
|
|
|
#include <input/PointerController.h>
|
|
|
|
|
|
|
|
#include <android_view_KeyEvent.h>
|
|
|
|
#include <android_view_MotionEvent.h>
|
|
|
|
#include <android_view_InputChannel.h>
|
|
|
|
#include <android/graphics/GraphicsJNI.h>
|
|
|
|
|
2010-07-02 15:37:36 -07:00
|
|
|
#include "com_android_server_PowerManagerService.h"
|
2011-01-10 11:17:36 -08:00
|
|
|
#include "com_android_server_InputApplication.h"
|
|
|
|
#include "com_android_server_InputApplicationHandle.h"
|
|
|
|
#include "com_android_server_InputWindow.h"
|
|
|
|
#include "com_android_server_InputWindowHandle.h"
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
|
|
|
|
|
|
|
jmethodID notifyConfigurationChanged;
|
|
|
|
jmethodID notifyLidSwitchChanged;
|
2010-06-17 20:52:56 -07:00
|
|
|
jmethodID notifyInputChannelBroken;
|
2010-06-22 01:27:15 -07:00
|
|
|
jmethodID notifyANR;
|
|
|
|
jmethodID interceptKeyBeforeQueueing;
|
|
|
|
jmethodID interceptKeyBeforeDispatching;
|
2010-11-05 15:02:16 -07:00
|
|
|
jmethodID dispatchUnhandledKey;
|
2010-06-22 01:27:15 -07:00
|
|
|
jmethodID checkInjectEventsPermission;
|
2010-06-15 01:31:58 -07:00
|
|
|
jmethodID filterTouchEvents;
|
|
|
|
jmethodID filterJumpyTouchEvents;
|
2011-01-18 15:10:10 -08:00
|
|
|
jmethodID getVirtualKeyQuietTimeMillis;
|
2010-06-15 01:31:58 -07:00
|
|
|
jmethodID getExcludedDeviceNames;
|
2010-08-18 15:51:08 -07:00
|
|
|
jmethodID getMaxEventsPerSecond;
|
2010-12-23 17:50:18 -08:00
|
|
|
jmethodID getPointerLayer;
|
2011-01-02 16:37:43 -08:00
|
|
|
jmethodID getPointerIcon;
|
2010-06-15 01:31:58 -07:00
|
|
|
} gCallbacksClassInfo;
|
|
|
|
|
2010-07-28 15:48:59 -07:00
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
|
|
|
} gKeyEventClassInfo;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
|
|
|
} gMotionEventClassInfo;
|
|
|
|
|
2010-08-30 03:02:23 -07:00
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
|
|
|
|
|
|
|
jmethodID ctor;
|
|
|
|
jmethodID addMotionRange;
|
|
|
|
|
|
|
|
jfieldID mId;
|
|
|
|
jfieldID mName;
|
|
|
|
jfieldID mSources;
|
|
|
|
jfieldID mKeyboardType;
|
|
|
|
} gInputDeviceClassInfo;
|
|
|
|
|
2010-09-21 18:22:55 -07:00
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
|
|
|
|
|
|
|
jfieldID touchscreen;
|
|
|
|
jfieldID keyboard;
|
|
|
|
jfieldID navigation;
|
|
|
|
} gConfigurationClassInfo;
|
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
static struct {
|
|
|
|
jclass clazz;
|
2010-12-23 17:50:18 -08:00
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
jfieldID bitmap;
|
|
|
|
jfieldID hotSpotX;
|
|
|
|
jfieldID hotSpotY;
|
|
|
|
} gPointerIconClassInfo;
|
2010-12-23 17:50:18 -08:00
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
|
|
|
|
// --- Global functions ---
|
|
|
|
|
|
|
|
static jobject getInputApplicationHandleObjLocalRef(JNIEnv* env,
|
|
|
|
const sp<InputApplicationHandle>& inputApplicationHandle) {
|
|
|
|
if (inputApplicationHandle == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return static_cast<NativeInputApplicationHandle*>(inputApplicationHandle.get())->
|
|
|
|
getInputApplicationHandleObjLocalRef(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
static jobject getInputWindowHandleObjLocalRef(JNIEnv* env,
|
|
|
|
const sp<InputWindowHandle>& inputWindowHandle) {
|
|
|
|
if (inputWindowHandle == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return static_cast<NativeInputWindowHandle*>(inputWindowHandle.get())->
|
|
|
|
getInputWindowHandleObjLocalRef(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --- NativeInputManager ---
|
2010-12-23 17:50:18 -08:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
class NativeInputManager : public virtual RefBase,
|
|
|
|
public virtual InputReaderPolicyInterface,
|
|
|
|
public virtual InputDispatcherPolicyInterface {
|
|
|
|
protected:
|
|
|
|
virtual ~NativeInputManager();
|
|
|
|
|
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-22 18:58:52 -07:00
|
|
|
public:
|
2010-06-15 01:31:58 -07:00
|
|
|
NativeInputManager(jobject callbacksObj);
|
|
|
|
|
|
|
|
inline sp<InputManager> getInputManager() const { return mInputManager; }
|
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-22 18:58:52 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
void dump(String8& dump);
|
2010-07-15 23:54:05 -07: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-22 18:58:52 -07:00
|
|
|
void setDisplaySize(int32_t displayId, int32_t width, int32_t height);
|
|
|
|
void setDisplayOrientation(int32_t displayId, int32_t orientation);
|
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
status_t registerInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel,
|
2011-01-10 11:17:36 -08:00
|
|
|
const sp<InputWindowHandle>& inputWindowHandle, bool monitor);
|
2010-06-17 20:52:56 -07:00
|
|
|
status_t unregisterInputChannel(JNIEnv* env, const sp<InputChannel>& inputChannel);
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
void setInputWindows(JNIEnv* env, jobjectArray windowObjArray);
|
|
|
|
void setFocusedApplication(JNIEnv* env, jobject applicationObj);
|
|
|
|
void setInputDispatchMode(bool enabled, bool frozen);
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
/* --- InputReaderPolicyInterface 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-22 18:58:52 -07:00
|
|
|
virtual bool getDisplayInfo(int32_t displayId,
|
|
|
|
int32_t* width, int32_t* height, int32_t* orientation);
|
|
|
|
virtual bool filterTouchEvents();
|
|
|
|
virtual bool filterJumpyTouchEvents();
|
2011-01-18 15:10:10 -08:00
|
|
|
virtual nsecs_t getVirtualKeyQuietTime();
|
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-22 18:58:52 -07:00
|
|
|
virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames);
|
2010-12-23 17:50:18 -08:00
|
|
|
virtual sp<PointerControllerInterface> obtainPointerController(int32_t deviceId);
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
/* --- InputDispatcherPolicyInterface 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-22 18:58:52 -07:00
|
|
|
|
2010-10-11 14:20:19 -07:00
|
|
|
virtual void notifySwitch(nsecs_t when, int32_t switchCode, int32_t switchValue,
|
|
|
|
uint32_t policyFlags);
|
2010-06-15 01:31:58 -07:00
|
|
|
virtual void notifyConfigurationChanged(nsecs_t when);
|
2010-09-15 15:18:56 -07:00
|
|
|
virtual nsecs_t notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
|
2011-01-10 11:17:36 -08:00
|
|
|
const sp<InputWindowHandle>& inputWindowHandle);
|
|
|
|
virtual void notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle);
|
2010-06-15 01:31:58 -07:00
|
|
|
virtual nsecs_t getKeyRepeatTimeout();
|
2010-09-07 10:44:57 -07:00
|
|
|
virtual nsecs_t getKeyRepeatDelay();
|
2010-08-18 15:51:08 -07:00
|
|
|
virtual int32_t getMaxEventsPerSecond();
|
2010-11-18 20:53:46 -08:00
|
|
|
virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
|
2010-10-08 22:31:17 -07:00
|
|
|
virtual void interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags);
|
2011-01-10 11:17:36 -08:00
|
|
|
virtual bool interceptKeyBeforeDispatching(const sp<InputWindowHandle>& inputWindowHandle,
|
2010-09-08 11:49:43 -07:00
|
|
|
const KeyEvent* keyEvent, uint32_t policyFlags);
|
2011-01-10 11:17:36 -08:00
|
|
|
virtual bool dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
|
2010-12-06 17:13:33 -08:00
|
|
|
const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent);
|
2010-09-26 22:20:12 -07:00
|
|
|
virtual void pokeUserActivity(nsecs_t eventTime, int32_t eventType);
|
2010-09-08 11:49:43 -07:00
|
|
|
virtual bool checkInjectEventsPermissionNonReentrant(
|
|
|
|
int32_t injectorPid, int32_t injectorUid);
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
private:
|
2010-06-15 01:31:58 -07:00
|
|
|
sp<InputManager> mInputManager;
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
jobject mCallbacksObj;
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
// Cached filtering policies.
|
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-22 18:58:52 -07:00
|
|
|
int32_t mFilterTouchEvents;
|
|
|
|
int32_t mFilterJumpyTouchEvents;
|
2011-01-18 15:10:10 -08:00
|
|
|
nsecs_t mVirtualKeyQuietTime;
|
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-22 18:58:52 -07:00
|
|
|
|
2010-08-18 15:51:08 -07:00
|
|
|
// Cached throttling policy.
|
|
|
|
int32_t mMaxEventsPerSecond;
|
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
Mutex mLock;
|
|
|
|
struct Locked {
|
|
|
|
// Display size information.
|
|
|
|
int32_t displayWidth, displayHeight; // -1 when initialized
|
|
|
|
int32_t displayOrientation;
|
|
|
|
|
|
|
|
// Pointer controller singleton, created and destroyed as needed.
|
|
|
|
wp<PointerController> pointerController;
|
|
|
|
} mLocked;
|
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-22 18:58:52 -07:00
|
|
|
|
2010-07-02 15:37:36 -07:00
|
|
|
// Power manager interactions.
|
2010-06-15 01:31:58 -07:00
|
|
|
bool isScreenOn();
|
|
|
|
bool isScreenBright();
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
static bool checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName);
|
2010-08-11 14:46:32 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
static inline JNIEnv* jniEnv() {
|
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-22 18:58:52 -07:00
|
|
|
return AndroidRuntime::getJNIEnv();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-01-10 11:17:36 -08: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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
NativeInputManager::NativeInputManager(jobject callbacksObj) :
|
2011-01-18 15:10:10 -08:00
|
|
|
mFilterTouchEvents(-1), mFilterJumpyTouchEvents(-1), mVirtualKeyQuietTime(-1),
|
2010-12-23 17:50:18 -08:00
|
|
|
mMaxEventsPerSecond(-1) {
|
2010-06-15 01:31:58 -07:00
|
|
|
JNIEnv* env = jniEnv();
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
mCallbacksObj = env->NewGlobalRef(callbacksObj);
|
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-22 18:58:52 -07:00
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
{
|
|
|
|
AutoMutex _l(mLock);
|
|
|
|
mLocked.displayWidth = -1;
|
|
|
|
mLocked.displayHeight = -1;
|
|
|
|
mLocked.displayOrientation = ROTATION_0;
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
sp<EventHub> eventHub = new EventHub();
|
|
|
|
mInputManager = new InputManager(eventHub, this, this);
|
|
|
|
}
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
NativeInputManager::~NativeInputManager() {
|
|
|
|
JNIEnv* env = jniEnv();
|
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-22 18:58:52 -07:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
env->DeleteGlobalRef(mCallbacksObj);
|
|
|
|
}
|
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-22 18:58:52 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
void NativeInputManager::dump(String8& dump) {
|
|
|
|
mInputManager->getReader()->dump(dump);
|
|
|
|
dump.append("\n");
|
2010-07-23 21:28:06 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
mInputManager->getDispatcher()->dump(dump);
|
|
|
|
dump.append("\n");
|
2010-06-15 01:31:58 -07: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-22 18:58:52 -07:00
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
bool NativeInputManager::checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
|
2010-06-15 01:31:58 -07:00
|
|
|
if (env->ExceptionCheck()) {
|
|
|
|
LOGE("An exception was thrown by callback '%s'.", methodName);
|
|
|
|
LOGE_EX(env);
|
|
|
|
env->ExceptionClear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NativeInputManager::setDisplaySize(int32_t displayId, int32_t width, int32_t height) {
|
|
|
|
if (displayId == 0) {
|
2010-12-23 17:50:18 -08:00
|
|
|
AutoMutex _l(mLock);
|
2010-06-15 01:31:58 -07:00
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
if (mLocked.displayWidth != width || mLocked.displayHeight != height) {
|
|
|
|
mLocked.displayWidth = width;
|
|
|
|
mLocked.displayHeight = height;
|
|
|
|
|
|
|
|
sp<PointerController> controller = mLocked.pointerController.promote();
|
|
|
|
if (controller != NULL) {
|
|
|
|
controller->setDisplaySize(width, height);
|
|
|
|
}
|
|
|
|
}
|
2010-06-15 01:31:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NativeInputManager::setDisplayOrientation(int32_t displayId, int32_t orientation) {
|
|
|
|
if (displayId == 0) {
|
2010-12-23 17:50:18 -08:00
|
|
|
AutoMutex _l(mLock);
|
|
|
|
|
|
|
|
if (mLocked.displayOrientation != orientation) {
|
|
|
|
mLocked.displayOrientation = orientation;
|
2010-06-15 01:31:58 -07:00
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
sp<PointerController> controller = mLocked.pointerController.promote();
|
|
|
|
if (controller != NULL) {
|
|
|
|
controller->setDisplayOrientation(orientation);
|
|
|
|
}
|
|
|
|
}
|
2010-06-15 01:31:58 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
status_t NativeInputManager::registerInputChannel(JNIEnv* env,
|
2011-01-10 11:17:36 -08:00
|
|
|
const sp<InputChannel>& inputChannel,
|
|
|
|
const sp<InputWindowHandle>& inputWindowHandle, bool monitor) {
|
|
|
|
return mInputManager->getDispatcher()->registerInputChannel(
|
|
|
|
inputChannel, inputWindowHandle, monitor);
|
2010-06-17 20:52:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
status_t NativeInputManager::unregisterInputChannel(JNIEnv* env,
|
|
|
|
const sp<InputChannel>& inputChannel) {
|
2010-09-08 11:49:43 -07:00
|
|
|
return mInputManager->getDispatcher()->unregisterInputChannel(inputChannel);
|
2010-06-17 20:52:56 -07:00
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
bool NativeInputManager::getDisplayInfo(int32_t displayId,
|
|
|
|
int32_t* width, int32_t* height, int32_t* orientation) {
|
|
|
|
bool result = false;
|
|
|
|
if (displayId == 0) {
|
2010-12-23 17:50:18 -08:00
|
|
|
AutoMutex _l(mLock);
|
2010-06-15 01:31:58 -07:00
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
if (mLocked.displayWidth > 0 && mLocked.displayHeight > 0) {
|
2010-07-23 21:28:06 -07:00
|
|
|
if (width) {
|
2010-12-23 17:50:18 -08:00
|
|
|
*width = mLocked.displayWidth;
|
2010-07-23 21:28:06 -07:00
|
|
|
}
|
|
|
|
if (height) {
|
2010-12-23 17:50:18 -08:00
|
|
|
*height = mLocked.displayHeight;
|
2010-07-23 21:28:06 -07:00
|
|
|
}
|
|
|
|
if (orientation) {
|
2010-12-23 17:50:18 -08:00
|
|
|
*orientation = mLocked.displayOrientation;
|
2010-07-23 21:28:06 -07:00
|
|
|
}
|
2010-06-15 01:31:58 -07:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NativeInputManager::filterTouchEvents() {
|
|
|
|
if (mFilterTouchEvents < 0) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
jboolean result = env->CallBooleanMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.filterTouchEvents);
|
2010-06-17 20:52:56 -07:00
|
|
|
if (checkAndClearExceptionFromCallback(env, "filterTouchEvents")) {
|
2010-06-15 01:31:58 -07:00
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFilterTouchEvents = result ? 1 : 0;
|
|
|
|
}
|
|
|
|
return mFilterTouchEvents;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NativeInputManager::filterJumpyTouchEvents() {
|
|
|
|
if (mFilterJumpyTouchEvents < 0) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
jboolean result = env->CallBooleanMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.filterJumpyTouchEvents);
|
2010-06-17 20:52:56 -07:00
|
|
|
if (checkAndClearExceptionFromCallback(env, "filterJumpyTouchEvents")) {
|
2010-06-15 01:31:58 -07:00
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
mFilterJumpyTouchEvents = result ? 1 : 0;
|
|
|
|
}
|
|
|
|
return mFilterJumpyTouchEvents;
|
|
|
|
}
|
|
|
|
|
2011-01-18 15:10:10 -08:00
|
|
|
nsecs_t NativeInputManager::getVirtualKeyQuietTime() {
|
|
|
|
if (mVirtualKeyQuietTime < 0) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
jint result = env->CallIntMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.getVirtualKeyQuietTimeMillis);
|
|
|
|
if (checkAndClearExceptionFromCallback(env, "getVirtualKeyQuietTimeMillis")) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
if (result < 0) {
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mVirtualKeyQuietTime = milliseconds_to_nanoseconds(result);
|
|
|
|
}
|
|
|
|
return mVirtualKeyQuietTime;
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
void NativeInputManager::getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames) {
|
2010-08-30 03:02:23 -07:00
|
|
|
outExcludedDeviceNames.clear();
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
jobjectArray result = jobjectArray(env->CallObjectMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.getExcludedDeviceNames));
|
2010-06-17 20:52:56 -07:00
|
|
|
if (! checkAndClearExceptionFromCallback(env, "getExcludedDeviceNames") && result) {
|
2010-06-15 01:31:58 -07:00
|
|
|
jsize length = env->GetArrayLength(result);
|
|
|
|
for (jsize i = 0; i < length; i++) {
|
|
|
|
jstring item = jstring(env->GetObjectArrayElement(result, i));
|
|
|
|
|
|
|
|
const char* deviceNameChars = env->GetStringUTFChars(item, NULL);
|
|
|
|
outExcludedDeviceNames.add(String8(deviceNameChars));
|
|
|
|
env->ReleaseStringUTFChars(item, deviceNameChars);
|
|
|
|
|
|
|
|
env->DeleteLocalRef(item);
|
|
|
|
}
|
|
|
|
env->DeleteLocalRef(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t deviceId) {
|
|
|
|
AutoMutex _l(mLock);
|
|
|
|
|
|
|
|
sp<PointerController> controller = mLocked.pointerController.promote();
|
|
|
|
if (controller == NULL) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
jint layer = env->CallIntMethod(mCallbacksObj, gCallbacksClassInfo.getPointerLayer);
|
2011-01-02 16:37:43 -08:00
|
|
|
if (checkAndClearExceptionFromCallback(env, "getPointerLayer")) {
|
|
|
|
layer = -1;
|
|
|
|
}
|
2010-12-23 17:50:18 -08:00
|
|
|
|
|
|
|
controller = new PointerController(layer);
|
|
|
|
mLocked.pointerController = controller;
|
|
|
|
|
|
|
|
controller->setDisplaySize(mLocked.displayWidth, mLocked.displayHeight);
|
|
|
|
controller->setDisplayOrientation(mLocked.displayOrientation);
|
2011-01-02 16:37:43 -08:00
|
|
|
|
|
|
|
jobject iconObj = env->CallObjectMethod(mCallbacksObj, gCallbacksClassInfo.getPointerIcon);
|
|
|
|
if (!checkAndClearExceptionFromCallback(env, "getPointerIcon") && iconObj) {
|
|
|
|
jfloat iconHotSpotX = env->GetFloatField(iconObj, gPointerIconClassInfo.hotSpotX);
|
|
|
|
jfloat iconHotSpotY = env->GetFloatField(iconObj, gPointerIconClassInfo.hotSpotY);
|
|
|
|
jobject iconBitmapObj = env->GetObjectField(iconObj, gPointerIconClassInfo.bitmap);
|
|
|
|
if (iconBitmapObj) {
|
|
|
|
SkBitmap* iconBitmap = GraphicsJNI::getNativeBitmap(env, iconBitmapObj);
|
|
|
|
if (iconBitmap) {
|
|
|
|
controller->setPointerIcon(iconBitmap, iconHotSpotX, iconHotSpotY);
|
|
|
|
}
|
|
|
|
env->DeleteLocalRef(iconBitmapObj);
|
|
|
|
}
|
|
|
|
env->DeleteLocalRef(iconObj);
|
|
|
|
}
|
2010-12-23 17:50:18 -08:00
|
|
|
}
|
|
|
|
return controller;
|
|
|
|
}
|
|
|
|
|
2010-10-11 14:20:19 -07:00
|
|
|
void NativeInputManager::notifySwitch(nsecs_t when, int32_t switchCode,
|
|
|
|
int32_t switchValue, uint32_t policyFlags) {
|
|
|
|
#if DEBUG_INPUT_DISPATCHER_POLICY
|
|
|
|
LOGD("notifySwitch - when=%lld, switchCode=%d, switchValue=%d, policyFlags=0x%x",
|
|
|
|
when, switchCode, switchValue, policyFlags);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
switch (switchCode) {
|
|
|
|
case SW_LID:
|
|
|
|
env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyLidSwitchChanged,
|
|
|
|
when, switchValue == 0);
|
|
|
|
checkAndClearExceptionFromCallback(env, "notifyLidSwitchChanged");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
void NativeInputManager::notifyConfigurationChanged(nsecs_t when) {
|
|
|
|
#if DEBUG_INPUT_DISPATCHER_POLICY
|
|
|
|
LOGD("notifyConfigurationChanged - when=%lld", when);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
2010-09-21 18:22:55 -07:00
|
|
|
env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyConfigurationChanged, when);
|
2010-06-17 20:52:56 -07:00
|
|
|
checkAndClearExceptionFromCallback(env, "notifyConfigurationChanged");
|
2010-06-15 01:31:58 -07:00
|
|
|
}
|
|
|
|
|
2010-09-15 15:18:56 -07:00
|
|
|
nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApplicationHandle,
|
2011-01-10 11:17:36 -08:00
|
|
|
const sp<InputWindowHandle>& inputWindowHandle) {
|
2010-09-08 11:49:43 -07:00
|
|
|
#if DEBUG_INPUT_DISPATCHER_POLICY
|
|
|
|
LOGD("notifyANR");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
jobject inputApplicationHandleObj =
|
|
|
|
getInputApplicationHandleObjLocalRef(env, inputApplicationHandle);
|
|
|
|
jobject inputWindowHandleObj =
|
|
|
|
getInputWindowHandleObjLocalRef(env, inputWindowHandle);
|
2010-09-08 11:49:43 -07:00
|
|
|
|
2010-09-15 15:18:56 -07:00
|
|
|
jlong newTimeout = env->CallLongMethod(mCallbacksObj,
|
2011-01-10 11:17:36 -08:00
|
|
|
gCallbacksClassInfo.notifyANR, inputApplicationHandleObj, inputWindowHandleObj);
|
2010-09-15 15:18:56 -07:00
|
|
|
if (checkAndClearExceptionFromCallback(env, "notifyANR")) {
|
2010-09-08 11:49:43 -07:00
|
|
|
newTimeout = 0; // abort dispatch
|
2010-09-15 15:18:56 -07:00
|
|
|
} else {
|
|
|
|
assert(newTimeout >= 0);
|
2010-09-08 11:49:43 -07:00
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
env->DeleteLocalRef(inputWindowHandleObj);
|
|
|
|
env->DeleteLocalRef(inputApplicationHandleObj);
|
2010-09-08 11:49:43 -07:00
|
|
|
return newTimeout;
|
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
void NativeInputManager::notifyInputChannelBroken(const sp<InputWindowHandle>& inputWindowHandle) {
|
2010-06-15 01:31:58 -07:00
|
|
|
#if DEBUG_INPUT_DISPATCHER_POLICY
|
2011-01-10 11:17:36 -08:00
|
|
|
LOGD("notifyInputChannelBroken");
|
2010-06-15 01:31:58 -07:00
|
|
|
#endif
|
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
jobject inputWindowHandleObj =
|
|
|
|
getInputWindowHandleObjLocalRef(env, inputWindowHandle);
|
|
|
|
if (inputWindowHandleObj) {
|
2010-06-17 20:52:56 -07:00
|
|
|
env->CallVoidMethod(mCallbacksObj, gCallbacksClassInfo.notifyInputChannelBroken,
|
2011-01-10 11:17:36 -08:00
|
|
|
inputWindowHandleObj);
|
2010-06-17 20:52:56 -07:00
|
|
|
checkAndClearExceptionFromCallback(env, "notifyInputChannelBroken");
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
env->DeleteLocalRef(inputWindowHandleObj);
|
2010-06-17 20:52:56 -07:00
|
|
|
}
|
2010-06-15 01:31:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsecs_t NativeInputManager::getKeyRepeatTimeout() {
|
|
|
|
if (! isScreenOn()) {
|
|
|
|
// Disable key repeat when the screen is off.
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
// TODO use ViewConfiguration.getLongPressTimeout()
|
|
|
|
return milliseconds_to_nanoseconds(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-07 10:44:57 -07:00
|
|
|
nsecs_t NativeInputManager::getKeyRepeatDelay() {
|
|
|
|
return milliseconds_to_nanoseconds(50);
|
|
|
|
}
|
|
|
|
|
2010-08-18 15:51:08 -07:00
|
|
|
int32_t NativeInputManager::getMaxEventsPerSecond() {
|
|
|
|
if (mMaxEventsPerSecond < 0) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
|
|
|
jint result = env->CallIntMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.getMaxEventsPerSecond);
|
|
|
|
if (checkAndClearExceptionFromCallback(env, "getMaxEventsPerSecond")) {
|
2010-08-18 17:48:53 -07:00
|
|
|
result = 60;
|
2010-08-18 15:51:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mMaxEventsPerSecond = result;
|
|
|
|
}
|
|
|
|
return mMaxEventsPerSecond;
|
|
|
|
}
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
void NativeInputManager::setInputWindows(JNIEnv* env, jobjectArray windowObjArray) {
|
2010-09-08 11:49:43 -07:00
|
|
|
Vector<InputWindow> windows;
|
2010-06-15 01:31:58 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
jsize length = env->GetArrayLength(windowObjArray);
|
|
|
|
for (jsize i = 0; i < length; i++) {
|
2011-01-10 11:17:36 -08:00
|
|
|
jobject windowObj = env->GetObjectArrayElement(windowObjArray, i);
|
|
|
|
if (! windowObj) {
|
2010-09-08 11:49:43 -07:00
|
|
|
break; // found null element indicating end of used portion of the array
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
windows.push();
|
|
|
|
InputWindow& window = windows.editTop();
|
2011-01-10 11:17:36 -08:00
|
|
|
android_server_InputWindow_toNative(env, windowObj, &window);
|
|
|
|
if (window.inputChannel == NULL) {
|
2010-09-08 11:49:43 -07:00
|
|
|
windows.pop();
|
2010-07-15 23:54:05 -07:00
|
|
|
}
|
2011-01-10 11:17:36 -08:00
|
|
|
env->DeleteLocalRef(windowObj);
|
2010-09-08 11:49:43 -07:00
|
|
|
}
|
2010-06-22 01:27:15 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
mInputManager->getDispatcher()->setInputWindows(windows);
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationObj) {
|
2010-09-08 11:49:43 -07:00
|
|
|
if (applicationObj) {
|
|
|
|
InputApplication application;
|
2011-01-10 11:17:36 -08:00
|
|
|
android_server_InputApplication_toNative(env, applicationObj, &application);
|
|
|
|
if (application.inputApplicationHandle != NULL) {
|
|
|
|
mInputManager->getDispatcher()->setFocusedApplication(&application);
|
|
|
|
}
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
2011-01-10 11:17:36 -08:00
|
|
|
mInputManager->getDispatcher()->setFocusedApplication(NULL);
|
2010-06-15 01:31:58 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) {
|
|
|
|
mInputManager->getDispatcher()->setInputDispatchMode(enabled, frozen);
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
|
|
|
|
2010-10-11 14:20:19 -07:00
|
|
|
bool NativeInputManager::isScreenOn() {
|
|
|
|
return android_server_PowerManagerService_isScreenOn();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NativeInputManager::isScreenBright() {
|
|
|
|
return android_server_PowerManagerService_isScreenBright();
|
|
|
|
}
|
|
|
|
|
2010-11-18 20:53:46 -08:00
|
|
|
void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent* keyEvent,
|
|
|
|
uint32_t& policyFlags) {
|
2010-10-11 23:32:49 -07:00
|
|
|
// Policy:
|
|
|
|
// - Ignore untrusted events and pass them along.
|
|
|
|
// - Ask the window manager what to do with normal events and trusted injected events.
|
|
|
|
// - For normal events wake and brighten the screen if currently off or dim.
|
|
|
|
if ((policyFlags & POLICY_FLAG_TRUSTED)) {
|
|
|
|
const int32_t WM_ACTION_PASS_TO_USER = 1;
|
|
|
|
const int32_t WM_ACTION_POKE_USER_ACTIVITY = 2;
|
|
|
|
const int32_t WM_ACTION_GO_TO_SLEEP = 4;
|
|
|
|
|
2010-11-18 20:53:46 -08:00
|
|
|
nsecs_t when = keyEvent->getEventTime();
|
2010-10-11 23:32:49 -07:00
|
|
|
bool isScreenOn = this->isScreenOn();
|
|
|
|
bool isScreenBright = this->isScreenBright();
|
2010-10-11 14:20:19 -07:00
|
|
|
|
2010-10-11 23:32:49 -07:00
|
|
|
JNIEnv* env = jniEnv();
|
2010-11-18 20:53:46 -08:00
|
|
|
jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
|
|
|
|
jint wmActions;
|
|
|
|
if (keyEventObj) {
|
|
|
|
wmActions = env->CallIntMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.interceptKeyBeforeQueueing,
|
|
|
|
keyEventObj, policyFlags, isScreenOn);
|
|
|
|
if (checkAndClearExceptionFromCallback(env, "interceptKeyBeforeQueueing")) {
|
|
|
|
wmActions = 0;
|
|
|
|
}
|
|
|
|
android_view_KeyEvent_recycle(env, keyEventObj);
|
|
|
|
env->DeleteLocalRef(keyEventObj);
|
|
|
|
} else {
|
|
|
|
LOGE("Failed to obtain key event object for interceptKeyBeforeQueueing.");
|
2010-10-11 23:32:49 -07:00
|
|
|
wmActions = 0;
|
2010-10-11 14:20:19 -07:00
|
|
|
}
|
|
|
|
|
2010-11-18 20:53:46 -08:00
|
|
|
if (!(policyFlags & POLICY_FLAG_INJECTED)) {
|
2010-10-11 23:32:49 -07:00
|
|
|
if (!isScreenOn) {
|
|
|
|
policyFlags |= POLICY_FLAG_WOKE_HERE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isScreenBright) {
|
|
|
|
policyFlags |= POLICY_FLAG_BRIGHT_HERE;
|
|
|
|
}
|
2010-10-11 14:20:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wmActions & WM_ACTION_GO_TO_SLEEP) {
|
|
|
|
android_server_PowerManagerService_goToSleep(when);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wmActions & WM_ACTION_POKE_USER_ACTIVITY) {
|
|
|
|
android_server_PowerManagerService_userActivity(when, POWER_MANAGER_BUTTON_EVENT);
|
|
|
|
}
|
2010-06-22 01:27:15 -07:00
|
|
|
|
2010-10-11 23:32:49 -07:00
|
|
|
if (wmActions & WM_ACTION_PASS_TO_USER) {
|
|
|
|
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
|
|
|
}
|
|
|
|
} else {
|
2010-10-11 14:20:19 -07:00
|
|
|
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NativeInputManager::interceptGenericBeforeQueueing(nsecs_t when, uint32_t& policyFlags) {
|
2010-10-11 23:32:49 -07:00
|
|
|
// Policy:
|
|
|
|
// - Ignore untrusted events and pass them along.
|
|
|
|
// - No special filtering for injected events required at this time.
|
|
|
|
// - Filter normal events based on screen state.
|
|
|
|
// - For normal events brighten (but do not wake) the screen if currently dim.
|
|
|
|
if ((policyFlags & POLICY_FLAG_TRUSTED) && !(policyFlags & POLICY_FLAG_INJECTED)) {
|
|
|
|
if (isScreenOn()) {
|
|
|
|
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
|
|
|
|
|
|
|
if (!isScreenBright()) {
|
|
|
|
policyFlags |= POLICY_FLAG_BRIGHT_HERE;
|
|
|
|
}
|
2010-10-11 14:20:19 -07:00
|
|
|
}
|
2010-10-11 23:32:49 -07:00
|
|
|
} else {
|
|
|
|
policyFlags |= POLICY_FLAG_PASS_TO_USER;
|
2010-10-11 14:20:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
bool NativeInputManager::interceptKeyBeforeDispatching(
|
|
|
|
const sp<InputWindowHandle>& inputWindowHandle,
|
2010-10-11 14:20:19 -07:00
|
|
|
const KeyEvent* keyEvent, uint32_t policyFlags) {
|
2010-10-11 23:32:49 -07:00
|
|
|
// Policy:
|
|
|
|
// - Ignore untrusted events and pass them along.
|
|
|
|
// - Filter normal events and trusted injected events through the window manager policy to
|
|
|
|
// handle the HOME key and the like.
|
2010-12-06 17:13:33 -08:00
|
|
|
bool result = false;
|
2010-10-11 23:32:49 -07:00
|
|
|
if (policyFlags & POLICY_FLAG_TRUSTED) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
// Note: inputWindowHandle may be null.
|
|
|
|
jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle);
|
2010-11-18 20:53:46 -08:00
|
|
|
jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
|
|
|
|
if (keyEventObj) {
|
|
|
|
jboolean consumed = env->CallBooleanMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.interceptKeyBeforeDispatching,
|
2011-01-10 11:17:36 -08:00
|
|
|
inputWindowHandleObj, keyEventObj, policyFlags);
|
2010-11-18 20:53:46 -08:00
|
|
|
bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching");
|
|
|
|
android_view_KeyEvent_recycle(env, keyEventObj);
|
|
|
|
env->DeleteLocalRef(keyEventObj);
|
|
|
|
result = consumed && !error;
|
|
|
|
} else {
|
|
|
|
LOGE("Failed to obtain key event object for interceptKeyBeforeDispatching.");
|
|
|
|
}
|
2011-01-10 11:17:36 -08:00
|
|
|
env->DeleteLocalRef(inputWindowHandleObj);
|
2010-10-11 23:32:49 -07:00
|
|
|
}
|
2010-11-18 20:53:46 -08:00
|
|
|
return result;
|
2010-06-30 14:41:59 -07:00
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
bool NativeInputManager::dispatchUnhandledKey(const sp<InputWindowHandle>& inputWindowHandle,
|
2010-12-06 17:13:33 -08:00
|
|
|
const KeyEvent* keyEvent, uint32_t policyFlags, KeyEvent* outFallbackKeyEvent) {
|
2010-11-05 15:02:16 -07:00
|
|
|
// Policy:
|
|
|
|
// - Ignore untrusted events and do not perform default handling.
|
2010-12-06 17:13:33 -08:00
|
|
|
bool result = false;
|
2010-11-05 15:02:16 -07:00
|
|
|
if (policyFlags & POLICY_FLAG_TRUSTED) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
// Note: inputWindowHandle may be null.
|
|
|
|
jobject inputWindowHandleObj = getInputWindowHandleObjLocalRef(env, inputWindowHandle);
|
2010-11-18 20:53:46 -08:00
|
|
|
jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
|
|
|
|
if (keyEventObj) {
|
2010-12-06 17:13:33 -08:00
|
|
|
jobject fallbackKeyEventObj = env->CallObjectMethod(mCallbacksObj,
|
2010-11-18 20:53:46 -08:00
|
|
|
gCallbacksClassInfo.dispatchUnhandledKey,
|
2011-01-10 11:17:36 -08:00
|
|
|
inputWindowHandleObj, keyEventObj, policyFlags);
|
2010-12-06 17:13:33 -08:00
|
|
|
checkAndClearExceptionFromCallback(env, "dispatchUnhandledKey");
|
2010-11-18 20:53:46 -08:00
|
|
|
android_view_KeyEvent_recycle(env, keyEventObj);
|
|
|
|
env->DeleteLocalRef(keyEventObj);
|
2010-12-06 17:13:33 -08:00
|
|
|
|
|
|
|
if (fallbackKeyEventObj) {
|
|
|
|
// Note: outFallbackKeyEvent may be the same object as keyEvent.
|
|
|
|
if (!android_view_KeyEvent_toNative(env, fallbackKeyEventObj,
|
|
|
|
outFallbackKeyEvent)) {
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
android_view_KeyEvent_recycle(env, fallbackKeyEventObj);
|
|
|
|
env->DeleteLocalRef(fallbackKeyEventObj);
|
|
|
|
}
|
2010-11-18 20:53:46 -08:00
|
|
|
} else {
|
|
|
|
LOGE("Failed to obtain key event object for dispatchUnhandledKey.");
|
|
|
|
}
|
2011-01-10 11:17:36 -08:00
|
|
|
env->DeleteLocalRef(inputWindowHandleObj);
|
2010-11-05 15:02:16 -07:00
|
|
|
}
|
2010-11-18 20:53:46 -08:00
|
|
|
return result;
|
2010-11-05 15:02:16 -07:00
|
|
|
}
|
|
|
|
|
2010-09-26 22:20:12 -07:00
|
|
|
void NativeInputManager::pokeUserActivity(nsecs_t eventTime, int32_t eventType) {
|
|
|
|
android_server_PowerManagerService_userActivity(eventTime, eventType);
|
2010-07-23 21:28:06 -07:00
|
|
|
}
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
bool NativeInputManager::checkInjectEventsPermissionNonReentrant(
|
|
|
|
int32_t injectorPid, int32_t injectorUid) {
|
|
|
|
JNIEnv* env = jniEnv();
|
|
|
|
jboolean result = env->CallBooleanMethod(mCallbacksObj,
|
|
|
|
gCallbacksClassInfo.checkInjectEventsPermission, injectorPid, injectorUid);
|
|
|
|
checkAndClearExceptionFromCallback(env, "checkInjectEventsPermission");
|
2010-06-22 01:27:15 -07:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static sp<NativeInputManager> gNativeInputManager;
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
static bool checkInputManagerUnitialized(JNIEnv* env) {
|
2010-06-15 01:31:58 -07:00
|
|
|
if (gNativeInputManager == NULL) {
|
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-22 18:58:52 -07:00
|
|
|
LOGE("Input manager not initialized.");
|
|
|
|
jniThrowRuntimeException(env, "Input manager not initialized.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeInit(JNIEnv* env, jclass clazz,
|
|
|
|
jobject callbacks) {
|
2010-06-15 01:31:58 -07:00
|
|
|
if (gNativeInputManager == NULL) {
|
|
|
|
gNativeInputManager = new NativeInputManager(callbacks);
|
|
|
|
} else {
|
|
|
|
LOGE("Input manager already initialized.");
|
|
|
|
jniThrowRuntimeException(env, "Input manager already initialized.");
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeStart(JNIEnv* env, jclass clazz) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
status_t result = gNativeInputManager->getInputManager()->start();
|
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-22 18:58:52 -07:00
|
|
|
if (result) {
|
|
|
|
jniThrowRuntimeException(env, "Input manager could not be started.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeSetDisplaySize(JNIEnv* env, jclass clazz,
|
|
|
|
jint displayId, jint width, jint height) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX we could get this from the SurfaceFlinger directly instead of requiring it
|
|
|
|
// to be passed in like this, not sure which is better but leaving it like this
|
|
|
|
// keeps the window manager in direct control of when display transitions propagate down
|
|
|
|
// to the input dispatcher
|
2010-06-15 01:31:58 -07:00
|
|
|
gNativeInputManager->setDisplaySize(displayId, width, height);
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeSetDisplayOrientation(JNIEnv* env, jclass clazz,
|
|
|
|
jint displayId, jint orientation) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
gNativeInputManager->setDisplayOrientation(displayId, orientation);
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static jint android_server_InputManager_nativeGetScanCodeState(JNIEnv* env, jclass clazz,
|
2010-07-23 21:28:06 -07:00
|
|
|
jint deviceId, jint sourceMask, jint scanCode) {
|
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-22 18:58:52 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
2010-07-14 18:48:53 -07:00
|
|
|
return AKEY_STATE_UNKNOWN;
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
return gNativeInputManager->getInputManager()->getReader()->getScanCodeState(
|
2010-07-23 21:28:06 -07:00
|
|
|
deviceId, uint32_t(sourceMask), scanCode);
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static jint android_server_InputManager_nativeGetKeyCodeState(JNIEnv* env, jclass clazz,
|
2010-07-23 21:28:06 -07:00
|
|
|
jint deviceId, jint sourceMask, jint keyCode) {
|
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-22 18:58:52 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
2010-07-14 18:48:53 -07:00
|
|
|
return AKEY_STATE_UNKNOWN;
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
return gNativeInputManager->getInputManager()->getReader()->getKeyCodeState(
|
2010-07-23 21:28:06 -07:00
|
|
|
deviceId, uint32_t(sourceMask), keyCode);
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static jint android_server_InputManager_nativeGetSwitchState(JNIEnv* env, jclass clazz,
|
2010-07-23 21:28:06 -07:00
|
|
|
jint deviceId, jint sourceMask, jint sw) {
|
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-22 18:58:52 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
2010-07-14 18:48:53 -07:00
|
|
|
return AKEY_STATE_UNKNOWN;
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
return gNativeInputManager->getInputManager()->getReader()->getSwitchState(
|
2010-07-23 21:28:06 -07:00
|
|
|
deviceId, uint32_t(sourceMask), sw);
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static jboolean android_server_InputManager_nativeHasKeys(JNIEnv* env, jclass clazz,
|
2010-07-23 21:28:06 -07:00
|
|
|
jint deviceId, jint sourceMask, jintArray keyCodes, jbooleanArray outFlags) {
|
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-22 18:58:52 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return JNI_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t* codes = env->GetIntArrayElements(keyCodes, NULL);
|
|
|
|
uint8_t* flags = env->GetBooleanArrayElements(outFlags, NULL);
|
|
|
|
jsize numCodes = env->GetArrayLength(keyCodes);
|
|
|
|
jboolean result;
|
2010-07-23 21:28:06 -07:00
|
|
|
if (numCodes == env->GetArrayLength(keyCodes)) {
|
2010-09-08 11:49:43 -07:00
|
|
|
result = gNativeInputManager->getInputManager()->getReader()->hasKeys(
|
2010-07-23 21:28:06 -07:00
|
|
|
deviceId, uint32_t(sourceMask), numCodes, codes, 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-22 18:58:52 -07:00
|
|
|
} else {
|
|
|
|
result = JNI_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
env->ReleaseBooleanArrayElements(outFlags, flags, 0);
|
|
|
|
env->ReleaseIntArrayElements(keyCodes, codes, 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void throwInputChannelNotInitialized(JNIEnv* env) {
|
|
|
|
jniThrowException(env, "java/lang/IllegalStateException",
|
|
|
|
"inputChannel is not initialized");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_handleInputChannelDisposed(JNIEnv* env,
|
|
|
|
jobject inputChannelObj, const sp<InputChannel>& inputChannel, void* data) {
|
|
|
|
LOGW("Input channel object '%s' was disposed without first being unregistered with "
|
|
|
|
"the input manager!", inputChannel->getName().string());
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
if (gNativeInputManager != NULL) {
|
2010-06-17 20:52:56 -07:00
|
|
|
gNativeInputManager->unregisterInputChannel(env, inputChannel);
|
2010-06-15 01:31:58 -07: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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeRegisterInputChannel(JNIEnv* env, jclass clazz,
|
2011-01-10 11:17:36 -08:00
|
|
|
jobject inputChannelObj, jobject inputWindowHandleObj, jboolean monitor) {
|
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-22 18:58:52 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
|
|
|
inputChannelObj);
|
|
|
|
if (inputChannel == NULL) {
|
|
|
|
throwInputChannelNotInitialized(env);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
sp<InputWindowHandle> inputWindowHandle =
|
|
|
|
android_server_InputWindowHandle_getHandle(env, inputWindowHandleObj);
|
2010-06-17 20:52:56 -07:00
|
|
|
|
|
|
|
status_t status = gNativeInputManager->registerInputChannel(
|
2011-01-10 11:17:36 -08:00
|
|
|
env, inputChannel, inputWindowHandle, monitor);
|
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-22 18:58:52 -07:00
|
|
|
if (status) {
|
|
|
|
jniThrowRuntimeException(env, "Failed to register input channel. "
|
|
|
|
"Check logs for details.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-11 14:46:32 -07:00
|
|
|
if (! monitor) {
|
|
|
|
android_view_InputChannel_setDisposeCallback(env, inputChannelObj,
|
|
|
|
android_server_InputManager_handleInputChannelDisposed, NULL);
|
|
|
|
}
|
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-22 18:58:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeUnregisterInputChannel(JNIEnv* env, jclass clazz,
|
|
|
|
jobject inputChannelObj) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
|
|
|
inputChannelObj);
|
|
|
|
if (inputChannel == NULL) {
|
|
|
|
throwInputChannelNotInitialized(env);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
android_view_InputChannel_setDisposeCallback(env, inputChannelObj, NULL, NULL);
|
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
status_t status = gNativeInputManager->unregisterInputChannel(env, 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-22 18:58:52 -07:00
|
|
|
if (status) {
|
|
|
|
jniThrowRuntimeException(env, "Failed to unregister input channel. "
|
|
|
|
"Check logs for details.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-28 15:48:59 -07:00
|
|
|
static jint android_server_InputManager_nativeInjectInputEvent(JNIEnv* env, jclass clazz,
|
|
|
|
jobject inputEventObj, jint injectorPid, jint injectorUid,
|
|
|
|
jint syncMode, jint timeoutMillis) {
|
2010-06-17 20:52:56 -07:00
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return INPUT_EVENT_INJECTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2010-07-28 15:48:59 -07:00
|
|
|
if (env->IsInstanceOf(inputEventObj, gKeyEventClassInfo.clazz)) {
|
|
|
|
KeyEvent keyEvent;
|
2010-11-18 20:53:46 -08:00
|
|
|
status_t status = android_view_KeyEvent_toNative(env, inputEventObj, & keyEvent);
|
|
|
|
if (status) {
|
|
|
|
jniThrowRuntimeException(env, "Could not read contents of KeyEvent object.");
|
|
|
|
return INPUT_EVENT_INJECTION_FAILED;
|
|
|
|
}
|
2010-06-17 20:52:56 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
return gNativeInputManager->getInputManager()->getDispatcher()->injectInputEvent(
|
|
|
|
& keyEvent, injectorPid, injectorUid, syncMode, timeoutMillis);
|
2010-07-28 15:48:59 -07:00
|
|
|
} else if (env->IsInstanceOf(inputEventObj, gMotionEventClassInfo.clazz)) {
|
|
|
|
MotionEvent motionEvent;
|
2010-11-18 20:53:46 -08:00
|
|
|
status_t status = android_view_MotionEvent_toNative(env, inputEventObj, & motionEvent);
|
|
|
|
if (status) {
|
|
|
|
jniThrowRuntimeException(env, "Could not read contents of MotionEvent object.");
|
|
|
|
return INPUT_EVENT_INJECTION_FAILED;
|
|
|
|
}
|
2010-06-17 20:52:56 -07:00
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
return gNativeInputManager->getInputManager()->getDispatcher()->injectInputEvent(
|
|
|
|
& motionEvent, injectorPid, injectorUid, syncMode, timeoutMillis);
|
2010-07-28 15:48:59 -07:00
|
|
|
} else {
|
|
|
|
jniThrowRuntimeException(env, "Invalid input event type.");
|
2010-06-17 20:52:56 -07:00
|
|
|
return INPUT_EVENT_INJECTION_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
static void android_server_InputManager_nativeSetInputWindows(JNIEnv* env, jclass clazz,
|
|
|
|
jobjectArray windowObjArray) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gNativeInputManager->setInputWindows(env, windowObjArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeSetFocusedApplication(JNIEnv* env, jclass clazz,
|
|
|
|
jobject applicationObj) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gNativeInputManager->setFocusedApplication(env, applicationObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void android_server_InputManager_nativeSetInputDispatchMode(JNIEnv* env,
|
|
|
|
jclass clazz, jboolean enabled, jboolean frozen) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gNativeInputManager->setInputDispatchMode(enabled, frozen);
|
|
|
|
}
|
|
|
|
|
2010-08-30 03:02:23 -07:00
|
|
|
static jobject android_server_InputManager_nativeGetInputDevice(JNIEnv* env,
|
|
|
|
jclass clazz, jint deviceId) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDeviceInfo deviceInfo;
|
2010-09-08 11:49:43 -07:00
|
|
|
status_t status = gNativeInputManager->getInputManager()->getReader()->getInputDeviceInfo(
|
2010-08-30 03:02:23 -07:00
|
|
|
deviceId, & deviceInfo);
|
|
|
|
if (status) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
jobject deviceObj = env->NewObject(gInputDeviceClassInfo.clazz, gInputDeviceClassInfo.ctor);
|
|
|
|
if (! deviceObj) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
jstring deviceNameObj = env->NewStringUTF(deviceInfo.getName().string());
|
|
|
|
if (! deviceNameObj) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
env->SetIntField(deviceObj, gInputDeviceClassInfo.mId, deviceInfo.getId());
|
|
|
|
env->SetObjectField(deviceObj, gInputDeviceClassInfo.mName, deviceNameObj);
|
|
|
|
env->SetIntField(deviceObj, gInputDeviceClassInfo.mSources, deviceInfo.getSources());
|
|
|
|
env->SetIntField(deviceObj, gInputDeviceClassInfo.mKeyboardType, deviceInfo.getKeyboardType());
|
|
|
|
|
|
|
|
const KeyedVector<int, InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
|
|
|
|
for (size_t i = 0; i < ranges.size(); i++) {
|
|
|
|
int rangeType = ranges.keyAt(i);
|
|
|
|
const InputDeviceInfo::MotionRange& range = ranges.valueAt(i);
|
|
|
|
env->CallVoidMethod(deviceObj, gInputDeviceClassInfo.addMotionRange,
|
|
|
|
rangeType, range.min, range.max, range.flat, range.fuzz);
|
|
|
|
if (env->ExceptionCheck()) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return deviceObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
static jintArray android_server_InputManager_nativeGetInputDeviceIds(JNIEnv* env,
|
|
|
|
jclass clazz) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector<int> deviceIds;
|
2010-09-08 11:49:43 -07:00
|
|
|
gNativeInputManager->getInputManager()->getReader()->getInputDeviceIds(deviceIds);
|
2010-08-30 03:02:23 -07:00
|
|
|
|
|
|
|
jintArray deviceIdsObj = env->NewIntArray(deviceIds.size());
|
|
|
|
if (! deviceIdsObj) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
env->SetIntArrayRegion(deviceIdsObj, 0, deviceIds.size(), deviceIds.array());
|
|
|
|
return deviceIdsObj;
|
|
|
|
}
|
|
|
|
|
2010-09-21 18:22:55 -07:00
|
|
|
static void android_server_InputManager_nativeGetInputConfiguration(JNIEnv* env,
|
|
|
|
jclass clazz, jobject configObj) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputConfiguration config;
|
|
|
|
gNativeInputManager->getInputManager()->getReader()->getInputConfiguration(& config);
|
|
|
|
|
|
|
|
env->SetIntField(configObj, gConfigurationClassInfo.touchscreen, config.touchScreen);
|
|
|
|
env->SetIntField(configObj, gConfigurationClassInfo.keyboard, config.keyboard);
|
|
|
|
env->SetIntField(configObj, gConfigurationClassInfo.navigation, config.navigation);
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:52:15 -07:00
|
|
|
static jboolean android_server_InputManager_nativeTransferTouchFocus(JNIEnv* env,
|
|
|
|
jclass clazz, jobject fromChannelObj, jobject toChannelObj) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
sp<InputChannel> fromChannel =
|
|
|
|
android_view_InputChannel_getInputChannel(env, fromChannelObj);
|
|
|
|
sp<InputChannel> toChannel =
|
|
|
|
android_view_InputChannel_getInputChannel(env, toChannelObj);
|
|
|
|
|
|
|
|
if (fromChannel == NULL || toChannel == NULL) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return gNativeInputManager->getInputManager()->getDispatcher()->
|
|
|
|
transferTouchFocus(fromChannel, toChannel);
|
|
|
|
}
|
|
|
|
|
2010-07-15 23:54:05 -07:00
|
|
|
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
|
|
|
|
if (checkInputManagerUnitialized(env)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-09-08 11:49:43 -07:00
|
|
|
String8 dump;
|
|
|
|
gNativeInputManager->dump(dump);
|
2010-07-15 23:54:05 -07:00
|
|
|
return env->NewStringUTF(dump.string());
|
|
|
|
}
|
|
|
|
|
2010-06-15 01:31:58 -07: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-22 18:58:52 -07:00
|
|
|
static JNINativeMethod gInputManagerMethods[] = {
|
|
|
|
/* name, signature, funcPtr */
|
|
|
|
{ "nativeInit", "(Lcom/android/server/InputManager$Callbacks;)V",
|
|
|
|
(void*) android_server_InputManager_nativeInit },
|
|
|
|
{ "nativeStart", "()V",
|
|
|
|
(void*) android_server_InputManager_nativeStart },
|
|
|
|
{ "nativeSetDisplaySize", "(III)V",
|
|
|
|
(void*) android_server_InputManager_nativeSetDisplaySize },
|
|
|
|
{ "nativeSetDisplayOrientation", "(II)V",
|
|
|
|
(void*) android_server_InputManager_nativeSetDisplayOrientation },
|
|
|
|
{ "nativeGetScanCodeState", "(III)I",
|
|
|
|
(void*) android_server_InputManager_nativeGetScanCodeState },
|
|
|
|
{ "nativeGetKeyCodeState", "(III)I",
|
|
|
|
(void*) android_server_InputManager_nativeGetKeyCodeState },
|
|
|
|
{ "nativeGetSwitchState", "(III)I",
|
|
|
|
(void*) android_server_InputManager_nativeGetSwitchState },
|
2010-07-23 21:28:06 -07:00
|
|
|
{ "nativeHasKeys", "(II[I[Z)Z",
|
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-22 18:58:52 -07:00
|
|
|
(void*) android_server_InputManager_nativeHasKeys },
|
2011-01-10 11:17:36 -08:00
|
|
|
{ "nativeRegisterInputChannel",
|
|
|
|
"(Landroid/view/InputChannel;Lcom/android/server/InputWindowHandle;Z)V",
|
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-22 18:58:52 -07:00
|
|
|
(void*) android_server_InputManager_nativeRegisterInputChannel },
|
|
|
|
{ "nativeUnregisterInputChannel", "(Landroid/view/InputChannel;)V",
|
2010-06-17 20:52:56 -07:00
|
|
|
(void*) android_server_InputManager_nativeUnregisterInputChannel },
|
2010-07-28 15:48:59 -07:00
|
|
|
{ "nativeInjectInputEvent", "(Landroid/view/InputEvent;IIII)I",
|
|
|
|
(void*) android_server_InputManager_nativeInjectInputEvent },
|
2010-06-22 01:27:15 -07:00
|
|
|
{ "nativeSetInputWindows", "([Lcom/android/server/InputWindow;)V",
|
|
|
|
(void*) android_server_InputManager_nativeSetInputWindows },
|
|
|
|
{ "nativeSetFocusedApplication", "(Lcom/android/server/InputApplication;)V",
|
|
|
|
(void*) android_server_InputManager_nativeSetFocusedApplication },
|
|
|
|
{ "nativeSetInputDispatchMode", "(ZZ)V",
|
|
|
|
(void*) android_server_InputManager_nativeSetInputDispatchMode },
|
2010-08-30 03:02:23 -07:00
|
|
|
{ "nativeGetInputDevice", "(I)Landroid/view/InputDevice;",
|
|
|
|
(void*) android_server_InputManager_nativeGetInputDevice },
|
|
|
|
{ "nativeGetInputDeviceIds", "()[I",
|
|
|
|
(void*) android_server_InputManager_nativeGetInputDeviceIds },
|
2010-09-21 18:22:55 -07:00
|
|
|
{ "nativeGetInputConfiguration", "(Landroid/content/res/Configuration;)V",
|
|
|
|
(void*) android_server_InputManager_nativeGetInputConfiguration },
|
2010-09-27 14:52:15 -07:00
|
|
|
{ "nativeTransferTouchFocus", "(Landroid/view/InputChannel;Landroid/view/InputChannel;)Z",
|
|
|
|
(void*) android_server_InputManager_nativeTransferTouchFocus },
|
2010-07-15 23:54:05 -07:00
|
|
|
{ "nativeDump", "()Ljava/lang/String;",
|
|
|
|
(void*) android_server_InputManager_nativeDump },
|
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-22 18:58:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define FIND_CLASS(var, className) \
|
|
|
|
var = env->FindClass(className); \
|
|
|
|
LOG_FATAL_IF(! var, "Unable to find class " className); \
|
|
|
|
var = jclass(env->NewGlobalRef(var));
|
|
|
|
|
|
|
|
#define GET_METHOD_ID(var, clazz, methodName, methodDescriptor) \
|
|
|
|
var = env->GetMethodID(clazz, methodName, methodDescriptor); \
|
|
|
|
LOG_FATAL_IF(! var, "Unable to find method " methodName);
|
|
|
|
|
|
|
|
#define GET_FIELD_ID(var, clazz, fieldName, fieldDescriptor) \
|
|
|
|
var = env->GetFieldID(clazz, fieldName, fieldDescriptor); \
|
|
|
|
LOG_FATAL_IF(! var, "Unable to find field " fieldName);
|
|
|
|
|
|
|
|
int register_android_server_InputManager(JNIEnv* env) {
|
|
|
|
int res = jniRegisterNativeMethods(env, "com/android/server/InputManager",
|
|
|
|
gInputManagerMethods, NELEM(gInputManagerMethods));
|
|
|
|
LOG_FATAL_IF(res < 0, "Unable to register native methods.");
|
|
|
|
|
2010-06-15 01:31:58 -07:00
|
|
|
// Callbacks
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
FIND_CLASS(gCallbacksClassInfo.clazz, "com/android/server/InputManager$Callbacks");
|
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.notifyConfigurationChanged, gCallbacksClassInfo.clazz,
|
2010-09-21 18:22:55 -07:00
|
|
|
"notifyConfigurationChanged", "(J)V");
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.notifyLidSwitchChanged, gCallbacksClassInfo.clazz,
|
|
|
|
"notifyLidSwitchChanged", "(JZ)V");
|
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.notifyInputChannelBroken, gCallbacksClassInfo.clazz,
|
2011-01-10 11:17:36 -08:00
|
|
|
"notifyInputChannelBroken", "(Lcom/android/server/InputWindowHandle;)V");
|
2010-06-17 20:52:56 -07:00
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.notifyANR, gCallbacksClassInfo.clazz,
|
2011-01-10 11:17:36 -08:00
|
|
|
"notifyANR",
|
|
|
|
"(Lcom/android/server/InputApplicationHandle;Lcom/android/server/InputWindowHandle;)J");
|
2010-06-22 01:27:15 -07:00
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeQueueing, gCallbacksClassInfo.clazz,
|
2010-11-18 20:53:46 -08:00
|
|
|
"interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;IZ)I");
|
2010-06-22 01:27:15 -07:00
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.interceptKeyBeforeDispatching, gCallbacksClassInfo.clazz,
|
2010-11-18 20:53:46 -08:00
|
|
|
"interceptKeyBeforeDispatching",
|
2011-01-10 11:17:36 -08:00
|
|
|
"(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Z");
|
2010-06-22 01:27:15 -07:00
|
|
|
|
2010-11-05 15:02:16 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.dispatchUnhandledKey, gCallbacksClassInfo.clazz,
|
2010-12-06 17:13:33 -08:00
|
|
|
"dispatchUnhandledKey",
|
2011-01-10 11:17:36 -08:00
|
|
|
"(Lcom/android/server/InputWindowHandle;Landroid/view/KeyEvent;I)Landroid/view/KeyEvent;");
|
2010-11-05 15:02:16 -07:00
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.checkInjectEventsPermission, gCallbacksClassInfo.clazz,
|
|
|
|
"checkInjectEventsPermission", "(II)Z");
|
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-22 18:58:52 -07:00
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.filterTouchEvents, gCallbacksClassInfo.clazz,
|
|
|
|
"filterTouchEvents", "()Z");
|
|
|
|
|
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.filterJumpyTouchEvents, gCallbacksClassInfo.clazz,
|
|
|
|
"filterJumpyTouchEvents", "()Z");
|
|
|
|
|
2011-01-18 15:10:10 -08:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.getVirtualKeyQuietTimeMillis, gCallbacksClassInfo.clazz,
|
|
|
|
"getVirtualKeyQuietTimeMillis", "()I");
|
|
|
|
|
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-22 18:58:52 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, gCallbacksClassInfo.clazz,
|
|
|
|
"getExcludedDeviceNames", "()[Ljava/lang/String;");
|
|
|
|
|
2010-08-18 15:51:08 -07:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, gCallbacksClassInfo.clazz,
|
|
|
|
"getMaxEventsPerSecond", "()I");
|
|
|
|
|
2010-12-23 17:50:18 -08:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.getPointerLayer, gCallbacksClassInfo.clazz,
|
|
|
|
"getPointerLayer", "()I");
|
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
GET_METHOD_ID(gCallbacksClassInfo.getPointerIcon, gCallbacksClassInfo.clazz,
|
|
|
|
"getPointerIcon", "()Lcom/android/server/InputManager$PointerIcon;");
|
|
|
|
|
2010-07-28 15:48:59 -07:00
|
|
|
// KeyEvent
|
|
|
|
|
|
|
|
FIND_CLASS(gKeyEventClassInfo.clazz, "android/view/KeyEvent");
|
|
|
|
|
2010-08-30 03:02:23 -07:00
|
|
|
// MotionEvent
|
2010-07-28 15:48:59 -07:00
|
|
|
|
|
|
|
FIND_CLASS(gMotionEventClassInfo.clazz, "android/view/MotionEvent");
|
|
|
|
|
2010-08-30 03:02:23 -07:00
|
|
|
// InputDevice
|
|
|
|
|
|
|
|
FIND_CLASS(gInputDeviceClassInfo.clazz, "android/view/InputDevice");
|
|
|
|
|
|
|
|
GET_METHOD_ID(gInputDeviceClassInfo.ctor, gInputDeviceClassInfo.clazz,
|
|
|
|
"<init>", "()V");
|
|
|
|
|
|
|
|
GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz,
|
|
|
|
"addMotionRange", "(IFFFF)V");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gInputDeviceClassInfo.mId, gInputDeviceClassInfo.clazz,
|
|
|
|
"mId", "I");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gInputDeviceClassInfo.mName, gInputDeviceClassInfo.clazz,
|
|
|
|
"mName", "Ljava/lang/String;");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gInputDeviceClassInfo.mSources, gInputDeviceClassInfo.clazz,
|
|
|
|
"mSources", "I");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gInputDeviceClassInfo.mKeyboardType, gInputDeviceClassInfo.clazz,
|
|
|
|
"mKeyboardType", "I");
|
|
|
|
|
2010-09-21 18:22:55 -07:00
|
|
|
// Configuration
|
|
|
|
|
|
|
|
FIND_CLASS(gConfigurationClassInfo.clazz, "android/content/res/Configuration");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gConfigurationClassInfo.touchscreen, gConfigurationClassInfo.clazz,
|
|
|
|
"touchscreen", "I");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gConfigurationClassInfo.keyboard, gConfigurationClassInfo.clazz,
|
|
|
|
"keyboard", "I");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gConfigurationClassInfo.navigation, gConfigurationClassInfo.clazz,
|
|
|
|
"navigation", "I");
|
|
|
|
|
2011-01-02 16:37:43 -08:00
|
|
|
// PointerIcon
|
|
|
|
|
|
|
|
FIND_CLASS(gPointerIconClassInfo.clazz, "com/android/server/InputManager$PointerIcon");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gPointerIconClassInfo.bitmap, gPointerIconClassInfo.clazz,
|
|
|
|
"bitmap", "Landroid/graphics/Bitmap;");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gPointerIconClassInfo.hotSpotX, gPointerIconClassInfo.clazz,
|
|
|
|
"hotSpotX", "F");
|
|
|
|
|
|
|
|
GET_FIELD_ID(gPointerIconClassInfo.hotSpotY, gPointerIconClassInfo.clazz,
|
|
|
|
"hotSpotY", "F");
|
|
|
|
|
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-22 18:58:52 -07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace android */
|