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

Commit 80adf03d authored by Svetoslav's avatar Svetoslav Committed by Android (Google) Code Review
Browse files

Merge "Fix crash in spooler if printing app dies." into lmp-dev

parents 112d0abb 2fb64a5c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -55,7 +55,8 @@

        <service
            android:name=".renderer.PdfManipulationService"
            android:isolatedProcess="true">
            android:isolatedProcess="true"
            android:process=":renderer">
        </service>

        <activity
+11 −9
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ public final class RemotePrintDocument {
    private final DeathRecipient mDeathRecipient = new DeathRecipient() {
        @Override
        public void binderDied() {
            mAdapterDeathObserver.onDied();
            notifyPrintingAppDied();
        }
    };

@@ -180,7 +180,6 @@ public final class RemotePrintDocument {
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error calling start()", re);
            mState = STATE_FAILED;
            mAdapterDeathObserver.onDied();
        }
    }

@@ -269,7 +268,6 @@ public final class RemotePrintDocument {
        } catch (RemoteException re) {
            Log.e(LOG_TAG, "Error calling finish()", re);
            mState = STATE_FAILED;
            mAdapterDeathObserver.onDied();
        }
    }

@@ -1108,6 +1106,15 @@ public final class RemotePrintDocument {
        }
    }

    private void notifyPrintingAppDied() {
        new Handler(mLooper).post(new Runnable() {
            @Override
            public void run() {
                mAdapterDeathObserver.onDied();
            }
        });
    }

    private static final class PrintDocumentAdapterObserver
            extends IPrintDocumentAdapterObserver.Stub {
        private final WeakReference<RemotePrintDocument> mWeakDocument;
@@ -1120,12 +1127,7 @@ public final class RemotePrintDocument {
        public void onDestroy() {
            final RemotePrintDocument document = mWeakDocument.get();
            if (document != null) {
                new Handler(document.mLooper).post(new Runnable() {
                    @Override
                    public void run() {
                        document.mAdapterDeathObserver.onDied();
                    }
                });
                document.notifyPrintingAppDied();
            }
        }
    }