use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.
the class UserState method failScheduledPrintJobsForServiceInternal.
private void failScheduledPrintJobsForServiceInternal(ComponentName serviceName) {
List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(serviceName, PrintJobInfo.STATE_ANY_SCHEDULED, PrintManager.APP_ID_ANY);
if (printJobs == null) {
return;
}
final long identity = Binder.clearCallingIdentity();
try {
final int printJobCount = printJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo printJob = printJobs.get(i);
mSpooler.setPrintJobState(printJob.getId(), PrintJobInfo.STATE_FAILED, mContext.getString(R.string.reason_service_unavailable));
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.
the class NotificationController method updateNotifications.
/**
* Update notifications for the given print jobs, remove all other notifications.
*
* @param printJobs The print job that we want to create notifications for.
*/
private void updateNotifications(List<PrintJobInfo> printJobs) {
ArraySet<PrintJobId> removedPrintJobs = new ArraySet<>(mNotifications);
final int numPrintJobs = printJobs.size();
// Create summary notification
if (numPrintJobs > 1) {
createStackedNotification(printJobs);
} else {
mNotificationManager.cancel(PRINT_JOB_NOTIFICATION_SUMMARY, 0);
}
// Create per print job notification
for (int i = 0; i < numPrintJobs; i++) {
PrintJobInfo printJob = printJobs.get(i);
PrintJobId printJobId = printJob.getId();
removedPrintJobs.remove(printJobId);
mNotifications.add(printJobId);
createSimpleNotification(printJob);
}
// Remove notifications for print jobs that do not exist anymore
final int numRemovedPrintJobs = removedPrintJobs.size();
for (int i = 0; i < numRemovedPrintJobs; i++) {
PrintJobId removedPrintJob = removedPrintJobs.valueAt(i);
mNotificationManager.cancel(removedPrintJob.flattenToString(), 0);
mNotifications.remove(removedPrintJob);
}
}
use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.
the class NotificationController method createStackedNotification.
private void createStackedNotification(List<PrintJobInfo> printJobs) {
Notification.Builder builder = new Notification.Builder(mContext).setContentIntent(createContentIntent(null)).setWhen(System.currentTimeMillis()).setOngoing(true).setShowWhen(true).setGroup(PRINT_JOB_NOTIFICATION_GROUP_KEY).setGroupSummary(true);
final int printJobCount = printJobs.size();
InboxStyle inboxStyle = new InboxStyle();
int icon = com.android.internal.R.drawable.ic_print;
for (int i = printJobCount - 1; i >= 0; i--) {
PrintJobInfo printJob = printJobs.get(i);
inboxStyle.addLine(computeNotificationTitle(printJob));
// if any print job is in an error state show an error icon for the summary
if (printJob.getState() == PrintJobInfo.STATE_FAILED || printJob.getState() == PrintJobInfo.STATE_BLOCKED) {
icon = com.android.internal.R.drawable.ic_print_error;
}
}
builder.setSmallIcon(icon);
builder.setLargeIcon(((BitmapDrawable) mContext.getResources().getDrawable(icon, null)).getBitmap());
builder.setNumber(printJobCount);
builder.setStyle(inboxStyle);
builder.setColor(mContext.getColor(com.android.internal.R.color.system_notification_accent_color));
mNotificationManager.notify(PRINT_JOB_NOTIFICATION_SUMMARY, 0, builder.build());
}
use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.
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);
}
}
}
use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.
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());
}
}
Aggregations