summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/inputmethodservice/InputMethodService.java8
-rw-r--r--core/java/android/view/inputmethod/InputMethod.java8
2 files changed, 9 insertions, 7 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java
index 9295bb7c021c..64c934b332f2 100644
--- a/core/java/android/inputmethodservice/InputMethodService.java
+++ b/core/java/android/inputmethodservice/InputMethodService.java
@@ -450,10 +450,12 @@ public class InputMethodService extends AbstractInputMethodService {
@MainThread
@Override
public void attachToken(IBinder token) {
- if (mToken == null) {
- mToken = token;
- mWindow.setToken(token);
+ if (mToken != null) {
+ throw new IllegalStateException(
+ "attachToken() must be called at most once. token=" + token);
}
+ mToken = token;
+ mWindow.setToken(token);
}
/**
diff --git a/core/java/android/view/inputmethod/InputMethod.java b/core/java/android/view/inputmethod/InputMethod.java
index ab8886bb8479..ca14ebef392b 100644
--- a/core/java/android/view/inputmethod/InputMethod.java
+++ b/core/java/android/view/inputmethod/InputMethod.java
@@ -86,10 +86,10 @@ public interface InputMethod {
* needed to identify itself with the service to validate its operations.
* This token <strong>must not</strong> be passed to applications, since
* it grants special priviledges that should not be given to applications.
- *
- * <p>Note: to protect yourself from malicious clients, you should only
- * accept the first token given to you. Any after that may come from the
- * client.
+ *
+ * <p>The system guarantees that this method is called back between
+ * {@link InputMethodService#onCreate()} and {@link InputMethodService#onDestroy()}
+ * at most once.
*/
@MainThread
public void attachToken(IBinder token);