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

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

Init and clean up printer registry independat of state.

The printer registry is created not in sync with the states or the
activity life-cycle. It might not be initialized when stop is called as
we might have a very quick

create -> start -> stop -> finish

without time for the print subsystem to initialize.

Bug: 21749058
Change-Id: I991029a7fd0ad162c1144ff03438707f16bf0b02
parent 1a8fbfce
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
    @Override
    public void onStart() {
        super.onStart();
        if (mState != STATE_INITIALIZING && mCurrentPrinter != null) {
        if (mPrinterRegistry != null && mCurrentPrinter != null) {
            mPrinterRegistry.setTrackedPrinter(mCurrentPrinter.getId());
        }
        MetricsLogger.count(this, "print_preview", 1);
@@ -384,7 +384,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
    @Override
    protected void onStop() {
        mPrinterAvailabilityDetector.cancel();

        if (mPrinterRegistry != null) {
            mPrinterRegistry.setTrackedPrinter(null);
        }

        super.onStop();
    }
@@ -1912,9 +1915,12 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
    }

    private void doFinish() {
        if (mPrinterRegistry != null) {
            mPrinterRegistry.setTrackedPrinter(null);
        }

        if (mState != STATE_INITIALIZING) {
            mProgressMessageController.cancel();
            mPrinterRegistry.setTrackedPrinter(null);
            mSpoolerProvider.destroy();
            mPrintedDocument.finish();
            mPrintedDocument.destroy();