diff options
author | Gilles Debunne <debunne@google.com> | 2011-12-06 10:27:00 -0800 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2011-12-06 10:29:08 -0800 |
commit | c5436f204ba938219223a57c83586aba543f6888 (patch) | |
tree | 0e71d1a765ccc3f6eb00f1eebe4cc62e74007d89 /core | |
parent | 9a856f4ee7b49f735e31b57a09bee2f033ce20a5 (diff) | |
download | frameworks_base-c5436f204ba938219223a57c83586aba543f6888.zip frameworks_base-c5436f204ba938219223a57c83586aba543f6888.tar.gz frameworks_base-c5436f204ba938219223a57c83586aba543f6888.tar.bz2 |
Prevent NPE in SuggestionSpan
One SuggestionSpan constructor provide null as the default context.
This will always create an NPE in initStyle. Prevent this.
Change-Id: Ic2acffd2c8b9cda9c99b689d1b1a7f15d17b65d0
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/text/style/SuggestionSpan.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/core/java/android/text/style/SuggestionSpan.java b/core/java/android/text/style/SuggestionSpan.java index ed2af10..0f26a34 100644 --- a/core/java/android/text/style/SuggestionSpan.java +++ b/core/java/android/text/style/SuggestionSpan.java @@ -92,11 +92,6 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan { private float mAutoCorrectionUnderlineThickness; private int mAutoCorrectionUnderlineColor; - /* - * TODO: If switching IME is required, needs to add parameters for ids of InputMethodInfo - * and InputMethodSubtype. - */ - /** * @param context Context for the application * @param suggestions Suggestions for the string under the span @@ -146,6 +141,16 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan { } private void initStyle(Context context) { + if (context == null) { + mMisspelledUnderlineThickness = 0; + mEasyCorrectUnderlineThickness = 0; + mAutoCorrectionUnderlineThickness = 0; + mMisspelledUnderlineColor = Color.BLACK; + mEasyCorrectUnderlineColor = Color.BLACK; + mAutoCorrectionUnderlineColor = Color.BLACK; + return; + } + int defStyle = com.android.internal.R.attr.textAppearanceMisspelledSuggestion; TypedArray typedArray = context.obtainStyledAttributes( null, com.android.internal.R.styleable.SuggestionSpan, defStyle, 0); @@ -169,7 +174,6 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan { com.android.internal.R.styleable.SuggestionSpan_textUnderlineThickness, 0); mAutoCorrectionUnderlineColor = typedArray.getColor( com.android.internal.R.styleable.SuggestionSpan_textUnderlineColor, Color.BLACK); - } public SuggestionSpan(Parcel src) { |