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

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

Merge changes from topic "b/142461756"

* changes:
  Ime target window should control when to hide IME (2/2)
  Ime target window should control when to hide IME (1/2)
parents 30f59237 d7fc5864
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -81,6 +81,14 @@ oneway interface IWindow {
     */
    void showInsets(int types, boolean fromIme);

    /**
     * Called when a set of insets source window should be hidden by policy.
     *
     * @param types internal inset types (WindowInsets.Type.InsetType) to hide
     * @param fromIme true if this request originated from IME (InputMethodService).
     */
    void hideInsets(int types, boolean fromIme);

    void moved(int newX, int newY);
    void dispatchAppVisibility(boolean visible);
    void dispatchGetNewSurface();
+4 −0
Original line number Diff line number Diff line
@@ -229,6 +229,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
            final InsetsSourceConsumer consumer = items.valueAt(i);
            final InsetsSource source = mInitialInsetsState.getSource(consumer.getType());
            final InsetsSourceControl control = consumer.getControl();
            if (control == null) {
                // Control may not be available for consumer yet or revoked.
                continue;
            }
            final SurfaceControl leash = consumer.getControl().getLeash();

            mTmpMatrix.setTranslate(control.getSurfacePosition().x, control.getSurfacePosition().y);
+31 −34
Original line number Diff line number Diff line
@@ -251,6 +251,10 @@ public class InsetsController implements WindowInsetsController {

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

    void hide(@InsetType int types, boolean fromIme) {
        int typesReady = 0;
        final ArraySet<Integer> internalTypes = InsetsState.toInternalType(types);
        for (int i = internalTypes.size() - 1; i >= 0; i--) {
@@ -265,7 +269,7 @@ public class InsetsController implements WindowInsetsController {
            }
            typesReady |= InsetsState.toPublicType(consumer.getType());
        }
        applyAnimation(typesReady, false /* show */, false /* fromIme */);
        applyAnimation(typesReady, false /* show */, fromIme /* fromIme */);
    }

    @Override
@@ -331,8 +335,6 @@ public class InsetsController implements WindowInsetsController {
        boolean isReady = true;
        for (int i = internalTypes.size() - 1; i >= 0; i--) {
            InsetsSourceConsumer consumer = getSourceConsumer(internalTypes.valueAt(i));
            // Double check for IME that IME target window has focus.
            if (consumer.getType() != TYPE_IME || consumer.hasWindowFocus()) {
            boolean setVisible = !consumer.isVisible();
            if (setVisible) {
                // Show request
@@ -356,17 +358,12 @@ public class InsetsController implements WindowInsetsController {
                // Hide request
                // TODO: Move notifyHidden() to beginning of the hide animation
                // (when visibility actually changes using hideDirectly()).
                if (!fromIme) {
                    consumer.notifyHidden();
                }
                typesReady |= InsetsState.toPublicType(consumer.getType());
            }
            consumers.put(consumer.getType(), consumer);
            } else {
                // window doesnt have focus, no-op.
                isReady = false;
                // TODO: Let the calling app know that window has lost focus and
                //       show()/hide()/controlWindowInsetsAnimation requests will be ignored.
                typesReady &= ~InsetsState.toPublicType(consumer.getType());
            }
        }
        return new Pair<>(typesReady, isReady);
    }
+19 −0
Original line number Diff line number Diff line
@@ -4570,6 +4570,7 @@ public final class ViewRootImpl implements ViewParent,
    private static final int MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED = 32;
    private static final int MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED = 33;
    private static final int MSG_SHOW_INSETS = 34;
    private static final int MSG_HIDE_INSETS = 35;


    final class ViewRootHandler extends Handler {
@@ -4636,6 +4637,8 @@ public final class ViewRootImpl implements ViewParent,
                    return "MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED";
                case MSG_SHOW_INSETS:
                    return "MSG_SHOW_INSETS";
                case MSG_HIDE_INSETS:
                    return "MSG_HIDE_INSETS";
            }
            return super.getMessageName(message);
        }
@@ -4754,6 +4757,10 @@ public final class ViewRootImpl implements ViewParent,
                    mInsetsController.show(msg.arg1, msg.arg2 == 1);
                    break;
                }
                case MSG_HIDE_INSETS: {
                    mInsetsController.hide(msg.arg1, msg.arg2 == 1);
                    break;
                }
                case MSG_WINDOW_MOVED:
                    if (mAdded) {
                        final int w = mWinFrame.width();
@@ -7559,6 +7566,10 @@ public final class ViewRootImpl implements ViewParent,
        mHandler.obtainMessage(MSG_SHOW_INSETS, types, fromIme ? 1 : 0).sendToTarget();
    }

    private void hideInsets(@InsetType int types, boolean fromIme) {
        mHandler.obtainMessage(MSG_HIDE_INSETS, types, fromIme ? 1 : 0).sendToTarget();
    }

    public void dispatchMoved(int newX, int newY) {
        if (DEBUG_LAYOUT) Log.v(mTag, "Window moved " + this + ": newX=" + newX + " newY=" + newY);
        if (mTranslator != null) {
@@ -8681,6 +8692,14 @@ public final class ViewRootImpl implements ViewParent,
            }
        }

        @Override
        public void hideInsets(@InsetType int types, boolean fromIme) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
            if (viewAncestor != null) {
                viewAncestor.hideInsets(types, fromIme);
            }
        }

        @Override
        public void moved(int newX, int newY) {
            final ViewRootImpl viewAncestor = mViewAncestor.get();
+4 −0
Original line number Diff line number Diff line
@@ -79,6 +79,10 @@ public class BaseIWindow extends IWindow.Stub {
    public void showInsets(@InsetType int types, boolean fromIme)  throws RemoteException {
    }

    @Override
    public void hideInsets(@InsetType int types, boolean fromIme)  throws RemoteException {
    }

    @Override
    public void moved(int newX, int newY) {
    }
Loading