Search in sources :

Example 31 with PrintJobInfo

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

the class PrintSpoolerService method removeObsoletePrintJobs.

private void removeObsoletePrintJobs() {
    synchronized (mLock) {
        boolean persistState = false;
        final int printJobCount = mPrintJobs.size();
        for (int i = printJobCount - 1; i >= 0; i--) {
            PrintJobInfo printJob = mPrintJobs.get(i);
            if (isObsoleteState(printJob.getState())) {
                mPrintJobs.remove(i);
                if (DEBUG_PRINT_JOB_LIFECYCLE) {
                    Slog.i(LOG_TAG, "[REMOVE] " + printJob.getId().flattenToString());
                }
                removePrintJobFileLocked(printJob.getId());
                persistState = true;
            }
        }
        if (persistState) {
            mPersistanceManager.writeStateLocked();
        }
    }
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 32 with PrintJobInfo

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

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

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

the class UserState method getPrintJobInfo.

public PrintJobInfo getPrintJobInfo(@NonNull PrintJobId printJobId, int appId) {
    PrintJobInfo printJob = mPrintJobForAppCache.getPrintJob(printJobId, appId);
    if (printJob == null) {
        printJob = mSpooler.getPrintJobInfo(printJobId, appId);
    }
    if (printJob != null) {
        // Strip out the tag and the advanced print options.
        // They are visible only to print services.
        printJob.setTag(null);
        printJob.setAdvancedOptions(null);
    }
    return printJob;
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 34 with PrintJobInfo

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

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)

Example 35 with PrintJobInfo

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);
    }
}
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