From 9035d72c61868193b5630db16a71a0d208bc4666 Mon Sep 17 00:00:00 2001 From: Juho Ha Date: Mon, 12 Jun 2017 20:15:31 +0900 Subject: [PATCH] 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. Bug: 62401135 Test: Device without the display does not crash when app dies. Change-Id: I367008405e6238baf3e56974f7d363ea81dfa916 --- .../core/java/com/android/server/wm/TaskSnapshotController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java index edb88530c7aae..649795aa26a86 100644 --- a/services/core/java/com/android/server/wm/TaskSnapshotController.java +++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java @@ -192,7 +192,7 @@ class TaskSnapshotController { } final GraphicBuffer buffer = top.mDisplayContent.screenshotApplicationsToBuffer(top.token, -1, -1, false, 1.0f, false, true); - if (buffer == null) { + if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) { return null; } return new TaskSnapshot(buffer, top.getConfiguration().orientation,