Fix a crash in print spooler.

1. Leftover code was setting the state to configuring
   before initialization is complete.

2. We were not cancelling the print job if cancelled
   when initializing.

3. The remote print document was cancelled even if
   doing nothing.

bug:17451600

Change-Id: I79a80b723af8537da260012470748b4e8831fd9e
This commit is contained in:
Svetoslav
2014-09-10 14:35:58 -07:00
parent 9127e4580c
commit 3ef8e203c8

View File

@@ -219,8 +219,6 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setState(STATE_CONFIGURING);
Bundle extras = getIntent().getExtras();
mPrintJob = extras.getParcelable(PrintManager.EXTRA_PRINT_JOB);
@@ -311,13 +309,17 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
@Override
public void onPause() {
PrintSpoolerService spooler = mSpoolerProvider.getSpooler();
if (mState == STATE_INITIALIZING) {
if (isFinishing()) {
spooler.setPrintJobState(mPrintJob.getId(), PrintJobInfo.STATE_CANCELED, null);
}
super.onPause();
return;
}
if (isFinishing()) {
PrintSpoolerService spooler = mSpoolerProvider.getSpooler();
spooler.updatePrintJobUserConfigurableOptionsNoPersistence(mPrintJob);
switch (mState) {
@@ -343,6 +345,10 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
mPrinterRegistry.setTrackedPrinter(null);
mPrintPreviewController.destroy();
mSpoolerProvider.destroy();
if (mPrintedDocument.isUpdating()) {
mPrintedDocument.cancel();
}
mPrintedDocument.finish();
mPrintedDocument.destroy();
}
@@ -364,7 +370,8 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (mState == STATE_INITIALIZING) {
return super.onKeyUp(keyCode, event);
finish();
return true;
}
if (keyCode == KeyEvent.KEYCODE_BACK