Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfce110c authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Android (Google) Code Review
Browse files

Merge "Send update notifications when the status of a print job updates and...

Merge "Send update notifications when the status of a print job updates and make sure to only access mPrintServicesChangeListenerRecords when locked." into nyc-dev
parents 6e685dc3 4bd8fac4
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -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);
            }
        }
    }

+5 −1
Original line number Diff line number Diff line
@@ -593,8 +593,12 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
                    new ListenerRecord<IPrintServicesChangeListener>(listener) {
                        @Override
                        public void onBinderDied() {
                            synchronized (mLock) {
                                if (mPrintServicesChangeListenerRecords != null) {
                                    mPrintServicesChangeListenerRecords.remove(this);
                                }
                            }
                        }
                    });
        }
    }