NPE when iterating by character and word in Launcher widgets.
1. The character and word iterators were use the application
context to keep track of locale changes. However, for widgets
the context from which the app context is obtained is custom
created therefore the app context is null and the iterators
code does not expect that. Now we are caching the locale
and update it when the configuration changes.
bug:6642281
Change-Id: I3fd201ab9e4efd79e3bdc8afd8ee644e4354a7fb
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index f005eeb..816b631 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6957,7 +6957,8 @@
CharSequence text = getIterableTextForAccessibility();
if (text != null && text.length() > 0) {
CharacterTextSegmentIterator iterator =
- CharacterTextSegmentIterator.getInstance(mContext);
+ CharacterTextSegmentIterator.getInstance(
+ mContext.getResources().getConfiguration().locale);
iterator.initialize(text.toString());
return iterator;
}
@@ -6966,7 +6967,8 @@
CharSequence text = getIterableTextForAccessibility();
if (text != null && text.length() > 0) {
WordTextSegmentIterator iterator =
- WordTextSegmentIterator.getInstance(mContext);
+ WordTextSegmentIterator.getInstance(
+ mContext.getResources().getConfiguration().locale);
iterator.initialize(text.toString());
return iterator;
}