Clarify synchronization between PrintActivity and RemotePrintDocument
The general theme of these changes is to always delay any action until the printDocument finishes a command. This is done: - Before callinng for into a different activity to select a name for the PDF - Before finishing The second theme is to fix the canceling behavior of RemotePrintDocument.AsyncCommand. There are four bugs fixed in this review: (1) When the RemotePrintDocument.AsyncCommand is canceled it goes into the "canceling" state. When it is canceled again it should stay in this state. Before it went to "canceled" but the command was still running. (see AsyncCommand#cancel()). (2) When finishing the PrintActivity in PrintActivity.doFinish() we cancel the RemotePrintDocument. If there is a command still in progress (i.e. isUpdating()) and it finished as canceled we used to call doFinish() again and then try to double-clean up which lead to exceptions. The new behavior is that is the PrintActivity is calling doFinish() while a command is still in progress (i.e. isUpdating()) we delay the cleanup until the command finishes. The command might finish as canceled, completed or failed. Hence we have to call doFinish() in the callbacks for all three cases. (3) When canceling there might have still been a nextCommand ready, hence canceling does not stop execution of the RemotePrintDocument which could lead to running commands while finshing. (4) When getting the location to store the PDF at a command might still be in progress. This lead to half executed commands and caused issues once we try to continue after the select-location-activity returns Bug: 24713704 Bug: 24973884 Change-Id: Ied90fe8dc9bd6ea7f8b3e4ce4f922e477015568d
Loading
Please register or sign in to comment