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

Commit 885810de authored by Svetoslav's avatar Svetoslav
Browse files

Created print jobs should not be persisted until they are queued.

Print jobs in a created state should not be persisted. However,
if a print service sets the tag to a print job that is queued,
we were persisting even print jobs in a created state. This
change adds a simple check while persisting to avoid storing
created print jobs.

bug:11696785

Change-Id: Idf28f3634b91fd5bf345f376114af4ed478ed3c6
parent 39af5a78
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@
            android:layout_marginBottom="32dip"
            android:layout_gravity="center"
            style="?android:attr/buttonBarButtonStyle"
            android:singleLine="true"
            android:ellipsize="end"
            android:text="@string/print_error_default_message"
            android:textColor="@color/important_text"
+9 −1
Original line number Diff line number Diff line
@@ -441,6 +441,7 @@ public final class PrintSpoolerService extends Service {

    private void removeObsoletePrintJobs() {
        synchronized (mLock) {
            boolean persistState = false;
            final int printJobCount = mPrintJobs.size();
            for (int i = printJobCount - 1; i >= 0; i--) {
                PrintJobInfo printJob = mPrintJobs.get(i);
@@ -450,11 +451,14 @@ public final class PrintSpoolerService extends Service {
                        Slog.i(LOG_TAG, "[REMOVE] " + printJob.getId().flattenToString());
                    }
                    removePrintJobFileLocked(printJob.getId());
                    persistState = true;
                }
            }
            if (persistState) {
                mPersistanceManager.writeStateLocked();
            }
        }
    }

    private void removePrintJobFileLocked(PrintJobId printJobId) {
        File file = generateFileForPrintJob(printJobId);
@@ -799,6 +803,10 @@ public final class PrintSpoolerService extends Service {
                for (int j = 0; j < printJobCount; j++) {
                    PrintJobInfo printJob = printJobs.get(j);

                    if (!shouldPersistPrintJob(printJob)) {
                        continue;
                    }

                    serializer.startTag(null, TAG_JOB);

                    serializer.attribute(null, ATTR_ID, printJob.getId().flattenToString());