aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorDan Zivkovic <zivkovic@google.com>2015-03-26 15:33:12 -0700
committerDan Zivkovic <zivkovic@google.com>2015-03-26 15:33:12 -0700
commit68c88982178d9c40a0dc9e2edd2340632b0429b2 (patch)
tree9badf2c70f954a58607d8240d9152fa77e2ce776 /java/src
parent8f526c9a55e0b30f81dcca07dc4f5f4fd341bdb1 (diff)
downloadlatinime-68c88982178d9c40a0dc9e2edd2340632b0429b2.tar.gz
latinime-68c88982178d9c40a0dc9e2edd2340632b0429b2.tar.xz
latinime-68c88982178d9c40a0dc9e2edd2340632b0429b2.zip
Handle missing resources.
Needed for unit tests related to various bug fixes. Bug 19930761. Change-Id: I776ccccb032e3d1b181b02c6bb768500790870f7
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index e00532aa6..f4300c462 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -91,10 +91,15 @@ final public class BinaryDictionaryGetter {
*/
public static AssetFileAddress loadFallbackResource(final Context context,
final int fallbackResId) {
- final AssetFileDescriptor afd = context.getResources().openRawResourceFd(fallbackResId);
+ AssetFileDescriptor afd = null;
+ try {
+ afd = context.getResources().openRawResourceFd(fallbackResId);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Resource not found: " + fallbackResId, e);
+ return null;
+ }
if (afd == null) {
- Log.e(TAG, "Found the resource but cannot read it. Is it compressed? resId="
- + fallbackResId);
+ Log.e(TAG, "Resource cannot be opened: " + fallbackResId);
return null;
}
try {
@@ -103,8 +108,7 @@ final public class BinaryDictionaryGetter {
} finally {
try {
afd.close();
- } catch (IOException e) {
- // Ignored
+ } catch (IOException ignored) {
}
}
}