use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
the class UserState method getPrintJobInfos.
public List<PrintJobInfo> getPrintJobInfos(int appId) {
List<PrintJobInfo> cachedPrintJobs = mPrintJobForAppCache.getPrintJobs(appId);
// Note that the print spooler is not storing print jobs that
// are in a terminal state as it is non-trivial to properly update
// the spooler state for when to forget print jobs in terminal state.
// Therefore, we fuse the cached print jobs for running apps (some
// jobs are in a terminal state) with the ones that the print
// spooler knows about (some jobs are being processed).
ArrayMap<PrintJobId, PrintJobInfo> result = new ArrayMap<PrintJobId, PrintJobInfo>();
// Add the cached print jobs for running apps.
final int cachedPrintJobCount = cachedPrintJobs.size();
for (int i = 0; i < cachedPrintJobCount; i++) {
PrintJobInfo cachedPrintJob = cachedPrintJobs.get(i);
result.put(cachedPrintJob.getId(), cachedPrintJob);
// Strip out the tag and the advanced print options.
// They are visible only to print services.
cachedPrintJob.setTag(null);
cachedPrintJob.setAdvancedOptions(null);
}
// Add everything else the spooler knows about.
List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(null, PrintJobInfo.STATE_ANY, appId);
if (printJobs != null) {
final int printJobCount = printJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo printJob = printJobs.get(i);
result.put(printJob.getId(), printJob);
// Strip out the tag and the advanced print options.
// They are visible only to print services.
printJob.setTag(null);
printJob.setAdvancedOptions(null);
}
}
return new ArrayList<PrintJobInfo>(result.values());
}
use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class NotificationController method onUpdateNotifications.
public void onUpdateNotifications(List<PrintJobInfo> printJobs) {
List<PrintJobInfo> notifyPrintJobs = new ArrayList<>();
final int printJobCount = printJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo printJob = printJobs.get(i);
if (shouldNotifyForState(printJob.getState())) {
notifyPrintJobs.add(printJob);
}
}
updateNotifications(notifyPrintJobs);
}
use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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);
}
}
}
Aggregations