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