Disable task snapshot when image size is invalid

Since devices such as IoT can have no screen, the size of
graphic buffer can be 1x1. In this case the WindowManager crashes
while making bitmap with reduced size.
To prevent the crash, disabled snapshotting on this screen.

This may also happen on phones sporadically.

Bug: 62401135
Fixes: 64733031
Test: Device without the display does not crash when app dies.
Change-Id: I367008405e6238baf3e56974f7d363ea81dfa916
(cherry picked from commit 9035d72c61)
This commit is contained in:
Juho Ha
2017-06-12 20:15:31 +09:00
committed by Jorim Jaggi
parent 1ec1ab6803
commit d864b44295

View File

@@ -211,7 +211,7 @@ class TaskSnapshotController {
} }
final GraphicBuffer buffer = top.mDisplayContent.screenshotApplicationsToBuffer(top.token, final GraphicBuffer buffer = top.mDisplayContent.screenshotApplicationsToBuffer(top.token,
-1, -1, false, 1.0f, false, true); -1, -1, false, 1.0f, false, true);
if (buffer == null) { if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
return null; return null;
} }
return new TaskSnapshot(buffer, top.getConfiguration().orientation, return new TaskSnapshot(buffer, top.getConfiguration().orientation,