Search in sources :

Example 11 with PrintJobInfo

use of android.print.PrintJobInfo in project platform_frameworks_base by android.

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

Example 12 with PrintJobInfo

use of android.print.PrintJobInfo in project platform_frameworks_base by android.

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

Example 13 with PrintJobInfo

use of android.print.PrintJobInfo in project platform_frameworks_base by android.

the class UserState method restartPrintJob.

public void restartPrintJob(@NonNull PrintJobId printJobId, int appId) {
    PrintJobInfo printJobInfo = getPrintJobInfo(printJobId, appId);
    if (printJobInfo == null || printJobInfo.getState() != PrintJobInfo.STATE_FAILED) {
        return;
    }
    mSpooler.setPrintJobState(printJobId, PrintJobInfo.STATE_QUEUED, null);
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 14 with PrintJobInfo

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

Example 15 with PrintJobInfo

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

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