Fix edge case crash with invalid bitmap dimensions.

- In these cases, skip returning an animation spec for that task

Bug: 28235453
Change-Id: I611dc4390c0cbd2ca5f16112e4784848b2d6896f
This commit is contained in:
Winson
2016-05-04 17:21:22 -07:00
committed by Winson Chung
parent c1ff12eccd
commit f9e79e0499

View File

@@ -306,8 +306,11 @@ public class RecentsTransitionHelper {
mTmpTransform.fillIn(taskView); mTmpTransform.fillIn(taskView);
stackLayout.transformToScreenCoordinates(mTmpTransform, stackLayout.transformToScreenCoordinates(mTmpTransform,
null /* windowOverrideRect */); null /* windowOverrideRect */);
specs.add(composeAnimationSpec(stackView, taskView, mTmpTransform, AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, taskView,
true /* addHeaderBitmap */)); mTmpTransform, true /* addHeaderBitmap */);
if (spec != null) {
specs.add(spec);
}
} }
return specs; return specs;
} }
@@ -329,8 +332,11 @@ public class RecentsTransitionHelper {
mTmpTransform.fillIn(taskView); mTmpTransform.fillIn(taskView);
stackLayout.transformToScreenCoordinates(mTmpTransform, stackLayout.transformToScreenCoordinates(mTmpTransform,
null /* windowOverrideRect */); null /* windowOverrideRect */);
specs.add(composeAnimationSpec(stackView, tv, mTmpTransform, AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, tv,
true /* addHeaderBitmap */)); mTmpTransform, true /* addHeaderBitmap */);
if (spec != null) {
specs.add(spec);
}
} }
} }
} }
@@ -376,11 +382,13 @@ public class RecentsTransitionHelper {
private static Bitmap composeHeaderBitmap(TaskView taskView, private static Bitmap composeHeaderBitmap(TaskView taskView,
TaskViewTransform transform) { TaskViewTransform transform) {
float scale = transform.scale; float scale = transform.scale;
int fromHeaderWidth = (int) (transform.rect.width()); int headerWidth = (int) (transform.rect.width());
int fromHeaderHeight = (int) (taskView.mHeaderView.getMeasuredHeight() * scale); int headerHeight = (int) (taskView.mHeaderView.getMeasuredHeight() * scale);
Bitmap b = Bitmap.createBitmap(fromHeaderWidth, fromHeaderHeight, if (headerWidth == 0 || headerHeight == 0) {
Bitmap.Config.ARGB_8888); return null;
}
Bitmap b = Bitmap.createBitmap(headerWidth, headerHeight, Bitmap.Config.ARGB_8888);
if (RecentsDebugFlags.Static.EnableTransitionThumbnailDebugMode) { if (RecentsDebugFlags.Static.EnableTransitionThumbnailDebugMode) {
b.eraseColor(0xFFff0000); b.eraseColor(0xFFff0000);
} else { } else {
@@ -400,6 +408,9 @@ public class RecentsTransitionHelper {
Bitmap b = null; Bitmap b = null;
if (addHeaderBitmap) { if (addHeaderBitmap) {
b = composeHeaderBitmap(taskView, transform); b = composeHeaderBitmap(taskView, transform);
if (b == null) {
return null;
}
} }
Rect taskRect = new Rect(); Rect taskRect = new Rect();