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

Commit 5c5bc294 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Separate mIsLeashInitialized from isLeashReadyForDispatching" into main

parents fc8f7c21 41a43ee2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -132,15 +132,15 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    }

    @Override
    protected boolean isLeashReadyForDispatching(InsetsControlTarget target) {
    protected boolean isLeashReadyForDispatching() {
        if (android.view.inputmethod.Flags.refactorInsetsController()) {
            final WindowState ws =
                    mWindowContainer != null ? mWindowContainer.asWindowState() : null;
            final boolean isDrawn = ws != null && ws.isDrawn();
            return super.isLeashReadyForDispatching(target)
            return super.isLeashReadyForDispatching()
                    && mServerVisible && isDrawn && mGivenInsetsReady;
        } else {
            return super.isLeashReadyForDispatching(target);
            return super.isLeashReadyForDispatching();
        }
    }

@@ -636,7 +636,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
            sb.append(", leash is: ").append(hasLeash ? "non-null" : "null");
            if (!hasLeash) {
                sb.append(", control is: ").append(mControl != null ? "non-null" : "null");
                sb.append(", mIsLeashReadyForDispatching: ").append(mIsLeashReadyForDispatching);
                sb.append(", mIsLeashInitialized: ").append(mIsLeashInitialized);
            }
            sb.append(", isImeLayeringTarget: ");
            sb.append(isImeLayeringTarget(mImeRequester, dcTarget));
+15 −12
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class InsetsSourceProvider {
    protected @Nullable WindowContainer mWindowContainer;
    protected @Nullable InsetsSourceControl mControl;
    protected @Nullable InsetsControlTarget mControlTarget;
    protected boolean mIsLeashReadyForDispatching;
    protected boolean mIsLeashInitialized;

    private final Rect mTmpRect = new Rect();
    private final InsetsSourceControl mFakeControl;
@@ -565,8 +565,8 @@ class InsetsSourceProvider {
                ANIMATION_TYPE_INSETS_CONTROL);

        // The leash was just created. We cannot dispatch it until its surface transaction is
        // applied. Otherwise, the client's operation to the leash might be overwritten by us.
        mIsLeashReadyForDispatching = false;
        // committed. Otherwise, the client's operation to the leash might be overwritten by us.
        mIsLeashInitialized = false;

        final SurfaceControl leash = mAdapter.mCapturedLeash;
        mControlTarget = target;
@@ -602,7 +602,7 @@ class InsetsSourceProvider {
     * @param id Indicates which transaction is committed so that stale callbacks can be dropped.
     */
    void onSurfaceTransactionCommitted(long id) {
        if (mIsLeashReadyForDispatching) {
        if (mIsLeashInitialized) {
            return;
        }
        if (mControl == null) {
@@ -611,7 +611,7 @@ class InsetsSourceProvider {
        if (id != getSurfaceTransactionId(mControl.getLeash())) {
            return;
        }
        mIsLeashReadyForDispatching = true;
        mIsLeashInitialized = true;
        mStateController.notifySurfaceTransactionReady(this, 0, false);
    }

@@ -662,9 +662,12 @@ class InsetsSourceProvider {
                mServerVisible, mClientVisible);
    }

    protected boolean isLeashReadyForDispatching(InsetsControlTarget target) {
        // If the target is not the control target, we are ready for dispatching a null-leash to it.
        return target != mControlTarget || mIsLeashReadyForDispatching;
    protected boolean isLeashReadyForDispatching() {
        return isLeashInitialized();
    }

    boolean isLeashInitialized() {
        return mIsLeashInitialized;
    }

    /**
@@ -677,7 +680,7 @@ class InsetsSourceProvider {
    @Nullable
    InsetsSourceControl getControl(InsetsControlTarget target) {
        if (target == mControlTarget) {
            if (!isLeashReadyForDispatching(target) && mControl != null) {
            if (!isLeashReadyForDispatching() && mControl != null) {
                // The surface transaction of preparing leash is not applied yet. We don't send it
                // to the client in case that the client applies its transaction sooner than ours
                // that we could unexpectedly overwrite the surface state.
@@ -702,7 +705,7 @@ class InsetsSourceProvider {
     */
    @Nullable
    protected SurfaceControl getLeash(@NonNull InsetsControlTarget target) {
        return target == mControlTarget && mIsLeashReadyForDispatching && mControl != null
        return target == mControlTarget && mIsLeashInitialized && mControl != null
                ? mControl.getLeash() : null;
    }

@@ -751,7 +754,7 @@ class InsetsSourceProvider {
            pw.println();
        }
        pw.print(prefix);
        pw.print("mIsLeashReadyForDispatching="); pw.print(mIsLeashReadyForDispatching);
        pw.print("mIsLeashInitialized="); pw.print(mIsLeashInitialized);
        pw.print(" mHasPendingPosition="); pw.print(mHasPendingPosition);
        pw.println();
        if (mWindowContainer != null) {
@@ -797,7 +800,7 @@ class InsetsSourceProvider {
        if (mAdapter != null && mAdapter.mCapturedLeash != null) {
            mAdapter.mCapturedLeash.dumpDebug(proto, CAPTURED_LEASH);
        }
        proto.write(IS_LEASH_READY_FOR_DISPATCHING, mIsLeashReadyForDispatching);
        proto.write(IS_LEASH_READY_FOR_DISPATCHING, isLeashReadyForDispatching());
        proto.write(CLIENT_VISIBLE, mClientVisible);
        proto.write(SERVER_VISIBLE, mServerVisible);
        proto.write(SEAMLESS_ROTATING, mSeamlessRotating);
+1 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ class InsetsStateController {
                final ArrayList<InsetsSourceProvider> providers = pendingControlMap.valueAt(i);
                for (int p = providers.size() - 1; p >= 0; p--) {
                    final InsetsSourceProvider provider = providers.get(p);
                    if (provider.isLeashReadyForDispatching(target)) {
                    if (provider.isLeashInitialized() || provider.getControlTarget() != target) {
                        // Stop waiting for this provider.
                        providers.remove(p);
                    }
+1 −1
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ public class InsetsSourceProviderTest extends WindowTestsBase {
        assertNull(mProvider.getLeash(target));

        // Set the leash to be ready for dispatching.
        mProvider.mIsLeashReadyForDispatching = true;
        mProvider.mIsLeashInitialized = true;
        assertNotNull(mProvider.getLeash(target));

        // We do have fake control for the fake control target, but that has no leash.