Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d798a70d authored by Benjamin Gordon's avatar Benjamin Gordon
Browse files

PrintSpooler: Avoid crash in DocumentTransformer shutdown

When DocumentTransformer's background task finishes, onPostExecute tries
to unbind the PdfManipulationService that was previously bound in
transform().  If the background task finishes after the PrintActivity is
already closing, the service may have already been unbound.  Since this
is happening during final cleanup of DocumentTransformer already, the
resulting exception can be suppressed instead of thrown.

Bug: 438886442
Test: Save a 1200 page document to PDF
Flag: EXEMPT bugfix
Change-Id: I535c9c5350ce93adeeccfc6913bee4b6bf58dcfa
parent 285d7ba2
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -3282,8 +3282,20 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat

                    @Override
                    protected void onPostExecute(String error) {
                        try {
                            mContext.unbindService(DocumentTransformer.this);
                            mCallback.accept(error);
                        } catch (IllegalArgumentException e) {
                            // Unbinding can fail if the PrintActivity has already been torn down
                            // before the document transform completes.  Since this is about to
                            // exit, there's no need to attempt additional error recovery.
                            Log.w(
                                    LOG_TAG,
                                    "Unable to unbind PdfManipulationService: "
                                            + e
                                            + ". Original error: "
                                            + error);
                        }
                    }
                }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);