diff options
| author | 2018-10-21 20:15:11 -0700 | |
|---|---|---|
| committer | 2018-10-21 20:15:11 -0700 | |
| commit | 499e3f764e21dcee109121ef7c09795d7876112c (patch) | |
| tree | d5dc562ae96be1897b45b1190dec7e83c6ad79ad | |
| parent | 4219422bb3f8dfe10bf89e562107dd850148af21 (diff) | |
Extract UnbindReason from InputMethodClient
This is another step to split InputMethodClient into multiple classes.
With this CL, InputMethodClient is completely removed.
This is a mechanical refactoring. There should be no user-visible
behavior change.
Bug: 118040692
Test: prebuilts/checkstyle/checkstyle.py -f \
frameworks/base/core/java/com/android/internal/inputmethod/UnbindReason.java
Change-Id: I3b96a351413025338776f6c87cbaa8cf28c3a44f
6 files changed, 87 insertions, 62 deletions
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 1157a6db5a89..e370e1175de5 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -62,6 +62,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.inputmethod.InputMethodDebug; import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.inputmethod.StartInputReason; +import com.android.internal.inputmethod.UnbindReason; import com.android.internal.os.SomeArgs; import com.android.internal.view.IInputConnectionWrapper; import com.android.internal.view.IInputContext; @@ -69,7 +70,6 @@ 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 java.io.FileDescriptor; import java.io.PrintWriter; @@ -547,7 +547,7 @@ public final class InputMethodManager { } case MSG_UNBIND: { final int sequence = msg.arg1; - @InputMethodClient.UnbindReason + @UnbindReason final int reason = msg.arg2; if (DEBUG) { Log.i(TAG, "handleMessage: MSG_UNBIND " + sequence + @@ -695,7 +695,7 @@ public final class InputMethodManager { } @Override - public void onUnbindMethod(int sequence, @InputMethodClient.UnbindReason int unbindReason) { + public void onUnbindMethod(int sequence, @UnbindReason int unbindReason) { mH.obtainMessage(MSG_UNBIND, sequence, unbindReason).sendToTarget(); } diff --git a/core/java/com/android/internal/inputmethod/InputMethodDebug.java b/core/java/com/android/internal/inputmethod/InputMethodDebug.java index 94e8c228835a..aa01e4bbbb91 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodDebug.java +++ b/core/java/com/android/internal/inputmethod/InputMethodDebug.java @@ -19,9 +19,6 @@ package com.android.internal.inputmethod; import android.view.WindowManager; import android.view.WindowManager.LayoutParams.SoftInputModeFlags; -import com.android.internal.view.InputMethodClient; -import com.android.internal.view.InputMethodClient.UnbindReason; - /** * Provides useful methods for debugging. */ @@ -73,19 +70,19 @@ public final class InputMethodDebug { */ public static String unbindReasonToString(@UnbindReason int reason) { switch (reason) { - case InputMethodClient.UNBIND_REASON_UNSPECIFIED: + case UnbindReason.UNBIND_REASON_UNSPECIFIED: return "UNSPECIFIED"; - case InputMethodClient.UNBIND_REASON_SWITCH_CLIENT: + case UnbindReason.UNBIND_REASON_SWITCH_CLIENT: return "SWITCH_CLIENT"; - case InputMethodClient.UNBIND_REASON_SWITCH_IME: + case UnbindReason.UNBIND_REASON_SWITCH_IME: return "SWITCH_IME"; - case InputMethodClient.UNBIND_REASON_DISCONNECT_IME: + case UnbindReason.UNBIND_REASON_DISCONNECT_IME: return "DISCONNECT_IME"; - case InputMethodClient.UNBIND_REASON_NO_IME: + case UnbindReason.UNBIND_REASON_NO_IME: return "NO_IME"; - case InputMethodClient.UNBIND_REASON_SWITCH_IME_FAILED: + case UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED: return "SWITCH_IME_FAILED"; - case InputMethodClient.UNBIND_REASON_SWITCH_USER: + case UnbindReason.UNBIND_REASON_SWITCH_USER: return "SWITCH_USER"; default: return "Unknown=" + reason; diff --git a/core/java/com/android/internal/inputmethod/UnbindReason.java b/core/java/com/android/internal/inputmethod/UnbindReason.java new file mode 100644 index 000000000000..8b46c8a16bd6 --- /dev/null +++ b/core/java/com/android/internal/inputmethod/UnbindReason.java @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2018 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.inputmethod; + +import static java.lang.annotation.RetentionPolicy.SOURCE; + +import android.annotation.IntDef; + +import java.lang.annotation.Retention; + +/** + * Describes the reason why {@link com.android.server.inputmethod.InputMethodManagerService} is + * calling {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}. + */ +@Retention(SOURCE) +@IntDef(prefix = "UNBIND_REASON_", value = { + UnbindReason.UNBIND_REASON_UNSPECIFIED, + UnbindReason.UNBIND_REASON_SWITCH_CLIENT, + UnbindReason.UNBIND_REASON_SWITCH_IME, + UnbindReason.UNBIND_REASON_DISCONNECT_IME, + UnbindReason.UNBIND_REASON_NO_IME, + UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED, + UnbindReason.UNBIND_REASON_SWITCH_USER}) +public @interface UnbindReason { + /** + * Reason is not specified. + */ + int UNBIND_REASON_UNSPECIFIED = 0; + /** + * When a new IME client becomes active, the previous IME client will unbound from the current + * IME. + */ + int UNBIND_REASON_SWITCH_CLIENT = 1; + /** + * Before a new IME becomes active, the current IME client be unbound from the previous IME. + */ + int UNBIND_REASON_SWITCH_IME = 2; + /** + * When the current IME is disconnected, the current IME client will be unbound. + */ + int UNBIND_REASON_DISCONNECT_IME = 3; + /** + * When the system loses the last enabled IME, the current IME client will be unbound. + */ + int UNBIND_REASON_NO_IME = 4; + /** + * When the system failed to switch to another IME, the current IME client will be unbound. + */ + int UNBIND_REASON_SWITCH_IME_FAILED = 5; + /** + * When a new user becomes foreground, the previous IME client will be unbound from the previous + * user's active IME. + */ + int UNBIND_REASON_SWITCH_USER = 6; +} diff --git a/core/java/com/android/internal/view/IInputMethodClient.aidl b/core/java/com/android/internal/view/IInputMethodClient.aidl index 2618356d7a09..17b2bc46de36 100644 --- a/core/java/com/android/internal/view/IInputMethodClient.aidl +++ b/core/java/com/android/internal/view/IInputMethodClient.aidl @@ -24,7 +24,6 @@ import com.android.internal.view.InputBindResult; */ oneway interface IInputMethodClient { void onBindMethod(in InputBindResult res); - // unbindReason corresponds to InputMethodClient.UnbindReason. void onUnbindMethod(int sequence, int unbindReason); void setActive(boolean active, boolean fullscreen); void reportFullscreenMode(boolean fullscreen); diff --git a/core/java/com/android/internal/view/InputMethodClient.java b/core/java/com/android/internal/view/InputMethodClient.java deleted file mode 100644 index e4adaaf81fae..000000000000 --- a/core/java/com/android/internal/view/InputMethodClient.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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_SWITCH_USER = 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_SWITCH_USER}) - public @interface UnbindReason {} -} diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index cf1d0a496a58..f025eebc4b37 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -133,6 +133,7 @@ import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.InputMethodDebug; import com.android.internal.inputmethod.StartInputReason; +import com.android.internal.inputmethod.UnbindReason; import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.internal.notification.SystemNotificationChannels; import com.android.internal.os.HandlerCaller; @@ -148,8 +149,6 @@ 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.internal.view.InputMethodClient.UnbindReason; import com.android.server.EventLogTags; import com.android.server.LocalServices; import com.android.server.SystemService; @@ -1508,7 +1507,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // TODO: Is it really possible that switchUserLocked() happens before system ready? if (mSystemReady) { hideCurrentInputLocked(0, null); - resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_SWITCH_USER); + resetCurrentMethodAndClient(UnbindReason.UNBIND_REASON_SWITCH_USER); buildInputMethodListLocked(initialUserSwitch); if (TextUtils.isEmpty(mSettings.getSelectedInputMethod())) { // This is the first time of the user switch and @@ -1738,7 +1737,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub * {@link InputMethodManagerService}. * * <p>As a general principle, IPCs from the application process that take - * {@link InputMethodClient} will be rejected without this step.</p> + * {@link IInputMethodClient} will be rejected without this step.</p> * * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client @@ -1927,7 +1926,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mCurClientInKeyguard = isKeyguardLocked(); // If the client is changing, we need to switch over to the new // one. - unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_CLIENT); + unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_SWITCH_CLIENT); if (DEBUG) Slog.v(TAG, "switching to client: client=" + cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard); @@ -2171,7 +2170,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mLastBindTime = SystemClock.uptimeMillis(); mShowRequested = mInputShown; mInputShown = false; - unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_DISCONNECT_IME); + unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_DISCONNECT_IME); } } } @@ -2482,12 +2481,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(InputMethodClient.UNBIND_REASON_SWITCH_IME_FAILED); + resetCurrentMethodAndClient(UnbindReason.UNBIND_REASON_SWITCH_IME_FAILED); } mShortcutInputMethodsAndSubtypes.clear(); } else { // There is no longer an input method set, so stop any current one. - resetCurrentMethodAndClient(InputMethodClient.UNBIND_REASON_NO_IME); + resetCurrentMethodAndClient(UnbindReason.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. @@ -2565,7 +2564,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub intent.putExtra("input_method_id", id); mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT); } - unbindCurrentClientLocked(InputMethodClient.UNBIND_REASON_SWITCH_IME); + unbindCurrentClientLocked(UnbindReason.UNBIND_REASON_SWITCH_IME); } finally { Binder.restoreCallingIdentity(ident); } |