@@ -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