Skip to content

Commit 8d03305

Browse files
committed
Hide current soft input when a background user gains window focus.
Bug: 7507226 Change-Id: If58f68469e21eaaba8536c4b54b3aa8cf8c08eb5
1 parent 2656abe commit 8d03305

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,9 +1814,9 @@ boolean hideCurrentInputLocked(int flags, ResultReceiver resultReceiver) {
18141814
public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder windowToken,
18151815
int controlFlags, int softInputMode, int windowFlags,
18161816
EditorInfo attribute, IInputContext inputContext) {
1817-
if (!calledFromValidUser()) {
1818-
return null;
1819-
}
1817+
// Needs to check the validity before clearing calling identity
1818+
final boolean calledFromValidUser = calledFromValidUser();
1819+
18201820
InputBindResult res = null;
18211821
long ident = Binder.clearCallingIdentity();
18221822
try {
@@ -1846,6 +1846,14 @@ public InputBindResult windowGainedFocus(IInputMethodClient client, IBinder wind
18461846
} catch (RemoteException e) {
18471847
}
18481848

1849+
if (!calledFromValidUser) {
1850+
Slog.w(TAG, "A background user is requesting window. Hiding IME.");
1851+
Slog.w(TAG, "If you want to interect with IME, you need "
1852+
+ "android.permission.INTERACT_ACROSS_USERS_FULL");
1853+
hideCurrentInputLocked(0, null);
1854+
return null;
1855+
}
1856+
18491857
if (mCurFocusedWindow == windowToken) {
18501858
Slog.w(TAG, "Window already focused, ignoring focus gain of: " + client
18511859
+ " attribute=" + attribute + ", token = " + windowToken);

0 commit comments

Comments
 (0)