Merge "Cancel current work in PrintDocumentAdatper if printing is cancelled." into klp-dev

This commit is contained in:
Svetoslav
2013-10-31 21:42:06 +00:00
committed by Android (Google) Code Review
4 changed files with 27 additions and 0 deletions

View File

@@ -37,4 +37,5 @@ oneway interface IPrintDocumentAdapter {
void write(in PageRange[] pages, in ParcelFileDescriptor fd,
IWriteResultCallback callback, int sequence);
void finish();
void cancel();
}

View File

@@ -615,6 +615,18 @@ public final class PrintManager {
}
}
@Override
public void cancel() {
// Start not called or finish called or destroyed - nothing to do.
if (!mStartReqeusted || mFinishRequested || mDestroyed) {
return;
}
// Request cancellation of pending work if needed.
synchronized (mLock) {
cancelPreviousCancellableOperationLocked();
}
}
@Override
public void onActivityPaused(Activity activity) {
/* do nothing */

View File

@@ -357,6 +357,9 @@ public class PrintJobConfigActivity extends Activity {
}
public void cancel() {
if (isWorking()) {
mRemotePrintAdapter.cancel();
}
mControllerState = CONTROLLER_STATE_CANCELLED;
}

View File

@@ -137,4 +137,15 @@ final class RemotePrintDocumentAdapter {
Log.e(LOG_TAG, "Error calling finish()", re);
}
}
public void cancel() {
if (DEBUG) {
Log.i(LOG_TAG, "cancel()");
}
try {
mRemoteInterface.cancel();
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error calling cancel()", re);
}
}
}