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

Commit 1a7fc5b6 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Decouple DisplayImeController and IInputMethodManager

This CL removes the direct dependency on IInputMethodManager from
DisplayImeController by using IInputMethodManagerGlobal, which was
introduced recently [1].

This is mechanical refactoring.  There must be no observable behavior
change.

 [1]: I5412eb1d44e3d515ca955f00a2e777b659a15b14

Fix: 192610976
Test: presubmit
Test: atest DisplayImeControllerTest
Change-Id: I9de401ad0a1051790d95fcfc8d2552a656281273
parent 7f0c721f
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -155,4 +155,21 @@ public final class IInputMethodManagerGlobal {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Invokes {@link IInputMethodManager#removeImeSurface()}
     */
    @RequiresPermission(android.Manifest.permission.INTERNAL_SYSTEM_WINDOW)
    @AnyThread
    public static void removeImeSurface(@Nullable Consumer<RemoteException> exceptionHandler) {
        final IInputMethodManager service = getService();
        if (service == null) {
            return;
        }
        try {
            service.removeImeSurface();
        } catch (RemoteException e) {
            handleRemoteExceptionOrRethrow(e, exceptionHandler);
        }
    }
}
+5 −18
Original line number Diff line number Diff line
@@ -21,12 +21,10 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.IntDef;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
import android.util.SparseArray;
import android.view.IDisplayWindowInsetsController;
@@ -43,7 +41,7 @@ import android.view.animation.PathInterpolator;

import androidx.annotation.VisibleForTesting;

import com.android.internal.view.IInputMethodManager;
import com.android.internal.inputmethod.IInputMethodManagerGlobal;
import com.android.wm.shell.sysui.ShellInit;

import java.util.ArrayList;
@@ -514,16 +512,10 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
    }

    void removeImeSurface() {
        final IInputMethodManager imms = getImms();
        if (imms != null) {
            try {
        // Remove the IME surface to make the insets invisible for
        // non-client controlled insets.
                imms.removeImeSurface();
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to remove IME surface.", e);
            }
        }
        IInputMethodManagerGlobal.removeImeSurface(
                e -> Slog.e(TAG, "Failed to remove IME surface.", e));
    }

    /**
@@ -597,11 +589,6 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
        }
    }

    public IInputMethodManager getImms() {
        return IInputMethodManager.Stub.asInterface(
                ServiceManager.getService(Context.INPUT_METHOD_SERVICE));
    }

    private static boolean haveSameLeash(InsetsSourceControl a, InsetsSourceControl b) {
        if (a == b) {
            return true;
+0 −7
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.view.SurfaceControl;

import androidx.test.filters.SmallTest;

import com.android.internal.view.IInputMethodManager;
import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.sysui.ShellInit;

@@ -56,8 +55,6 @@ public class DisplayImeControllerTest extends ShellTestCase {
    @Mock
    private SurfaceControl.Transaction mT;
    @Mock
    private IInputMethodManager mMock;
    @Mock
    private ShellInit mShellInit;
    private DisplayImeController.PerDisplay mPerDisplay;
    private Executor mExecutor;
@@ -76,10 +73,6 @@ public class DisplayImeControllerTest extends ShellTestCase {
            public void release(SurfaceControl.Transaction t) {
            }
        }, mExecutor) {
            @Override
            public IInputMethodManager getImms() {
                return mMock;
            }
            @Override
            void removeImeSurface() { }
        }.new PerDisplay(DEFAULT_DISPLAY, ROTATION_0);