Merge "Decouple DisplayImeController and IInputMethodManager"
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
// Remove the IME surface to make the insets invisible for
|
||||
// non-client controlled insets.
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user