Fix a possible crash

If the dictionary ID, as indicated in the metadata, is
less than three chars long, it crashes LatinIME.
Of course we don't have such dictionary IDs in the current
metadata, but it's still better to be able to handle
the case gracefully ^^;

Change-Id: I60cdf6f8ecce9f4d44b42ddd5d157aebff9a4163
This commit is contained in:
Jean Chalard 2013-02-23 01:41:44 -08:00
parent aefaec3c5f
commit 76ead0ead0

View File

@ -68,9 +68,13 @@ final class BinaryDictionaryGetter {
/**
* Generates a unique temporary file name in the app cache directory.
*/
public static String getTempFileName(String id, Context context) throws IOException {
return File.createTempFile(DictionaryInfoUtils.replaceFileNameDangerousCharacters(id),
null).getAbsolutePath();
public static String getTempFileName(final String id, final Context context)
throws IOException {
final String safeId = DictionaryInfoUtils.replaceFileNameDangerousCharacters(id);
// If the first argument is less than three chars, createTempFile throws a
// RuntimeException. We don't really care about what name we get, so just
// put a three-chars prefix makes us safe.
return File.createTempFile("xxx" + safeId, null).getAbsolutePath();
}
/**