Loading core/java/android/view/inputmethod/InputMethodManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.internal.view.IInputMethodClient; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.InputBindResult; import com.android.internal.view.InputMethodClient; import android.annotation.RequiresPermission; import android.content.Context; Loading Loading @@ -440,8 +441,11 @@ public final class InputMethodManager { } case MSG_UNBIND: { final int sequence = msg.arg1; @InputMethodClient.UnbindReason final int reason = msg.arg2; if (DEBUG) { Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence); Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence + " reason=" + InputMethodClient.getUnbindReason(reason)); } final boolean startInput; synchronized (mH) { Loading Loading @@ -569,8 +573,8 @@ public final class InputMethodManager { } @Override public void onUnbindMethod(int sequence) { mH.sendMessage(mH.obtainMessage(MSG_UNBIND, sequence, 0)); public void onUnbindMethod(int sequence, @InputMethodClient.UnbindReason int unbindReason) { mH.sendMessage(mH.obtainMessage(MSG_UNBIND, sequence, unbindReason)); } @Override Loading core/java/com/android/internal/view/IInputMethodClient.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ import com.android.internal.view.InputBindResult; oneway interface IInputMethodClient { void setUsingInputMethod(boolean state); void onBindMethod(in InputBindResult res); void onUnbindMethod(int sequence); // unbindReason corresponds to InputMethodClient.UnbindReason. void onUnbindMethod(int sequence, int unbindReason); void setActive(boolean active); void setUserActionNotificationSequenceNumber(int sequenceNumber); } core/java/com/android/internal/view/InputMethodClient.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.view; import android.annotation.IntDef; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.SOURCE; public final class InputMethodClient { public static final int UNBIND_REASON_UNSPECIFIED = 0; public static final int UNBIND_REASON_SWITCH_CLIENT = 1; public static final int UNBIND_REASON_SWITCH_IME = 2; public static final int UNBIND_REASON_DISCONNECT_IME = 3; public static final int UNBIND_REASON_NO_IME = 4; public static final int UNBIND_REASON_SWITCH_IME_FAILED = 5; public static final int UNBIND_REASON_RESET_IME = 6; @Retention(SOURCE) @IntDef({UNBIND_REASON_UNSPECIFIED, UNBIND_REASON_SWITCH_CLIENT, UNBIND_REASON_SWITCH_IME, UNBIND_REASON_DISCONNECT_IME, UNBIND_REASON_NO_IME, UNBIND_REASON_SWITCH_IME_FAILED, UNBIND_REASON_RESET_IME}) public @interface UnbindReason {} public static String getUnbindReason(@UnbindReason final int reason) { switch (reason) { case UNBIND_REASON_UNSPECIFIED: return "UNSPECIFIED"; case UNBIND_REASON_SWITCH_CLIENT: return "SWITCH_CLIENT"; case UNBIND_REASON_SWITCH_IME: return "SWITCH_IME"; case UNBIND_REASON_DISCONNECT_IME: return "DISCONNECT_IME"; case UNBIND_REASON_NO_IME: return "NO_IME"; case UNBIND_REASON_SWITCH_IME_FAILED: return "SWITCH_IME_FAILED"; case UNBIND_REASON_RESET_IME: return "RESET_IME"; default: return "Unknown=" + reason; } } } services/core/java/com/android/server/InputMethodManagerService.java +22 −18 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; import com.android.internal.view.InputBindResult; import com.android.internal.view.InputMethodClient; import com.android.server.statusbar.StatusBarManagerService; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -160,8 +161,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub static final int MSG_START_INPUT = 2000; static final int MSG_RESTART_INPUT = 2010; static final int MSG_UNBIND_METHOD = 3000; static final int MSG_BIND_METHOD = 3010; static final int MSG_UNBIND_CLIENT = 3000; static final int MSG_BIND_CLIENT = 3010; static final int MSG_SET_ACTIVE = 3020; static final int MSG_SET_INTERACTIVE = 3030; static final int MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 3040; Loading Loading @@ -935,7 +936,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub || (newLocale != null && !newLocale.equals(mLastSystemLocale))) { if (!updateOnlyWhenLocaleChanged) { hideCurrentInputLocked(0, null); resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_RESET_IME); } if (DEBUG) { Slog.i(TAG, "Locale has been changed to " + newLocale); Loading Loading @@ -1208,7 +1209,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } void unbindCurrentClientLocked() { void unbindCurrentClientLocked( /* @InputMethodClient.UnbindReason */ final int unbindClientReason) { if (mCurClient != null) { if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client = " + mCurClient.client.asBinder()); Loading @@ -1222,8 +1224,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_SET_ACTIVE, 0, mCurClient)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_UNBIND_METHOD, mCurSeq, mCurClient.client)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIIO( MSG_UNBIND_CLIENT, mCurSeq, unbindClientReason, mCurClient.client)); mCurClient.sessionRequested = false; mCurClient = null; Loading Loading @@ -1324,7 +1326,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurClientInKeyguard = isKeyguardLocked(); // If the client is changing, we need to switch over to the new // one. unbindCurrentClientLocked(); unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_CLIENT); if (DEBUG) Slog.v(TAG, "switching to client: client = " + cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard); Loading Loading @@ -1479,7 +1481,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub InputBindResult res = attachNewInputLocked(true); if (res.method != null) { executeOrSendMessage(mCurClient.client, mCaller.obtainMessageOO( MSG_BIND_METHOD, mCurClient.client, res)); MSG_BIND_CLIENT, mCurClient.client, res)); } return; } Loading Loading @@ -1518,10 +1520,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub clearCurMethodLocked(); } void resetCurrentMethodAndClient() { void resetCurrentMethodAndClient( /* @InputMethodClient.UnbindReason */ final int unbindClientReason) { mCurMethodId = null; unbindCurrentMethodLocked(false); unbindCurrentClientLocked(); unbindCurrentClientLocked(unbindClientReason); } void requestClientSessionLocked(ClientState cs) { Loading Loading @@ -1588,8 +1591,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mShowRequested = mInputShown; mInputShown = false; if (mCurClient != null) { executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_UNBIND_METHOD, mCurSeq, mCurClient.client)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIIO( MSG_UNBIND_CLIENT, InputMethodClient.UNBIND_REASON_DISCONNECT_IME, mCurSeq, mCurClient.client)); } } } Loading Loading @@ -1874,12 +1878,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); } catch (IllegalArgumentException e) { Slog.w(TAG, "Unknown input method from prefs: " + id, e); resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_SWITCH_IME_FAILED); } mShortcutInputMethodsAndSubtypes.clear(); } else { // There is no longer an input method set, so stop any current one. resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_NO_IME); } // Here is not the perfect place to reset the switching controller. Ideally // mSwitchingController and mSettings should be able to share the same state. Loading Loading @@ -1965,7 +1969,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub intent.putExtra("input_method_id", id); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); } unbindCurrentClientLocked(); unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_IME); } finally { Binder.restoreCallingIdentity(ident); } Loading Loading @@ -2769,14 +2773,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // --------------------------------------------------------- case MSG_UNBIND_METHOD: case MSG_UNBIND_CLIENT: try { ((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1); ((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1, msg.arg2); } catch (RemoteException e) { // There is nothing interesting about the last client dying. } return true; case MSG_BIND_METHOD: { case MSG_BIND_CLIENT: { args = (SomeArgs)msg.obj; IInputMethodClient client = (IInputMethodClient)args.arg1; InputBindResult res = (InputBindResult)args.arg2; Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +7 −3 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import com.android.internal.view.IInputMethodClient; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.InputBindResult; import com.android.internal.view.InputMethodClient; import android.annotation.RequiresPermission; import android.content.Context; Loading Loading @@ -440,8 +441,11 @@ public final class InputMethodManager { } case MSG_UNBIND: { final int sequence = msg.arg1; @InputMethodClient.UnbindReason final int reason = msg.arg2; if (DEBUG) { Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence); Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence + " reason=" + InputMethodClient.getUnbindReason(reason)); } final boolean startInput; synchronized (mH) { Loading Loading @@ -569,8 +573,8 @@ public final class InputMethodManager { } @Override public void onUnbindMethod(int sequence) { mH.sendMessage(mH.obtainMessage(MSG_UNBIND, sequence, 0)); public void onUnbindMethod(int sequence, @InputMethodClient.UnbindReason int unbindReason) { mH.sendMessage(mH.obtainMessage(MSG_UNBIND, sequence, unbindReason)); } @Override Loading
core/java/com/android/internal/view/IInputMethodClient.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,8 @@ import com.android.internal.view.InputBindResult; oneway interface IInputMethodClient { void setUsingInputMethod(boolean state); void onBindMethod(in InputBindResult res); void onUnbindMethod(int sequence); // unbindReason corresponds to InputMethodClient.UnbindReason. void onUnbindMethod(int sequence, int unbindReason); void setActive(boolean active); void setUserActionNotificationSequenceNumber(int sequenceNumber); }
core/java/com/android/internal/view/InputMethodClient.java 0 → 100644 +60 −0 Original line number Diff line number Diff line /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.internal.view; import android.annotation.IntDef; import java.lang.annotation.Retention; import static java.lang.annotation.RetentionPolicy.SOURCE; public final class InputMethodClient { public static final int UNBIND_REASON_UNSPECIFIED = 0; public static final int UNBIND_REASON_SWITCH_CLIENT = 1; public static final int UNBIND_REASON_SWITCH_IME = 2; public static final int UNBIND_REASON_DISCONNECT_IME = 3; public static final int UNBIND_REASON_NO_IME = 4; public static final int UNBIND_REASON_SWITCH_IME_FAILED = 5; public static final int UNBIND_REASON_RESET_IME = 6; @Retention(SOURCE) @IntDef({UNBIND_REASON_UNSPECIFIED, UNBIND_REASON_SWITCH_CLIENT, UNBIND_REASON_SWITCH_IME, UNBIND_REASON_DISCONNECT_IME, UNBIND_REASON_NO_IME, UNBIND_REASON_SWITCH_IME_FAILED, UNBIND_REASON_RESET_IME}) public @interface UnbindReason {} public static String getUnbindReason(@UnbindReason final int reason) { switch (reason) { case UNBIND_REASON_UNSPECIFIED: return "UNSPECIFIED"; case UNBIND_REASON_SWITCH_CLIENT: return "SWITCH_CLIENT"; case UNBIND_REASON_SWITCH_IME: return "SWITCH_IME"; case UNBIND_REASON_DISCONNECT_IME: return "DISCONNECT_IME"; case UNBIND_REASON_NO_IME: return "NO_IME"; case UNBIND_REASON_SWITCH_IME_FAILED: return "SWITCH_IME_FAILED"; case UNBIND_REASON_RESET_IME: return "RESET_IME"; default: return "Unknown=" + reason; } } }
services/core/java/com/android/server/InputMethodManagerService.java +22 −18 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; import com.android.internal.view.InputBindResult; import com.android.internal.view.InputMethodClient; import com.android.server.statusbar.StatusBarManagerService; import org.xmlpull.v1.XmlPullParser; Loading Loading @@ -160,8 +161,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub static final int MSG_START_INPUT = 2000; static final int MSG_RESTART_INPUT = 2010; static final int MSG_UNBIND_METHOD = 3000; static final int MSG_BIND_METHOD = 3010; static final int MSG_UNBIND_CLIENT = 3000; static final int MSG_BIND_CLIENT = 3010; static final int MSG_SET_ACTIVE = 3020; static final int MSG_SET_INTERACTIVE = 3030; static final int MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER = 3040; Loading Loading @@ -935,7 +936,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub || (newLocale != null && !newLocale.equals(mLastSystemLocale))) { if (!updateOnlyWhenLocaleChanged) { hideCurrentInputLocked(0, null); resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_RESET_IME); } if (DEBUG) { Slog.i(TAG, "Locale has been changed to " + newLocale); Loading Loading @@ -1208,7 +1209,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } } void unbindCurrentClientLocked() { void unbindCurrentClientLocked( /* @InputMethodClient.UnbindReason */ final int unbindClientReason) { if (mCurClient != null) { if (DEBUG) Slog.v(TAG, "unbindCurrentInputLocked: client = " + mCurClient.client.asBinder()); Loading @@ -1222,8 +1224,8 @@ public class InputMethodManagerService extends IInputMethodManager.Stub executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_SET_ACTIVE, 0, mCurClient)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_UNBIND_METHOD, mCurSeq, mCurClient.client)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIIO( MSG_UNBIND_CLIENT, mCurSeq, unbindClientReason, mCurClient.client)); mCurClient.sessionRequested = false; mCurClient = null; Loading Loading @@ -1324,7 +1326,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurClientInKeyguard = isKeyguardLocked(); // If the client is changing, we need to switch over to the new // one. unbindCurrentClientLocked(); unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_CLIENT); if (DEBUG) Slog.v(TAG, "switching to client: client = " + cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard); Loading Loading @@ -1479,7 +1481,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub InputBindResult res = attachNewInputLocked(true); if (res.method != null) { executeOrSendMessage(mCurClient.client, mCaller.obtainMessageOO( MSG_BIND_METHOD, mCurClient.client, res)); MSG_BIND_CLIENT, mCurClient.client, res)); } return; } Loading Loading @@ -1518,10 +1520,11 @@ public class InputMethodManagerService extends IInputMethodManager.Stub clearCurMethodLocked(); } void resetCurrentMethodAndClient() { void resetCurrentMethodAndClient( /* @InputMethodClient.UnbindReason */ final int unbindClientReason) { mCurMethodId = null; unbindCurrentMethodLocked(false); unbindCurrentClientLocked(); unbindCurrentClientLocked(unbindClientReason); } void requestClientSessionLocked(ClientState cs) { Loading Loading @@ -1588,8 +1591,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mShowRequested = mInputShown; mInputShown = false; if (mCurClient != null) { executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO( MSG_UNBIND_METHOD, mCurSeq, mCurClient.client)); executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIIO( MSG_UNBIND_CLIENT, InputMethodClient.UNBIND_REASON_DISCONNECT_IME, mCurSeq, mCurClient.client)); } } } Loading Loading @@ -1874,12 +1878,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub setInputMethodLocked(id, mSettings.getSelectedInputMethodSubtypeId(id)); } catch (IllegalArgumentException e) { Slog.w(TAG, "Unknown input method from prefs: " + id, e); resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_SWITCH_IME_FAILED); } mShortcutInputMethodsAndSubtypes.clear(); } else { // There is no longer an input method set, so stop any current one. resetCurrentMethodAndClient(); resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_NO_IME); } // Here is not the perfect place to reset the switching controller. Ideally // mSwitchingController and mSettings should be able to share the same state. Loading Loading @@ -1965,7 +1969,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub intent.putExtra("input_method_id", id); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); } unbindCurrentClientLocked(); unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_IME); } finally { Binder.restoreCallingIdentity(ident); } Loading Loading @@ -2769,14 +2773,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // --------------------------------------------------------- case MSG_UNBIND_METHOD: case MSG_UNBIND_CLIENT: try { ((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1); ((IInputMethodClient)msg.obj).onUnbindMethod(msg.arg1, msg.arg2); } catch (RemoteException e) { // There is nothing interesting about the last client dying. } return true; case MSG_BIND_METHOD: { case MSG_BIND_CLIENT: { args = (SomeArgs)msg.obj; IInputMethodClient client = (IInputMethodClient)args.arg1; InputBindResult res = (InputBindResult)args.arg2; Loading