Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08e59efe authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "drag surface stuck"

* changes:
  Fix drag surface would be stuck (1/2)
  Revert "Fix drag and drop (3/3)"
  Revert "Fix drag and drop (2/3)"
  Revert "Fix drag and drop (1/3)"
parents a650fe00 b62e500e
Loading
Loading
Loading
Loading
+1 −18
Original line number Diff line number Diff line
@@ -187,8 +187,7 @@ public final class SurfaceControl implements Parcelable {

    private static native void nativeSetInputWindowInfo(long transactionObj, long nativeObject,
            InputWindowHandle handle);
    private static native void nativeTransferTouchFocus(long transactionObj, IBinder fromToken,
            IBinder toToken);

    private static native boolean nativeGetProtectedContentSupport();
    private static native void nativeSetMetadata(long transactionObj, long nativeObject, int key,
            Parcel data);
@@ -2238,22 +2237,6 @@ public final class SurfaceControl implements Parcelable {
            return this;
        }

        /**
         * Transfers touch focus from one window to another. 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 fromToken The token of a window that currently has touch focus.
         * @param toToken The token of the window that should receive touch focus in
         * place of the first.
         * @hide
         */
        public Transaction transferTouchFocus(IBinder fromToken, IBinder toToken) {
            nativeTransferTouchFocus(mNativeObject, fromToken, toToken);
            return this;
        }

        /**
         * Waits until any changes to input windows have been sent from SurfaceFlinger to
         * InputFlinger before returning.
+0 −11
Original line number Diff line number Diff line
@@ -458,15 +458,6 @@ static void nativeSetInputWindowInfo(JNIEnv* env, jclass clazz, jlong transactio
    transaction->setInputWindowInfo(ctrl, *handle->getInfo());
}

static void nativeTransferTouchFocus(JNIEnv* env, jclass clazz, jlong transactionObj,
        jobject fromTokenObj, jobject toTokenObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);

    sp<IBinder> fromToken(ibinderForJavaObject(env, fromTokenObj));
    sp<IBinder> toToken(ibinderForJavaObject(env, toTokenObj));
    transaction->transferTouchFocus(fromToken, toToken);
}

static void nativeSyncInputWindows(JNIEnv* env, jclass clazz, jlong transactionObj) {
    auto transaction = reinterpret_cast<SurfaceComposerClient::Transaction*>(transactionObj);
    transaction->syncInputWindows();
@@ -1381,8 +1372,6 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*)nativeCaptureLayers },
    {"nativeSetInputWindowInfo", "(JJLandroid/view/InputWindowHandle;)V",
            (void*)nativeSetInputWindowInfo },
    {"nativeTransferTouchFocus", "(JLandroid/os/IBinder;Landroid/os/IBinder;)V",
            (void*)nativeTransferTouchFocus },
    {"nativeSetMetadata", "(JJILandroid/os/Parcel;)V",
            (void*)nativeSetMetadata },
    {"nativeGetDisplayedContentSamplingAttributes",
+25 −0
Original line number Diff line number Diff line
@@ -220,6 +220,8 @@ public class InputManagerService extends IInputManager.Stub
    private static native void nativeSetFocusedApplication(long ptr,
            int displayId, InputApplicationHandle application);
    private static native void nativeSetFocusedDisplay(long ptr, int displayId);
    private static native boolean nativeTransferTouchFocus(long ptr,
            InputChannel fromChannel, InputChannel toChannel);
    private static native void nativeSetPointerSpeed(long ptr, int speed);
    private static native void nativeSetShowTouches(long ptr, boolean enabled);
    private static native void nativeSetInteractive(long ptr, boolean interactive);
@@ -1533,6 +1535,29 @@ public class InputManagerService extends IInputManager.Stub
        nativeSetSystemUiVisibility(mPtr, visibility);
    }

    /**
     * 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(mPtr, fromChannel, toChannel);
    }

    @Override // Binder call
    public void tryPointerSpeed(int speed) {
        if (!checkCallingPermission(android.Manifest.permission.SET_POINTER_SPEED,
+2 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class DragDropController {

                    final WindowState callingWin = mService.windowForClientLocked(
                            null, window, false);
                    if (callingWin == null) {
                    if (callingWin == null || callingWin.cantReceiveTouchInput()) {
                        Slog.w(TAG_WM, "Bad requesting window " + window);
                        return null;  // !!! TODO: throw here?
                    }
@@ -167,8 +167,7 @@ class DragDropController {
                    final SurfaceControl surfaceControl = mDragState.mSurfaceControl;
                    if (SHOW_LIGHT_TRANSACTIONS) Slog.i(TAG_WM, ">>> OPEN TRANSACTION performDrag");

                    final SurfaceControl.Transaction transaction =
                            callingWin.getPendingTransaction();
                    final SurfaceControl.Transaction transaction = mDragState.mTransaction;
                    transaction.setAlpha(surfaceControl, mDragState.mOriginalAlpha);
                    transaction.setPosition(
                            surfaceControl, touchX - thumbCenterX, touchY - thumbCenterY);
+4 −6
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class DragState {
    // A surface used to catch input events for the drag-and-drop operation.
    SurfaceControl mInputSurface;

    private final SurfaceControl.Transaction mTransaction;
    final SurfaceControl.Transaction mTransaction;

    private final Rect mTmpClipRect = new Rect();

@@ -129,7 +129,6 @@ class DragState {
     * {@code true} when {@link #closeLocked()} is called.
     */
    private boolean mIsClosing;
    IBinder mTransferTouchFromToken;

    DragState(WindowManagerService service, DragDropController controller, IBinder token,
            SurfaceControl surface, int flags, IBinder localWin) {
@@ -167,12 +166,11 @@ class DragState {

        mTmpClipRect.set(0, 0, mDisplaySize.x, mDisplaySize.y);
        mTransaction.setWindowCrop(mInputSurface, mTmpClipRect);
        mTransaction.transferTouchFocus(mTransferTouchFromToken, h.token);
        mTransferTouchFromToken = null;

        // syncInputWindows here to ensure the input channel isn't removed before the transfer.
        // syncInputWindows here to ensure the input window info is sent before the
        // transferTouchFocus is called.
        mTransaction.syncInputWindows();
        mTransaction.apply();
        mTransaction.apply(true);
    }

    /**
Loading