OSDN Git Service

Crash in print spooler when back pressed before content update complted.
authorSvet Ganov <svetoslavganov@google.com>
Wed, 26 Nov 2014 12:09:27 +0000 (04:09 -0800)
committerSvetoslav Ganov <svetoslavganov@google.com>
Tue, 2 Dec 2014 18:43:05 +0000 (18:43 +0000)
We are updating the printed content asynchronously. If the user cancels
printing before the first update is complete the spooler components are
in a destroyed state but we attempt to handle the completed update resulting
in a crash. Now if printing is cancelled we ignore the update result.

bug:18525491

Change-Id: I1ef47a17de19896cba2c7a1dd2bfc205065e0a5a

packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java

index 90875c0..ea6281d 100644 (file)
@@ -486,7 +486,9 @@ public final class PageContentRepository {
                 protected Void doInBackground(Void... params) {
                     synchronized (mLock) {
                         try {
-                            mRenderer.closeDocument();
+                            if (mRenderer != null) {
+                                mRenderer.closeDocument();
+                            }
                         } catch (RemoteException re) {
                             /* ignore */
                         }
index 352b545..f3a5c95 100644 (file)
@@ -487,6 +487,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
                 requestCreatePdfFileOrFinish();
             } break;
 
+            case STATE_PRINT_CANCELED: {
+                updateOptionsUi();
+            } break;
+
             default: {
                 updatePrintPreviewController(document.changed);