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

Commit ed30002d authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by android-build-merger
Browse files

Hold no locks when calling RemotePrintSpooler am: 1d6e7cc5

am: 684aa472

Change-Id: I8a1e03422291d1931cd93625eaedf739b5c17c16
parents deb91b89 684aa472
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ import java.util.concurrent.TimeoutException;
 * spooler if needed, to make the timed remote calls, to handle
 * remote exceptions, and to bind/unbind to the remote instance as
 * needed.
 *
 * The calls might be blocking and need the main thread of to be unblocked to finish. Hence do not
 * call this while holding any monitors that might need to be acquired the main thread.
 */
final class RemotePrintSpooler {

+11 −7
Original line number Diff line number Diff line
@@ -434,12 +434,12 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
    }

    public void createPrinterDiscoverySession(@NonNull IPrinterDiscoveryObserver observer) {
        mSpooler.clearCustomPrinterIconCache();

        synchronized (mLock) {
            throwIfDestroyedLocked();

            if (mPrinterDiscoverySession == null) {
                mSpooler.clearCustomPrinterIconCache();

                // If we do not have a session, tell all service to create one.
                mPrinterDiscoverySession = new PrinterDiscoverySessionMediator(mContext) {
                    @Override
@@ -731,6 +731,8 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,

    @Override
    public void onCustomPrinterIconLoaded(PrinterId printerId, Icon icon) {
        mSpooler.onCustomPrinterIconLoaded(printerId, icon);

        synchronized (mLock) {
            throwIfDestroyedLocked();

@@ -738,7 +740,6 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
            if (mPrinterDiscoverySession == null) {
                return;
            }
            mSpooler.onCustomPrinterIconLoaded(printerId, icon);
            mPrinterDiscoverySession.onCustomPrinterIconLoadedLocked(printerId);
        }
    }
@@ -979,18 +980,21 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
     * Prune persistent state if a print service was uninstalled
     */
    public void prunePrintServices() {
        ArrayList<ComponentName> installedComponents;

        synchronized (mLock) {
            ArrayList<ComponentName> installedComponents = getInstalledComponents();
            installedComponents = getInstalledComponents();

            // Remove unnecessary entries from persistent state "disabled services"
            boolean disabledServicesUninstalled = mDisabledServices.retainAll(installedComponents);
            if (disabledServicesUninstalled) {
                writeDisabledPrintServicesLocked(mDisabledServices);
            }
        }

        // Remove unnecessary entries from persistent state "approved services"
        mSpooler.pruneApprovedPrintServices(installedComponents);
        }

    }

    private void onConfigurationChangedLocked() {