Do not do a layout and write while a cancellation is in progress.

While printing the app gets callbacks to do a layout and a write. Since
these operations can take a very long time they are implemented in a async
fashion. For example, if there is a layout request while we are still doing
a layout, we ask the application to cancel the previous layout. The problem
was that we were not waiting for the cancellation result before calling
the subsequent layout. Hence, the app ends up having to do two layouts at
the same time which breaks the printing contract. Same for write.

bug:11118426

Change-Id: If7b191c44387d88d5cec195d1785a47f986965ba
1 file changed