Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaa347bc authored by Keisuke Kuroyanagi's avatar Keisuke Kuroyanagi Committed by Android (Google) Code Review
Browse files

Merge "Add VERSION4_TEST for testing."

parents 82fa755b 455dc84c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -540,7 +540,9 @@ public final class BinaryDictionary extends Dictionary {
        close();
        final File dictFile = new File(mDictFilePath);
        final File tmpDictFile = new File(tmpDictFilePath);
        FileUtils.deleteRecursively(dictFile);
        if (!FileUtils.deleteRecursively(dictFile)) {
            return false;
        }
        if (!BinaryDictionaryUtils.renameDict(tmpDictFile, dictFile)) {
            return false;
        }
+3 −2
Original line number Diff line number Diff line
@@ -112,8 +112,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
    }

    private boolean needsToMigrateDictionary(final int formatVersion) {
        // TODO: Check version.
        return false;
        // When we bump up the dictionary format version, the old version should be added to here
        // for supporting migration. Note that native code has to support reading such formats.
        return formatVersion == FormatSpec.VERSION4_ONLY_FOR_TESTING;
    }

    public boolean isValidDictionaryLocked() {
+5 −0
Original line number Diff line number Diff line
@@ -186,7 +186,12 @@ public final class FormatSpec {
    // From version 4 on, we use version * 100 + revision as a version number. That allows
    // us to change the format during development while having testing devices remove
    // older files with each upgrade, while still having a readable versioning scheme.
    // When we bump up the dictionary format version, we should update
    // ExpandableDictionary.needsToMigrateDictionary() and
    // ExpandableDictionary.matchesExpectedBinaryDictFormatVersionForThisType().
    public static final int VERSION2 = 2;
    // Dictionary version used for testing.
    public static final int VERSION4_ONLY_FOR_TESTING = 399;
    public static final int VERSION4 = 401;
    static final int MINIMUM_SUPPORTED_VERSION = VERSION2;
    static final int MAXIMUM_SUPPORTED_VERSION = VERSION4;
+2 −0
Original line number Diff line number Diff line
@@ -139,6 +139,8 @@ class HeaderPolicy : public DictionaryHeaderStructurePolicy {
        switch (mDictFormatVersion) {
            case FormatUtils::VERSION_2:
                return FormatUtils::VERSION_2;
            case FormatUtils::VERSION_4_ONLY_FOR_TESTING:
                return FormatUtils::VERSION_4_ONLY_FOR_TESTING;
            case FormatUtils::VERSION_4:
                return FormatUtils::VERSION_4;
            default:
+2 −1
Original line number Diff line number Diff line
@@ -98,8 +98,9 @@ typedef DictionaryHeaderStructurePolicy::AttributeMap AttributeMap;
        case FormatUtils::VERSION_2:
            // Version 2 dictionary writing is not supported.
            return false;
        case FormatUtils::VERSION_4_ONLY_FOR_TESTING:
        case FormatUtils::VERSION_4:
            return buffer->writeUintAndAdvancePosition(FormatUtils::VERSION_4 /* data */,
            return buffer->writeUintAndAdvancePosition(version /* data */,
                    HEADER_DICTIONARY_VERSION_SIZE, writingPos);
        default:
            return false;
Loading