Search in sources :

Example 41 with PrintJobInfo

use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.

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);
        }
    }
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 42 with PrintJobInfo

use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.

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);
        }
    }
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 43 with PrintJobInfo

use of android.print.PrintJobInfo in project android_frameworks_base by crdroidandroid.

the class PrintSpoolerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    String prefix = (args.length > 0) ? args[0] : "";
    String tab = "  ";
    synchronized (mLock) {
        pw.append(prefix).append("print jobs:").println();
        final int printJobCount = mPrintJobs.size();
        for (int i = 0; i < printJobCount; i++) {
            PrintJobInfo printJob = mPrintJobs.get(i);
            pw.append(prefix).append(tab).append(printJob.toString());
            pw.println();
        }
        pw.append(prefix).append("print job files:").println();
        File[] files = getFilesDir().listFiles();
        if (files != null) {
            final int fileCount = files.length;
            for (int i = 0; i < fileCount; i++) {
                File file = files[i];
                if (file.isFile() && file.getName().startsWith(PRINT_JOB_FILE_PREFIX)) {
                    pw.append(prefix).append(tab).append(file.getName()).println();
                }
            }
        }
    }
    pw.append(prefix).append("approved print services:").println();
    Set<String> approvedPrintServices = (new ApprovedPrintServices(this)).getApprovedServices();
    if (approvedPrintServices != null) {
        for (String approvedService : approvedPrintServices) {
            pw.append(prefix).append(tab).append(approvedService).println();
        }
    }
}
Also used : PrintJobInfo(android.print.PrintJobInfo) ApprovedPrintServices(com.android.printspooler.util.ApprovedPrintServices) AtomicFile(android.util.AtomicFile) File(java.io.File)

Example 44 with PrintJobInfo

use of android.print.PrintJobInfo in project android_frameworks_base by AOSPA.

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());
}
Also used : InboxStyle(android.app.Notification.InboxStyle) PrintJobInfo(android.print.PrintJobInfo) Notification(android.app.Notification)

Example 45 with PrintJobInfo

use of android.print.PrintJobInfo in project android_frameworks_base by AOSPA.

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);
}
Also used : PrintJobInfo(android.print.PrintJobInfo) ArrayList(java.util.ArrayList)

Aggregations

PrintJobInfo (android.print.PrintJobInfo)110 PrintJobId (android.print.PrintJobId)18 AtomicFile (android.util.AtomicFile)15 File (java.io.File)15 PrinterId (android.print.PrinterId)14 ArrayList (java.util.ArrayList)14 MainThread (android.annotation.MainThread)10 ComponentName (android.content.ComponentName)9 NonNull (android.annotation.NonNull)5 Notification (android.app.Notification)5 InboxStyle (android.app.Notification.InboxStyle)5 Message (android.os.Message)5 RemoteException (android.os.RemoteException)5 PageRange (android.print.PageRange)5 PrintAttributes (android.print.PrintAttributes)5 MediaSize (android.print.PrintAttributes.MediaSize)5 Resolution (android.print.PrintAttributes.Resolution)5 PrintDocumentInfo (android.print.PrintDocumentInfo)5 PrinterCapabilitiesInfo (android.print.PrinterCapabilitiesInfo)5 ArraySet (android.util.ArraySet)5