Skip to content
Snippets Groups Projects
Commit 68c88982 authored by Dan Zivkovic's avatar Dan Zivkovic
Browse files

Handle missing resources.

Needed for unit tests related to various bug fixes.

Bug 19930761.

Change-Id: I776ccccb032e3d1b181b02c6bb768500790870f7
parent 8f526c9a
No related branches found
No related tags found
No related merge requests found
...@@ -91,10 +91,15 @@ final public class BinaryDictionaryGetter { ...@@ -91,10 +91,15 @@ final public class BinaryDictionaryGetter {
*/ */
public static AssetFileAddress loadFallbackResource(final Context context, public static AssetFileAddress loadFallbackResource(final Context context,
final int fallbackResId) { 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) { if (afd == null) {
Log.e(TAG, "Found the resource but cannot read it. Is it compressed? resId=" Log.e(TAG, "Resource cannot be opened: " + fallbackResId);
+ fallbackResId);
return null; return null;
} }
try { try {
...@@ -103,8 +108,7 @@ final public class BinaryDictionaryGetter { ...@@ -103,8 +108,7 @@ final public class BinaryDictionaryGetter {
} finally { } finally {
try { try {
afd.close(); afd.close();
} catch (IOException e) { } catch (IOException ignored) {
// Ignored
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment