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

Commit 2fb64a5c authored by Svetoslav's avatar Svetoslav
Browse files

Fix crash in spooler if printing app dies.

bug:16966145

Change-Id: I092c489a7f1b4000a96d3f12f2996ccabf734b9a
parent 139ba7fb
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();
            }
        }
    }