Native crash -> ISE
Do some basic validation of the Bitmap given to BitmapShader to avoid a subsequent native crash in favor of a proper IllegalStateException Fixes: 274860420 Test: BitmapShaderTest#testRecycledBitmapThrowsISE Change-Id: I9ee64df5fc34909e5c91e979b1d21a4f94ca5e57
This commit is contained in:
@@ -401,8 +401,9 @@ public final class Bitmap implements Parcelable {
|
||||
/**
|
||||
* This is called by methods that want to throw an exception if the bitmap
|
||||
* has already been recycled.
|
||||
* @hide
|
||||
*/
|
||||
private void checkRecycled(String errorMessage) {
|
||||
void checkRecycled(String errorMessage) {
|
||||
if (mRecycled) {
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public class BitmapShader extends Shader {
|
||||
if (bitmap == null) {
|
||||
throw new IllegalArgumentException("Bitmap must be non-null");
|
||||
}
|
||||
bitmap.checkRecycled("Cannot create BitmapShader for recycled bitmap");
|
||||
mBitmap = bitmap;
|
||||
mTileX = tileX;
|
||||
mTileY = tileY;
|
||||
@@ -188,6 +189,8 @@ public class BitmapShader extends Shader {
|
||||
/** @hide */
|
||||
@Override
|
||||
protected long createNativeInstance(long nativeMatrix, boolean filterFromPaint) {
|
||||
mBitmap.checkRecycled("BitmapShader's bitmap has been recycled");
|
||||
|
||||
boolean enableLinearFilter = mFilterMode == FILTER_MODE_LINEAR;
|
||||
if (mFilterMode == FILTER_MODE_DEFAULT) {
|
||||
mFilterFromPaint = filterFromPaint;
|
||||
|
||||
Reference in New Issue
Block a user