diff options
author | 2015-04-03 01:09:53 +0000 | |
---|---|---|
committer | 2015-04-03 01:09:53 +0000 | |
commit | ceaafa2ff99fd881b5fa6053734a7e38a594638f (patch) | |
tree | 2da611984f304ce4649d046623fb66e6cb89bf0d /java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java | |
parent | 4c326c66e983ece2b8fb6c8b3220c7281e26a7b8 (diff) | |
parent | 9a3598b0ee8ab5d8b90e35d65190ecea1aef7828 (diff) | |
download | latinime-ceaafa2ff99fd881b5fa6053734a7e38a594638f.tar.gz latinime-ceaafa2ff99fd881b5fa6053734a7e38a594638f.tar.xz latinime-ceaafa2ff99fd881b5fa6053734a7e38a594638f.zip |
Merge "Do not throw NPE if the dictionary info is not available on db"
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java b/java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java index 329b9f62e..e5d632fbe 100644 --- a/java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java +++ b/java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java @@ -19,6 +19,7 @@ package com.android.inputmethod.dictionarypack; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; +import android.util.Log; import java.io.IOException; import java.io.InputStreamReader; @@ -30,10 +31,13 @@ import java.util.List; * Helper class to easy up manipulation of dictionary pack metadata. */ public class MetadataHandler { + + public static final String TAG = MetadataHandler.class.getSimpleName(); + // The canonical file name for metadata. This is not the name of a real file on the // device, but a symbolic name used in the database and in metadata handling. It is never // tested against, only used for human-readability as the file name for the metadata. - public final static String METADATA_FILENAME = "metadata.json"; + public static final String METADATA_FILENAME = "metadata.json"; /** * Reads the data from the cursor and store it in metadata objects. @@ -114,6 +118,14 @@ public class MetadataHandler { final String clientId, final String wordListId, final int version) { final ContentValues contentValues = MetadataDbHelper.getContentValuesByWordListId( MetadataDbHelper.getDb(context, clientId), wordListId, version); + if (contentValues == null) { + // TODO: Figure out why this would happen. + // Check if this happens when the metadata gets updated in the background. + Log.e(TAG, String.format( "Unable to find the current metadata for wordlist " + + "(clientId=%s, wordListId=%s, version=%d) on the database", + clientId, wordListId, version)); + return null; + } return WordListMetadata.createFromContentValues(contentValues); } |