From f156cb31c0928cc739c4dc79813d13f92389877e Mon Sep 17 00:00:00 2001 From: Roozbeh Pournader Date: Fri, 15 May 2015 17:34:59 -0700 Subject: Make unicodeWrap() return null if the input string is null. Previously, a NullPointerException was raised if the input was null. Bug: 12894042 Change-Id: I5c5db484e5659659c1da91079adcba773ba7d83d --- core/java/android/text/BidiFormatter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/java/android/text/BidiFormatter.java b/core/java/android/text/BidiFormatter.java index 2a2589ae7ee3..7ea9da1715c4 100644 --- a/core/java/android/text/BidiFormatter.java +++ b/core/java/android/text/BidiFormatter.java @@ -25,7 +25,7 @@ import java.util.Locale; /** * Utility class for formatting text for display in a potentially opposite-directionality context * without garbling. The directionality of the context is set at formatter creation and the - * directionality of the text can be either estimated or passed in when known. + * directionality of the text can be either estimated or passed in when known. * *

To support versions lower than {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}, * you can use the support library's {@link android.support.v4.text.BidiFormatter} class. @@ -377,9 +377,11 @@ public final class BidiFormatter { * See {@link TextDirectionHeuristics} for pre-defined heuristics. * @param isolate Whether to directionally isolate the string to prevent it from garbling the * content around it - * @return Input string after applying the above processing. + * @return Input string after applying the above processing. {@code null} if {@code str} is + * {@code null}. */ public String unicodeWrap(String str, TextDirectionHeuristic heuristic, boolean isolate) { + if (str == null) return null; final boolean isRtl = heuristic.isRtl(str, 0, str.length()); StringBuilder result = new StringBuilder(); if (getStereoReset() && isolate) { -- cgit v1.2.3-59-g8ed1b