Merge "Native crash -> ISE" into udc-dev

This commit is contained in:
Treehugger Robot
2023-04-10 21:18:37 +00:00
committed by Android (Google) Code Review
2 changed files with 5 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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;