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

Commit 24ab9e18 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove the dependency on IWindowManager from IMMS

Relying on IWindowManager from InputMethodManagerService is just
confusing.  Let's use WindowManagerInternal insted.

There must be no observable behavior change in this CL.

Bug: 234882948
Test: presubmit
Change-Id: I6ad818fc9ef08991e24c5020498243f1fc417998
parent be0ad5c9
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -126,7 +126,6 @@ import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.proto.ProtoOutputStream;
import android.view.DisplayInfo;
import android.view.IWindowManager;
import android.view.InputChannel;
import android.view.InputDevice;
import android.view.MotionEvent;
@@ -289,7 +288,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
    private final Handler mHandler;
    final InputMethodSettings mSettings;
    final SettingsObserver mSettingsObserver;
    final IWindowManager mIWindowManager;
    private final SparseBooleanArray mLoggedDeniedGetInputMethodWindowVisibleHeightForUid =
            new SparseBooleanArray(0);
    final WindowManagerInternal mWindowManagerInternal;
@@ -1715,8 +1713,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        mHandler = Handler.createAsync(thread.getLooper(), this);
        // Note: SettingsObserver doesn't register observers in its constructor.
        mSettingsObserver = new SettingsObserver(mHandler);
        mIWindowManager = IWindowManager.Stub.asInterface(
                ServiceManager.getService(Context.WINDOW_SERVICE));
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
        mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
        mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
@@ -3160,10 +3156,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                mImeSwitcherNotification.setContentTitle(title)
                        .setContentText(summary)
                        .setContentIntent(mImeSwitchPendingIntent);
                try {
                // TODO(b/120076400): Figure out what is the best behavior
                if ((mNotificationManager != null)
                            && !mIWindowManager.hasNavigationBar(DEFAULT_DISPLAY)) {
                        && !mWindowManagerInternal.hasNavigationBar(DEFAULT_DISPLAY)) {
                    if (DEBUG) {
                        Slog.d(TAG, "--- show notification: label =  " + summary);
                    }
@@ -3172,8 +3167,6 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
                            mImeSwitcherNotification.build(), UserHandle.ALL);
                    mNotificationShown = true;
                }
                } catch (RemoteException e) {
                }
            } else {
                if (mNotificationShown && mNotificationManager != null) {
                    if (DEBUG) {
+9 −0
Original line number Diff line number Diff line
@@ -602,6 +602,15 @@ public abstract class WindowManagerInternal {
    public abstract void updateInputMethodTargetWindow(@NonNull IBinder imeToken,
            @NonNull IBinder imeTargetWindowToken);

    /**
     * Returns the presence of a software navigation bar on the specified display.
     *
     * @param displayId the id of display to check if there is a software navigation bar.
     * @return {@code true} if there is a software navigation. {@code false} otherwise, including
     *         the case when the specified display does not exist.
     */
    public abstract boolean hasNavigationBar(int displayId);

    /**
      * Returns true when the hardware keyboard is available.
      */
+5 −0
Original line number Diff line number Diff line
@@ -7910,6 +7910,11 @@ public class WindowManagerService extends IWindowManager.Stub
            }
        }

        @Override
        public boolean hasNavigationBar(int displayId) {
            return WindowManagerService.this.hasNavigationBar(displayId);
        }

        @Override
        public boolean isHardKeyboardAvailable() {
            synchronized (mGlobalLock) {