From 981717da4c414caee57ba98596f9bc634a97f74f Mon Sep 17 00:00:00 2001 From: Keisuke Kuroynagi Date: Tue, 25 Jun 2013 17:39:06 +0900 Subject: [PATCH] Add a parameter isUpdatable to the constructor of BinaryDictionary. Bug: 6669677 Change-Id: I6bc25131afd97112e3bbde036a81ab559a9a6460 --- .../android/inputmethod/latin/BinaryDictionary.java | 10 ++++++---- .../android/inputmethod/latin/DictionaryFactory.java | 8 +++++--- .../inputmethod/latin/ExpandableBinaryDictionary.java | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 4425d7d25..f36c9e878 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -78,13 +78,15 @@ public final class BinaryDictionary extends Dictionary { * @param length the length of the binary data. * @param useFullEditDistance whether to use the full edit distance in suggestions * @param dictType the dictionary type, as a human-readable string + * @param isUpdatable whether to open the dictionary file in writable mode. */ public BinaryDictionary(final String filename, final long offset, final long length, - final boolean useFullEditDistance, final Locale locale, final String dictType) { + final boolean useFullEditDistance, final Locale locale, final String dictType, + final boolean isUpdatable) { super(dictType); mLocale = locale; mNativeSuggestOptions.setUseFullEditDistance(useFullEditDistance); - loadDictionary(filename, offset, length); + loadDictionary(filename, offset, length, isUpdatable); } static { @@ -106,8 +108,8 @@ public final class BinaryDictionary extends Dictionary { // TODO: Move native dict into session private final void loadDictionary(final String path, final long startOffset, - final long length) { - mNativeDict = openNative(path, startOffset, length, false /* isUpdatable */); + final long length, final boolean isUpdatable) { + mNativeDict = openNative(path, startOffset, length, isUpdatable); } @Override diff --git a/java/src/com/android/inputmethod/latin/DictionaryFactory.java b/java/src/com/android/inputmethod/latin/DictionaryFactory.java index 5b98613a4..3721132c5 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFactory.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFactory.java @@ -60,7 +60,8 @@ public final class DictionaryFactory { if (null != assetFileList) { for (final AssetFileAddress f : assetFileList) { final BinaryDictionary binaryDictionary = new BinaryDictionary(f.mFilename, - f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN); + f.mOffset, f.mLength, useFullEditDistance, locale, Dictionary.TYPE_MAIN, + false /* isUpdatable */); if (binaryDictionary.isValidDictionary()) { dictList.add(binaryDictionary); } @@ -113,7 +114,8 @@ public final class DictionaryFactory { return null; } return new BinaryDictionary(sourceDir, afd.getStartOffset(), afd.getLength(), - false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN); + false /* useFullEditDistance */, locale, Dictionary.TYPE_MAIN, + false /* isUpdatable */); } catch (android.content.res.Resources.NotFoundException e) { Log.e(TAG, "Could not find the resource"); return null; @@ -142,7 +144,7 @@ public final class DictionaryFactory { for (final AssetFileAddress address : dictionaryList) { final BinaryDictionary binaryDictionary = new BinaryDictionary(address.mFilename, address.mOffset, address.mLength, useFullEditDistance, locale, - Dictionary.TYPE_MAIN); + Dictionary.TYPE_MAIN, false /* isUpdatable */); dictionaryCollection.addDictionary(binaryDictionary); } return dictionaryCollection; diff --git a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java index f357e2a1e..9cdb86c2d 100644 --- a/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ExpandableBinaryDictionary.java @@ -286,7 +286,7 @@ abstract public class ExpandableBinaryDictionary extends Dictionary { // Build the new binary dictionary final BinaryDictionary newBinaryDictionary = new BinaryDictionary(filename, 0, length, - true /* useFullEditDistance */, null, mDictType); + true /* useFullEditDistance */, null, mDictType, false /* isUpdatable */); if (mBinaryDictionary != null) { // Ensure all threads accessing the current dictionary have finished before swapping in