aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-03-15 19:00:51 +0900
committerJean Chalard <jchalard@google.com>2013-03-19 15:40:14 +0900
commit0cc0544a2995c7eb54a830ae54db60af89d4073d (patch)
tree095745e7050c4a8f557f8967217f332874c78f04 /java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
parent5b048292540b6fbbd8929a3622262f352245d464 (diff)
downloadlatinime-0cc0544a2995c7eb54a830ae54db60af89d4073d.tar.gz
latinime-0cc0544a2995c7eb54a830ae54db60af89d4073d.tar.xz
latinime-0cc0544a2995c7eb54a830ae54db60af89d4073d.zip
Merge the dictionary pack in Latin IME.
Bug: 8161354 Change-Id: I17c23f56dd3bc2f27726556bf2c5a9d5520bd172
Diffstat (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java')
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
index cd3f9e442..4f86a3175 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin.spellcheck;
import android.content.ContentResolver;
import android.database.ContentObserver;
+import android.os.Binder;
import android.provider.UserDictionary.Words;
import android.service.textservice.SpellCheckerService.Session;
import android.text.TextUtils;
@@ -234,13 +235,12 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
* corrections for the text passed as an argument. It may split or group words, and
* even perform grammatical analysis.
*/
- @Override
- public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
+ private SuggestionsInfo onGetSuggestionsInternal(final TextInfo textInfo,
final int suggestionsLimit) {
- return onGetSuggestions(textInfo, null, suggestionsLimit);
+ return onGetSuggestionsInternal(textInfo, null, suggestionsLimit);
}
- protected SuggestionsInfo onGetSuggestions(
+ protected SuggestionsInfo onGetSuggestionsInternal(
final TextInfo textInfo, final String prevWord, final int suggestionsLimit) {
try {
final String inText = textInfo.getText();
@@ -357,4 +357,22 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
}
}
}
+
+ /*
+ * The spell checker acts on its own behalf. That is needed, in particular, to be able to
+ * access the dictionary files, which the provider restricts to the identity of Latin IME.
+ * Since it's called externally by the application, the spell checker is using the identity
+ * of the application by default unless we clearCallingIdentity.
+ * That's what the following method does.
+ */
+ @Override
+ public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
+ final int suggestionsLimit) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ return onGetSuggestionsInternal(textInfo, suggestionsLimit);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
}