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

Commit a95895ed authored by Johannes Gallmann's avatar Johannes Gallmann Committed by Android (Google) Code Review
Browse files

Merge "Add debug logging to ImeOnBackInvokedDispatcher" into main

parents 9d6484c2 9bb8aac5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4640,6 +4640,7 @@ public class InputMethodService extends AbstractInputMethodService {
                + " touchableRegion=" + mTmpInsets.touchableRegion);
        p.println("  mSettingsObserver=" + mSettingsObserver);
        p.println("  mNavigationBarController=" + mNavigationBarController.toDebugString());
        p.println("  mBackCallbackRegistered=" + mBackCallbackRegistered);
    }

    private final ImeTracing.ServiceDumper mDumper = new ImeTracing.ServiceDumper() {
+31 −3
Original line number Diff line number Diff line
@@ -79,6 +79,11 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

    /** Set receiving dispatcher to consume queued receiving events. */
    public void updateReceivingDispatcher(@NonNull WindowOnBackInvokedDispatcher dispatcher) {
        if (!mQueuedReceive.isEmpty()) {
            //TODO(b/407224281): Remove this log again once b/407224281 is resolved
            Log.d(TAG, "updateReceivingDispatcher (mQueuedReceive.size=" + mQueuedReceive.size()
                    + ")");
        }
        while (!mQueuedReceive.isEmpty()) {
            final Pair<Integer, Bundle> queuedMessage = mQueuedReceive.poll();
            receive(queuedMessage.first, queuedMessage.second, dispatcher);
@@ -118,6 +123,9 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
        bundle.putInt(RESULT_KEY_PRIORITY, priority);
        bundle.putInt(RESULT_KEY_ID, callback.hashCode());
        mResultReceiver.send(RESULT_CODE_REGISTER, bundle);
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG,
                "Send callback registration id=" + callback.hashCode() + " priority=" + priority);
    }

    @Override
@@ -126,6 +134,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
        Bundle bundle = new Bundle();
        bundle.putInt(RESULT_KEY_ID, callback.hashCode());
        mResultReceiver.send(RESULT_CODE_UNREGISTER, bundle);
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Send callback unregistration id=" + callback.hashCode());
    }

    @Override
@@ -187,12 +197,16 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                    + "reregistering. (callbackId: " + callbackId
                    + " current callbacks: " + mImeCallbacks.size() + ")");
        }
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Register received callback id=" + callbackId + " priority=" + priority);
        mImeCallbacks.add(imeCallback);
        receivingDispatcher.registerOnBackInvokedCallbackUnchecked(imeCallback, priority);
    }

    private void unregisterReceivedCallback(
            int callbackId, @NonNull OnBackInvokedDispatcher receivingDispatcher) {
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Unregister received callback id=" + callbackId);
        if (!unregisterCallback(callbackId, receivingDispatcher)) {
            Log.w(TAG, "Ime callback not found. Ignoring unregisterReceivedCallback. "
                    + "callbackId: " + callbackId
@@ -223,6 +237,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
     * {@link ImeOnBackInvokedDispatcher#undoPreliminaryClear()}.
     */
    public void preliminaryClear() {
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Preliminary clear (mImeCallbacks.size=" + mImeCallbacks.size() + ")");
        // Unregister previously registered callbacks if there's any.
        if (getReceivingDispatcher() != null) {
            for (ImeOnBackInvokedCallback callback : mImeCallbacks) {
@@ -237,6 +253,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
     * animation is interrupted causing the IME to reappear.
     */
    public void undoPreliminaryClear() {
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Undo preliminary clear (mImeCallbacks.size=" + mImeCallbacks.size() + ")");
        if (getReceivingDispatcher() != null) {
            for (ImeOnBackInvokedCallback callback : mImeCallbacks) {
                getReceivingDispatcher().registerOnBackInvokedCallbackUnchecked(callback,
@@ -247,6 +265,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

    /** Clears all registered callbacks on the instance. */
    public void clear() {
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "Clear (mImeCallbacks.size=" + mImeCallbacks.size() + ")");
        // Unregister previously registered callbacks if there's any.
        if (getReceivingDispatcher() != null) {
            for (ImeOnBackInvokedCallback callback : mImeCallbacks) {
@@ -277,12 +297,12 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
    @VisibleForTesting(visibility = PACKAGE)
    public static class ImeOnBackInvokedCallback implements OnBackAnimationCallback {
        @NonNull
        private final IOnBackInvokedCallback mIOnBackInvokedCallback;
        protected final IOnBackInvokedCallback mIOnBackInvokedCallback;
        /**
         * The hashcode of the callback instance in the IME process, used as a unique id to
         * identify the callback when it's passed between processes.
         */
        private final int mId;
        protected final int mId;
        private final int mPriority;

        ImeOnBackInvokedCallback(@NonNull IOnBackInvokedCallback iCallback, int id,
@@ -348,7 +368,7 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc

        @Override
        public String toString() {
            return "ImeCallback=ImeOnBackInvokedCallback@" + mId
            return "ImeOnBackInvokedCallback@" + mId
                    + " Callback=" + mIOnBackInvokedCallback;
        }
    }
@@ -363,6 +383,12 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
                int priority) {
            super(iCallback, id, priority);
        }

        @Override
        public String toString() {
            return "DefaultImeOnBackAnimationCallback@" + mId
                    + " Callback=" + mIOnBackInvokedCallback;
        }
    }

    /**
@@ -373,6 +399,8 @@ public class ImeOnBackInvokedDispatcher implements OnBackInvokedDispatcher, Parc
     * @param current  the currently focused {@link ViewRootImpl}.
     */
    public void switchRootView(ViewRootImpl previous, ViewRootImpl current) {
        //TODO(b/407224281): Remove this log again once b/407224281 is resolved
        Log.d(TAG, "switch root view (mImeCallbacks.size=" + mImeCallbacks.size() + ")");
        for (ImeOnBackInvokedCallback imeCallback : mImeCallbacks) {
            if (previous != null) {
                previous.getOnBackInvokedDispatcher().unregisterOnBackInvokedCallback(imeCallback);