diff options
author | 2015-04-02 17:50:48 -0700 | |
---|---|---|
committer | 2015-04-02 17:50:48 -0700 | |
commit | 9a3598b0ee8ab5d8b90e35d65190ecea1aef7828 (patch) | |
tree | 021cfbf7c37c2765e8fd009009c5f1d610f19c9f /java/src/com/android/inputmethod/dictionarypack/MetadataHandler.java | |
parent | a0a66638947b5b26e7e1e5cd263a070d9ba50074 (diff) | |
download | latinime-9a3598b0ee8ab5d8b90e35d65190ecea1aef7828.tar.gz latinime-9a3598b0ee8ab5d8b90e35d65190ecea1aef7828.tar.xz latinime-9a3598b0ee8ab5d8b90e35d65190ecea1aef7828.zip |
Do not throw NPE if the dictionary info is not available on db
Bug: 20035793
Change-Id: Idc13af405eab5457954a93db3dddcd81f6eb6435
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); } |