am 38b54262: Merge "Add a parameter isUpdatable to the constructor of BinaryDictionary."

* commit '38b542629adb4e79cb08f6324f82307784e3da0f':
  Add a parameter isUpdatable to the constructor of BinaryDictionary.
This commit is contained in:
Keisuke Kuroynagi 2013-06-25 01:45:58 -07:00 committed by Android Git Automerger
commit 9a5e0d9cfd
3 changed files with 12 additions and 8 deletions

View file

@ -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

View file

@ -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;

View file

@ -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