summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2013-04-04 23:04:03 -0700
committerJeff Brown <jeffbrown@google.com>2013-04-08 15:31:47 -0700
commitf9e989d5f09e72f5c9a59d713521f37d3fdd93dd (patch)
tree1495fe6c1ac72db7420839e7ec068e1e152571fa /tools/layoutlib
parent1951ce86c21445ac191e4d2d95233f4f5c096b56 (diff)
downloadframeworks_base-f9e989d5f09e72f5c9a59d713521f37d3fdd93dd.zip
frameworks_base-f9e989d5f09e72f5c9a59d713521f37d3fdd93dd.tar.gz
frameworks_base-f9e989d5f09e72f5c9a59d713521f37d3fdd93dd.tar.bz2
Queues, queues, queues and input.
Redesigned how ViewRootImpl delivers input events to views, the IME and to native activities to fix several issues. The prior change to make IME input event delegation use InputChannels failed to take into account that InputMethodManager is a singleton attached to the main looper whereas UI may be attached to any looper. Consequently interactions with the InputChannel might occur on the wrong thread. Fixed this problem by checking the current thread and posting input events or callbacks to the correct looper when necessary. NativeActivity has also been broken for a while because the default event handling logic for joysticks and touch navigation was unable to dispatch events back into the native activity. In particular, this meant that DPad synthesis from touch navigation would not work in any native activity. The plan is to fix this problem by passing all events through ViewRootImpl as usual then forwarding them to native activity as needed. This should greatly simplify IME pre-dispatch and system key handling and make everything more robust overall. Fixed issues related to when input events are synthesized. In particular, added a more robust mechanism to ensure that synthetic events are canceled appropriately when we discover that events are no longer being resynthesized (because the application or IME is handling or dropping them). The new design is structured as a pipeline with a chain of responsibility consisting of InputStage objects. Each InputStage is responsible for some part of handling each input event such as dispatching to the view hierarchy or to the IME. As a stage processes an input event, it has the option of finishing the event, forwarding the event to the next stage or handling the event asynchronously. Some queueing logic takes care to ensure that events are forwarded downstream in the correct order even if they are handled out of order by a given stage. Cleaned up the InputMethodManager singleton initialization logic to make it clearer that it must be attached to the main looper. We don't actually need to pass this looper around. Deleted the LatencyTimer class since no one uses it and we have better ways of measuring latency these days using systrace. Added a hidden helper to Looper to determine whether the current thread is the indicated Looper thread. Note: NativeActivity's IME dispatch is broken by this patch. This will be fixed later in another patch. Bug: 8473020 Change-Id: Iac2a1277545195a7a0137bbbdf04514c29165c60
Diffstat (limited to 'tools/layoutlib')
-rw-r--r--tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java2
-rw-r--r--tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java29
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java2
3 files changed, 10 insertions, 23 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
index 7a6e52e..dc4f9c8 100644
--- a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
+++ b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Accessor.java
@@ -22,6 +22,6 @@ package android.view.inputmethod;
public class InputMethodManager_Accessor {
public static void resetInstance() {
- InputMethodManager.mInstance = null;
+ InputMethodManager.sInstance = null;
}
}
diff --git a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java
index f056040..7c98847 100644
--- a/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/view/inputmethod/InputMethodManager_Delegate.java
@@ -35,28 +35,15 @@ public class InputMethodManager_Delegate {
// ---- Overridden methods ----
@LayoutlibDelegate
- /*package*/ static InputMethodManager getInstance(Looper mainLooper) {
- synchronized (InputMethodManager.mInstanceSync) {
- if (InputMethodManager.mInstance != null) {
- return InputMethodManager.mInstance;
+ /*package*/ static InputMethodManager getInstance() {
+ synchronized (InputMethodManager.class) {
+ InputMethodManager imm = InputMethodManager.peekInstance();
+ if (imm == null) {
+ imm = new InputMethodManager(
+ new BridgeIInputMethodManager(), Looper.getMainLooper());
+ InputMethodManager.sInstance = imm;
}
-
- InputMethodManager.mInstance = new InputMethodManager(new BridgeIInputMethodManager(),
- mainLooper);
- }
- return InputMethodManager.mInstance;
- }
-
- @LayoutlibDelegate
- /*package*/ static InputMethodManager getInstance(Context context) {
- synchronized (InputMethodManager.mInstanceSync) {
- if (InputMethodManager.mInstance != null) {
- return InputMethodManager.mInstance;
- }
-
- InputMethodManager.mInstance = new InputMethodManager(new BridgeIInputMethodManager(),
- Looper.myLooper());
+ return imm;
}
- return InputMethodManager.mInstance;
}
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index f109e39..cbefd3d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -232,7 +232,7 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
sCurrentContext = mContext;
// create an InputMethodManager
- InputMethodManager.getInstance(Looper.myLooper());
+ InputMethodManager.getInstance();
LayoutLog currentLog = mParams.getLog();
Bridge.setLog(currentLog);