ImageWriter: Check Surface is valid before use

For some reason, getProducer() returns a nullptr even though the
JNI context is valid.

The only explanation is that ~JNIImageWriterContext is called
right before ImageWriter_attachAndQueueImage().
When ImageWriter_attachAndQueueImage() is called, the context is still
valid even though mProducer is already cleared.

Flag: EXEMPT bug-fix
Test: ImageWriterTest
Bug: 362116761
Change-Id: Id24e7fc7ac63e703146337690f42df99e3daac5b
1 file changed