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

Commit 4c478950 authored by Felix Stern's avatar Felix Stern Committed by Android (Google) Code Review
Browse files

Merge "Clean-up unused fromIme parameter" into main

parents f2d5a0b9 a143c5fa
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -49,12 +49,12 @@ oneway interface IDisplayWindowInsetsController {
    /**
     * @see IWindow#showInsets
     */
    void showInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
    void showInsets(int types, in @nullable ImeTracker.Token statsToken);

    /**
     * @see IWindow#hideInsets
     */
    void hideInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
    void hideInsets(int types, in @nullable ImeTracker.Token statsToken);

    /**
     * Reports the requested IME visibility of the IME input target to
+2 −4
Original line number Diff line number Diff line
@@ -75,19 +75,17 @@ oneway interface IWindow {
     * Called when a set of insets source window should be shown by policy.
     *
     * @param types internal insets types (WindowInsets.Type.InsetsType) to show
     * @param fromIme true if this request originated from IME (InputMethodService).
     * @param statsToken the token tracking the current IME request or {@code null} otherwise.
     */
    void showInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
    void showInsets(int types, in @nullable ImeTracker.Token statsToken);

    /**
     * Called when a set of insets source window should be hidden by policy.
     *
     * @param types internal insets types (WindowInsets.Type.InsetsType) to hide
     * @param fromIme true if this request originated from IME (InputMethodService).
     * @param statsToken the token tracking the current IME request or {@code null} otherwise.
     */
    void hideInsets(int types, boolean fromIme, in @nullable ImeTracker.Token statsToken);
    void hideInsets(int types, in @nullable ImeTracker.Token statsToken);

    void moved(int newX, int newY);
    void dispatchAppVisibility(boolean visible);
+2 −2
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
                    public void onCancelled(@Nullable WindowInsetsAnimationController controller) {
                        reset();
                    }
                }, /*fromIme*/ false, /*durationMs*/ -1, /*interpolator*/ null, ANIMATION_TYPE_USER,
                }, /*durationMs*/ -1, /*interpolator*/ null, ANIMATION_TYPE_USER,
                /*fromPredictiveBack*/ true);
    }

@@ -146,7 +146,7 @@ public class ImeBackAnimationController implements OnBackAnimationCallback {
            ImeTracker.Token statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE,
                    ImeTracker.ORIGIN_CLIENT,
                    SoftInputShowHideReason.HIDE_SOFT_INPUT_REQUEST_HIDE_WITH_CONTROL, true);
            mInsetsController.hide(IME, /*fromIme*/ false, statsToken);
            mInsetsController.hide(IME, statsToken);
        } else {
            startPostCommitAnim(/*hideIme*/ true);
        }
+30 −63
Original line number Diff line number Diff line
@@ -1027,15 +1027,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_CLIENT_ON_CONTROLS_CHANGED);
                }
                applyAnimation(showTypes[0], true /* show */, false /* fromIme */,
                        false /* skipsCallbacks */, statsToken);
                applyAnimation(showTypes[0], true /* show */, false /* skipsCallbacks */,
                        statsToken);
            }
            if (hideTypes[0] != 0) {
                if ((hideTypes[0] & ime()) != 0) {
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_CLIENT_ON_CONTROLS_CHANGED);
                }
                applyAnimation(hideTypes[0], false /* show */, false /* fromIme */,
                applyAnimation(hideTypes[0], false /* show */,
                        // The animation of hiding transient types shouldn't be detected by the
                        // app. Otherwise, it might be able to react to the callbacks and cause
                        // flickering.
@@ -1089,14 +1089,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    @Override
    public void show(@InsetsType int types) {
        show(types, false /* fromIme */, null /* statsToken */);
        show(types, null /* statsToken */);
    }

    @VisibleForTesting(visibility = PACKAGE)
    public void show(@InsetsType int types, boolean fromIme,
            @Nullable ImeTracker.Token statsToken) {
    public void show(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
        if ((types & ime()) != 0) {
            Log.d(TAG, "show(ime(), fromIme=" + fromIme + ")");
            Log.d(TAG, "show(ime())");

            if (statsToken == null) {
                statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_SHOW,
@@ -1106,15 +1104,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            }
        }

        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#show",
                    mHost.getInputMethodManager(), null /* icProto */);
            Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.showRequestFromApiToImeReady", 0);
            Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.showRequestFromIme", 0);
        } else {
        Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.showRequestFromApi", 0);
        Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.showRequestFromApiToImeReady", 0);
        }

        // TODO: Support a ResultReceiver for IME.
        // TODO(b/123718661): Make show() work for multi-session IME.
@@ -1154,8 +1145,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            // TODO(b/353463205) check if this is needed here
            ImeTracker.forLatency().onShown(statsToken, ActivityThread::currentApplication);
        }
        applyAnimation(typesReady, true /* show */, fromIme, false /* skipsCallbacks */,
                statsToken);
        applyAnimation(typesReady, true /* show */, false /* skipsCallbacks */, statsToken);
    }

    /**
@@ -1173,7 +1163,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        // We are about to playing the default animation. Passing a null frame indicates the
        // controlled types should be animated regardless of the frame.
        controlAnimationUnchecked(pendingRequest.types, pendingRequest.cancellationSignal,
                pendingRequest.listener, null /* frame */, null /* bounds */, true /* fromIme */,
                pendingRequest.listener, null /* frame */, null /* bounds */,
                pendingRequest.mInsetsAnimationSpec,
                pendingRequest.animationType, pendingRequest.layoutInsetsDuringAnimation,
                pendingRequest.useInsetsAnimationThread, statsToken,
@@ -1182,14 +1172,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

    @Override
    public void hide(@InsetsType int types) {
        hide(types, false /* fromIme */, null /* statsToken */);
        hide(types, null /* statsToken */);
    }

    @VisibleForTesting(visibility = PACKAGE)
    public void hide(@InsetsType int types, boolean fromIme,
            @Nullable ImeTracker.Token statsToken) {
    public void hide(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
        if ((types & ime()) != 0) {
            Log.d(TAG, "hide(ime(), fromIme=" + fromIme + ")");
            Log.d(TAG, "hide(ime())");

            if (statsToken == null) {
                statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE,
@@ -1198,13 +1186,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                        mHost.isHandlingPointerEvent() /* fromUser */);
            }
        }
        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump("InsetsController#hide",
                    mHost.getInputMethodManager(), null /* icProto */);
            Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.hideRequestFromIme", 0);
        } else {
        Trace.asyncTraceBegin(TRACE_TAG_VIEW, "IC.hideRequestFromApi", 0);
        }

        @InsetsType int typesReady = 0;
        boolean hasImeRequestedHidden = false;
        final boolean hadPendingImeControlRequest = mPendingImeControlRequest != null;
@@ -1254,8 +1237,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            // has being requested hidden.
            handlePendingControlRequest(statsToken);
        }
        applyAnimation(typesReady, false /* show */, fromIme, false /* skipsCallbacks */,
                statsToken);
        applyAnimation(typesReady, false /* show */, false /* skipsCallbacks */, statsToken);
    }

    @Override
@@ -1263,16 +1245,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            @Nullable Interpolator interpolator,
            @Nullable CancellationSignal cancellationSignal,
            @NonNull WindowInsetsAnimationControlListener listener) {
        controlWindowInsetsAnimation(types, cancellationSignal, listener,
                false /* fromIme */, durationMillis, interpolator, ANIMATION_TYPE_USER,
                false /* fromPredictiveBack */);
        controlWindowInsetsAnimation(types, cancellationSignal, listener, durationMillis,
                interpolator, ANIMATION_TYPE_USER, false /* fromPredictiveBack */);
    }

    @VisibleForTesting(visibility = PACKAGE)
    public void controlWindowInsetsAnimation(@InsetsType int types,
            @Nullable CancellationSignal cancellationSignal,
            WindowInsetsAnimationControlListener listener,
            boolean fromIme, long durationMs, @Nullable Interpolator interpolator,
            long durationMs, @Nullable Interpolator interpolator,
            @AnimationType int animationType, boolean fromPredictiveBack) {
        if ((mState.calculateUncontrollableInsetsFromFrame(mFrame, mBounds) & types) != 0
                || (fromPredictiveBack && ((mRequestedVisibleTypes & ime()) == 0))) {
@@ -1281,11 +1262,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            listener.onCancelled(null);
            return;
        }
        if (fromIme) {
            ImeTracing.getInstance().triggerClientDump(
                    "InsetsController#controlWindowInsetsAnimation",
                    mHost.getInputMethodManager(), null /* icProto */);
        }

        InsetsAnimationSpec spec = new InsetsAnimationSpec() {
            @Override
@@ -1298,15 +1274,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            }
        };
        // TODO(b/342111149): Create statsToken here once ImeTracker#onStart becomes async.
        controlAnimationUnchecked(types, cancellationSignal, listener, mFrame, mBounds, fromIme,
                spec, animationType, getLayoutInsetsDuringAnimationMode(types, fromPredictiveBack),
        controlAnimationUnchecked(types, cancellationSignal, listener, mFrame, mBounds, spec,
                animationType, getLayoutInsetsDuringAnimationMode(types, fromPredictiveBack),
                false /* useInsetsAnimationThread */, null, fromPredictiveBack);
    }

    private void controlAnimationUnchecked(@InsetsType int types,
            @Nullable CancellationSignal cancellationSignal,
            WindowInsetsAnimationControlListener listener, @Nullable Rect frame,
            @Nullable Rect bounds, boolean fromIme, InsetsAnimationSpec insetsAnimationSpec,
            @Nullable Rect bounds, InsetsAnimationSpec insetsAnimationSpec,
            @AnimationType int animationType,
            @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
            boolean useInsetsAnimationThread, @Nullable ImeTracker.Token statsToken,
@@ -1323,7 +1299,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

        // However, we might reject the request in some cases, such as delaying showing IME or
        // rejecting showing IME.
        controlAnimationUncheckedInner(types, cancellationSignal, listener, frame, bounds, fromIme,
        controlAnimationUncheckedInner(types, cancellationSignal, listener, frame, bounds,
                insetsAnimationSpec, animationType, layoutInsetsDuringAnimation,
                useInsetsAnimationThread, statsToken, fromPredictiveBack);

@@ -1335,7 +1311,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    private void controlAnimationUncheckedInner(@InsetsType int types,
            @Nullable CancellationSignal cancellationSignal,
            WindowInsetsAnimationControlListener listener, @Nullable Rect frame,
            @Nullable Rect bounds, boolean fromIme, InsetsAnimationSpec insetsAnimationSpec,
            @Nullable Rect bounds, InsetsAnimationSpec insetsAnimationSpec,
            @AnimationType int animationType,
            @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation,
            boolean useInsetsAnimationThread, @Nullable ImeTracker.Token statsToken,
@@ -1474,16 +1450,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation

        onAnimationStateChanged(types, true /* running */);

        if (fromIme) {
            switch (animationType) {
                case ANIMATION_TYPE_SHOW:
                    Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.showRequestFromIme", 0);
                    break;
                case ANIMATION_TYPE_HIDE:
                    Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.hideRequestFromIme", 0);
                    break;
            }
        } else if (animationType == ANIMATION_TYPE_HIDE) {
        if (animationType == ANIMATION_TYPE_HIDE) {
            Trace.asyncTraceEnd(TRACE_TAG_VIEW, "IC.hideRequestFromApi", 0);
        }
    }
@@ -1845,8 +1812,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
    }

    @VisibleForTesting
    public void applyAnimation(@InsetsType final int types, boolean show, boolean fromIme,
            boolean skipsCallbacks, @Nullable ImeTracker.Token statsToken) {
    public void applyAnimation(@InsetsType final int types, boolean show, boolean skipsCallbacks,
            @Nullable ImeTracker.Token statsToken) {
        // TODO(b/166736352): We should only skip the animation of specific types, not all types.
        boolean skipsAnim = false;
        if ((types & ime()) != 0) {
@@ -1858,11 +1825,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                        && mImeSourceConsumer.hasViewFocusWhenWindowFocusGain();
            }
        }
        applyAnimation(types, show, fromIme, skipsAnim, skipsCallbacks, statsToken);
        applyAnimation(types, show, skipsAnim, skipsCallbacks, statsToken);
    }

    @VisibleForTesting
    public void applyAnimation(@InsetsType final int types, boolean show, boolean fromIme,
    public void applyAnimation(@InsetsType final int types, boolean show,
            boolean skipsAnim, boolean skipsCallbacks, @Nullable ImeTracker.Token statsToken) {
        if (types == 0) {
            // nothing to animate.
@@ -1881,7 +1848,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        // the controlled types should be animated regardless of the frame.
        controlAnimationUnchecked(
                types, null /* cancellationSignal */, listener, null /* frame */, null /* bounds */,
                fromIme, listener /* insetsAnimationSpec */,
                listener /* insetsAnimationSpec */,
                show ? ANIMATION_TYPE_SHOW : ANIMATION_TYPE_HIDE,
                show ? LAYOUT_INSETS_DURING_ANIMATION_SHOWN : LAYOUT_INSETS_DURING_ANIMATION_HIDDEN,
                !hasAnimationCallbacks || skipsCallbacks /* useInsetsAnimationThread */, statsToken,
+29 −32
Original line number Diff line number Diff line
@@ -3205,11 +3205,10 @@ public final class ViewRootImpl implements ViewParent,
     * cleared for compatibility.
     *
     * @param showTypes {@link InsetsType types} shown by the system.
     * @param fromIme {@code true} if the invocation is from IME.
     */
    private void clearLowProfileModeIfNeeded(@InsetsType int showTypes, boolean fromIme) {
    private void clearLowProfileModeIfNeeded(@InsetsType int showTypes) {
        final SystemUiVisibilityInfo info = mCompatibleVisibilityInfo;
        if ((showTypes & Type.systemBars()) != 0 && !fromIme
        if ((showTypes & Type.systemBars()) != 0
                && (info.globalVisibility & SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
            info.globalVisibility &= ~SYSTEM_UI_FLAG_LOW_PROFILE;
            info.localChanges |= SYSTEM_UI_FLAG_LOW_PROFILE;
@@ -7035,23 +7034,29 @@ public final class ViewRootImpl implements ViewParent,
                    break;
                }
                case MSG_SHOW_INSETS: {
                    final ImeTracker.Token statsToken = (ImeTracker.Token) msg.obj;
                    final SomeArgs args = (SomeArgs) msg.obj;
                    @InsetsType final int types = (int) args.arg1;
                    final ImeTracker.Token statsToken = (ImeTracker.Token) args.arg2;
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_CLIENT_HANDLE_SHOW_INSETS);
                    if (mView == null) {
                        Log.e(TAG,
                                String.format("Calling showInsets(%d,%b) on window that no longer"
                                        + " has views.", msg.arg1, msg.arg2 == 1));
                                String.format("Calling showInsets(%d) on window that no longer"
                                        + " has views.", types));
                    }
                    clearLowProfileModeIfNeeded(msg.arg1, msg.arg2 == 1);
                    mInsetsController.show(msg.arg1, msg.arg2 == 1, statsToken);
                    clearLowProfileModeIfNeeded(types);
                    mInsetsController.show(types, statsToken);
                    args.recycle();
                    break;
                }
                case MSG_HIDE_INSETS: {
                    final ImeTracker.Token statsToken = (ImeTracker.Token) msg.obj;
                    final SomeArgs args = (SomeArgs) msg.obj;
                    @InsetsType final int types = (int) args.arg1;
                    final ImeTracker.Token statsToken = (ImeTracker.Token) args.arg2;
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_CLIENT_HANDLE_HIDE_INSETS);
                    mInsetsController.hide(msg.arg1, msg.arg2 == 1, statsToken);
                    mInsetsController.hide(types, statsToken);
                    args.recycle();
                    break;
                }
                case MSG_WINDOW_MOVED:
@@ -10317,14 +10322,18 @@ public final class ViewRootImpl implements ViewParent,
        mHandler.obtainMessage(MSG_INSETS_CONTROL_CHANGED, args).sendToTarget();
    }
    private void showInsets(@InsetsType int types, boolean fromIme,
            @Nullable ImeTracker.Token statsToken) {
        mHandler.obtainMessage(MSG_SHOW_INSETS, types, fromIme ? 1 : 0, statsToken).sendToTarget();
    private void showInsets(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
        final SomeArgs args = SomeArgs.obtain();
        args.arg1 = types;
        args.arg2 = statsToken;
        mHandler.obtainMessage(MSG_SHOW_INSETS, args).sendToTarget();
    }
    private void hideInsets(@InsetsType int types, boolean fromIme,
            @Nullable ImeTracker.Token statsToken) {
        mHandler.obtainMessage(MSG_HIDE_INSETS, types, fromIme ? 1 : 0, statsToken).sendToTarget();
    private void hideInsets(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
        final SomeArgs args = SomeArgs.obtain();
        args.arg1 = types;
        args.arg2 = statsToken;
        mHandler.obtainMessage(MSG_HIDE_INSETS, args).sendToTarget();
    }
    public void dispatchMoved(int newX, int newY) {
@@ -11875,34 +11884,22 @@ public final class ViewRootImpl implements ViewParent,
        }
        @Override
        public void showInsets(@InsetsType int types, boolean fromIme,
                @Nullable ImeTracker.Token statsToken) {
        public void showInsets(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (fromIme) {
                ImeTracing.getInstance().triggerClientDump("ViewRootImpl.W#showInsets",
                        viewAncestor.getInsetsController().getHost().getInputMethodManager(),
                        null /* icProto */);
            }
            if (viewAncestor != null) {
                ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_SHOW_INSETS);
                viewAncestor.showInsets(types, fromIme, statsToken);
                viewAncestor.showInsets(types, statsToken);
            } else {
                ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_SHOW_INSETS);
            }
        }
        @Override
        public void hideInsets(@InsetsType int types, boolean fromIme,
                @Nullable ImeTracker.Token statsToken) {
        public void hideInsets(@InsetsType int types, @Nullable ImeTracker.Token statsToken) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (fromIme) {
                ImeTracing.getInstance().triggerClientDump("ViewRootImpl.W#hideInsets",
                        viewAncestor.getInsetsController().getHost().getInputMethodManager(),
                        null /* icProto */);
            }
            if (viewAncestor != null) {
                ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_HIDE_INSETS);
                viewAncestor.hideInsets(types, fromIme, statsToken);
                viewAncestor.hideInsets(types, statsToken);
            } else {
                ImeTracker.forLogging().onFailed(statsToken, ImeTracker.PHASE_CLIENT_HIDE_INSETS);
            }
Loading