From b170c08387169ea65da445b579de2a5655ec8454 Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Mon, 21 Mar 2016 12:48:58 -0700 Subject: [PATCH] Don't mix UI and print job state In PrintActivity.OnPause we set the print job state based on the PrintActivity state. The issue was that FINISHED was interpreted as "cancel print job". Actually with FINISHED does not tell what state the job should be in. The only purpose of the finished state was to guard against double-invocation of doFinish(). Hence remove this recently introduced state and use a simple boolean to guard against doule invocation of doFinish(). Bug: 27760331 Change-Id: I0767c2b0b9c28e8904647cc832c236f67f92bcfe --- .../src/com/android/printspooler/ui/PrintActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index 4e1180d051bfa..bb34fcfdd96bc 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -159,7 +159,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat private static final int STATE_PRINTER_UNAVAILABLE = 6; private static final int STATE_UPDATE_SLOW = 7; private static final int STATE_PRINT_COMPLETED = 8; - private static final int STATE_FINISHING = 9; private static final int UI_STATE_PREVIEW = 0; private static final int UI_STATE_ERROR = 1; @@ -255,6 +254,9 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat /** Whether at least one print services is enabled or not */ private boolean mArePrintServicesEnabled; + /** Is doFinish() already in progress */ + private boolean mIsFinishing; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -2035,11 +2037,11 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat return; } - if (mState == STATE_FINISHING) { + if (mIsFinishing) { return; } - mState = STATE_FINISHING; + mIsFinishing = true; if (mPrinterRegistry != null) { mPrinterRegistry.setTrackedPrinter(null);