diff options
author | Svet Ganov <svetoslavganov@google.com> | 2014-11-24 02:01:37 -0800 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2014-11-24 22:12:34 +0000 |
commit | c80814e70aea8940d0d43cd7170baae8c0c4e8e3 (patch) | |
tree | fbadedca5d4b3331d056435571692cb447ca11bc /packages/PrintSpooler/src | |
parent | 760cfb02de1e547b2823bf2b9621ef5b953cc5bd (diff) | |
download | frameworks_base-c80814e70aea8940d0d43cd7170baae8c0c4e8e3.zip frameworks_base-c80814e70aea8940d0d43cd7170baae8c0c4e8e3.tar.gz frameworks_base-c80814e70aea8940d0d43cd7170baae8c0c4e8e3.tar.bz2 |
Lockup in the print spooler.
A recent change modified the way we destroy the remote renderer from
asynchronous to synchronous. This caused problems since it was possible
that the remote rendering service is unbound while we are reading the
contents of a rendered page. As a result the reader was blocking on I/O
and the print spooler was getting into a locked state that required a
restart of its process. Now the remote renderer is destroyed
asynchronously.
bug:18498626
Change-Id: I1312bf808f30430728b4038dd4be43c55d2be825
Diffstat (limited to 'packages/PrintSpooler/src')
4 files changed, 33 insertions, 13 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java index 0923649..90875c0 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java @@ -106,12 +106,26 @@ public final class PageContentRepository { mRenderer.close(callback); } - public void destroy() { + public void destroy(final Runnable callback) { + if (mState == STATE_OPENED) { + close(new Runnable() { + @Override + public void run() { + destroy(callback); + } + }); + return; + } + mState = STATE_DESTROYED; if (DEBUG) { Log.i(LOG_TAG, "STATE_DESTROYED"); } mRenderer.destroy(); + + if (callback != null) { + callback.run(); + } } public void startPreload(int firstShownPage, int lastShownPage) { @@ -158,7 +172,7 @@ public final class PageContentRepository { try { if (mState != STATE_DESTROYED) { mCloseGuard.warnIfOpen(); - destroy(); + destroy(null); } } finally { super.finalize(); @@ -455,6 +469,10 @@ public final class PageContentRepository { public void close(final Runnable callback) { cancelAllRendering(); + if (mOpenTask != null) { + mOpenTask.cancel(); + } + new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { @@ -492,10 +510,6 @@ public final class PageContentRepository { mContext.unbindService(AsyncRenderer.this); } - if (mOpenTask != null) { - mOpenTask.cancel(); - } - mPageContentCache.invalidate(); mPageContentCache.clear(); mDestroyed = true; diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java index 0d2e736..2757b81 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PageAdapter.java @@ -493,13 +493,13 @@ public final class PageAdapter extends Adapter { return selectedPages; } - public void destroy() { - mPageContentRepository.destroy(); + public void destroy(Runnable callback) { mCloseGuard.close(); mState = STATE_DESTROYED; if (DEBUG) { Log.i(LOG_TAG, "STATE_DESTROYED"); } + mPageContentRepository.destroy(callback); } @Override @@ -507,7 +507,7 @@ public final class PageAdapter extends Adapter { try { if (mState != STATE_DESTROYED) { mCloseGuard.warnIfOpen(); - destroy(); + destroy(null); } } finally { super.finalize(); diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index 71d5340..352b545 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -1635,9 +1635,15 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat mSpoolerProvider.destroy(); mPrintedDocument.finish(); mPrintedDocument.destroy(); - mPrintPreviewController.destroy(); + mPrintPreviewController.destroy(new Runnable() { + @Override + public void run() { + finish(); + } + }); + } else { + finish(); } - finish(); } private final class SpinnerItem<T> { diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java index 15342ae..8716fd2 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintPreviewController.java @@ -192,10 +192,10 @@ class PrintPreviewController implements MutexFileProvider.OnReleaseRequestCallba }); } - public void destroy() { + public void destroy(Runnable callback) { mHandler.cancelQueuedOperations(); mRecyclerView.setAdapter(null); - mPageAdapter.destroy(); + mPageAdapter.destroy(callback); } @Override |