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

Commit 603ece2e authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android Git Automerger
Browse files

am bfc8edcf: am 63ce2019: Merge "Fail only scheduled print jobs, i.e. handed...

am bfc8edcf: am 63ce2019: Merge "Fail only scheduled print jobs, i.e. handed to a service, if the service is disabled." into klp-dev

* commit 'bfc8edcf':
  Fail only scheduled print jobs, i.e. handed to a service, if the service is disabled.
parents 5f2bc80f bfc8edcf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -47,6 +47,14 @@ public final class PrintJobInfo implements Parcelable {
     */
    public static final int STATE_ANY_ACTIVE = -3;

    /**
     * Constant for matching any scheduled, i.e. delivered to a print
     * service, print job state.
     *
     * @hide
     */
    public static final int STATE_ANY_SCHEDULED = -4;

    /**
     * Print job state: The print job is being created but not yet
     * ready to be printed.
+9 −1
Original line number Diff line number Diff line
@@ -268,7 +268,9 @@ public final class PrintSpoolerService extends Service {
                        || (state == PrintJobInfo.STATE_ANY_VISIBLE_TO_CLIENTS
                            && isStateVisibleToUser(printJob.getState()))
                        || (state == PrintJobInfo.STATE_ANY_ACTIVE
                            && isActiveState(printJob.getState()));
                            && isActiveState(printJob.getState()))
                        || (state == PrintJobInfo.STATE_ANY_SCHEDULED
                            && isScheduledState(printJob.getState()));
                if (sameComponent && sameAppId && sameState) {
                    if (foundPrintJobs == null) {
                        foundPrintJobs = new ArrayList<PrintJobInfo>();
@@ -554,6 +556,12 @@ public final class PrintSpoolerService extends Service {
                || printJobState == PrintJobInfo.STATE_QUEUED);
    }

    private boolean isScheduledState(int printJobState) {
        return printJobState == PrintJobInfo.STATE_QUEUED
                || printJobState == PrintJobInfo.STATE_STARTED
                || printJobState == PrintJobInfo.STATE_BLOCKED;
    }

    private boolean isActiveState(int printJobState) {
        return printJobState == PrintJobInfo.STATE_CREATED
                || printJobState == PrintJobInfo.STATE_QUEUED
+4 −4
Original line number Diff line number Diff line
@@ -798,17 +798,17 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
            BackgroundThread.getHandler().post(new Runnable() {
                @Override
                public void run() {
                    failActivePrintJobsForServiceInternal(serviceName);
                    failScheduledPrintJobsForServiceInternal(serviceName);
                }
            });
        } else {
            failActivePrintJobsForServiceInternal(serviceName);
            failScheduledPrintJobsForServiceInternal(serviceName);
        }
    }

    private void failActivePrintJobsForServiceInternal(ComponentName serviceName) {
    private void failScheduledPrintJobsForServiceInternal(ComponentName serviceName) {
        List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(serviceName,
                PrintJobInfo.STATE_ANY_ACTIVE, PrintManager.APP_ID_ANY);
                PrintJobInfo.STATE_ANY_SCHEDULED, PrintManager.APP_ID_ANY);
        if (printJobs == null) {
            return;
        }