Don't crash after unsetting char[] in TextView
TextView.setText(char[]) is from API 1 and follows a running with scissors API style of not copying the passed array. To avoid a leak, in TextView.setText(String), the char[] would be nulled out. However, an internal object could have been read using .getText() prior to this second setText would immmediatly become a CharSequence that crashed when you called any methods on it. After this change, the CharWrapper will stay valid if had been previously retrieved. The general shape of the API will be maintained. Fixes: b/227218386 Test: atest android.widget.TextViewTest Relnote: "Calling TextView.getText() after calling TextView.setText(char[]) will now return a valid CharSequence. The char[] pointed to by this char sequnece may still be mutated by future calls to setText(char[]), but it will no longer allow a (char[]) null to be set, which lead to crashes when reading CharSequence returned from getText on TextView." Change-Id: I35a2a76d58ec1946dace2f615cacf6a6085efdeb
Loading
Please register or sign in to comment