use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
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;
}
use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
the class PrintSpoolerService method setPrintJobCancelling.
public void setPrintJobCancelling(PrintJobId printJobId, boolean cancelling) {
synchronized (mLock) {
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
if (printJob != null) {
printJob.setCancelling(cancelling);
if (shouldPersistPrintJob(printJob)) {
mPersistanceManager.writeStateLocked();
}
mNotificationController.onUpdateNotifications(mPrintJobs);
Message message = mHandlerCaller.obtainMessageO(HandlerCallerCallback.MSG_ON_PRINT_JOB_STATE_CHANGED, printJob);
mHandlerCaller.executeOrSendMessage(message);
}
}
}
use of android.print.PrintJobInfo in project android_frameworks_base by ResurrectionRemix.
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 NotificationController method updateNotifications.
/**
* Update notifications for the given print jobs, remove all other notifications.
*
* @param printJobs The print job that we want to create notifications for.
*/
private void updateNotifications(List<PrintJobInfo> printJobs) {
ArraySet<PrintJobId> removedPrintJobs = new ArraySet<>(mNotifications);
final int numPrintJobs = printJobs.size();
// Create summary notification
if (numPrintJobs > 1) {
createStackedNotification(printJobs);
} else {
mNotificationManager.cancel(PRINT_JOB_NOTIFICATION_SUMMARY, 0);
}
// Create per print job notification
for (int i = 0; i < numPrintJobs; i++) {
PrintJobInfo printJob = printJobs.get(i);
PrintJobId printJobId = printJob.getId();
removedPrintJobs.remove(printJobId);
mNotifications.add(printJobId);
createSimpleNotification(printJob);
}
// Remove notifications for print jobs that do not exist anymore
final int numRemovedPrintJobs = removedPrintJobs.size();
for (int i = 0; i < numRemovedPrintJobs; i++) {
PrintJobId removedPrintJob = removedPrintJobs.valueAt(i);
mNotificationManager.cancel(removedPrintJob.flattenToString(), 0);
mNotifications.remove(removedPrintJob);
}
}
Aggregations