Loading services/core/java/com/android/server/wm/DragDropController.java +65 −61 Original line number Diff line number Diff line Loading @@ -150,23 +150,24 @@ class DragDropController { Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data); } if (!mCallback.get().prePerformDrag(window, dragToken, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data)) { return false; } final boolean callbackResult = mCallback.get().prePerformDrag(window, dragToken, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data); try { synchronized (mService.mWindowMap) { if (mDragState == null) { Slog.w(TAG_WM, "No drag prepared"); throw new IllegalStateException("performDrag() without prepareDrag()"); mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder()); try { if (!callbackResult) { return false; } if (dragToken != mDragState.mToken) { Slog.w(TAG_WM, "Performing mismatched drag"); throw new IllegalStateException("performDrag() does not match prepareDrag()"); } Preconditions.checkState( mDragState != null, "performDrag() without prepareDrag()"); Preconditions.checkState( mDragState.mToken == dragToken, "performDrag() does not match prepareDrag()"); final WindowState callingWin = mService.windowForClientLocked(null, window, false); final WindowState callingWin = mService.windowForClientLocked( null, window, false); if (callingWin == null) { Slog.w(TAG_WM, "Bad requesting window " + window); return false; // !!! TODO: throw here? Loading @@ -176,8 +177,6 @@ class DragDropController { // the drag initiation (e.g. an alarm window popped up just as the application // called performDrag() mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder()); // !!! TODO: extract the current touch (x, y) in screen coordinates. That // will let us eliminate the (touchX,touchY) parameters from the API. Loading @@ -186,14 +185,15 @@ class DragDropController { final DisplayContent displayContent = callingWin.getDisplayContent(); if (displayContent == null) { Slog.w(TAG_WM, "display content is null"); return false; } Display display = displayContent.getDisplay(); final Display display = displayContent.getDisplay(); mDragState.register(display); if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, mDragState.getInputChannel())) { Slog.e(TAG_WM, "Unable to transfer touch focus"); mDragState.closeLocked(); return false; } Loading @@ -201,7 +201,6 @@ class DragDropController { mDragState.mData = data; mDragState.broadcastDragStartedLocked(touchX, touchY); mDragState.overridePointerIconLocked(touchSource); // remember the thumb offsets for later mDragState.mThumbOffsetX = thumbCenterX; mDragState.mThumbOffsetY = thumbCenterY; Loading @@ -224,6 +223,11 @@ class DragDropController { } mDragState.notifyLocationLocked(touchX, touchY); } finally { if (mDragState != null && !mDragState.isInProgress()) { mDragState.closeLocked(); } } } return true; // success! } finally { Loading services/core/java/com/android/server/wm/DragState.java +8 −0 Original line number Diff line number Diff line Loading @@ -568,6 +568,14 @@ class DragState { mToken = token; } /** * Returns true if it has sent DRAG_STARTED broadcast out but has not been sent DRAG_END * broadcast. */ boolean isInProgress() { return mDragInProgress; } private static DragEvent obtainDragEvent(WindowState win, int action, float x, float y, Object localState, ClipDescription description, ClipData data, Loading Loading
services/core/java/com/android/server/wm/DragDropController.java +65 −61 Original line number Diff line number Diff line Loading @@ -150,23 +150,24 @@ class DragDropController { Slog.d(TAG_WM, "perform drag: win=" + window + " data=" + data); } if (!mCallback.get().prePerformDrag(window, dragToken, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data)) { return false; } final boolean callbackResult = mCallback.get().prePerformDrag(window, dragToken, touchSource, touchX, touchY, thumbCenterX, thumbCenterY, data); try { synchronized (mService.mWindowMap) { if (mDragState == null) { Slog.w(TAG_WM, "No drag prepared"); throw new IllegalStateException("performDrag() without prepareDrag()"); mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder()); try { if (!callbackResult) { return false; } if (dragToken != mDragState.mToken) { Slog.w(TAG_WM, "Performing mismatched drag"); throw new IllegalStateException("performDrag() does not match prepareDrag()"); } Preconditions.checkState( mDragState != null, "performDrag() without prepareDrag()"); Preconditions.checkState( mDragState.mToken == dragToken, "performDrag() does not match prepareDrag()"); final WindowState callingWin = mService.windowForClientLocked(null, window, false); final WindowState callingWin = mService.windowForClientLocked( null, window, false); if (callingWin == null) { Slog.w(TAG_WM, "Bad requesting window " + window); return false; // !!! TODO: throw here? Loading @@ -176,8 +177,6 @@ class DragDropController { // the drag initiation (e.g. an alarm window popped up just as the application // called performDrag() mHandler.removeMessages(MSG_DRAG_START_TIMEOUT, window.asBinder()); // !!! TODO: extract the current touch (x, y) in screen coordinates. That // will let us eliminate the (touchX,touchY) parameters from the API. Loading @@ -186,14 +185,15 @@ class DragDropController { final DisplayContent displayContent = callingWin.getDisplayContent(); if (displayContent == null) { Slog.w(TAG_WM, "display content is null"); return false; } Display display = displayContent.getDisplay(); final Display display = displayContent.getDisplay(); mDragState.register(display); if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, mDragState.getInputChannel())) { Slog.e(TAG_WM, "Unable to transfer touch focus"); mDragState.closeLocked(); return false; } Loading @@ -201,7 +201,6 @@ class DragDropController { mDragState.mData = data; mDragState.broadcastDragStartedLocked(touchX, touchY); mDragState.overridePointerIconLocked(touchSource); // remember the thumb offsets for later mDragState.mThumbOffsetX = thumbCenterX; mDragState.mThumbOffsetY = thumbCenterY; Loading @@ -224,6 +223,11 @@ class DragDropController { } mDragState.notifyLocationLocked(touchX, touchY); } finally { if (mDragState != null && !mDragState.isInProgress()) { mDragState.closeLocked(); } } } return true; // success! } finally { Loading
services/core/java/com/android/server/wm/DragState.java +8 −0 Original line number Diff line number Diff line Loading @@ -568,6 +568,14 @@ class DragState { mToken = token; } /** * Returns true if it has sent DRAG_STARTED broadcast out but has not been sent DRAG_END * broadcast. */ boolean isInProgress() { return mDragInProgress; } private static DragEvent obtainDragEvent(WindowState win, int action, float x, float y, Object localState, ClipDescription description, ClipData data, Loading