summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yohei Yukawa <yukawa@google.com> 2022-10-07 07:12:31 -0700
committer Yohei Yukawa <yukawa@google.com> 2022-10-07 07:12:31 -0700
commit24ab9e18a74b052e4f5b8fb04c48d7f16ea071ae (patch)
treea684dca0b2d3e70caa51e88146fb53952136d851
parentbe0ad5c9b68ddec1634d51d9fe35b4cc7f63c8f9 (diff)
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
-rw-r--r--services/core/java/com/android/server/inputmethod/InputMethodManagerService.java25
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerInternal.java9
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java5
3 files changed, 23 insertions, 16 deletions
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 0ec210090437..832e91035d09 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -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,19 +3156,16 @@ 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)) {
- if (DEBUG) {
- Slog.d(TAG, "--- show notification: label = " + summary);
- }
- mNotificationManager.notifyAsUser(null,
- SystemMessage.NOTE_SELECT_INPUT_METHOD,
- mImeSwitcherNotification.build(), UserHandle.ALL);
- mNotificationShown = true;
+ // TODO(b/120076400): Figure out what is the best behavior
+ if ((mNotificationManager != null)
+ && !mWindowManagerInternal.hasNavigationBar(DEFAULT_DISPLAY)) {
+ if (DEBUG) {
+ Slog.d(TAG, "--- show notification: label = " + summary);
}
- } catch (RemoteException e) {
+ mNotificationManager.notifyAsUser(null,
+ SystemMessage.NOTE_SELECT_INPUT_METHOD,
+ mImeSwitcherNotification.build(), UserHandle.ALL);
+ mNotificationShown = true;
}
} else {
if (mNotificationShown && mNotificationManager != null) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerInternal.java b/services/core/java/com/android/server/wm/WindowManagerInternal.java
index 11475ac6150b..1e6c7207e34a 100644
--- a/services/core/java/com/android/server/wm/WindowManagerInternal.java
+++ b/services/core/java/com/android/server/wm/WindowManagerInternal.java
@@ -603,6 +603,15 @@ public abstract class WindowManagerInternal {
@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.
*/
public abstract boolean isHardKeyboardAvailable();
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 502b4bb695b0..dff1a349eb9f 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -7911,6 +7911,11 @@ public class WindowManagerService extends IWindowManager.Stub
}
@Override
+ public boolean hasNavigationBar(int displayId) {
+ return WindowManagerService.this.hasNavigationBar(displayId);
+ }
+
+ @Override
public boolean isHardKeyboardAvailable() {
synchronized (mGlobalLock) {
return mHardKeyboardAvailable;