From 0cc0544a2995c7eb54a830ae54db60af89d4073d Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 15 Mar 2013 19:00:51 +0900 Subject: Merge the dictionary pack in Latin IME. Bug: 8161354 Change-Id: I17c23f56dd3bc2f27726556bf2c5a9d5520bd172 --- .../AndroidWordLevelSpellCheckerSession.java | 26 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java') 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); + } + } } -- cgit v1.2.3-83-g751a