Merge "Update Material Dark theme"
diff --git a/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java b/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
index 8bd9197..09f39a7 100644
--- a/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/TextInfoCompatUtils.java
@@ -22,7 +22,6 @@
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.util.Locale;
 
 @UsedForTesting
 public final class TextInfoCompatUtils {
@@ -50,9 +49,18 @@
                 sequenceNumber);
     }
 
+    /**
+     * Returns the result of {@link TextInfo#getCharSequence()} when available. Otherwise returns
+     * the result of {@link TextInfo#getText()} as fall back.
+     * @param textInfo the instance for which {@link TextInfo#getCharSequence()} or
+     * {@link TextInfo#getText()} is called.
+     * @return the result of {@link TextInfo#getCharSequence()} when available. Otherwise returns
+     * the result of {@link TextInfo#getText()} as fall back. If {@code textInfo} is {@code null},
+     * returns {@code null}.
+     */
     @UsedForTesting
-    public static CharSequence getCharSequence(final TextInfo textInfo,
-            final CharSequence defaultValue) {
+    public static CharSequence getCharSequenceOrString(final TextInfo textInfo) {
+        final CharSequence defaultValue = (textInfo == null ? null : textInfo.getText());
         return (CharSequence) CompatUtils.invoke(textInfo, defaultValue,
                 TEXT_INFO_GET_CHAR_SEQUENCE);
     }
diff --git a/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java b/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
index 5721ed1..c399cce 100644
--- a/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
+++ b/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
@@ -58,7 +58,7 @@
         final Spanned expectedSpanned = (Spanned) text.subSequence(TEST_CHAR_SEQUENCE_START,
                 TEST_CHAR_SEQUENCE_END);
         final CharSequence actualCharSequence =
-                TextInfoCompatUtils.getCharSequence(textInfo, textInfo.getText());
+                TextInfoCompatUtils.getCharSequenceOrString(textInfo);
 
         // This should be valid even if TextInfo#getCharSequence is not supported.
         assertTrue(TextUtils.equals(expectedSpanned, actualCharSequence));