Simplify IMMS#calledFromValidUserLocked()
With my previous CL [1], IMMS#calledFromValidUserLocked() now always
gets called with the same parameter. Let's simplify it.
This is a mechanical refactoring. There should be no behavior change.
[1]: Ieb94ed14698ee2669adc5fb2ea0e93c7d0e09e8b
716897ce2ee155b3bda109bc5092b142fd63c350
Bug: 34886274
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: I571db5a648ddf8b35caad3d3b64549b7cc067d14
diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
index 2d197bb..52074a7 100644
--- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java
@@ -1607,7 +1607,7 @@
// 1) it comes from the system process
// 2) the calling process' user id is identical to the current user id IMMS thinks.
@GuardedBy("mMethodMap")
- private boolean calledFromValidUserLocked(boolean allowCrossProfileAccess) {
+ private boolean calledFromValidUserLocked() {
final int uid = Binder.getCallingUid();
final int userId = UserHandle.getUserId(uid);
if (DEBUG) {
@@ -1623,7 +1623,7 @@
if (userId == mSettings.getCurrentUserId()) {
return true;
}
- if (allowCrossProfileAccess && mSettings.isCurrentProfile(userId)) {
+ if (!PER_PROFILE_IME_ENABLED && mSettings.isCurrentProfile(userId)) {
return true;
}
@@ -2651,7 +2651,7 @@
ResultReceiver resultReceiver) {
int uid = Binder.getCallingUid();
synchronized (mMethodMap) {
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return false;
}
final long ident = Binder.clearCallingIdentity();
@@ -2736,7 +2736,7 @@
ResultReceiver resultReceiver) {
int uid = Binder.getCallingUid();
synchronized (mMethodMap) {
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return false;
}
final long ident = Binder.clearCallingIdentity();
@@ -3087,7 +3087,7 @@
public void showInputMethodPickerFromClient(
IInputMethodClient client, int auxiliarySubtypeMode) {
synchronized (mMethodMap) {
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return;
}
if(!canShowInputMethodPickerLocked(client)) {
@@ -3159,7 +3159,7 @@
IInputMethodClient client, String inputMethodId) {
synchronized (mMethodMap) {
// TODO(yukawa): Should we verify the display ID?
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return;
}
executeOrSendMessage(mCurMethod, mCaller.obtainMessageO(
@@ -3274,7 +3274,7 @@
@Override
public InputMethodSubtype getLastInputMethodSubtype() {
synchronized (mMethodMap) {
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return null;
}
final Pair<String, String> lastIme = mSettings.getLastInputMethodAndSubtypeLocked();
@@ -3312,7 +3312,7 @@
}
}
synchronized (mMethodMap) {
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return;
}
if (!mSystemReady) {
@@ -4158,7 +4158,7 @@
public InputMethodSubtype getCurrentInputMethodSubtype() {
synchronized (mMethodMap) {
// TODO: Make this work even for non-current users?
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return null;
}
return getCurrentInputMethodSubtypeLocked();
@@ -4208,7 +4208,7 @@
public boolean setCurrentInputMethodSubtype(InputMethodSubtype subtype) {
synchronized (mMethodMap) {
// TODO: Make this work even for non-current users?
- if (!calledFromValidUserLocked(!PER_PROFILE_IME_ENABLED)) {
+ if (!calledFromValidUserLocked()) {
return false;
}
if (subtype != null && mCurMethodId != null) {