Merge "Cancel current work in PrintDocumentAdatper if printing is cancelled." into klp-dev
This commit is contained in:
@@ -37,4 +37,5 @@ oneway interface IPrintDocumentAdapter {
|
||||
void write(in PageRange[] pages, in ParcelFileDescriptor fd,
|
||||
IWriteResultCallback callback, int sequence);
|
||||
void finish();
|
||||
void cancel();
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -357,6 +357,9 @@ public class PrintJobConfigActivity extends Activity {
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (isWorking()) {
|
||||
mRemotePrintAdapter.cancel();
|
||||
}
|
||||
mControllerState = CONTROLLER_STATE_CANCELLED;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user