Print job files and print job records not always cleaned up.

1. We want the files for a print job to be removed as early as possible
   typically because the print job was cancelled, completed, the app
   or the spooler crashed during print job construction. We were keeping
   around in the spooler and hence to disc infos for jobs that are in
   final state since the app that created them may hold a reference to
   a local print job objec whose info it can access to get the latest
   print job state potentially after the job reached final state. The
   issue was that we were persisting to disc created print jobs which
   were during construction which requires careful handling for the
   various cases above. This is tricky and error prone.

   We used to tell the spooler to forget the print jobs infos when the
   app that created them died. The implementation to forget a print
   job was not careful and was nuking currently running print jobs in
   addition to the ones in a terminal state. Further, if the app dies
   before a print job is completed we were left with a stale print
   job in the spooler since we missed the signal to forget it (assuming
   we forget only inactive jobs). These issues suggest that the approach
   is problematic.

   Now we have a cache of print job infos for the jobs an app created.
   This cache is updated when the state of a print jobs changes using
   the new print job state observation code. When the app dies we
   remove the cached jobs for that app. Now if the app calls to get
   the print jobs it gets the cached ones, i.e. the print jobs it
   created during its lifetime, plus the print jobs that are still
   active fetched from the spooler. Note that transient state cannot
   be kept in the spooler since we unbind from it if there is no
   work and it may get killed.

2. Improved the print sub-system logging code to show the cached
   print job infos for apps and also dump the print job PDF file
   names.

bug:10958357

Change-Id: I6f7c1968b6b7ba5be182a10df044ff7ea1fc3a61
5 files changed