Check for existance of hyphenation pattern files first
This CL checks for existance (and readability) of hyphenation pattern
files before trying to read them. The main impact is reducing the
spam in the log due to the failure of calling RandomAccessFile() with
non-existing paths.
Test: Manual
Bug: 31727175
Bug: 36023892
Change-Id: I6963790fa205ab16d4ece548e4cbb0c15e279a14
diff --git a/core/java/android/text/Hyphenator.java b/core/java/android/text/Hyphenator.java
index c2508a6..ea1100e 100644
--- a/core/java/android/text/Hyphenator.java
+++ b/core/java/android/text/Hyphenator.java
@@ -135,6 +135,10 @@
private static Hyphenator loadHyphenator(HyphenationData data) {
String patternFilename = "hyph-" + data.mLanguageTag.toLowerCase(Locale.US) + ".hyb";
File patternFile = new File(getSystemHyphenatorLocation(), patternFilename);
+ if (!patternFile.canRead()) {
+ Log.e(TAG, "hyphenation patterns for " + patternFile + " not found or unreadable");
+ return null;
+ }
try {
RandomAccessFile f = new RandomAccessFile(patternFile, "r");
try {