@@ -139,6 +139,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
139139
140140 static final int MSG_UNBIND_METHOD = 3000 ;
141141 static final int MSG_BIND_METHOD = 3010 ;
142+ static final int MSG_SET_ACTIVE = 3020 ;
142143
143144 static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000 ;
144145
@@ -413,13 +414,9 @@ public void onReceive(Context context, Intent intent) {
413414 }
414415
415416 // Inform the current client of the change in active status
416- try {
417- if (mCurClient != null && mCurClient .client != null ) {
418- mCurClient .client .setActive (mScreenOn );
419- }
420- } catch (RemoteException e ) {
421- Slog .w (TAG , "Got RemoteException sending 'screen on/off' notification to pid "
422- + mCurClient .pid + " uid " + mCurClient .uid );
417+ if (mCurClient != null && mCurClient .client != null ) {
418+ executeOrSendMessage (mCurClient .client , mCaller .obtainMessageIO (
419+ MSG_SET_ACTIVE , mScreenOn ? 1 : 0 , mCurClient ));
423420 }
424421 }
425422 }
@@ -882,17 +879,12 @@ void unbindCurrentClientLocked() {
882879 MSG_UNBIND_INPUT , mCurMethod ));
883880 }
884881 }
882+
883+ executeOrSendMessage (mCurClient .client , mCaller .obtainMessageIO (
884+ MSG_SET_ACTIVE , 0 , mCurClient ));
885885 executeOrSendMessage (mCurClient .client , mCaller .obtainMessageIO (
886886 MSG_UNBIND_METHOD , mCurSeq , mCurClient .client ));
887887 mCurClient .sessionRequested = false ;
888-
889- // Call setActive(false) on the old client
890- try {
891- mCurClient .client .setActive (false );
892- } catch (RemoteException e ) {
893- Slog .w (TAG , "Got RemoteException sending setActive(false) notification to pid "
894- + mCurClient .pid + " uid " + mCurClient .uid );
895- }
896888 mCurClient = null ;
897889
898890 hideInputMethodMenuLocked ();
@@ -987,12 +979,8 @@ InputBindResult startInputUncheckedLocked(ClientState cs,
987979
988980 // If the screen is on, inform the new client it is active
989981 if (mScreenOn ) {
990- try {
991- cs .client .setActive (mScreenOn );
992- } catch (RemoteException e ) {
993- Slog .w (TAG , "Got RemoteException sending setActive notification to pid "
994- + cs .pid + " uid " + cs .uid );
995- }
982+ executeOrSendMessage (cs .client , mCaller .obtainMessageIO (
983+ MSG_SET_ACTIVE , mScreenOn ? 1 : 0 , cs ));
996984 }
997985 }
998986
@@ -2140,6 +2128,15 @@ public boolean handleMessage(Message msg) {
21402128 Slog .w (TAG , "Client died receiving input method " + args .arg2 );
21412129 }
21422130 return true ;
2131+ case MSG_SET_ACTIVE :
2132+ try {
2133+ ((ClientState )msg .obj ).client .setActive (msg .arg1 != 0 );
2134+ } catch (RemoteException e ) {
2135+ Slog .w (TAG , "Got RemoteException sending setActive(false) notification to pid "
2136+ + ((ClientState )msg .obj ).pid + " uid "
2137+ + ((ClientState )msg .obj ).uid );
2138+ }
2139+ return true ;
21432140
21442141 // --------------------------------------------------------------
21452142 case MSG_HARD_KEYBOARD_SWITCH_CHANGED :
0 commit comments