Search in sources :

Example 86 with PrintJobInfo

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

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

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

the class PrintSpoolerService method writePrintJobData.

public void writePrintJobData(final ParcelFileDescriptor fd, final PrintJobId printJobId) {
    final PrintJobInfo printJob;
    synchronized (mLock) {
        printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
    }
    new AsyncTask<Void, Void, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            FileInputStream in = null;
            FileOutputStream out = null;
            try {
                if (printJob != null) {
                    File file = generateFileForPrintJob(PrintSpoolerService.this, printJobId);
                    in = new FileInputStream(file);
                    out = new FileOutputStream(fd.getFileDescriptor());
                }
                final byte[] buffer = new byte[8192];
                while (true) {
                    final int readByteCount = in.read(buffer);
                    if (readByteCount < 0) {
                        return null;
                    }
                    out.write(buffer, 0, readByteCount);
                }
            } catch (FileNotFoundException fnfe) {
                Log.e(LOG_TAG, "Error writing print job data!", fnfe);
            } catch (IOException ioe) {
                Log.e(LOG_TAG, "Error writing print job data!", ioe);
            } finally {
                IoUtils.closeQuietly(in);
                IoUtils.closeQuietly(out);
                IoUtils.closeQuietly(fd);
            }
            Log.i(LOG_TAG, "[END WRITE]");
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
}
Also used : PrintJobInfo(android.print.PrintJobInfo) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) AtomicFile(android.util.AtomicFile) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 88 with PrintJobInfo

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

the class PrintSpoolerService method setPrintJobTag.

public boolean setPrintJobTag(PrintJobId printJobId, String tag) {
    synchronized (mLock) {
        PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
        if (printJob != null) {
            String printJobTag = printJob.getTag();
            if (printJobTag == null) {
                if (tag == null) {
                    return false;
                }
            } else if (printJobTag.equals(tag)) {
                return false;
            }
            printJob.setTag(tag);
            if (shouldPersistPrintJob(printJob)) {
                mPersistanceManager.writeStateLocked();
            }
            return true;
        }
    }
    return false;
}
Also used : PrintJobInfo(android.print.PrintJobInfo)

Example 89 with PrintJobInfo

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

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

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

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)

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