diff options
author | Michael Wright <michaelwr@google.com> | 2016-05-16 15:21:03 +0100 |
---|---|---|
committer | Michael Wright <michaelwr@google.com> | 2016-05-17 18:02:37 +0100 |
commit | 778e3b91acad6da04341d439f0c66a4fd09def4f (patch) | |
tree | 2c01c845476a9362e81725f3bd657ea50f8a1162 | |
parent | f9d9ce7705475874c82af04eb9b208a7fb556792 (diff) |
DO NOT MERGE Remove Pointer Capture API
The underlying implementation needs to be completely rethought. If a
process crashed while you were in pointer capture mode, you were
pretty much stuck in it. If the mouse happened to move outside of
your bounds right before you called the API, you'd never actually get
an event (whatever it was hovering over would). There's no easy way
for the system to tell you when you enter or exit this mode because
it doesn't actually track who the current request is from.
These are all solvable, but not in the N time frame. Maybe next time.
Bug: 26830970
Change-Id: I03efd63c499b86dc278491ca3284566c1965581f
-rw-r--r-- | api/current.txt | 3 | ||||
-rw-r--r-- | api/system-current.txt | 3 | ||||
-rw-r--r-- | api/test-current.txt | 3 | ||||
-rw-r--r-- | core/java/android/hardware/input/IInputManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/hardware/input/InputManager.java | 18 | ||||
-rw-r--r-- | core/java/android/view/View.java | 52 | ||||
-rw-r--r-- | core/java/android/view/ViewRootImpl.java | 32 | ||||
-rw-r--r-- | libs/input/PointerController.cpp | 29 | ||||
-rw-r--r-- | libs/input/PointerController.h | 6 | ||||
-rw-r--r-- | services/core/java/com/android/server/input/InputManagerService.java | 6 | ||||
-rw-r--r-- | services/core/jni/com_android_server_input_InputManagerService.cpp | 17 |
11 files changed, 0 insertions, 171 deletions
diff --git a/api/current.txt b/api/current.txt index cf5119c9b5ac..6e776969cdbf 100644 --- a/api/current.txt +++ b/api/current.txt @@ -42390,7 +42390,6 @@ package android.view { method public boolean hasNestedScrollingParent(); method public boolean hasOnClickListeners(); method public boolean hasOverlappingRendering(); - method public boolean hasPointerCapture(); method public boolean hasTransientState(); method public boolean hasWindowFocus(); method public static android.view.View inflate(android.content.Context, int, android.view.ViewGroup); @@ -42520,7 +42519,6 @@ package android.view { method public void postOnAnimation(java.lang.Runnable); method public void postOnAnimationDelayed(java.lang.Runnable, long); method public void refreshDrawableState(); - method public void releasePointerCapture(); method public boolean removeCallbacks(java.lang.Runnable); method public void removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener); method public void removeOnLayoutChangeListener(android.view.View.OnLayoutChangeListener); @@ -42531,7 +42529,6 @@ package android.view { method public boolean requestFocus(int, android.graphics.Rect); method public final boolean requestFocusFromTouch(); method public void requestLayout(); - method public void requestPointerCapture(); method public boolean requestRectangleOnScreen(android.graphics.Rect); method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean); method public final void requestUnbufferedDispatch(android.view.MotionEvent); diff --git a/api/system-current.txt b/api/system-current.txt index 57c1ef65ca25..71d37d1ed5d0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -45384,7 +45384,6 @@ package android.view { method public boolean hasNestedScrollingParent(); method public boolean hasOnClickListeners(); method public boolean hasOverlappingRendering(); - method public boolean hasPointerCapture(); method public boolean hasTransientState(); method public boolean hasWindowFocus(); method public static android.view.View inflate(android.content.Context, int, android.view.ViewGroup); @@ -45514,7 +45513,6 @@ package android.view { method public void postOnAnimation(java.lang.Runnable); method public void postOnAnimationDelayed(java.lang.Runnable, long); method public void refreshDrawableState(); - method public void releasePointerCapture(); method public boolean removeCallbacks(java.lang.Runnable); method public void removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener); method public void removeOnLayoutChangeListener(android.view.View.OnLayoutChangeListener); @@ -45525,7 +45523,6 @@ package android.view { method public boolean requestFocus(int, android.graphics.Rect); method public final boolean requestFocusFromTouch(); method public void requestLayout(); - method public void requestPointerCapture(); method public boolean requestRectangleOnScreen(android.graphics.Rect); method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean); method public final void requestUnbufferedDispatch(android.view.MotionEvent); diff --git a/api/test-current.txt b/api/test-current.txt index e7212ecff4df..d74b3786acb7 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -42468,7 +42468,6 @@ package android.view { method public boolean hasNestedScrollingParent(); method public boolean hasOnClickListeners(); method public boolean hasOverlappingRendering(); - method public boolean hasPointerCapture(); method public boolean hasTransientState(); method public boolean hasWindowFocus(); method public static android.view.View inflate(android.content.Context, int, android.view.ViewGroup); @@ -42598,7 +42597,6 @@ package android.view { method public void postOnAnimation(java.lang.Runnable); method public void postOnAnimationDelayed(java.lang.Runnable, long); method public void refreshDrawableState(); - method public void releasePointerCapture(); method public boolean removeCallbacks(java.lang.Runnable); method public void removeOnAttachStateChangeListener(android.view.View.OnAttachStateChangeListener); method public void removeOnLayoutChangeListener(android.view.View.OnLayoutChangeListener); @@ -42609,7 +42607,6 @@ package android.view { method public boolean requestFocus(int, android.graphics.Rect); method public final boolean requestFocusFromTouch(); method public void requestLayout(); - method public void requestPointerCapture(); method public boolean requestRectangleOnScreen(android.graphics.Rect); method public boolean requestRectangleOnScreen(android.graphics.Rect, boolean); method public final void requestUnbufferedDispatch(android.view.MotionEvent); diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl index 49c106e69d9f..a9c09c4bb58a 100644 --- a/core/java/android/hardware/input/IInputManager.aidl +++ b/core/java/android/hardware/input/IInputManager.aidl @@ -81,6 +81,4 @@ interface IInputManager { void setPointerIconType(int typeId); void setCustomPointerIcon(in PointerIcon icon); - - void setPointerIconDetached(boolean detached); } diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index a5aeae331f84..803337b016f9 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -893,24 +893,6 @@ public final class InputManager { } } - /** - * Update the pointer icon status. When detached, the pointer icon disappears, and further - * mouse location will be stuck at the current point. Mouse movement events will still arrive, - * and movement should be handled through {@link MotionEvent.AXIS_RELATIVE_X} and - * {@link MotionEvent.AXIS_RELATIVE_Y}. - * - * @param detached true if the icon will be detached from the actual mouse movement. - * - * @hide - */ - public void setPointerIconDetached(boolean detached) { - try { - mIm.setPointerIconDetached(detached); - } catch (RemoteException ex) { - throw ex.rethrowFromSystemServer(); - } - } - private void populateInputDevicesLocked() { if (mInputDevicesChangedListener == null) { final InputDevicesChangedListener listener = new InputDevicesChangedListener(); diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2269282a5771..251ce25b8137 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -15250,7 +15250,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, destroyDrawingCache(); cleanupDraw(); - releasePointerCapture(); mCurrentAnimation = null; } @@ -21824,57 +21823,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, return mPointerIcon; } - - /** - * Request capturing further mouse events. - * - * When the view captures, the pointer icon will disappear and will not change its - * position. Further pointer events will come to the capturing view, and the pointer movements - * will can be detected through {@link MotionEvent#AXIS_RELATIVE_X} and - * {@link MotionEvent#AXIS_RELATIVE_Y}. Non-mouse events (touchscreens, or stylus) will not - * be affected. - * - * The capture will be released through {@link #releasePointerCapture()}, or will be lost - * automatically when the view or containing window disappear. - * - * @return true when succeeds. - * @see #releasePointerCapture() - * @see #hasPointerCapture() - */ - public void requestPointerCapture() { - final ViewRootImpl viewRootImpl = getViewRootImpl(); - if (viewRootImpl != null) { - viewRootImpl.requestPointerCapture(this); - } - } - - - /** - * Release the current capture of mouse events. - * - * If the view does not have the capture, it will do nothing. - * @see #requestPointerCapture() - * @see #hasPointerCapture() - */ - public void releasePointerCapture() { - final ViewRootImpl viewRootImpl = getViewRootImpl(); - if (viewRootImpl != null) { - viewRootImpl.releasePointerCapture(this); - } - } - - /** - * Checks the capture status of mouse events. - * - * @return true if the view has the capture. - * @see #requestPointerCapture() - * @see #hasPointerCapture() - */ - public boolean hasPointerCapture() { - final ViewRootImpl viewRootImpl = getViewRootImpl(); - return (viewRootImpl != null) && viewRootImpl.hasPointerCapture(this); - } - // // Properties // diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 1c6600d0b3ac..d812cb42c671 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3168,32 +3168,6 @@ public final class ViewRootImpl implements ViewParent, } } - void requestPointerCapture(View view) { - if (!mAttachInfo.mHasWindowFocus) { - Log.w(mTag, "Can't set capture if it's not focused."); - return; - } - if (mCapturingView == view) { - return; - } - mCapturingView = view; - InputManager.getInstance().setPointerIconDetached(true); - return; - } - - void releasePointerCapture(View view) { - if (mCapturingView != view || mCapturingView == null) { - return; - } - - mCapturingView = null; - InputManager.getInstance().setPointerIconDetached(false); - } - - boolean hasPointerCapture(View view) { - return view != null && mCapturingView == view; - } - @Override public void requestChildFocus(View child, View focused) { if (DEBUG_INPUT_RESIZE) { @@ -3271,10 +3245,6 @@ public final class ViewRootImpl implements ViewParent, mView = null; mAttachInfo.mRootView = null; - if (mCapturingView != null) { - releasePointerCapture(mCapturingView); - } - mSurface.release(); if (mInputQueueCallback != null && mInputQueue != null) { @@ -3615,8 +3585,6 @@ public final class ViewRootImpl implements ViewParent, .softInputMode &= ~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION; mHasHadWindowFocus = true; - } else if (mCapturingView != null) { - releasePointerCapture(mCapturingView); } } } break; diff --git a/libs/input/PointerController.cpp b/libs/input/PointerController.cpp index 61f78cc069c5..27193b743379 100644 --- a/libs/input/PointerController.cpp +++ b/libs/input/PointerController.cpp @@ -90,7 +90,6 @@ PointerController::PointerController(const sp<PointerControllerPolicyInterface>& mLocked.lastFrameUpdatedTime = 0; mLocked.buttonState = 0; - mLocked.iconDetached = false; mPolicy->loadPointerIcon(&mLocked.pointerIcon); @@ -185,10 +184,6 @@ void PointerController::setPosition(float x, float y) { } void PointerController::setPositionLocked(float x, float y) { - if (mLocked.iconDetached) { - return; - } - float minX, minY, maxX, maxY; if (getBoundsLocked(&minX, &minY, &maxX, &maxY)) { if (x <= minX) { @@ -222,10 +217,6 @@ void PointerController::fade(Transition transition) { // Remove the inactivity timeout, since we are fading now. removeInactivityTimeoutLocked(); - if (mLocked.iconDetached) { - return; - } - // Start fading. if (transition == TRANSITION_IMMEDIATE) { mLocked.pointerFadeDirection = 0; @@ -243,10 +234,6 @@ void PointerController::unfade(Transition transition) { // Always reset the inactivity timer. resetInactivityTimeoutLocked(); - if (mLocked.iconDetached) { - return; - } - // Start unfading. if (transition == TRANSITION_IMMEDIATE) { mLocked.pointerFadeDirection = 0; @@ -362,22 +349,6 @@ void PointerController::reloadPointerResources() { updatePointerLocked(); } -void PointerController::detachPointerIcon(bool detached) { - AutoMutex _l(mLock); - - if (mLocked.iconDetached == detached) { - return; - } - - mLocked.iconDetached = detached; - if (detached) { - mLocked.pointerFadeDirection = -1; - } else { - mLocked.pointerFadeDirection = 1; - } - startAnimationLocked(); -} - void PointerController::setDisplayViewport(int32_t width, int32_t height, int32_t orientation) { AutoMutex _l(mLock); diff --git a/libs/input/PointerController.h b/libs/input/PointerController.h index b47139adaf90..99292d7ca8a6 100644 --- a/libs/input/PointerController.h +++ b/libs/input/PointerController.h @@ -111,10 +111,6 @@ public: void setInactivityTimeout(InactivityTimeout inactivityTimeout); void reloadPointerResources(); - /* Detach or attach the pointer icon status. When detached, the pointer icon disappears - * and the icon location does not change at all. */ - void detachPointerIcon(bool detached); - private: static const size_t MAX_RECYCLED_SPRITES = 12; static const size_t MAX_SPOTS = 12; @@ -184,8 +180,6 @@ private: int32_t buttonState; - bool iconDetached; - Vector<Spot*> spots; Vector<sp<Sprite> > recycledSprites; } mLocked; diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index b54f839ced30..573689ed1d98 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -222,7 +222,6 @@ public class InputManagerService extends IInputManager.Stub private static native void nativeSetPointerIconType(long ptr, int iconId); private static native void nativeReloadPointerIcons(long ptr); private static native void nativeSetCustomPointerIcon(long ptr, PointerIcon icon); - private static native void nativeSetPointerIconDetached(long ptr, boolean detached); // Input event injection constants defined in InputDispatcher.h. private static final int INPUT_EVENT_INJECTION_SUCCEEDED = 0; @@ -1503,11 +1502,6 @@ public class InputManagerService extends IInputManager.Stub nativeSetFocusedApplication(mPtr, application); } - @Override - public void setPointerIconDetached(boolean detached) { - nativeSetPointerIconDetached(mPtr, detached); - } - public void setInputDispatchMode(boolean enabled, boolean frozen) { nativeSetInputDispatchMode(mPtr, enabled, frozen); } diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 2e82cec7e9d9..2f72a5cd1ab5 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -207,7 +207,6 @@ public: void setPointerIconType(int32_t iconId); void reloadPointerIcons(); void setCustomPointerIcon(const SpriteIcon& icon); - void setPointerIconDetached(bool detached); /* --- InputReaderPolicyInterface implementation --- */ @@ -712,14 +711,6 @@ void NativeInputManager::setFocusedApplication(JNIEnv* env, jobject applicationH mInputManager->getDispatcher()->setFocusedApplication(applicationHandle); } -void NativeInputManager::setPointerIconDetached(bool detached) { - AutoMutex _l(mLock); - sp<PointerController> controller = mLocked.pointerController.promote(); - if (controller != NULL) { - controller->detachPointerIcon(detached); - } -} - void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) { mInputManager->getDispatcher()->setInputDispatchMode(enabled, frozen); } @@ -1332,12 +1323,6 @@ static void nativeSetFocusedApplication(JNIEnv* env, jclass /* clazz */, im->setFocusedApplication(env, applicationHandleObj); } -static void nativeSetPointerIconDetached(JNIEnv* env, jclass /* clazz */, jlong ptr, - jboolean detached) { - NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); - im->setPointerIconDetached(detached); -} - static void nativeSetInputDispatchMode(JNIEnv* /* env */, jclass /* clazz */, jlong ptr, jboolean enabled, jboolean frozen) { NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr); @@ -1520,8 +1505,6 @@ static const JNINativeMethod gInputManagerMethods[] = { (void*) nativeSetInputWindows }, { "nativeSetFocusedApplication", "(JLcom/android/server/input/InputApplicationHandle;)V", (void*) nativeSetFocusedApplication }, - { "nativeSetPointerIconDetached", "(JZ)V", - (void*) nativeSetPointerIconDetached }, { "nativeSetInputDispatchMode", "(JZZ)V", (void*) nativeSetInputDispatchMode }, { "nativeSetSystemUiVisibility", "(JI)V", |