diff options
author | 2018-02-21 13:59:47 -0800 | |
---|---|---|
committer | 2018-02-21 14:40:17 -0800 | |
commit | e65a9b8ebe464c52c565802a4a24232cc108dffe (patch) | |
tree | 469c9ca5e63a4faf6b9c402e51ede382eaf4ff25 /packages/PrintSpooler/src | |
parent | 9131b2f1c833270096e85744fbf14e3a2e6af85b (diff) |
Create print job when print activity starts
This guarantees that the print job is created before the print activity
deals with it.
Test: CtsPrintTestCases
Change-Id: I3451fff71bd981beb45882b7b42d4cc49d63a91c
Fixes: 73127052
Diffstat (limited to 'packages/PrintSpooler/src')
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerProvider.java | 4 | ||||
-rw-r--r-- | packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java | 29 |
2 files changed, 19 insertions, 14 deletions
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerProvider.java b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerProvider.java index 06723c33814d..24449fd393a0 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerProvider.java +++ b/packages/PrintSpooler/src/com/android/printspooler/model/PrintSpoolerProvider.java @@ -16,6 +16,8 @@ package com.android.printspooler.model; +import static android.content.Context.BIND_AUTO_CREATE; + import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -32,7 +34,7 @@ public class PrintSpoolerProvider implements ServiceConnection { mContext = context; mCallback = callback; Intent intent = new Intent(mContext, PrintSpoolerService.class); - mContext.bindService(intent, this, 0); + mContext.bindService(intent, this, BIND_AUTO_CREATE); } public PrintSpoolerService getSpooler() { diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java index d73a5d73e5bf..83d7e1666809 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java @@ -306,19 +306,22 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat // This will take just a few milliseconds, so just wait to // bind to the local service before showing the UI. mSpoolerProvider = new PrintSpoolerProvider(this, - new Runnable() { - @Override - public void run() { - if (isFinishing() || isDestroyed()) { - // onPause might have not been able to cancel the job, see PrintActivity#onPause - // To be sure, cancel the job again. Double canceling does no harm. - mSpoolerProvider.getSpooler().setPrintJobState(mPrintJob.getId(), - PrintJobInfo.STATE_CANCELED, null); - } else { - onConnectedToPrintSpooler(adapter); - } - } - }); + () -> { + if (isFinishing() || isDestroyed()) { + if (savedInstanceState != null) { + // onPause might have not been able to cancel the job, see + // PrintActivity#onPause + // To be sure, cancel the job again. Double canceling does no harm. + mSpoolerProvider.getSpooler().setPrintJobState(mPrintJob.getId(), + PrintJobInfo.STATE_CANCELED, null); + } + } else { + if (savedInstanceState == null) { + mSpoolerProvider.getSpooler().createPrintJob(mPrintJob); + } + onConnectedToPrintSpooler(adapter); + } + }); getLoaderManager().initLoader(LOADER_ID_ENABLED_PRINT_SERVICES, null, this); } |