Check return value in screencap in case of failure.
Check the results for an error when generating a screencap so invalid data is not returned as the captured image. Test: screencap works Change-Id: I377c11c1e07cd04a6b3882ac20d7be9d6ddb25c5 Fixes: 80106675
This commit is contained in:
@@ -207,7 +207,14 @@ int main(int argc, char** argv)
|
||||
|
||||
result = outBuffer->lock(GraphicBuffer::USAGE_SW_READ_OFTEN, &base);
|
||||
|
||||
if (base == NULL) {
|
||||
if (base == nullptr || result != NO_ERROR) {
|
||||
String8 reason;
|
||||
if (base == nullptr) {
|
||||
reason = "Failed to write to buffer";
|
||||
} else {
|
||||
reason.appendFormat("Error Code: %d", result);
|
||||
}
|
||||
fprintf(stderr, "Failed to take screenshot (%s)\n", reason.c_str());
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user