Merge "Send update notifications when the status of a print job updates and make sure to only access mPrintServicesChangeListenerRecords when locked." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bfce110c63
@@ -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) {
|
public boolean setPrintJobState(PrintJobId printJobId, int state, String error) {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
@@ -549,12 +563,7 @@ public final class PrintSpoolerService extends Service {
|
|||||||
notifyOnAllPrintJobsHandled();
|
notifyOnAllPrintJobsHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
Message message = mHandlerCaller.obtainMessageO(
|
notifyPrintJobUpdated(printJob);
|
||||||
HandlerCallerCallback.MSG_ON_PRINT_JOB_STATE_CHANGED,
|
|
||||||
printJob);
|
|
||||||
mHandlerCaller.executeOrSendMessage(message);
|
|
||||||
|
|
||||||
mNotificationController.onUpdateNotifications(mPrintJobs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,9 +593,12 @@ public final class PrintSpoolerService extends Service {
|
|||||||
*/
|
*/
|
||||||
public void setStatus(@NonNull PrintJobId printJobId, @Nullable CharSequence status) {
|
public void setStatus(@NonNull PrintJobId printJobId, @Nullable CharSequence status) {
|
||||||
synchronized (mLock) {
|
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,
|
public void setStatus(@NonNull PrintJobId printJobId, @StringRes int status,
|
||||||
@Nullable CharSequence appPackageName) {
|
@Nullable CharSequence appPackageName) {
|
||||||
synchronized (mLock) {
|
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,8 +593,12 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
|
|||||||
new ListenerRecord<IPrintServicesChangeListener>(listener) {
|
new ListenerRecord<IPrintServicesChangeListener>(listener) {
|
||||||
@Override
|
@Override
|
||||||
public void onBinderDied() {
|
public void onBinderDied() {
|
||||||
|
synchronized (mLock) {
|
||||||
|
if (mPrintServicesChangeListenerRecords != null) {
|
||||||
mPrintServicesChangeListenerRecords.remove(this);
|
mPrintServicesChangeListenerRecords.remove(this);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user