diff options
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java index e913f2852..294312843 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java @@ -22,6 +22,7 @@ import com.android.inputmethod.latin.makedict.FormatSpec; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.AssetFileDescriptor; import android.util.Log; @@ -95,18 +96,8 @@ final class BinaryDictionaryGetter { private static final class DictPackSettings { final SharedPreferences mDictPreferences; public DictPackSettings(final Context context) { - Context dictPackContext = null; - try { - final String dictPackName = - context.getString(R.string.dictionary_pack_package_name); - dictPackContext = context.createPackageContext(dictPackName, 0); - } catch (NameNotFoundException e) { - // The dictionary pack is not installed... - // TODO: fallback on the built-in dict, see the TODO above - Log.e(TAG, "Could not find a dictionary pack"); - } - mDictPreferences = null == dictPackContext ? null - : dictPackContext.getSharedPreferences(COMMON_PREFERENCES_NAME, + mDictPreferences = null == context ? null + : context.getSharedPreferences(COMMON_PREFERENCES_NAME, Context.MODE_WORLD_READABLE | Context.MODE_MULTI_PROCESS); } public boolean isWordListActive(final String dictId) { @@ -288,10 +279,16 @@ final class BinaryDictionaryGetter { // cacheWordListsFromContentProvider returns the list of files it copied to local // storage, but we don't really care about what was copied NOW: what we want is the // list of everything we ever cached, so we ignore the return value. - // TODO: The experimental version is not supported by the Dictionary Pack Service yet - if (!ProductionFlag.IS_EXPERIMENTAL) { - BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context, - hasDefaultWordList); + // TODO: The development-only-diagnostic version is not supported by the Dictionary Pack + // Service yet + if (!ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { + // We need internet access to do the following. Only do this if the package actually + // has the permission. + if (context.checkCallingOrSelfPermission(android.Manifest.permission.INTERNET) + == PackageManager.PERMISSION_GRANTED) { + BinaryDictionaryFileDumper.cacheWordListsFromContentProvider(locale, context, + hasDefaultWordList); + } } final File[] cachedWordLists = getCachedWordLists(locale.toString(), context); final String mainDictId = DictionaryInfoUtils.getMainDictId(locale); |