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

Commit cf5b777c authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Cancel print job if PrintActivity was finished before spooler could be

connected.

This can happen if finish() was called immediately after onResume() and
before PrintSpoolerProvider.onServiceConnected.

There is actually a small issue left. If the connection to the spooler
gets destroyed before it was ever connected the print job does not get
canceled. In this case it will stay "created" until the next reboot and
then it will not get recreated.

Bug: 26428518
Change-Id: I1b8696f326b842160e4db77b985577a1c8978def
parent 56190d5e
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -265,8 +265,15 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
                new Runnable() {
            @Override
            public void run() {
                if (isFinishing()) {
                    // onPause might have not been able to cancel the job, see PrintActivity#onPause
                    // To be sure, cancel the job again. Double canceling does no harm.
                    mSpoolerProvider.getSpooler().setPrintJobState(mPrintJob.getId(),
                            PrintJobInfo.STATE_CANCELED, null);
                } else {
                    onConnectedToPrintSpooler(adapter);
                }
            }
        });
    }

@@ -353,8 +360,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat

        if (mState == STATE_INITIALIZING) {
            if (isFinishing()) {
                if (spooler != null) {
                    spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_CANCELED, null);
                }
            }
            super.onPause();
            return;
        }