Fix a bug with the passed dictionary id
We used to make the dictionary that we passed to the dictionary pack as an initial value based on the locale. This is wrong - it should be read from the dictionary. This change fixes that. Bug: 7005813 Change-Id: Ib08ed31dd9c216f6f7b9c6c3174ca514bf96e06f
This commit is contained in:
parent
8f794c72db
commit
2521edec09
2 changed files with 11 additions and 6 deletions
|
@ -41,8 +41,6 @@ public class DictionaryInfoUtils {
|
||||||
private static final String RESOURCE_PACKAGE_NAME =
|
private static final String RESOURCE_PACKAGE_NAME =
|
||||||
DictionaryInfoUtils.class.getPackage().getName();
|
DictionaryInfoUtils.class.getPackage().getName();
|
||||||
private static final String DEFAULT_MAIN_DICT = "main";
|
private static final String DEFAULT_MAIN_DICT = "main";
|
||||||
private static final String ID_CATEGORY_SEPARATOR =
|
|
||||||
BinaryDictionaryGetter.ID_CATEGORY_SEPARATOR;
|
|
||||||
private static final String MAIN_DICT_PREFIX = "main_";
|
private static final String MAIN_DICT_PREFIX = "main_";
|
||||||
// 6 digits - unicode is limited to 21 bits
|
// 6 digits - unicode is limited to 21 bits
|
||||||
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
|
private static final int MAX_HEX_DIGITS_FOR_CODEPOINT = 6;
|
||||||
|
@ -58,12 +56,12 @@ public class DictionaryInfoUtils {
|
||||||
public final AssetFileAddress mFileAddress;
|
public final AssetFileAddress mFileAddress;
|
||||||
public final int mVersion;
|
public final int mVersion;
|
||||||
public final String mId;
|
public final String mId;
|
||||||
public DictionaryInfo(final Locale locale, final AssetFileAddress fileAddress,
|
public DictionaryInfo(final String id, final Locale locale,
|
||||||
final int version) {
|
final AssetFileAddress fileAddress, final int version) {
|
||||||
|
mId = id;
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
mFileAddress = fileAddress;
|
mFileAddress = fileAddress;
|
||||||
mVersion = version;
|
mVersion = version;
|
||||||
mId = DEFAULT_MAIN_DICT + ID_CATEGORY_SEPARATOR + mLocale;
|
|
||||||
}
|
}
|
||||||
public ContentValues toContentValues() {
|
public ContentValues toContentValues() {
|
||||||
final ContentValues values = new ContentValues();
|
final ContentValues values = new ContentValues();
|
||||||
|
@ -283,9 +281,10 @@ public class DictionaryInfoUtils {
|
||||||
final AssetFileAddress fileAddress) {
|
final AssetFileAddress fileAddress) {
|
||||||
final FileHeader header = BinaryDictIOUtils.getDictionaryFileHeaderOrNull(
|
final FileHeader header = BinaryDictIOUtils.getDictionaryFileHeaderOrNull(
|
||||||
new File(fileAddress.mFilename), fileAddress.mOffset, fileAddress.mLength);
|
new File(fileAddress.mFilename), fileAddress.mOffset, fileAddress.mLength);
|
||||||
|
final String id = header.getId();
|
||||||
final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString());
|
final Locale locale = LocaleUtils.constructLocaleFromString(header.getLocaleString());
|
||||||
final String version = header.getVersion();
|
final String version = header.getVersion();
|
||||||
return new DictionaryInfo(locale, fileAddress, Integer.parseInt(version));
|
return new DictionaryInfo(id, locale, fileAddress, Integer.parseInt(version));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList,
|
private static void addOrUpdateDictInfo(final ArrayList<DictionaryInfo> dictList,
|
||||||
|
|
|
@ -258,6 +258,7 @@ public final class FormatSpec {
|
||||||
public final FormatOptions mFormatOptions;
|
public final FormatOptions mFormatOptions;
|
||||||
private static final String DICTIONARY_VERSION_ATTRIBUTE = "version";
|
private static final String DICTIONARY_VERSION_ATTRIBUTE = "version";
|
||||||
private static final String DICTIONARY_LOCALE_ATTRIBUTE = "locale";
|
private static final String DICTIONARY_LOCALE_ATTRIBUTE = "locale";
|
||||||
|
private static final String DICTIONARY_ID_ATTRIBUTE = "dictionary";
|
||||||
public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions,
|
public FileHeader(final int headerSize, final DictionaryOptions dictionaryOptions,
|
||||||
final FormatOptions formatOptions) {
|
final FormatOptions formatOptions) {
|
||||||
mHeaderSize = headerSize;
|
mHeaderSize = headerSize;
|
||||||
|
@ -274,6 +275,11 @@ public final class FormatSpec {
|
||||||
public String getVersion() {
|
public String getVersion() {
|
||||||
return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_VERSION_ATTRIBUTE);
|
return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_VERSION_ATTRIBUTE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper method to get the dictionary ID as a String
|
||||||
|
public String getId() {
|
||||||
|
return mDictionaryOptions.mAttributes.get(FileHeader.DICTIONARY_ID_ATTRIBUTE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FormatSpec() {
|
private FormatSpec() {
|
||||||
|
|
Loading…
Reference in a new issue