Deal with finalize() after failed constructor

If the constructor throws an exception, the object will still be
finalized. Hence we have to make sure to set objects that are cleaned up
to 0/null and clean up everything else. Otherwise the finalizer might
double clean up a failed PdfRenderer.

It also appears that the Pdfium error state is only set if a open-doc
function fail. Hence remove it in every other case. Otherwise successes
might read the error of the last call.

Fixes: 63875707, 37052344
Test: cts-tradefed run singleCommand cts-dev -m Pdf --test=android.graphics.pdf.cts.PdfRendererTest
Change-Id: I6d9fc26be768ba1e338344740e340cf9b56386e9
6 files changed