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

Commit 7668945a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27716496']...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/27716496'] into sparse-11944173-L29900030004348256.
SPARSE_CHANGE: I2883201aa59bb264e4c02246007c7c4788e8b07c

Change-Id: I5db1c249631243aa953561ef7314716622bcdaf3
parents 660fb6cd 0855f898
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
    static final int RESULT_CODE_UNREGISTER = 1;
    @NonNull
    private final ResultReceiver mResultReceiver;
    // The handler to run callbacks on. This should be on the same thread
    // the ViewRootImpl holding IME's WindowOnBackInvokedDispatcher is created on.
    private Handler mHandler;

    public ImeOnBackInvokedDispatcher(Handler handler) {
        mResultReceiver = new ResultReceiver(handler) {
@@ -68,6 +71,10 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
        };
    }

    void setHandler(@NonNull Handler handler) {
        mHandler = handler;
    }

    /**
     * Override this method to return the {@link WindowOnBackInvokedDispatcher} of the window
     * that should receive the forwarded callback.
@@ -326,7 +333,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

        @Override
        public void onBackInvoked() {
            mCallback.onBackInvoked();
            mHandler.post(mCallback::onBackInvoked);
        }

        @Override
@@ -336,7 +343,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

        private void maybeRunOnAnimationCallback(Consumer<OnBackAnimationCallback> block) {
            if (mCallback instanceof OnBackAnimationCallback) {
                block.accept((OnBackAnimationCallback) mCallback);
                mHandler.post(() -> block.accept((OnBackAnimationCallback) mCallback));
            }
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -550,6 +550,7 @@ public class WindowOnBackInvokedDispatcher implements OnBackInvokedDispatcher {
    public void setImeOnBackInvokedDispatcher(
            @NonNull ImeOnBackInvokedDispatcher imeDispatcher) {
        mImeDispatcher = imeDispatcher;
        mImeDispatcher.setHandler(mHandler);
    }

    /** Returns true if a non-null {@link ImeOnBackInvokedDispatcher} has been set. **/