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

Commit db85ad56 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Fail print jobs targeted to unavailable services.

It is possible that a print job is scheduled for handling, i.e. it is
queued, after the target print service is uninstalled or disabled.
In case like this we fail the print job with an appropriate error
message. Now the user can cancel the job when he/she sees the notification
or the status in the print settings. Trying to restart such a job will
end up failing it again with the same error message. So the user will
just have to canel the print job.

This apporach quarantees that the user is informed for the failure and
also is much simpler than trying to update the UI when print job's
target serivce is uninstalled. For example, the settings UI has to
be updated as well as the notifications. Also due to the async nature
of the system this we cannot completely avoid having a restart option
for a print job whose target service is gone. This scenario is very
unlikely but still we have to handle it.

bug:11012251

Change-Id: Id8c8c3cff75e0b6325552676b130ff1406edc069
parent c6568719
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -4440,6 +4440,9 @@
    <!-- Print fail reason: unknown. [CHAR LIMIT=25] -->
    <string name="reason_unknown">unknown</string>

    <!-- Print fail reason: the print service that has to process the print job is not available. [CHAR LIMIT=none] -->
    <string name="reason_service_unavailable">Print service not enabled</string>

    <!-- Title for the notification that a print service was installed. [CHAR LIMIT=50] -->
    <string name="print_service_installed_title"><xliff:g id="name" example="Cloud Print">%s</xliff:g> service installed</string>
    <!-- Message for the notification that a print service was installed. [CHAR LIMIT=50] -->
+1 −0
Original line number Diff line number Diff line
@@ -926,6 +926,7 @@
  <java-symbol type="string" name="mediasize_japanese_kahu" />
  <java-symbol type="string" name="mediasize_japanese_kaku2" />
  <java-symbol type="string" name="mediasize_japanese_you4" />
  <java-symbol type="string" name="reason_service_unavailable" />
  <java-symbol type="string" name="reason_unknown" />
  <java-symbol type="string" name="restr_pin_enter_admin_pin" />
  <java-symbol type="string" name="restr_pin_enter_pin" />
+6 −1
Original line number Diff line number Diff line
@@ -134,6 +134,11 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
        }
        if (service != null) {
            service.onPrintJobQueued(printJob);
        } else {
            // The service for the job is no longer enabled, so just
            // fail the job with the appropriate message.
            mSpooler.setPrintJobState(printJob.getId(), PrintJobInfo.STATE_FAILED,
                    mContext.getString(R.string.reason_service_unavailable));
        }
    }

@@ -779,7 +784,7 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
            for (int i = 0; i < printJobCount; i++) {
                PrintJobInfo printJob = printJobs.get(i);
                mSpooler.setPrintJobState(printJob.getId(), PrintJobInfo.STATE_FAILED,
                        mContext.getString(R.string.reason_unknown));
                        mContext.getString(R.string.reason_service_unavailable));
            }
        } finally {
            Binder.restoreCallingIdentity(identity);