Search in sources :

Example 61 with PrintJobInfo

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

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)

Example 62 with PrintJobInfo

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

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 63 with PrintJobInfo

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

the class PrintSpoolerService method getPrintJobInfos.

public List<PrintJobInfo> getPrintJobInfos(ComponentName componentName, int state, int appId) {
    List<PrintJobInfo> foundPrintJobs = null;
    synchronized (mLock) {
        final int printJobCount = mPrintJobs.size();
        for (int i = 0; i < printJobCount; i++) {
            PrintJobInfo printJob = mPrintJobs.get(i);
            PrinterId printerId = printJob.getPrinterId();
            final boolean sameComponent = (componentName == null || (printerId != null && componentName.equals(printerId.getServiceName())));
            final boolean sameAppId = appId == PrintManager.APP_ID_ANY || printJob.getAppId() == appId;
            final boolean sameState = (state == printJob.getState()) || (state == PrintJobInfo.STATE_ANY) || (state == PrintJobInfo.STATE_ANY_VISIBLE_TO_CLIENTS && isStateVisibleToUser(printJob.getState())) || (state == PrintJobInfo.STATE_ANY_ACTIVE && isActiveState(printJob.getState())) || (state == PrintJobInfo.STATE_ANY_SCHEDULED && isScheduledState(printJob.getState()));
            if (sameComponent && sameAppId && sameState) {
                if (foundPrintJobs == null) {
                    foundPrintJobs = new ArrayList<>();
                }
                foundPrintJobs.add(printJob);
            }
        }
    }
    return foundPrintJobs;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) PrinterId(android.print.PrinterId)

Example 64 with PrintJobInfo

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

the class PrintJob method block.

/**
     * Blocks the print job. You should call this method if {@link #isStarted()} returns true and
     * you need to block the print job. For example, the user has to add some paper to continue
     * printing. To resume the print job call {@link #start()}. To change the reason call
     * {@link #setStatus(CharSequence)}.
     *
     * @param reason The human readable, short, and translated reason why the print job is blocked.
     * @return Whether the job was blocked.
     *
     * @see #isStarted()
     * @see #isBlocked()
     */
@MainThread
public boolean block(@Nullable String reason) {
    PrintService.throwIfNotCalledOnMainThread();
    PrintJobInfo info = getInfo();
    final int state = info.getState();
    if (state == PrintJobInfo.STATE_STARTED || state == PrintJobInfo.STATE_BLOCKED) {
        return setState(PrintJobInfo.STATE_BLOCKED, reason);
    }
    return false;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) MainThread(android.annotation.MainThread)

Example 65 with PrintJobInfo

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

the class PrintJob method getInfo.

/**
     * Gets the {@link PrintJobInfo} that describes this job.
     * <p>
     * <strong>Node:</strong>The returned info object is a snapshot of the
     * current print job state. Every call to this method returns a fresh
     * info object that reflects the current print job state.
     * </p>
     *
     * @return The print job info.
     */
@MainThread
@NonNull
public PrintJobInfo getInfo() {
    PrintService.throwIfNotCalledOnMainThread();
    if (isInImmutableState()) {
        return mCachedInfo;
    }
    PrintJobInfo info = null;
    try {
        info = mPrintServiceClient.getPrintJobInfo(mCachedInfo.getId());
    } catch (RemoteException re) {
        Log.e(LOG_TAG, "Couldn't get info for job: " + mCachedInfo.getId(), re);
    }
    if (info != null) {
        mCachedInfo = info;
    }
    return mCachedInfo;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) RemoteException(android.os.RemoteException) MainThread(android.annotation.MainThread) NonNull(android.annotation.NonNull)

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