diff options
author | 2013-12-04 12:47:05 +0900 | |
---|---|---|
committer | 2013-12-04 16:19:55 +0900 | |
commit | 5e80e699c4369d3f4604728952ac3d4bc0bae23a (patch) | |
tree | 8a65896229e2dadf709b4ba8d03024d263c7de39 /java/src/com/android/inputmethod/latin/BinaryDictionary.java | |
parent | 294fe541c8689a1cb0783e16b83159a035464a5c (diff) | |
download | latinime-5e80e699c4369d3f4604728952ac3d4bc0bae23a.tar.gz latinime-5e80e699c4369d3f4604728952ac3d4bc0bae23a.tar.xz latinime-5e80e699c4369d3f4604728952ac3d4bc0bae23a.zip |
[RF1] Remove files that don't match the expected format, step 1
This implements the skeleton implementation, and enables a
fallback implementation in the case the file is coming from the
dictionary provider.
- A better scheme should be used for provider-supplied dicts.
- This does not implement the solution for device-generated
dicts yet. This will come in a future change.
- This does not implement the checking process on the native
side yet. This will come in a future change.
Bug: 11281748
Change-Id: Ifa6e237d19dfbffe503e3674915480ea867b0ddf
Diffstat (limited to 'java/src/com/android/inputmethod/latin/BinaryDictionary.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/BinaryDictionary.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java index 174bbfb8e..438f67e35 100644 --- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java @@ -121,6 +121,7 @@ public final class BinaryDictionary extends Dictionary { String[] attributeKeyStringArray, String[] attributeValueStringArray); private static native long openNative(String sourceDir, long dictOffset, long dictSize, boolean isUpdatable); + private static native boolean hasValidContentsNative(long dict); private static native void flushNative(long dict, String filePath); private static native boolean needsToRunGCNative(long dict, boolean mindsBlockByGC); private static native void flushWithGCNative(long dict, String filePath); @@ -242,6 +243,10 @@ public final class BinaryDictionary extends Dictionary { return mNativeDict != 0; } + public boolean hasValidContents() { + return hasValidContentsNative(mNativeDict); + } + public int getFormatVersion() { return getFormatVersionNative(mNativeDict); } @@ -376,7 +381,7 @@ public final class BinaryDictionary extends Dictionary { private void reopen() { close(); final File dictFile = new File(mDictFilePath); - // WARNING: Because we pass 0 as the offstet and file.length() as the length, this can + // WARNING: Because we pass 0 as the offset and file.length() as the length, this can // only be called for actual files. Right now it's only called by the flush() family of // functions, which require an updatable dictionary, so it's okay. But beware. loadDictionary(dictFile.getAbsolutePath(), 0 /* startOffset */, |