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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.android.server;
|
|
|
|
|
|
|
|
import com.android.internal.util.XmlUtils;
|
|
|
|
|
|
|
|
import org.xmlpull.v1.XmlPullParser;
|
2011-01-02 16:37:43 -08:00
|
|
|
import org.xmlpull.v1.XmlPullParserException;
|
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
|
|
|
|
|
|
|
import android.content.Context;
|
2010-06-22 01:27:15 -07:00
|
|
|
import android.content.pm.PackageManager;
|
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
|
|
|
import android.content.res.Configuration;
|
2011-01-02 16:37:43 -08:00
|
|
|
import android.content.res.Resources;
|
|
|
|
import android.content.res.TypedArray;
|
|
|
|
import android.content.res.XmlResourceParser;
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
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
|
|
|
import android.os.Environment;
|
2010-08-18 15:51:08 -07:00
|
|
|
import android.os.SystemProperties;
|
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
|
|
|
import android.util.Slog;
|
|
|
|
import android.util.Xml;
|
|
|
|
import android.view.InputChannel;
|
2010-08-30 03:02:23 -07:00
|
|
|
import android.view.InputDevice;
|
2010-07-28 15:48:59 -07:00
|
|
|
import android.view.InputEvent;
|
2010-11-18 20:53:46 -08:00
|
|
|
import android.view.KeyEvent;
|
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
|
|
|
import android.view.Surface;
|
2010-12-23 17:50:18 -08:00
|
|
|
import android.view.WindowManager;
|
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
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wraps the C++ InputManager and provides its callbacks.
|
|
|
|
*/
|
|
|
|
public class InputManager {
|
|
|
|
static final String TAG = "InputManager";
|
|
|
|
|
2010-10-08 22:31:17 -07:00
|
|
|
private static final boolean DEBUG = false;
|
|
|
|
|
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 final Callbacks mCallbacks;
|
|
|
|
private final Context mContext;
|
|
|
|
private final WindowManagerService mWindowManagerService;
|
|
|
|
|
|
|
|
private static native void nativeInit(Callbacks callbacks);
|
|
|
|
private static native void nativeStart();
|
|
|
|
private static native void nativeSetDisplaySize(int displayId, int width, int height);
|
|
|
|
private static native void nativeSetDisplayOrientation(int displayId, int rotation);
|
|
|
|
|
2010-07-23 21:28:06 -07:00
|
|
|
private static native int nativeGetScanCodeState(int deviceId, int sourceMask,
|
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
|
|
|
int scanCode);
|
2010-07-23 21:28:06 -07:00
|
|
|
private static native int nativeGetKeyCodeState(int deviceId, int sourceMask,
|
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
|
|
|
int keyCode);
|
2010-07-23 21:28:06 -07:00
|
|
|
private static native int nativeGetSwitchState(int deviceId, int sourceMask,
|
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
|
|
|
int sw);
|
2010-07-23 21:28:06 -07:00
|
|
|
private static native boolean nativeHasKeys(int deviceId, int sourceMask,
|
|
|
|
int[] keyCodes, boolean[] keyExists);
|
2010-08-11 14:46:32 -07:00
|
|
|
private static native void nativeRegisterInputChannel(InputChannel inputChannel,
|
2011-01-10 11:17:36 -08:00
|
|
|
InputWindowHandle inputWindowHandle, boolean 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
|
|
|
private static native void nativeUnregisterInputChannel(InputChannel inputChannel);
|
2010-07-28 15:48:59 -07:00
|
|
|
private static native int nativeInjectInputEvent(InputEvent event,
|
|
|
|
int injectorPid, int injectorUid, int syncMode, int timeoutMillis);
|
2010-06-22 01:27:15 -07:00
|
|
|
private static native void nativeSetInputWindows(InputWindow[] windows);
|
|
|
|
private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
|
|
|
|
private static native void nativeSetFocusedApplication(InputApplication application);
|
2010-08-30 03:02:23 -07:00
|
|
|
private static native InputDevice nativeGetInputDevice(int deviceId);
|
2010-09-21 18:22:55 -07:00
|
|
|
private static native void nativeGetInputConfiguration(Configuration configuration);
|
2010-08-30 03:02:23 -07:00
|
|
|
private static native int[] nativeGetInputDeviceIds();
|
2010-09-27 14:52:15 -07:00
|
|
|
private static native boolean nativeTransferTouchFocus(InputChannel fromChannel,
|
|
|
|
InputChannel toChannel);
|
2010-07-15 23:54:05 -07:00
|
|
|
private static native String 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
|
|
|
|
2010-06-17 20:52:56 -07:00
|
|
|
// Input event injection constants defined in InputDispatcher.h.
|
|
|
|
static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0;
|
|
|
|
static final int INPUT_EVENT_INJECTION_PERMISSION_DENIED = 1;
|
|
|
|
static final int INPUT_EVENT_INJECTION_FAILED = 2;
|
|
|
|
static final int INPUT_EVENT_INJECTION_TIMED_OUT = 3;
|
|
|
|
|
2010-07-28 15:48:59 -07:00
|
|
|
// Input event injection synchronization modes defined in InputDispatcher.h
|
|
|
|
static final int INPUT_EVENT_INJECTION_SYNC_NONE = 0;
|
|
|
|
static final int INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT = 1;
|
|
|
|
static final int INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH = 2;
|
|
|
|
|
2010-07-23 21:28:06 -07:00
|
|
|
// Key states (may be returned by queries about the current state of a
|
|
|
|
// particular key code, scan code or switch).
|
|
|
|
|
|
|
|
/** The key state is unknown or the requested key itself is not supported. */
|
|
|
|
public static final int KEY_STATE_UNKNOWN = -1;
|
|
|
|
|
|
|
|
/** The key is up. /*/
|
|
|
|
public static final int KEY_STATE_UP = 0;
|
|
|
|
|
|
|
|
/** The key is down. */
|
|
|
|
public static final int KEY_STATE_DOWN = 1;
|
|
|
|
|
|
|
|
/** The key is down but is a virtual key press that is being emulated by the system. */
|
|
|
|
public static final int KEY_STATE_VIRTUAL = 2;
|
|
|
|
|
2010-07-15 23:54:05 -07:00
|
|
|
public InputManager(Context context, WindowManagerService windowManagerService) {
|
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
|
|
|
this.mContext = context;
|
|
|
|
this.mWindowManagerService = windowManagerService;
|
|
|
|
|
|
|
|
this.mCallbacks = new Callbacks();
|
|
|
|
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void init() {
|
|
|
|
Slog.i(TAG, "Initializing input manager");
|
|
|
|
nativeInit(mCallbacks);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void start() {
|
|
|
|
Slog.i(TAG, "Starting input manager");
|
|
|
|
nativeStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDisplaySize(int displayId, int width, int height) {
|
|
|
|
if (width <= 0 || height <= 0) {
|
|
|
|
throw new IllegalArgumentException("Invalid display id or dimensions.");
|
|
|
|
}
|
|
|
|
|
2010-10-08 22:31:17 -07:00
|
|
|
if (DEBUG) {
|
|
|
|
Slog.d(TAG, "Setting display #" + displayId + " size to " + width + "x" + 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
|
|
|
nativeSetDisplaySize(displayId, width, height);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDisplayOrientation(int displayId, int rotation) {
|
|
|
|
if (rotation < Surface.ROTATION_0 || rotation > Surface.ROTATION_270) {
|
|
|
|
throw new IllegalArgumentException("Invalid rotation.");
|
|
|
|
}
|
|
|
|
|
2010-10-08 22:31:17 -07:00
|
|
|
if (DEBUG) {
|
|
|
|
Slog.d(TAG, "Setting display #" + displayId + " orientation to " + rotation);
|
|
|
|
}
|
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
|
|
|
nativeSetDisplayOrientation(displayId, rotation);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getInputConfiguration(Configuration config) {
|
|
|
|
if (config == null) {
|
|
|
|
throw new IllegalArgumentException("config must not be null.");
|
|
|
|
}
|
|
|
|
|
2010-09-21 18:22:55 -07:00
|
|
|
nativeGetInputConfiguration(config);
|
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-23 21:28:06 -07:00
|
|
|
/**
|
|
|
|
* Gets the current state of a key or button by key code.
|
|
|
|
* @param deviceId The input device id, or -1 to consult all devices.
|
|
|
|
* @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
|
|
|
|
* consider all input sources. An input device is consulted if at least one of its
|
|
|
|
* non-class input source bits matches the specified source mask.
|
|
|
|
* @param keyCode The key code to check.
|
|
|
|
* @return The key state.
|
|
|
|
*/
|
|
|
|
public int getKeyCodeState(int deviceId, int sourceMask, int keyCode) {
|
|
|
|
return nativeGetKeyCodeState(deviceId, 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
|
|
|
}
|
|
|
|
|
2010-07-23 21:28:06 -07:00
|
|
|
/**
|
|
|
|
* Gets the current state of a key or button by scan code.
|
|
|
|
* @param deviceId The input device id, or -1 to consult all devices.
|
|
|
|
* @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
|
|
|
|
* consider all input sources. An input device is consulted if at least one of its
|
|
|
|
* non-class input source bits matches the specified source mask.
|
|
|
|
* @param scanCode The scan code to check.
|
|
|
|
* @return The key state.
|
|
|
|
*/
|
|
|
|
public int getScanCodeState(int deviceId, int sourceMask, int scanCode) {
|
|
|
|
return nativeGetScanCodeState(deviceId, 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
|
|
|
}
|
|
|
|
|
2010-07-23 21:28:06 -07:00
|
|
|
/**
|
|
|
|
* Gets the current state of a switch by switch code.
|
|
|
|
* @param deviceId The input device id, or -1 to consult all devices.
|
|
|
|
* @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
|
|
|
|
* consider all input sources. An input device is consulted if at least one of its
|
|
|
|
* non-class input source bits matches the specified source mask.
|
|
|
|
* @param switchCode The switch code to check.
|
|
|
|
* @return The switch state.
|
|
|
|
*/
|
|
|
|
public int getSwitchState(int deviceId, int sourceMask, int switchCode) {
|
|
|
|
return nativeGetSwitchState(deviceId, sourceMask, switchCode);
|
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-23 21:28:06 -07:00
|
|
|
/**
|
|
|
|
* Determines whether the specified key codes are supported by a particular device.
|
|
|
|
* @param deviceId The input device id, or -1 to consult all devices.
|
|
|
|
* @param sourceMask The input sources to consult, or {@link InputDevice#SOURCE_ANY} to
|
|
|
|
* consider all input sources. An input device is consulted if at least one of its
|
|
|
|
* non-class input source bits matches the specified source mask.
|
|
|
|
* @param keyCodes The array of key codes to check.
|
|
|
|
* @param keyExists An array at least as large as keyCodes whose entries will be set
|
|
|
|
* to true or false based on the presence or absence of support for the corresponding
|
|
|
|
* key codes.
|
|
|
|
* @return True if the lookup was successful, false otherwise.
|
|
|
|
*/
|
|
|
|
public boolean hasKeys(int deviceId, int sourceMask, int[] keyCodes, boolean[] keyExists) {
|
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 (keyCodes == null) {
|
|
|
|
throw new IllegalArgumentException("keyCodes must not be null.");
|
|
|
|
}
|
2010-07-23 21:28:06 -07:00
|
|
|
if (keyExists == null || keyExists.length < keyCodes.length) {
|
|
|
|
throw new IllegalArgumentException("keyExists must not be null and must be at "
|
|
|
|
+ "least as large as keyCodes.");
|
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-23 21:28:06 -07:00
|
|
|
return nativeHasKeys(deviceId, sourceMask, keyCodes, keyExists);
|
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-11 14:46:32 -07:00
|
|
|
/**
|
|
|
|
* Creates an input channel that will receive all input from the input dispatcher.
|
|
|
|
* @param inputChannelName The input channel name.
|
|
|
|
* @return The input channel.
|
|
|
|
*/
|
|
|
|
public InputChannel monitorInput(String inputChannelName) {
|
|
|
|
if (inputChannelName == null) {
|
|
|
|
throw new IllegalArgumentException("inputChannelName must not be null.");
|
|
|
|
}
|
|
|
|
|
|
|
|
InputChannel[] inputChannels = InputChannel.openInputChannelPair(inputChannelName);
|
2011-01-10 11:17:36 -08:00
|
|
|
nativeRegisterInputChannel(inputChannels[0], null, true);
|
2010-08-11 14:46:32 -07:00
|
|
|
inputChannels[0].dispose(); // don't need to retain the Java object reference
|
|
|
|
return inputChannels[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers an input channel so that it can be used as an input event target.
|
|
|
|
* @param inputChannel The input channel to register.
|
2011-01-10 11:17:36 -08:00
|
|
|
* @param inputWindowHandle The handle of the input window associated with the
|
|
|
|
* input channel, or null if none.
|
2010-08-11 14:46:32 -07:00
|
|
|
*/
|
2011-01-10 11:17:36 -08:00
|
|
|
public void registerInputChannel(InputChannel inputChannel,
|
|
|
|
InputWindowHandle inputWindowHandle) {
|
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 (inputChannel == null) {
|
|
|
|
throw new IllegalArgumentException("inputChannel must not be null.");
|
|
|
|
}
|
|
|
|
|
2011-01-10 11:17:36 -08:00
|
|
|
nativeRegisterInputChannel(inputChannel, inputWindowHandle, false);
|
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-11 14:46:32 -07:00
|
|
|
/**
|
|
|
|
* Unregisters an input channel.
|
|
|
|
* @param inputChannel The input channel to unregister.
|
|
|
|
*/
|
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 void unregisterInputChannel(InputChannel inputChannel) {
|
|
|
|
if (inputChannel == null) {
|
|
|
|
throw new IllegalArgumentException("inputChannel must not be null.");
|
|
|
|
}
|
|
|
|
|
|
|
|
nativeUnregisterInputChannel(inputChannel);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-07-28 15:48:59 -07:00
|
|
|
* Injects an input event into the event system on behalf of an application.
|
|
|
|
* The synchronization mode determines whether the method blocks while waiting for
|
|
|
|
* input injection to proceed.
|
|
|
|
*
|
|
|
|
* {@link #INPUT_EVENT_INJECTION_SYNC_NONE} never blocks. Injection is asynchronous and
|
|
|
|
* is assumed always to be successful.
|
|
|
|
*
|
|
|
|
* {@link #INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_RESULT} waits for previous events to be
|
|
|
|
* dispatched so that the input dispatcher can determine whether input event injection will
|
|
|
|
* be permitted based on the current input focus. Does not wait for the input event to
|
|
|
|
* finish processing.
|
|
|
|
*
|
|
|
|
* {@link #INPUT_EVENT_INJECTION_SYNC_WAIT_FOR_FINISH} waits for the input event to
|
|
|
|
* be completely processed.
|
|
|
|
*
|
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
|
|
|
* @param event The event to inject.
|
2010-06-17 20:52:56 -07:00
|
|
|
* @param injectorPid The pid of the injecting application.
|
|
|
|
* @param injectorUid The uid of the injecting application.
|
2010-07-28 15:48:59 -07:00
|
|
|
* @param syncMode The synchronization mode.
|
2010-06-17 20:52:56 -07:00
|
|
|
* @param timeoutMillis The injection timeout in milliseconds.
|
|
|
|
* @return One of the INPUT_EVENT_INJECTION_XXX constants.
|
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-28 15:48:59 -07:00
|
|
|
public int injectInputEvent(InputEvent event, int injectorPid, int injectorUid,
|
|
|
|
int syncMode, int timeoutMillis) {
|
2010-06-17 20:52:56 -07:00
|
|
|
if (event == null) {
|
|
|
|
throw new IllegalArgumentException("event must not be null");
|
|
|
|
}
|
|
|
|
if (injectorPid < 0 || injectorUid < 0) {
|
|
|
|
throw new IllegalArgumentException("injectorPid and injectorUid must not be negative.");
|
|
|
|
}
|
|
|
|
if (timeoutMillis <= 0) {
|
|
|
|
throw new IllegalArgumentException("timeoutMillis must be positive");
|
|
|
|
}
|
2010-07-28 15:48:59 -07:00
|
|
|
|
|
|
|
return nativeInjectInputEvent(event, injectorPid, injectorUid, syncMode, timeoutMillis);
|
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-30 03:02:23 -07:00
|
|
|
/**
|
|
|
|
* Gets information about the input device with the specified id.
|
|
|
|
* @param id The device id.
|
|
|
|
* @return The input device or null if not found.
|
|
|
|
*/
|
|
|
|
public InputDevice getInputDevice(int deviceId) {
|
|
|
|
return nativeGetInputDevice(deviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the ids of all input devices in the system.
|
|
|
|
* @return The input device ids.
|
|
|
|
*/
|
|
|
|
public int[] getInputDeviceIds() {
|
|
|
|
return nativeGetInputDeviceIds();
|
|
|
|
}
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
public void setInputWindows(InputWindow[] windows) {
|
|
|
|
nativeSetInputWindows(windows);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFocusedApplication(InputApplication application) {
|
|
|
|
nativeSetFocusedApplication(application);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInputDispatchMode(boolean enabled, boolean frozen) {
|
|
|
|
nativeSetInputDispatchMode(enabled, frozen);
|
|
|
|
}
|
|
|
|
|
2010-09-27 14:52:15 -07:00
|
|
|
/**
|
|
|
|
* Atomically transfers touch focus from one window to another as identified by
|
|
|
|
* their input channels. It is possible for multiple windows to have
|
|
|
|
* touch focus if they support split touch dispatch
|
|
|
|
* {@link android.view.WindowManager.LayoutParams#FLAG_SPLIT_TOUCH} but this
|
|
|
|
* method only transfers touch focus of the specified window without affecting
|
|
|
|
* other windows that may also have touch focus at the same time.
|
|
|
|
* @param fromChannel The channel of a window that currently has touch focus.
|
|
|
|
* @param toChannel The channel of the window that should receive touch focus in
|
|
|
|
* place of the first.
|
|
|
|
* @return True if the transfer was successful. False if the window with the
|
|
|
|
* specified channel did not actually have touch focus at the time of the request.
|
|
|
|
*/
|
|
|
|
public boolean transferTouchFocus(InputChannel fromChannel, InputChannel toChannel) {
|
|
|
|
if (fromChannel == null) {
|
|
|
|
throw new IllegalArgumentException("fromChannel must not be null.");
|
|
|
|
}
|
|
|
|
if (toChannel == null) {
|
|
|
|
throw new IllegalArgumentException("toChannel must not be null.");
|
|
|
|
}
|
|
|
|
return nativeTransferTouchFocus(fromChannel, toChannel);
|
|
|
|
}
|
|
|
|
|
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 void dump(PrintWriter pw) {
|
2010-07-15 23:54:05 -07:00
|
|
|
String dumpStr = nativeDump();
|
|
|
|
if (dumpStr != null) {
|
|
|
|
pw.println(dumpStr);
|
|
|
|
}
|
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
|
|
|
}
|
2011-01-02 16:37:43 -08:00
|
|
|
|
|
|
|
private static final class PointerIcon {
|
|
|
|
public Bitmap bitmap;
|
|
|
|
public float hotSpotX;
|
|
|
|
public float hotSpotY;
|
|
|
|
|
|
|
|
public static PointerIcon load(Resources resources, int resourceId) {
|
|
|
|
PointerIcon icon = new PointerIcon();
|
|
|
|
|
|
|
|
XmlResourceParser parser = resources.getXml(resourceId);
|
|
|
|
final int bitmapRes;
|
|
|
|
try {
|
|
|
|
XmlUtils.beginDocument(parser, "pointer-icon");
|
|
|
|
|
|
|
|
TypedArray a = resources.obtainAttributes(
|
|
|
|
parser, com.android.internal.R.styleable.PointerIcon);
|
|
|
|
bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
|
|
|
|
icon.hotSpotX = a.getFloat(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0);
|
|
|
|
icon.hotSpotY = a.getFloat(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0);
|
|
|
|
a.recycle();
|
|
|
|
} catch (Exception ex) {
|
|
|
|
Slog.e(TAG, "Exception parsing pointer icon resource.", ex);
|
|
|
|
return null;
|
|
|
|
} finally {
|
|
|
|
parser.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bitmapRes == 0) {
|
|
|
|
Slog.e(TAG, "<pointer-icon> is missing bitmap attribute");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawable drawable = resources.getDrawable(bitmapRes);
|
|
|
|
if (!(drawable instanceof BitmapDrawable)) {
|
|
|
|
Slog.e(TAG, "<pointer-icon> bitmap attribute must refer to a bitmap drawable");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
icon.bitmap = ((BitmapDrawable)drawable).getBitmap();
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Callbacks from native.
|
|
|
|
*/
|
|
|
|
private class Callbacks {
|
|
|
|
static final String TAG = "InputManager-Callbacks";
|
|
|
|
|
|
|
|
private static final boolean DEBUG_VIRTUAL_KEYS = false;
|
|
|
|
private static final String EXCLUDED_DEVICES_PATH = "etc/excluded-input-devices.xml";
|
2010-08-30 03:02:23 -07:00
|
|
|
private static final String CALIBRATION_DIR_PATH = "usr/idc/";
|
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
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2010-09-21 18:22:55 -07:00
|
|
|
public void notifyConfigurationChanged(long whenNanos) {
|
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
|
|
|
mWindowManagerService.sendNewConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) {
|
2010-07-02 15:37:36 -07:00
|
|
|
mWindowManagerService.mInputMonitor.notifyLidSwitchChanged(whenNanos, lidOpen);
|
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
|
|
|
@SuppressWarnings("unused")
|
2011-01-10 11:17:36 -08:00
|
|
|
public void notifyInputChannelBroken(InputWindowHandle inputWindowHandle) {
|
|
|
|
mWindowManagerService.mInputMonitor.notifyInputChannelBroken(inputWindowHandle);
|
2010-06-17 20:52:56 -07:00
|
|
|
}
|
2010-06-22 01:27:15 -07:00
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2011-01-10 11:17:36 -08:00
|
|
|
public long notifyANR(InputApplicationHandle inputApplicationHandle,
|
|
|
|
InputWindowHandle inputWindowHandle) {
|
|
|
|
return mWindowManagerService.mInputMonitor.notifyANR(
|
|
|
|
inputApplicationHandle, inputWindowHandle);
|
2010-06-17 20:52:56 -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
|
|
|
@SuppressWarnings("unused")
|
2010-11-18 20:53:46 -08:00
|
|
|
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) {
|
2010-07-02 15:37:36 -07:00
|
|
|
return mWindowManagerService.mInputMonitor.interceptKeyBeforeQueueing(
|
2010-11-18 20:53:46 -08:00
|
|
|
event, policyFlags, isScreenOn);
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
2011-01-10 11:17:36 -08:00
|
|
|
public boolean interceptKeyBeforeDispatching(InputWindowHandle focus,
|
2010-11-18 20:53:46 -08:00
|
|
|
KeyEvent event, int policyFlags) {
|
|
|
|
return mWindowManagerService.mInputMonitor.interceptKeyBeforeDispatching(
|
|
|
|
focus, event, policyFlags);
|
2010-06-22 01:27:15 -07:00
|
|
|
}
|
|
|
|
|
2010-11-05 15:02:16 -07:00
|
|
|
@SuppressWarnings("unused")
|
2011-01-10 11:17:36 -08:00
|
|
|
public KeyEvent dispatchUnhandledKey(InputWindowHandle focus,
|
2010-11-18 20:53:46 -08:00
|
|
|
KeyEvent event, int policyFlags) {
|
|
|
|
return mWindowManagerService.mInputMonitor.dispatchUnhandledKey(
|
|
|
|
focus, event, policyFlags);
|
2010-11-05 15:02:16 -07:00
|
|
|
}
|
|
|
|
|
2010-06-22 01:27:15 -07:00
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public boolean checkInjectEventsPermission(int injectorPid, int injectorUid) {
|
|
|
|
return mContext.checkPermission(
|
|
|
|
android.Manifest.permission.INJECT_EVENTS, injectorPid, injectorUid)
|
|
|
|
== PackageManager.PERMISSION_GRANTED;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public boolean filterTouchEvents() {
|
|
|
|
return mContext.getResources().getBoolean(
|
|
|
|
com.android.internal.R.bool.config_filterTouchEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public boolean filterJumpyTouchEvents() {
|
|
|
|
return mContext.getResources().getBoolean(
|
|
|
|
com.android.internal.R.bool.config_filterJumpyTouchEvents);
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public String[] getExcludedDeviceNames() {
|
|
|
|
ArrayList<String> names = new ArrayList<String>();
|
|
|
|
|
|
|
|
// Read partner-provided list of excluded input devices
|
|
|
|
XmlPullParser parser = null;
|
|
|
|
// Environment.getRootDirectory() is a fancy way of saying ANDROID_ROOT or "/system".
|
|
|
|
File confFile = new File(Environment.getRootDirectory(), EXCLUDED_DEVICES_PATH);
|
|
|
|
FileReader confreader = null;
|
|
|
|
try {
|
|
|
|
confreader = new FileReader(confFile);
|
|
|
|
parser = Xml.newPullParser();
|
|
|
|
parser.setInput(confreader);
|
|
|
|
XmlUtils.beginDocument(parser, "devices");
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
XmlUtils.nextElement(parser);
|
|
|
|
if (!"device".equals(parser.getName())) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
String name = parser.getAttributeValue(null, "name");
|
|
|
|
if (name != null) {
|
|
|
|
names.add(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
// It's ok if the file does not exist.
|
|
|
|
} catch (Exception e) {
|
|
|
|
Slog.e(TAG, "Exception while parsing '" + confFile.getAbsolutePath() + "'", e);
|
|
|
|
} finally {
|
|
|
|
try { if (confreader != null) confreader.close(); } catch (IOException e) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
return names.toArray(new String[names.size()]);
|
|
|
|
}
|
2010-08-18 15:51:08 -07:00
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public int getMaxEventsPerSecond() {
|
|
|
|
int result = 0;
|
|
|
|
try {
|
|
|
|
result = Integer.parseInt(SystemProperties.get("windowsmgr.max_events_per_sec"));
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
}
|
|
|
|
if (result < 1) {
|
2010-08-18 17:48:53 -07:00
|
|
|
result = 60;
|
2010-08-18 15:51:08 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2010-12-23 17:50:18 -08:00
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public int getPointerLayer() {
|
|
|
|
return mWindowManagerService.mPolicy.windowTypeToLayerLw(
|
2011-01-02 16:37:43 -08:00
|
|
|
WindowManager.LayoutParams.TYPE_POINTER)
|
2010-12-23 17:50:18 -08:00
|
|
|
* WindowManagerService.TYPE_LAYER_MULTIPLIER
|
|
|
|
+ WindowManagerService.TYPE_LAYER_OFFSET;
|
|
|
|
}
|
2011-01-02 16:37:43 -08:00
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
public PointerIcon getPointerIcon() {
|
|
|
|
return PointerIcon.load(mContext.getResources(),
|
|
|
|
com.android.internal.R.drawable.pointericon_default);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|