Skip to content

Commit 1af0841

Browse files
satok16Android (Google) Code Review
authored andcommitted
Merge "Hide current soft input when a background user gains window focus." into jb-mr1.1-dev
2 parents de0bf8b + 8d03305 commit 1af0841

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

services/java/com/android/server/InputMethodManagerService.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,9 +1824,9 @@ boolean hideCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
18241824
public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder windowToken,
18251825
int controlFlags, int softInputMode, int windowFlags,
18261826
EditorInfo attribute, IInputContext inputContext) {
1827-
if (!calledFromValidUser()) {
1828-
return null;
1829-
}
1827+
// Needs to check the validity before clearing calling identity
1828+
final boolean calledFromValidUser = calledFromValidUser();
1829+
18301830
InputBindResult res = null;
18311831
long ident = Binder.clearCallingIdentity();
18321832
try {
@@ -1856,6 +1856,14 @@ public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder wind
18561856
} catch (RemoteException e) {
18571857
}
18581858

1859+
if (!calledFromValidUser) {
1860+
Slog.w(TAG, "A background user is requesting window. Hiding IME.");
1861+
Slog.w(TAG, "If you want to interect with IME, you need "
1862+
+ "android.permission.INTERACT_ACROSS_USERS_FULL");
1863+
hideCurrentInputLocked(0, null);
1864+
return null;
1865+
}
1866+
18591867
if (mCurFocusedWindow == windowToken) {
18601868
Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
18611869
+ " attribute=" + attribute + ", token = " + windowToken);

0 commit comments

Comments
 (0)