use of android.print.PrintJobInfo in project platform_frameworks_base by android.
the class PrintSpoolerService method updatePrintJobUserConfigurableOptionsNoPersistence.
public void updatePrintJobUserConfigurableOptionsNoPersistence(PrintJobInfo printJob) {
synchronized (mLock) {
final int printJobCount = mPrintJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo cachedPrintJob = mPrintJobs.get(i);
if (cachedPrintJob.getId().equals(printJob.getId())) {
cachedPrintJob.setPrinterId(printJob.getPrinterId());
cachedPrintJob.setPrinterName(printJob.getPrinterName());
cachedPrintJob.setCopies(printJob.getCopies());
cachedPrintJob.setDocumentInfo(printJob.getDocumentInfo());
cachedPrintJob.setPages(printJob.getPages());
cachedPrintJob.setAttributes(printJob.getAttributes());
cachedPrintJob.setAdvancedOptions(printJob.getAdvancedOptions());
return;
}
}
throw new IllegalArgumentException("No print job with id:" + printJob.getId());
}
}
use of android.print.PrintJobInfo in project platform_frameworks_base by android.
the class PrintSpoolerService method setPrintJobState.
public boolean setPrintJobState(PrintJobId printJobId, int state, String error) {
boolean success = false;
synchronized (mLock) {
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
if (printJob != null) {
final int oldState = printJob.getState();
if (oldState == state) {
return false;
}
success = true;
printJob.setState(state);
printJob.setStatus(error);
printJob.setCancelling(false);
if (DEBUG_PRINT_JOB_LIFECYCLE) {
Slog.i(LOG_TAG, "[STATE CHANGED] " + printJob);
}
MetricsLogger.histogram(this, "print_job_state", state);
switch(state) {
case PrintJobInfo.STATE_COMPLETED:
case PrintJobInfo.STATE_CANCELED:
mPrintJobs.remove(printJob);
removePrintJobFileLocked(printJob.getId());
case PrintJobInfo.STATE_FAILED:
{
PrinterId printerId = printJob.getPrinterId();
if (printerId != null) {
ComponentName service = printerId.getServiceName();
if (!hasActivePrintJobsForServiceLocked(service)) {
sendOnAllPrintJobsForServiceHandled(service);
}
}
}
break;
case PrintJobInfo.STATE_QUEUED:
{
sendOnPrintJobQueued(new PrintJobInfo(printJob));
}
break;
}
if (shouldPersistPrintJob(printJob)) {
mPersistanceManager.writeStateLocked();
}
if (!hasActivePrintJobsLocked()) {
notifyOnAllPrintJobsHandled();
}
notifyPrintJobUpdated(printJob);
}
}
return success;
}
use of android.print.PrintJobInfo in project platform_frameworks_base by android.
the class PrintSpoolerService method setStatus.
/**
* Set the status for a print job.
*
* @param printJobId ID of the print job to update
* @param status the new status as a string resource
* @param appPackageName app package the resource belongs to
*/
public void setStatus(@NonNull PrintJobId printJobId, @StringRes int status, @Nullable CharSequence appPackageName) {
synchronized (mLock) {
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
if (printJob != null) {
printJob.setStatus(status, appPackageName);
notifyPrintJobUpdated(printJob);
}
}
}
use of android.print.PrintJobInfo in project platform_frameworks_base by android.
the class PrintSpoolerService method setStatus.
/**
* Set the status for a print job.
*
* @param printJobId ID of the print job to update
* @param status the new status
*/
public void setStatus(@NonNull PrintJobId printJobId, @Nullable CharSequence status) {
synchronized (mLock) {
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
if (printJob != null) {
printJob.setStatus(status);
notifyPrintJobUpdated(printJob);
}
}
}
use of android.print.PrintJobInfo in project platform_frameworks_base by android.
the class PrintSpoolerService method setPrintJobCancelling.
public void setPrintJobCancelling(PrintJobId printJobId, boolean cancelling) {
synchronized (mLock) {
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
if (printJob != null) {
printJob.setCancelling(cancelling);
if (shouldPersistPrintJob(printJob)) {
mPersistanceManager.writeStateLocked();
}
mNotificationController.onUpdateNotifications(mPrintJobs);
Message message = mHandlerCaller.obtainMessageO(HandlerCallerCallback.MSG_ON_PRINT_JOB_STATE_CHANGED, printJob);
mHandlerCaller.executeOrSendMessage(message);
}
}
}
Aggregations