diff options
author | Craig Mautner <cmautner@google.com> | 2013-06-07 10:35:44 -0700 |
---|---|---|
committer | Craig Mautner <cmautner@google.com> | 2013-06-12 10:59:16 -0700 |
commit | 037aa8d434984840691378f3cc7d99d63dcc4076 (patch) | |
tree | fa2ffc022ec2c35282e4931752156f696dda81fa /policy | |
parent | 97f41383eb2bb098767ca153e470009fea810540 (diff) | |
download | frameworks_base-037aa8d434984840691378f3cc7d99d63dcc4076.zip frameworks_base-037aa8d434984840691378f3cc7d99d63dcc4076.tar.gz frameworks_base-037aa8d434984840691378f3cc7d99d63dcc4076.tar.bz2 |
Centralize all system InputEventReceiver monitors.
Implement all system level InputEvent monitors as new
InputEventListeners. Only one InputChannel required and monitoring
can be enabled or disabled by registering with WindowManagerService.
Change-Id: I64714ab858342ed183c62b421098478ffb6637bc
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/PhoneWindowManager.java | 56 | ||||
-rw-r--r-- | policy/src/com/android/internal/policy/impl/SystemGesturesPointerEventListener.java (renamed from policy/src/com/android/internal/policy/impl/SystemGestures.java) | 21 |
2 files changed, 19 insertions, 58 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index 0da3b56..4930d59 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -296,35 +296,18 @@ public class PhoneWindowManager implements WindowManagerPolicy { WindowState mFocusedWindow; IApplicationToken mFocusedApp; - private static final class PointerLocationInputEventReceiver extends InputEventReceiver { - private final PointerLocationView mView; - - public PointerLocationInputEventReceiver(InputChannel inputChannel, Looper looper, - PointerLocationView view) { - super(inputChannel, looper); - mView = view; - } - + private final class PointerLocationPointerEventListener implements PointerEventListener { @Override - public void onInputEvent(InputEvent event) { - boolean handled = false; - try { - if (event instanceof MotionEvent - && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { - final MotionEvent motionEvent = (MotionEvent)event; - mView.addPointerEvent(motionEvent); - handled = true; - } - } finally { - finishInputEvent(event, handled); + public void onPointerEvent(MotionEvent motionEvent) { + if (mPointerLocationView != null) { + mPointerLocationView.addPointerEvent(motionEvent); } } } // Pointer location view state, only modified on the mHandler Looper. - PointerLocationInputEventReceiver mPointerLocationInputEventReceiver; + PointerLocationPointerEventListener mPointerLocationPointerEventListener; PointerLocationView mPointerLocationView; - InputChannel mPointerLocationInputChannel; // The current size of the screen; really; extends into the overscan area of // the screen and doesn't account for any system elements like the status bar. @@ -568,8 +551,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private int mStatusHideybar; private int mNavigationHideybar; - private InputChannel mSystemGestureInputChannel; - private SystemGestures mSystemGestures; + private SystemGesturesPointerEventListener mSystemGestures; IStatusBarService getStatusBarService() { synchronized (mServiceAquireLock) { @@ -925,10 +907,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { context.registerReceiver(mMultiuserReceiver, filter); // monitor for system gestures - mSystemGestureInputChannel = mWindowManagerFuncs.monitorInput("SystemGestures"); - mSystemGestures = new SystemGestures(mSystemGestureInputChannel, - mHandler.getLooper(), context, - new SystemGestures.Callbacks() { + mSystemGestures = new SystemGesturesPointerEventListener(context, + new SystemGesturesPointerEventListener.Callbacks() { @Override public void onSwipeFromTop() { if (mStatusBar != null) { @@ -954,6 +934,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } }); + mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); mLongPressVibePattern = getLongIntArray(mContext.getResources(), @@ -1212,23 +1193,16 @@ public class PhoneWindowManager implements WindowManagerPolicy { lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; wm.addView(mPointerLocationView, lp); - mPointerLocationInputChannel = - mWindowManagerFuncs.monitorInput("PointerLocationView"); - mPointerLocationInputEventReceiver = - new PointerLocationInputEventReceiver(mPointerLocationInputChannel, - Looper.myLooper(), mPointerLocationView); + mPointerLocationPointerEventListener = new PointerLocationPointerEventListener(); + mWindowManagerFuncs.registerPointerEventListener(mPointerLocationPointerEventListener); } } private void disablePointerLocation() { - if (mPointerLocationInputEventReceiver != null) { - mPointerLocationInputEventReceiver.dispose(); - mPointerLocationInputEventReceiver = null; - } - - if (mPointerLocationInputChannel != null) { - mPointerLocationInputChannel.dispose(); - mPointerLocationInputChannel = null; + if (mPointerLocationPointerEventListener != null) { + mWindowManagerFuncs.unregisterPointerEventListener( + mPointerLocationPointerEventListener); + mPointerLocationPointerEventListener = null; } if (mPointerLocationView != null) { diff --git a/policy/src/com/android/internal/policy/impl/SystemGestures.java b/policy/src/com/android/internal/policy/impl/SystemGesturesPointerEventListener.java index c9731a5..6e8c841 100644 --- a/policy/src/com/android/internal/policy/impl/SystemGestures.java +++ b/policy/src/com/android/internal/policy/impl/SystemGesturesPointerEventListener.java @@ -17,19 +17,15 @@ package com.android.internal.policy.impl; import android.content.Context; -import android.os.Looper; import android.util.Slog; -import android.view.InputChannel; -import android.view.InputDevice; -import android.view.InputEvent; -import android.view.InputEventReceiver; import android.view.MotionEvent; +import android.view.WindowManagerPolicy.PointerEventListener; /* * Listens for system-wide input gestures, firing callbacks when detected. * @hide */ -public class SystemGestures extends InputEventReceiver { +public class SystemGesturesPointerEventListener implements PointerEventListener { private static final String TAG = "SystemGestures"; private static final boolean DEBUG = false; private static final long SWIPE_TIMEOUT_MS = 500; @@ -55,9 +51,7 @@ public class SystemGestures extends InputEventReceiver { private boolean mSwipeFireable; private boolean mDebugFireable; - public SystemGestures(InputChannel inputChannel, Looper looper, - Context context, Callbacks callbacks) { - super(inputChannel, looper); + public SystemGesturesPointerEventListener(Context context, Callbacks callbacks) { mCallbacks = checkNull("callbacks", callbacks); mSwipeStartThreshold = checkNull("context", context).getResources() .getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); @@ -72,14 +66,7 @@ public class SystemGestures extends InputEventReceiver { } @Override - public void onInputEvent(InputEvent event) { - if (event instanceof MotionEvent && event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { - onPointerMotionEvent((MotionEvent) event); - } - finishInputEvent(event, false /*handled*/); - } - - private void onPointerMotionEvent(MotionEvent event) { + public void onPointerEvent(MotionEvent event) { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: mSwipeFireable = true; |