Merge "Send update notifications when the status of a print job updates and make sure to only access mPrintServicesChangeListenerRecords when locked." into nyc-dev am: bfce110c63 am: 9cb79d193b
am: 2d4b463388
* commit '2d4b4633881afd722556dd5af59ab1067c03789a':
Send update notifications when the status of a print job updates and make sure to only access mPrintServicesChangeListenerRecords when locked.
Change-Id: I0af708f61999d5b9d4a1be6c87abf2858ac6f971
This commit is contained in:
@@ -497,6 +497,20 @@ public final class PrintSpoolerService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all interested parties that a print job has been updated.
|
||||
*
|
||||
* @param printJob The updated print job.
|
||||
*/
|
||||
private void notifyPrintJobUpdated(PrintJobInfo printJob) {
|
||||
Message message = mHandlerCaller.obtainMessageO(
|
||||
HandlerCallerCallback.MSG_ON_PRINT_JOB_STATE_CHANGED,
|
||||
printJob);
|
||||
mHandlerCaller.executeOrSendMessage(message);
|
||||
|
||||
mNotificationController.onUpdateNotifications(mPrintJobs);
|
||||
}
|
||||
|
||||
public boolean setPrintJobState(PrintJobId printJobId, int state, String error) {
|
||||
boolean success = false;
|
||||
|
||||
@@ -549,12 +563,7 @@ public final class PrintSpoolerService extends Service {
|
||||
notifyOnAllPrintJobsHandled();
|
||||
}
|
||||
|
||||
Message message = mHandlerCaller.obtainMessageO(
|
||||
HandlerCallerCallback.MSG_ON_PRINT_JOB_STATE_CHANGED,
|
||||
printJob);
|
||||
mHandlerCaller.executeOrSendMessage(message);
|
||||
|
||||
mNotificationController.onUpdateNotifications(mPrintJobs);
|
||||
notifyPrintJobUpdated(printJob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,9 +593,12 @@ public final class PrintSpoolerService extends Service {
|
||||
*/
|
||||
public void setStatus(@NonNull PrintJobId printJobId, @Nullable CharSequence status) {
|
||||
synchronized (mLock) {
|
||||
getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY).setStatus(status);
|
||||
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
|
||||
|
||||
mNotificationController.onUpdateNotifications(mPrintJobs);
|
||||
if (printJob != null) {
|
||||
printJob.setStatus(status);
|
||||
notifyPrintJobUpdated(printJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,9 +612,12 @@ public final class PrintSpoolerService extends Service {
|
||||
public void setStatus(@NonNull PrintJobId printJobId, @StringRes int status,
|
||||
@Nullable CharSequence appPackageName) {
|
||||
synchronized (mLock) {
|
||||
getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY).setStatus(status, appPackageName);
|
||||
PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
|
||||
|
||||
mNotificationController.onUpdateNotifications(mPrintJobs);
|
||||
if (printJob != null) {
|
||||
printJob.setStatus(status, appPackageName);
|
||||
notifyPrintJobUpdated(printJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -593,7 +593,11 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
|
||||
new ListenerRecord<IPrintServicesChangeListener>(listener) {
|
||||
@Override
|
||||
public void onBinderDied() {
|
||||
mPrintServicesChangeListenerRecords.remove(this);
|
||||
synchronized (mLock) {
|
||||
if (mPrintServicesChangeListenerRecords != null) {
|
||||
mPrintServicesChangeListenerRecords.remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user