• Home
  • History
  • Annotate
  • only in /frameworks/base/packages/PrintSpooler/src/com/android/
History log of /frameworks/base/packages/PrintSpooler/src/com/android/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
61209bc9245764f86b7d9fa9f1105239b994fe0b 23-Jun-2016 Philip P. Moltmann <moltmann@google.com> Do not launch non exposed add printer activity

Change-Id: I0b9b11ea0ce0140c77dff2539b1a0a9dcf1558b0
Fixes: 29580579
rintspooler/ui/AddPrinterActivity.java
0c470821d35d1aa13f051c883d9ab7ed292f81df 03-Jun-2016 Philip P. Moltmann <moltmann@google.com> Cache resources needed to sort media sizes.

- Cache media_standard_iso
- Cache labels between configuration changes (localization might
change labels)
- Use ints instead of String's for standards
- Use HashMap instead of Array map as the lookup is faster for
larger arrays

Fixes: 29068056
Change-Id: I027c80fac4d7e8ea6c2cac0f1a2d52b54807f5be
rintspooler/ui/PrintActivity.java
rintspooler/util/MediaSizeUtils.java
cd7b1b7cdf61298966ed7df6621d077afbf81aed 01-Jun-2016 Philip P. Moltmann <moltmann@google.com> Do not rotate PDFPrinter pages.

- applyPrintAttributes is only used by PDFPrinter

Fixes: 29057330
Change-Id: I883cc64039f4ca2c93810e99d758f2dceec67a8b
rintspooler/renderer/PdfManipulationService.java
b852d0138ab84817b042791e0e204459d87038ce 18-May-2016 Philip P. Moltmann <moltmann@google.com> Merge "Declare no print services if 0 print services are enabled." into nyc-dev
e951a139161db650ca711695f78a269e4daaf819 17-May-2016 Philip P. Moltmann <moltmann@google.com> Declare no print services if 0 print services are enabled.

Fixes: 28833953
Change-Id: I94e77dc23107fab10d45f51169d71e4da574ee66
rintspooler/ui/SelectPrinterActivity.java
f1413249db087509070a7a4ad67db781ef4845cf 17-May-2016 Philip P. Moltmann <moltmann@google.com> Handle printers selected by SelectPrinter activity

- Declare a printers availability when changing the removed state.
- Set printJob.printerId to current printer when returning from
SelectPrinter

Change-Id: Ie4680be04fa614a4088f2f32a527e80928c957cc
Fixes: 27643305
rintspooler/ui/PrintActivity.java
9a40a32ae96b791712d997d1a6147e3565ea5eef 12-May-2016 Philip P. Moltmann <moltmann@google.com> Clear state when ProgressMessageCtrl. is canceled

Otherwise the following can happen:
- The progressController is _not_ running and we are running through
an update.
- Then onUpdateCompleted is called which cancels the not running
progressController. This then reset whatever state was previously
stored as mPreviousState leaving the PrintActivity in a weird state.

Fixes: 27945565
Change-Id: Id46b8853ba634634198a74921c8a1790c435678c
rintspooler/ui/PrintActivity.java
e05a7b71c61a7dd4b7f6f55e23a33807d19b1d98 12-May-2016 Philip P. Moltmann <moltmann@google.com> Handle failure to create file.

This should never happen unless you disable the DocumentsUI app. Hence
handle it by a simple toast.

Bug: 28709934
Change-Id: Iac4aff32617120c442e0f994a2a8c0ce3cca380d
rintspooler/ui/PrintActivity.java
383189f494aba302555113ba6873a151bcb4a414 02-May-2016 Philip P. Moltmann <moltmann@google.com> Merge "Handle more config changes and handle onDestroy" into nyc-dev
8582909caefe952d02889e239642af945f64c03d 02-May-2016 Philip P. Moltmann <moltmann@google.com> Merge "Visibility of pageRangeTitle =!= pageRangeText" into nyc-dev
f24285d7b323ff7dd5b3f2f4d9910db2c9a6495d 30-Apr-2016 Philip P. Moltmann <moltmann@google.com> Visibility of pageRangeTitle =!= pageRangeText

Before if we had only a single page we showed the title, but not the
text

Change-Id: Ie2c178eaf19885e0b1dcc803b9da23ed687764a7
rintspooler/ui/PrintActivity.java
172d840cd133969a5d6c9e9657927ffdbcd44093 30-Apr-2016 Philip P. Moltmann <moltmann@google.com> Handle more config changes and handle onDestroy

- The PrintActivity has to handle all config changes to not loose track
close the connection to the printing app
- In the case where onDestroy is called we need to make sure to
- not do any more UI operation
- on async calls after destroy is already called, handle failure to
unbind services.

Change-Id: If21335543fbfa16ecfe77d1965b2e8a13dfa14b8
rintspooler/model/PageContentRepository.java
rintspooler/ui/PrintActivity.java
3c757036a3c0425ccabadb92e6e609bb2ea0a777 29-Apr-2016 Philip P. Moltmann <moltmann@google.com> Delay callback from printerRegistry after Constr.

If the leader inside of the printer registry can immediately initalize
the callback is called in the same thread as the contructor is
executing. Hence in this case the mPrinterRegistry field is used before
written.

Change-Id: I45239d2792f6c31ec215ddb01131038882ff0136
rintspooler/ui/PrintActivity.java
4bd8fac48ed28494ca24e456e20b3058f78e8fe9 22-Apr-2016 Philip P. Moltmann <moltmann@google.com> Send update notifications when the status of a print job updates and
make sure to only access mPrintServicesChangeListenerRecords when
locked.

Bug: 28315242
Change-Id: Ie41ee695e6b1b0394e55538b9d9edaee0610f1e0
rintspooler/model/PrintSpoolerService.java
d0e1239e81f1ee5c1d1d52bd2c2296b71d1a9e96 13-Apr-2016 Philip P. Moltmann <moltmann@google.com> Add a log if the printing activity died unexpectly.

Bug: 27861927
Change-Id: I431ba996e113043c224039a62a76ae23e9c7494a
rintspooler/ui/PrintActivity.java
1a1f24980cb440752910fd4caddcd0bdc27f2c35 06-Apr-2016 Philip P. Moltmann <moltmann@google.com> Merge "Prefix printer description with service-label instead of package-label." into nyc-dev
3df18a94657e1554ed1aca87b5aedbc2d7eb7a48 02-Apr-2016 Philip P. Moltmann <moltmann@google.com> Prefix printer description with service-label instead of package-label.

Change-Id: Ibe98e0037ad8d62b27b10b72d75fb2e548d0ee90
rintspooler/ui/SelectPrinterActivity.java
c6c319e9889874a1babafa4301dabe193737ebd9 01-Apr-2016 Philip P. Moltmann <moltmann@google.com> Print Activity: Use a single (re-implemented) parsing logig for page ranges.

- Support unbounded ranges, e.g. 4- == 4-pageCount and -2 == 1-2
- Do not allow reverse ranges, i.e. 7-3 is not allowed anymore
- restrict characters that can be typed into field
- force numeric keyboard

- Fix bug that we update the selected pages even if the page ranges are
invalid

Fixes: 13126748
Change-Id: I515d9346ceb152a41b7260792c5dd9bd91b27cab
rintspooler/ui/PrintActivity.java
rintspooler/util/PageRangeUtils.java
a97415b0b768194e3153f18a60b9cf9b0d8f8e33 01-Apr-2016 Philip P. Moltmann <moltmann@google.com> Merge "Make sure to update the selected pages when needed in the right order." into nyc-dev
9e4bbc60a9e95f624e577997259fbd6500dac15d 01-Apr-2016 Philip P. Moltmann <moltmann@google.com> Do not rely on documentInfo.pageCount when selecting which pages to
scrap

documentInfo.PageCount might be set to "unknown" == -1. Hence we don't
know where the last page to scrap ends. Hence defer this decision all
way until PdfManipulationService.removePages as then we know the actual
pages of the document.

Change-Id: I063c3cd084d65a3ac5c60c3d85cec3a346be2680
Fixed: 27948632
rintspooler/renderer/PdfManipulationService.java
rintspooler/ui/PrintActivity.java
7b92d3c04d1d256b4fc1f7a131c3cc4373c55128 31-Mar-2016 Philip P. Moltmann <moltmann@google.com> When we update slow we override the current state. Make sure to reset the state the operation finishes.

Bug: 27945565
Change-Id: If3dc3ad54bbf9bedae0e82aeef7b295ae16e1bf0
rintspooler/ui/PrintActivity.java
c309d7155a436df2bf6042e7564363c10204d00b 31-Mar-2016 Philip P. Moltmann <moltmann@google.com> Make sure to update the selected pages when needed in the right order.

Fixes: 27945066
Change-Id: I9c83a5283d6bf093a35ad835532d3c8690b4b989
rintspooler/ui/PrintActivity.java
9dcb86a48d73f399fb1b5c020005d76d350eeac2 14-Mar-2016 Philip P. Moltmann <moltmann@google.com> Add the print service recommendation service

This service connects through the print manager to the print spooler:

PrintSpooler.AddPrintersActivity <-> PrintManager <-> PrintManagerService <-> UserState <-> RemotePrintServiceRecommendationService <-> PrintRecommendationService <-> PrintRecommendationServiceImpl

Hence there is a lot of mindless plumming.

The actual changes are only in the AddPrintersActivity which is extended
to show another list of services: The recommended services.

The PrintServiceRecommendationService is based on the experimenal print
service stubs provider. This provider was contributed the Android by
Mopria. As this services uses Android own network discovery service most
code from the experimental provider goes away. In fact the only logic
left over is the selections of mdns-txt fields to look at and the
printer vendor configuration.

This relies on the Android MDNS to get fixed (Bug: 27696905). This also
does not deal with how to update the recommendation service.

Bug: 24533249
Change-Id: I6edc6e25fc08a50d478b61c71bb8ea158b08624c
rintspooler/ui/AddPrinterActivity.java
02add6aa91a5468458d6aa47b05701579c6da7d8 31-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Rewrite workflow on how the destination printer is selected." into nyc-dev
456f1e33b808052377a79b91d34091a356652f2c 30-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Update print preview when option is changed and clear ranges when they layout changes" into nyc-dev
7134fcc07ca71cdb9eeccfc7d1846e4408849aec 29-Mar-2016 Philip P. Moltmann <moltmann@google.com> RemotePrintDocument might get destroyed in constructor

... if it cannot connect to remote PrintDocumentAdapter. Then the state
will be set to destroyed and the print activity will be aborted via the
onDied callback.

Bug: 27899066
Change-Id: Ieb287b92ac21fc71a56b491a1035feaff6cd2837
rintspooler/model/RemotePrintDocument.java
c7927cb648c77ae80d18f39c222692f51130e1a9 28-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Update printers even if there are no printers found." into nyc-dev
b5be5ec3b70c2c310601e9d035b4e8fd0db8b085 26-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Handle all configuration changes in PrintActivity as it cannot be destroyed synchronously." into nyc-dev
ebf397625ea5ee41af531da251d8d0cb89c26beb 25-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Change hasCustomPrintIcon and setStatus as requested by API council." into nyc-dev
d74d1e549168ba521e8009961b76e8718be37aa1 18-Mar-2016 Philip P. Moltmann <moltmann@google.com> Change hasCustomPrintIcon and setStatus as requested by API council.

Bonus: null advanced keys produced a exception deep in the print
spooler. Hence prevent null keys on the surface from now on.

Bug: 27716355
Change-Id: I3c064956f4e670cd7091437ade06605aa8d797b0
rintspooler/model/NotificationController.java
rintspooler/model/PrintSpoolerService.java
4ef83c4647471aa5aefce463ed8abfe37da7fd00 24-Mar-2016 Philip P. Moltmann <moltmann@google.com> Update print preview when option is changed and clear ranges when they
layout changes

Before we updated the print preview when the paper size changed but not
when the page ranges changed. This is not consistent. We always change.

Also if there is a change to the options that changes the layout (i.e.
papersize, orientation, minMargins) then clear the selected ranges as
this does not make sense anymore.

This also fixes a bug that when having pages selected while we reduce
the number of pages in the preview we got a NPE.

Bonus: do not constantly re-update the options UI when range or copies
text is updated.

Bug: 27830850, 27741420
Change-Id: I7abe4a74b44ac5c5ee54d12cc0c1ca1540793f0e
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
13460a6cba25b99c405d00bb40939958df332f3f 18-Mar-2016 Joe Onorato <joeo@google.com> Turn off verbose logs and remove log that is covered by verbose logs.

Bug: 27744135
Change-Id: I436cfd325f87b3b9205d50e92e2a70a50dd33344
rintspooler/model/PrintSpoolerService.java
940fa80cd1c81926215a0175f16eb2fc9d5f097d 24-Mar-2016 Philip P. Moltmann <moltmann@google.com> Handle all configuration changes in PrintActivity as it cannot be
destroyed synchronously.

Also: Always destroy print spooler provider when it was initialized to
avoid service leakage if print activity was finished after
onCreate but before onPrinterRegistryReady.

Bug: 27814338
Change-Id: I8401dc6e447cbd726b1a8f7c361b4ddf42e7e11d
rintspooler/ui/PrintActivity.java
49435a72955fd6d2673ac33c34e2417c96fd87fb 23-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Deal with print-preview renderings that do not match the correct number of pages." into nyc-dev
b170c08387169ea65da445b579de2a5655ec8454 21-Mar-2016 Philip P. Moltmann <moltmann@google.com> Don't mix UI and print job state

In PrintActivity.OnPause we set the print job state based on the
PrintActivity state. The issue was that FINISHED was interpreted as
"cancel print job". Actually with FINISHED does not tell what state the
job should be in.

The only purpose of the finished state was to guard against
double-invocation of doFinish().

Hence remove this recently introduced state and use a simple boolean to
guard against doule invocation of doFinish().

Bug: 27760331
Change-Id: I0767c2b0b9c28e8904647cc832c236f67f92bcfe
rintspooler/ui/PrintActivity.java
066bf81b983ce23b91d19b85b7c37a61fba7a9a6 10-Mar-2016 Philip P. Moltmann <moltmann@google.com> Deal with print-preview renderings that do not match the correct number
of pages.

If the printing app declares more pages than the print preview pdf has
we used to throw an exception in the PDFManupulationService. This caused
the bitmap to be never written and the read-bitmap function to hang
forever. This was because read() return 0 meaning "pipe is closed" which
lead to an infinite loop. Now a read of 0 page might cause an exception
if the page is not fully read. This exception then causes the
preview_page_error to be displayed.

Bug: 27556666
Change-Id: I7b9de50dce930629e8d38efd4e2659a00b70cc4e
rintspooler/model/PageContentRepository.java
rintspooler/renderer/PdfManipulationService.java
rintspooler/ui/PageAdapter.java
rintspooler/widget/PageContentView.java
27db6611a76a11a5d271dd824167fa1d4b23f944 07-Mar-2016 Philip P. Moltmann <moltmann@google.com> Treat all remotedocumentadapter-command results as cancel in the case we
are canceling the command.

Before it could happen that we have a pending cancel on a layout command
but the layout command finishes normally. This enqueued a new write
command before the PrintActivity is notified. This in turn prevented the
printactivity from finishing as the write command was still pending.

Bug: 27642724
Change-Id: I3c532d53b0c66c40d2e48ab8b4419251ff473a79
rintspooler/model/RemotePrintDocument.java
74f9a2fc2e87b63ad7e367dff455f934c8a9d396 18-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Do not finish multiple times." into nyc-dev
5849f20124181f35063902829fdfc4c926b4424f 18-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "If we finish before the the remotePrintedDocument is initialized" into nyc-dev
e7f06a874a47df969603654e3ceb8beed288b4ec 17-Mar-2016 Philip P. Moltmann <moltmann@google.com> The PageAdapter update might be caused by the RecylerView.

In this case it cannot call back into the recyclerView and update the
data. For the call path please see the bug.

Bug: 27614499
Change-Id: I84733fea30429c20a2c96085efb47d4da5e1948a
rintspooler/ui/PageAdapter.java
63ce0b737c022281ce4c36e1d90ed9b0270512f0 08-Mar-2016 Philip P. Moltmann <moltmann@google.com> Rewrite workflow on how the destination printer is selected.

This fixes two bugs
(1)
1. Printer was unknown when "all printer" activity was opened
2. Printer gets selected in "all printers" activity
3. Printer is unknown at the time the activity returns and thereby does
not get selected

(2)
If a print service gets disabled _all_ printers of the print service
will be marked as "removed" but do not removed from the adapter. This
is superflous as none of them can be selected anymore. The only thing
we want to make sure of is that the currently selected printer does
not get removed.

The workflow is now always:
- set mCurrentPrinter if needed
- Adjust mPrinterHolders
- adapter.notifyDataSetChanged()
-> PrintersObserver.onChanged()
-> onItemSelected

Bug: 27643305
Change-Id: I35ea7078367ad5a918c6362c04a26c4326e6c3f4
rintspooler/ui/PrintActivity.java
rintspooler/ui/SelectPrinterActivity.java
ada5a047baefa5f4a857ac67aabe7c3a870dc3c7 08-Mar-2016 Philip P. Moltmann <moltmann@google.com> Update printers even if there are no printers found.

It can happen that before we stopped we reported a set of printers. Then
while the loader is stopped, we lost all printers. Then on re-start we
need to tell the clients that there are no printers anymore.

There is one issue: The fused-printers-provider might be started
before the printer registry is fully created. In this case we get a callback
and get all king of NPEs. Hence enqueue the first load behind the
current thread. This makes sure that the current operation - creation of
the printer registry - is finished.

Bug: 27643300
Change-Id: Ife6993d57457f23a0a4a54a11869c742c05da850
rintspooler/ui/FusedPrintersProvider.java
ba245f98d64ac2178205193dbc9c111b6080947e 07-Mar-2016 Philip P. Moltmann <moltmann@google.com> Update 'more options' button when changing the printer.

Change-Id: I1bf71629027c18e297426e26db2923c447e47734
rintspooler/ui/PrintActivity.java
0ad7fc5250334879fb96cdb6c4443c83f8094631 07-Mar-2016 Philip P. Moltmann <moltmann@google.com> Do not finish multiple times.

It can happen that multiple async calls fail and we end up calling
doFinish from all of them. We should just ignore the later ones.

Bug: 27198033
Change-Id: Ica596b966f96e9ade6409cc45c50fd62c4018b1e
rintspooler/ui/PrintActivity.java
32e0755afc236b13d2c3e41797acad56df7f8f74 07-Mar-2016 Philip P. Moltmann <moltmann@google.com> If we finish before the the remotePrintedDocument is initialized

... we should not check if it is updating. As it is not initailized,
we do not have to check either, hence we can just ignore this.

Bug: 27516795
Change-Id: If618f2a10563e83074e38f0b37342a648d54202a
rintspooler/ui/PrintActivity.java
66c96591e2ddb464c67e60dbf4193ef4ec8a620b 24-Feb-2016 Philip P. Moltmann <moltmann@google.com> Add "app printer activity" and always keep the print service state
updated. Also fiddle with the UI to use more standard values.

To be sure the print service state alwasy updated I changed
PrintManager.getPrintServices to return a loader which just wraps a
registerListener/getList/removeListener combo.

I also added a new function to enabled/disable a print service to be
keep all updating logic inside the PrintManagerService->UserState.

Then I changed all code to use this new interface.

Detailed comments:

PrintServiceInfo:
- I had to add the enabled state to the PrintServiceInfo as some users
of PrintManager.getPrintServices want all services but then display
different data depending on the enabled state. Of course I could have
created two PrintManager.getPrintServices-loaders to load the two
separate list of services. I think it is much easier to add this
property though. It is updated every time new data is returned to the
PrintManager.getPrintServices-loader.

AddPrinterActivity:
- This is shown as a dialog-style overlay to indicate that the user will
return to the select-printers activity. It contains of three list that
are updated via separate loaders.
- The recommended services will be added later to keep this path set
small.

PrintActivity:
- There are two small places where we have to update the data when we
get a new list of print services.
- In very, very rare conditions it can happen that the print service
of the current printer gains or looses the "advancedOptions"
activity
- If we have no enabled print services we want to show "Add printer"
instead of "All printers...".
- Also the print registry is not the only loader anymore, hence we have
to assign loader ids to it to not conflict with the other loaders in
this activity.
- Small bug in onPrintersChanged: If a printer is selected and the print
service of this printer gets disabled the holder goes into "removed"
state which disables the printer. When the print service is then
enabled again, we forgot to re-enable the holder.

PrinterRegistry:
- The registry assumed that the FusedPrinterProvider was the only loader
in the activity. This is not true anymore, hence it has to assign the
appropriate loader ids.
- The FusedPrinterProvider has an internal loader, hence we have to
forward a loader Id into it.
- The PrintRegistry is only called backed for a single loader, hence no
need to check the loader-id.

SelectPrinterActivity:
- The AddPrinterDialog was removed as we now have the
AddPrinterActivity.
- Added a loader for the enabled services to update the empty state.
- Added dedicated loader Id for the PrinterRegistry again.
- If we have no enabled services, the SelectPrinterActivity chainloads
the AddPrinterActivity as this is the only thing the user can do
anyway. "Save a click". This should only happen when the activity is
create the first time.
- Moved the "add printer" from the menu item to the list of printers as
suggested by UX and Zach.

PrintManagerService, UserState and IPrintManagerParamtersTest:
- As the only place where the print service state is updated is now the
userstate, we have no more sychronization problems. Whohoo.
- The users can now register for changes to the print services similar
as they can register for changes to the print jobs.
- UserState.getPrintServices is the only function can exposes any
knowledge of the print services to the outside world.

Change-Id: I9be2c7300431e06aaff9bdf7eb36120d869b56ac
rintspooler/ui/AddPrinterActivity.java
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrinterRegistry.java
rintspooler/ui/SelectPrinterActivity.java
rintspooler/util/PrintOptionUtils.java
59d12c6a27c3c928823b336e3f0c85a12a31f1ae 07-Mar-2016 Philip P. Moltmann <moltmann@google.com> Merge "Update print document view if printer capabilities changed" into nyc-dev
8eb451597d5f795c11e96663232ec58a2b1fc60f 04-Mar-2016 Philip P. Moltmann <moltmann@google.com> Redraw the UI when a print page preview is updated

When switching between two printers with different margins but with the
same paper size we were missing updates of the print preview. This
change triggers these updates.

The issue was the we reuse the a bitmap when a page is rewritten. This
causes View.setBackground(drawable) to do nothing as the old
background is the same as the new one. This function only checks the
background drawable object reference, not the content. Hence we need to
add a call that notifies the listeners to the changes on the content of
the drawable.

Bug: 26961677
Change-Id: Id8b9be59c9ca7220f40ac59168f78bfdcccb2761
rintspooler/model/PageContentRepository.java
1bb7f3638a67d4c391cf56753156fed1da5c1bfa 26-Feb-2016 Philip P. Moltmann <moltmann@google.com> Update print document view if printer capabilities changed

Bonus: Remove Printer-onChange listener before other state gets cleaned
up. Otherwise onChange callbacks at the wrong time cause into
destroyed data.

Bug: 27219320
Change-Id: I8335b9d8dd71112b76aa684f00524d4d8aad3f94
rintspooler/ui/PrintActivity.java
d365f695d2941c4fc7e550d4498006a5012a32f5 29-Feb-2016 Philip P. Moltmann <moltmann@google.com> Fix three bugs in the handling of the advanced options activity

- The selected pages is not stored in the print job. But this is used to
communicate with the advanced options activity. Hence patch it up
before sending it out.
- If no media size is set in the returned attributes, do not try to get
the portait size of this null-media size
- The copies can be 0 if the PrintJobInfo was created via
PrintJobInfo.Builder()

Change-Id: Ic75c1db0cd5ffad663d87913dfe23e3f5a729bbf
rintspooler/ui/PrintActivity.java
645a3e1ca6ce26da52fa158ca159a31bd38de77d 25-Feb-2016 Philip P. Moltmann <moltmann@google.com> Force cancel pending RemotePrintDocument commands when the PrintActivity exits

Otherwise the print-client app can prevent the print activity from exiting as
we wait for the command to finish. As this is a violation of the
remote-print-document contract we deal with this similar to a command failure.
As the PrintActivity is exiting we don't further send any commands to the
print-client.

Bug: 27207751
Change-Id: Ieacb16786112f217ca5b8031bfb597598e28dc3d
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PrintActivity.java
cc3fa0d295ea39e412e4a7e0dd4c916b5123bca5 03-Feb-2016 Philip P. Moltmann <moltmann@google.com> 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
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PrintActivity.java
cf5b777c13673cd54a0e9bb37f762aea301ebc07 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Cancel print job if PrintActivity was finished before spooler could be
connected.

This can happen if finish() was called immediately after onResume() and
before PrintSpoolerProvider.onServiceConnected.

There is actually a small issue left. If the connection to the spooler
gets destroyed before it was ever connected the print job does not get
canceled. In this case it will stay "created" until the next reboot and
then it will not get recreated.

Bug: 26428518
Change-Id: I1b8696f326b842160e4db77b985577a1c8978def
rintspooler/ui/PrintActivity.java
56190d5e4b9d940ee64fccd75f3759e68bee15a7 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "Also search in description when filtering printers."
e93cf151fbb0ed1e42d14b767f5f8798ab6876e7 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "Allow the PDF Printer to "print" non-locale-default paper sizes."
18fc58f13dc01cac43ea313800cfee14c6aa0cfa 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "UI improvements for the print spooler"
2fbd43ea27a35afc90d194755bc4269d1daca1d8 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "Update summary when printer changes"
76855d322b18f47962727588550e5aec3850c5e8 01-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "Init and clean up printer registry independat of state."
51dbc8ec6aa619fadb8e9f9bb9bf5bf3b971aa5d 01-Feb-2016 Philip P. Moltmann <moltmann@google.com> Init and clean up printer registry independat of state.

The printer registry is created not in sync with the states or the
activity life-cycle. It might not be initialized when stop is called as
we might have a very quick

create -> start -> stop -> finish

without time for the print subsystem to initialize.

Bug: 21749058
Change-Id: I991029a7fd0ad162c1144ff03438707f16bf0b02
rintspooler/ui/PrintActivity.java
c2f913d09be9b7db40f8135b61d3372dbcb30808 01-Feb-2016 Philip P. Moltmann <moltmann@google.com> Only update UI when bound

If the PrintActivity gets destroyed (e.g. due to low memory) it gets
re-created when the PrintToPDF activity returns in onActivityResult. In
this case onActivityResult is called right after onCreate and before the
UI is bound. This resulted in a NullPointerException when accessing the
unbound UI elements.

Bug: 21749058
Change-Id: I44e625e8c4f10432591d0afcf7825d7e0dbee6f5
rintspooler/ui/PrintActivity.java
17332cb2a7e7a24f97090b489c3bd6c67f8a3906 30-Jan-2016 Philip P. Moltmann <moltmann@google.com> Update summary when printer changes

The new printer might not support the currently selected paper size
hence the printer update changes the paper size.

Change-Id: Ie3864d87df425383b4c37f325c8fbea12f6f6051
rintspooler/ui/PrintActivity.java
443075ab9784f168fc7a73bb09dabf8bf7ab308e 26-Jan-2016 Philip P. Moltmann <moltmann@google.com> UI improvements for the print spooler

- gray out printer icons of unavailable printers
- Increase touch target of more into button
- Use same info icon as in the Settings
- Align text correctly in destination drop down
- In general use same layout as generic list-item (as much as possible)
- remove unnecesary color file

Change-Id: I8b0339df0cb6a5130b5530f21c4ef86cb75a683b
rintspooler/ui/PrintActivity.java
rintspooler/ui/SelectPrinterActivity.java
e33b954165595acec9cf9fe2bc14f4586f541f73 26-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "Check parameters for callers of IPrintManager"
e58d8ff1fbb9d53d9b2ae941fb00721e6195213e 26-Jan-2016 Philip P. Moltmann <moltmann@google.com> Also search in description when filtering printers.

Bug: 26780192
Change-Id: Icd95e7e4daee21bd5904d3a271f306864cf47631
rintspooler/ui/SelectPrinterActivity.java
dc5765eb0c2e9da0d5aa70627f18cf2253f71f53 22-Jan-2016 Philip P. Moltmann <moltmann@google.com> Carry over orientation when updating the printAttributes with the capabilities of the printer.

Bug: 19194758
Change-Id: Iaa9897bc730d8cefa63bed8a5ad02e0a5dc89c71
rintspooler/ui/PrintActivity.java
4959caf149c49f0a58c6a89ec01b909baf3fa579 21-Jan-2016 Philip P. Moltmann <moltmann@google.com> Allow the PDF Printer to "print" non-locale-default paper sizes.

The MediaSizeComparator already sorts the media sizes correctly.

Bug: 12675943
Change-Id: I6fa4b1a8885a60704bc175ec849ea483ffb4bcd8
rintspooler/ui/PrintActivity.java
76d7e3ee70c4299b22b1a03505d2b4f108716c75 15-Jan-2016 Philip P. Moltmann <moltmann@google.com> Check parameters for callers of IPrintManager

- Propagate nullness and non-null-ness up and down from the interfaces.
- Add non-CTS print tests for IPrintManager binder.

Change-Id: I0c310d9cea8aefba5ce386931521ffaf19712bbb
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrinterRegistry.java
5462e88c0272d08773ac6cd16cce435c32d2d9bf 20-Jan-2016 Philip P. Moltmann <moltmann@google.com> Treat empty strings similar to null-strings when composing the subtitle in the SelectPrinterActivity.

Change-Id: Ia0ee353df56b2f835f1ac291dc69eb3747425e6b
rintspooler/ui/SelectPrinterActivity.java
c2ad22663ba8cbd0ceb35e760c5f3c4084fb5033 13-Jan-2016 Philip P. Moltmann <moltmann@google.com> Clean up API for PrinterInfo.

- Make immutable
- Check parameters
- Check state while unparcelling

Change-Id: I13959845ca508936331488506380e894f49abf25
rintspooler/ui/PrintActivity.java
e978af63e63979aa791143c849fc3b1c02e13345 11-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "Do not add far favorite printers more than once."
fcb51b8270f6e91f7eb3c6ab8efe62d92f2b9b73 11-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "ApprovedServices might be null, handle the case:"
8d978ba1e7dfd2f6ee74dbc3a32d272d4d8ed964 11-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "In rare cases the printing client app might have been dieded before remotePrintDocument.start(). In this case the print spooler should not crash."
0d1e622000820bf3d83419757929367ecb9f1fdd 09-Jan-2016 Philip P. Moltmann <moltmann@google.com> ApprovedServices might be null, handle the case:

Bug: 26454066
Change-Id: I909d84d08a1f6d29f486e8ea6097e782b054864e
rintspooler/util/ApprovedPrintServices.java
9b99d76a7141f782f12cc3e78aa45e2cd4a4a097 09-Jan-2016 Philip P. Moltmann <moltmann@google.com> Do not add far favorite printers more than once.

The favorite printer list contains a printer multiple times as it might
have been used at different locations. Hence it can be that a printer is
in the favorite printer list multipe times but never considered close.

Hence we go into the second loop and add it multiple times as we never
add it to alreadyAddedPrinter.

Change-Id: I4ca8a6a5a05f43645a0b2c891a55df2ccce05ad4
rintspooler/ui/FusedPrintersProvider.java
f6114c4f1ea92e740191b173515e1fdbc7450583 08-Jan-2016 Philip P. Moltmann <moltmann@google.com> In rare cases the printing client app might have been dieded before remotePrintDocument.start(). In this case the print spooler should not crash.

Change-Id: Ica1b46fadf6bccbd28e8f9c928f5d504cccff792
rintspooler/model/RemotePrintDocument.java
1f46779f5ecaa9e71bf91474160007203b213fc2 08-Jan-2016 Philip P. Moltmann <moltmann@google.com> Display toast when print services are disabled.

Change-Id: Id1ebcbbf39eb558bc15c7c69c03fe8124b9c79d7
rintspooler/ui/SelectPrinterActivity.java
8141bdfa56f13c3946bed12ba7801e492ec25c11 22-Dec-2015 Philip P. Moltmann <moltmann@google.com> Store which print services are disabled instead of which are enabled

This make services that appreared while the print manager was not active
by default enabled.

In the case we upgrade from pre-N we convert the enabled-list into a
disabled-list.

Bug: 26249649
Change-Id: Iae783a8dd19f1a9d75d675710ea4348fdfbd34f3
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/SelectPrinterActivity.java
rintspooler/util/ApprovedPrintServices.java
a5fcd5028a158df5ed11413ac2d4c5a313ecdb37 07-Jan-2016 Philip P. Moltmann <moltmann@google.com> Remove debugging from print notification code.

Change-Id: I3f0fb6c68de0b3f4cd0fa67ddf8c405199d6498e
rintspooler/model/NotificationController.java
a1cdb4bacb737db91cf35a1d49e59b8844c69409 06-Jan-2016 Philip P. Moltmann <moltmann@google.com> Use notification grouping for print notification.

Change-Id: Ifb5bc0f233611a056db511b15379165ac6fe0edf
rintspooler/model/NotificationController.java
f25c40333760a7f6fc54ed6693080219ee06b2c4 23-Dec-2015 Philip P. Moltmann <moltmann@google.com> Show indeterminate progress bar when job is queued or started and the progress is not known.

Bug: 24135025
Change-Id: Id8d365e41573a3ea7018cadeb8d6e857f0dbe1cf
rintspooler/model/NotificationController.java
98963260dc30f1dc3e89dbd0efdfcdc6398d753c 17-Dec-2015 Philip P. Moltmann <moltmann@google.com> Prefer printers that have been used physically close to the current
location of the user.

Commonly the users prints on a printer that this near the user current
location. Hence if possible we want to show the user printers that he
used before and that are close to him.

Hence store the location of the previous uses of a printer and prefer
printer that are close to the user.

Unfortunately getLastLocation might not report a usable location and it
will take at least 5 seconds until the first usable location arrives. At
this time the user might have already opened the destionation spinner.
It would be unexpected for the printers to suddenly change under the
users finger. Hence it might be that we did first show the printer
without any location information and then once the location is known we
cannot update thedestination spinner anymore.

The select printer activity does not have this issue, hence in the worst
case the user has to enter this activity to select a printer and by then
the location is usually determined.

This is not ideal but better than before.

Bug: 24133609
Change-Id: Ie7d20cf3d9dd163e57903f8f6ecc0b3fd4f4374e
rintspooler/ui/FusedPrintersProvider.java
4c95567b5f572a3ec505308c9f3a9609d4149fdb 23-Dec-2015 Philip P. Moltmann <moltmann@google.com> Merge "Clean up print subsystem"
30172e25615de5eb5ea2477a7e6845541e5574c5 23-Dec-2015 Philip P. Moltmann <moltmann@google.com> Merge "Close closeguard of PageContentRepository."
c43639c3067dda5df189fb3cbf14f256c17e677d 18-Dec-2015 Philip P. Moltmann <moltmann@google.com> Clean up print subsystem

- Stop using deprecated APIs
- Fix all public and some internal javadoc
- Add @Decorations to public APIs
- Some minor cleanup, e.g. don't use variables with overlapping names in same scope
- remove unnecessary properties from manifest (they are set by the build
system)

Change-Id: I0ce8849a516414763fe9de76c3a18ce17d896816
rintspooler/model/PrintSpoolerService.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PrintContentView.java
bb9f686b40743df2642b7d3b7778dbf7284ae665 01-Dec-2015 Philip P. Moltmann <moltmann@google.com> Allow a print service to specify per printer icons, description and
info-activities

The icon is loaded from the discovery session only when it is displayed
to avoid having to store too many icons in memory.

Also the icons are not maintained in the historical printers. Only if
the printers are available nice icons are shown. A historical printer is
updated with the appropriate properties (including icon) once it becomes
available.

Bug: 24135005
Change-Id: Iec389bab514b024634be8fb5fc8928371cba8740
rintspooler/model/CustomPrinterIconCache.java
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/SelectPrinterActivity.java
38fdd4f486fea2a816ca43f365e68118fe747c61 17-Dec-2015 Philip P. Moltmann <moltmann@google.com> Close closeguard of PageContentRepository.

Change-Id: I4ee143e94fde7ac4dbc25e6208caafdab819df31
rintspooler/model/PageContentRepository.java
a958fc336b277cf2838ccd50ef3d3484644b100a 03-Dec-2015 Philip P. Moltmann <moltmann@google.com> Unset is -1 not Nan

Change-Id: I6e7fac4b9f1c3dc6cc88c786db856ddecf3f8538
rintspooler/model/PrintSpoolerService.java
b3078c235e7674fd61be75fb469105ba6174aba5 24-Nov-2015 Philip P. Moltmann <moltmann@google.com> Allow print service to specify progress of print and status

The status has always been there in error cases, it is now also visible
in non-error cases.

If the progress is not set, no progress bar is shown.

Bug: 24135025
Change-Id: Iea23f45d236365433c6f6739597833d236ed6d19
rintspooler/model/NotificationController.java
rintspooler/model/PrintSpoolerService.java
1f3257d7666a5bcb16bc15fca8cad13cea6caf11 26-Nov-2015 Yohei Yukawa <yukawa@google.com> Merge changes Iee47e374,Icc64942a

* changes:
Use Context.getSystemService(Class<T>) for InputManager.
Use Context.getSystemService(Class<T>) for InputMethodManager.
777ef95ebf18c61ff09e7567a06058d351c530ca 26-Nov-2015 Yohei Yukawa <yukawa@google.com> Use Context.getSystemService(Class<T>) for InputMethodManager.

This is a mechanical replacement of Context.getSystemService(String)
with Context.getSystemService(Class<T>) when retrieving
InputMethodManager. Note those are bundled code. Hence we don't need
to make sure Build.VERSION.SDK_INT >= 23.

Change-Id: Icc64942ad8f11e44bf84f8d4fe476b2fdd1257f3
rintspooler/ui/PrintActivity.java
03755a1f12390be9ddfcce8c5ad3f887fa5ccf9f 25-Nov-2015 Philip P. Moltmann <moltmann@google.com> Syncronosuly notify SelectPrinterActivity about changes to enabled print
services

If the SelectPrinterActivity is visible it shows different emptyState
depending on if there are print services available or not. Hence the
activity has to listen to changes to the list of enabled services.

This also fixes a small syncronsation problem if two observers are
registered for the enabled print services.

Bug: 25666802
Change-Id: I79af66f25f10e66347b48ce9bb99c1657b30a8dd
rintspooler/ui/SelectPrinterActivity.java
c9137615e437b2bfa2ce47db0ec338df0030fe3f 24-Nov-2015 Philip P. Moltmann <moltmann@google.com> Merge changes from topic 'AddPrinters'

* changes:
Create PrintDiscoverySession for future print services
Update printer availability when printSpooler is paused. This makes the window update syncronously when in multi-window mode.
abef6d6f2b3224960be4cb5625e862498f4b7edf 24-Nov-2015 Svetoslav Ganov <svetoslavganov@google.com> Merge "Allow fragment state loss on fragment transaction"
d25ddc3d0ee9d24f0e4c2e7c92defce4c3228f11 24-Nov-2015 Svetoslav <svetoslavganov@google.com> Allow fragment state loss on fragment transaction

We are not saving the state of this fragment on onSaveState,
so its Okay to loose state while confirming the transaction.

bug:25847358

Change-Id: I2f6587d528b2d8b8f24a83954cc896a6ff514996
rintspooler/ui/PrintActivity.java
dd635ce95cd6824b5d6e101f77d0bff154b3e4b4 21-Nov-2015 Philip P. Moltmann <moltmann@google.com> printspooler.NotificationCOntroller: Remove deprecated APIs and silence other warnings.

Change-Id: I53000e49793dccd6f53b0813e5ce97c5c6929832
rintspooler/model/NotificationController.java
e2b95e4c5689d55e078076d4cc030c1609429bfb 20-Nov-2015 Philip P. Moltmann <moltmann@google.com> Update printer availability when printSpooler is paused. This makes the window update syncronously when in multi-window mode.

Change-Id: If802f32a011b24ec8cca9292eb12bbb399548a40
rintspooler/ui/PrintActivity.java
5e54896d0b0748d46bfcecef92148ad365119696 14-Nov-2015 Philip P. Moltmann <moltmann@google.com> Show "select a printer" as "destination" the first the the user prints

The Spinner does not support a prompt, hence temporarily hijack the
first element and install an alternate view. Once the Spinner is touched
revert to the old behavior.

If we showed a prompt the views in the spinner cannot be recycled.

Bug: 24132864
Change-Id: Iaf97878f85388a8c6351e716117b16f34919ad84
rintspooler/ui/PrintActivity.java
d86e8d813b120f0d82265f15fd15cc49c90e26e4 13-Nov-2015 Philip P. Moltmann <moltmann@google.com> Merge "Do not disable the add printer icon and have special empty view if no print services are enabled"
953639cb826ad5fb85fcc18cbc0833a9dedb8227 12-Nov-2015 Philip P. Moltmann <moltmann@google.com> Do not disable the add printer icon and have special empty view if no
print services are enabled

The add printer icon is always visible as this is used for both adding
a printer and adding addition print services

We have three different empty views now:
1. No print services
2. No printers found (not search filter set)
3. No printers found (search filter set)

Bug: 24132367
Change-Id: Ic30812b60986f1e0f023488cefc6aa901ce20824
rintspooler/ui/SelectPrinterActivity.java
6dc9114ef8a214d11d8df7babf1959d0193e95bc 12-Nov-2015 Philip P. Moltmann <moltmann@google.com> Merge "Deal correctly with suggested print attributes"
b4efdb4726a442eef38bb6417d5acb8eb68b912d 10-Nov-2015 Philip P. Moltmann <moltmann@google.com> Deal correctly with suggested print attributes

An app might suggest certain attribute for an print job. This patch
fixes

- PrintActivity should not silently overwrite the attributes with
the default values
- Handle duplex mode in PrintAttributes similar to the other attributes.
I.e. have an "unset" value (0). This is an API change. But the only
use case for PrintAttributes was to pass them to print() and thereby
the PrintActivity. This was broken (see above), hence we are changing
and API that could have never been used.

Bug: 23629618
Change-Id: I43c25704497c799352fb806126dc93f6db4879f5
rintspooler/ui/PrintActivity.java
59cf3086a9db64244743c2ef4a91102acf89d955 10-Nov-2015 Svetoslav Ganov <svetoslavganov@google.com> Merge "Avoid NPE in printspooler when changing language" am: 8d8515e708 am: 5522efb130
am: 16009a6dea

* commit '16009a6deaff272c94046facbeb567bafdaacc69':
Avoid NPE in printspooler when changing language
853a6f564abaf8acbd88c6704008c5d150d00471 03-Nov-2015 Philip P. Moltmann <moltmann@google.com> Add a alert that allows the user to approve a print service when
we print using it the first time.

This warning used to be shown when the print settings app was used
to enable a service.

If two warning as shown for the same print service we automcatially
dismiss all dialogs once one dialog is confirmed. Please note that
we are not confirming the printjob as it is unexpeced to have a
single click to confirm multiple print jobs.

Change-Id: I8bb0a49bac2063c1c55e2f24bd34df2c44e2df89
Bug: 24135353
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/PrintActivity.java
rintspooler/util/ApprovedPrintServices.java
86d13f3daf6f5562bd83d086008d287c58d841c3 03-Apr-2015 Masaaki Iwaguchi <masaaki.x.iwaguchi@sonymobile.com> Avoid NPE in printspooler when changing language

PrintActivity is recreated when the language setting is changed.
As a result of the recreation mCurrentPrinter is null, which causes
a NullPointerException when onActivityResult() is called.

The issue is solved with a simple null check.

Change-Id: Ic58f0ca01577d2ec02d494739f3bc2f06240dd44
rintspooler/ui/PrintActivity.java
dcc34fd8a3f718e5e5cfaccb87eeffd64ac80f63 30-Jul-2015 Chris Wren <cwren@android.com> Instrument printing service for metrics collection.

Bug: 22837316
Change-Id: I8bf62940f5eb495d8d7a10df958d9bc8ad76662a
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/PrintActivity.java
f12b393ff406a3bb8967b69a9be2dd27b0725b33 25-Jul-2015 Svet Ganov <svetoslavganov@google.com> Pass correct extras to the custom print options activity

bug:22734138

Change-Id: Iea1bc32c3e863072b2021b823bef2cefa54fa540
rintspooler/ui/PrintActivity.java
5772b5c671a13d9c4bbc1e3803667166f811cb33 11-Jun-2015 Svet Ganov <svetoslavganov@google.com> Propagete document meta-data to custom print UI.

Change-Id: I3f122224e1b311a222969253ae0336177989a414
rintspooler/ui/PrintActivity.java
9e9e2e73c6ec7bece20268196dc89ad0c8bafad4 08-May-2015 Wojciech Staszkiewicz <staszkiewicz@google.com> Pass charset to XmlPullParser.setInput instead of null

Passing null to XmlPullParser.setInput forces it to do additional
work, which can be easily avoided if we know the charset beforehand.

bug: b/20849543

Change-Id: Iaff97be9df2d0f99d7af8f19f65934439c9658e2
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/FusedPrintersProvider.java
4a357cd2e55293402d7172766f7f9419815fc1e8 19-Mar-2015 Alan Viverette <alanv@google.com> Replace usages of deprecated Resources.getColor() and getColorStateList()

Change-Id: I8f64fe6c4c44a92ff6d07250223ba590a1d691b0
rintspooler/model/NotificationController.java
rintspooler/widget/PrintContentView.java
08c7116ab9cd04ad6dd3c04aa1017237e7f409ac 28-Feb-2015 John Spurlock <jspurlock@google.com> Remove unused imports in frameworks/base.

Change-Id: I031443de83f93eb57a98863001826671b18f3b17
rintspooler/model/PrintSpoolerProvider.java
a7bb6fbeab933326d58aa806d8194b7b13239d34 04-Feb-2015 Dianne Hackborn <hackbod@google.com> First quick implementation of auto assist data.

Introduce new AssistData class that contains all data
the framework automatically generates for assist. Currently
populated with a very simple tree structure representing
the app's view hierarchy.

Reworked how we populate the class name for accessibility
info, so this is provided through a new method call on View
that subclasses can override. This method is also used
to populate the class name in AssistData.

Change-Id: Ibd0acdc8354727d4291473283b5e4b70894905dc
rintspooler/widget/PreviewPageFrame.java
948c9a6393e0995a4d988d5d164998aa0e12b25d 03-Feb-2015 Svetoslav <svetoslavganov@google.com> Add duplex mode support.

This change adds support for duplex printing. The print UI now has a duplex
option which allows the user to choose one of the supported duplex options
by the currently selected printer. The chosen duplex mode is propaged to the
print service that manages this printer.

Change-Id: I807ba9da2723531535c0e1e33f2f4e1b503a54b0
rintspooler/model/PrintSpoolerService.java
rintspooler/ui/PrintActivity.java
eaaf0512fcbf03b926cdbbbb7f54df474ecf861a 26-Nov-2014 Svet Ganov <svetoslavganov@google.com> Crash in print spooler when back pressed before content update complted.

We are updating the printed content asynchronously. If the user cancels
printing before the first update is complete the spooler components are
in a destroyed state but we attempt to handle the completed update resulting
in a crash. Now if printing is cancelled we ignore the update result.

bug:18525491

Change-Id: I1ef47a17de19896cba2c7a1dd2bfc205065e0a5a
rintspooler/model/PageContentRepository.java
rintspooler/ui/PrintActivity.java
c80814e70aea8940d0d43cd7170baae8c0c4e8e3 24-Nov-2014 Svet Ganov <svetoslavganov@google.com> Lockup in the print spooler.

A recent change modified the way we destroy the remote renderer from
asynchronous to synchronous. This caused problems since it was possible
that the remote rendering service is unbound while we are reading the
contents of a rendered page. As a result the reader was blocking on I/O
and the print spooler was getting into a locked state that required a
restart of its process. Now the remote renderer is destroyed
asynchronously.

bug:18498626

Change-Id: I1312bf808f30430728b4038dd4be43c55d2be825
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
f6cd14dbc99b38af7afe1e5f72347395603d7de2 20-Nov-2014 Svet Ganov <svetoslavganov@google.com> Print spooler crash when printing after a rotation.

1. Available printers are provided by a loader driven by the activity
lifecycle. After a rotation of an app that does not handle rotation
the print activity is destroyed in a delayed fashion. When another
print task is started the loader of the destroed activity gets two
cancellations, one when the activity is stopped and one when it is
destroyed but when the second cancellation happens the loader has a
bad state that it is loading while it is not and a NPE occurs.

2. If a rotation happens early before the print activity is fully initialized
(there are asyncrconous operations that take place) we get a NPE as
the print preview controller is not created yet.

3. A lockup of the print preview process occurs if the print print
activity is destroyed after we initiated binding to the rendering
service but before we receive the remote interface. In this case no
remote service is received as exepcted since we already unbound from
it resulting in a missed signal.

bug:18238590

Change-Id: I81817d81702f649ded97dfbab7d7bba28f22fa91
rintspooler/model/PageContentRepository.java
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrintActivity.java
fce84f035c35606c5707e735f503f7bdcfd5b2a1 01-Nov-2014 Svet Ganov <svetoslavganov@google.com> Crash apps that print malformed or password protected PDFs.

If apps are writing malformed content (typically not a PDF file) or if the
PDF content they provide to the print system is password protected, are now
crashed as both of these are app bugs.

bug:17636435

Change-Id: Ifce6a3199e587448dd38f6a84290a965c24b698b
rintspooler/model/OpenDocumentCallback.java
rintspooler/model/PageContentRepository.java
rintspooler/model/RemotePrintDocument.java
rintspooler/renderer/PdfManipulationService.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
93134ce87e7b33e599c9ef9ed8b19ec2556ca8f1 31-Oct-2014 Svetoslav <svetoslavganov@google.com> Merge "Save to a PDF file should look like print preview." into lmp-mr1-dev
bec22beb99b279d381f720d761ca75fe3e7414dc 25-Sep-2014 Svetoslav <svetoslavganov@google.com> Save to a PDF file should look like print preview.

When rendering a PDF file for print preview we take into account
the selected print options such as paper size, orientation, etc
without modifying the document. To print we send the doc in its
original form and the print options so the print service can apply
the necessary transforms in addition to the optional custom options
it supports. When saving to PDF we have to actually change the
document as we act as a print service.

bug:13545980

Change-Id: Icdcecf962bec6ff742cc6015df5af9d9086ce760
rintspooler/renderer/IPdfEditor.aidl
rintspooler/renderer/PdfManipulationService.java
rintspooler/ui/PrintActivity.java
7c053c1e414c77ae28adb90390027e21ce57bc5e 29-Oct-2014 Svetoslav <svetoslavganov@google.com> Print preview disappearing if printer is changed.

This is a regression caused by my previous patch.

Change-Id: I80a0b4d880fd4e48e6a44fac303a4c8204e8ec0d
rintspooler/model/PageContentRepository.java
b32f04b785306f06d7d07b824fb8dcc1b4a61aa6 25-Oct-2014 Svet Ganov <svetoslavganov@google.com> Merge "Printing from two apps at the same time not working." into lmp-mr1-dev
99a82437ed8e0537d9a355a124d2bb30aea46ad8 25-Oct-2014 Svet Ganov <svetoslavganov@google.com> Printing from two apps at the same time not working.

When printing from two apps at the same time the second print UI is
getting stuck. There were a couple of issues here:

AdapterView was not notifying for item selection if the data changes
after scheduling a dalayed selection notification and the notification
execution. The code assumed that a layout pass will occur and posponed
the notification after the layout pass but it is not guaranteed that
such a layout pass will occur. Now we delay only if a layout pass is
being scheduled.

Also when binding to the PDF rendering service the print spooler was
using the same intent and as a result two print activites were getting
the same renderer instance while they should get separate ones. Now
we use different data in the intent to ensure we get separate renderer
instances.

Change-Id: I6aa7c7b041957804b4273549dd837a6d70064efc
rintspooler/model/PageContentRepository.java
7cf7c364386d18b94d212d98072e97c1c3d87e26 24-Oct-2014 Svet Ganov <svetoslavganov@google.com> Merge "Crash in print spooler if printing app killed from recents." into lmp-mr1-dev
4237c92d850b7fb0fa0be15df94e4d1689e353fc 24-Oct-2014 Svet Ganov <svetoslavganov@google.com> Crash in print spooler if printing app killed from recents.

If the printing app with the print UI on top is killed from recents we get
a crash because: 1) the remote print document was not transitioned to a
failed state if the printing app dies (this is an unrecoverable failure);
2) the print preview controller was destroyed asyncronosly during which it
also asynchronously disconnects from the rendering service which however
happens after the system has already cleaned up all connections of the print
UI activity as it is being destoryed.

bug:18109386

Change-Id: If6200b14a8aa90622228bbb659e9c4962226f561
rintspooler/model/PageContentRepository.java
rintspooler/model/PrintSpoolerService.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
2916f658c9a55aa5b08a3bbe3056dbfd78e0e1b0 24-Oct-2014 Svet Ganov <svetoslavganov@google.com> Sometimes historical printers not properly ordered.

We order printers based on past usage. In some cases the ordering
does not work. The reason for that was an incorrect assumption that
the entries in an ArrayMap are ordered in the order they are added.

bug:18109283

Change-Id: Ie367e4ca5e6bd79f335a060074c9211054e3a931
rintspooler/ui/FusedPrintersProvider.java
9920a0dcf15ba2036cdcc5d6548efa6b4a8bc944 24-Oct-2014 Svet Ganov <svetoslavganov@google.com> Merge "Set copies to one when saving to PDF." into lmp-mr1-dev
45e50e99cdb10b43b062612c2e87e75841f2c424 23-Oct-2014 Svet Ganov <svetoslavganov@google.com> Set copies to one when saving to PDF.

One can save only one copy to PDF. Showing more that one copy when saving
to PDF enven in a disabled input box is confusing to the user. We now set
the copies to one when the PDF printer is selected.

bug:17631303

Change-Id: Ia04d144efc899e7f3836c19349d9c87f3ae8f0f0
rintspooler/ui/PrintActivity.java
0c8e15c016efa64cc8db6a1f1fbcade34543cf3f 15-Oct-2014 Svetoslav <svetoslavganov@google.com> am 60cdb909: am 0a1ffdb3: Merge "Handle if the printing app is killed while saving to PDF." into lmp-dev

* commit '60cdb909304f0d4b93a1a17228bdcc888f16cf41':
Handle if the printing app is killed while saving to PDF.
05e041b013d8750a66787f5f7eb77c7ec95a670f 14-Oct-2014 Svetoslav <svetoslavganov@google.com> Handle if the printing app is killed while saving to PDF.

When saving to PDF we bring up the file picker UI which covers
the print UI. In this case the printing app may get killed as
it is not in the forground (the system is bound to the print
spooler so it cannot get killed). If that happens we are ending
up with an empty file. However, if the file chooser UI is up
we already have everything from the app we need and it dying
does not matter. This change takes care if ignoring printing
app death while saving to PDF.

bug:17922948

Change-Id: I10d808e3c3e93e850dbc2a948f2482381a887928
rintspooler/ui/PrintActivity.java
2eb7fadcd64120f0e94ebb0f91188900e916c559 02-Oct-2014 Svet Ganov <svetoslavganov@google.com> Custom print settings cannot change resolution.

bug:17677133

Change-Id: Ib8a24101f12d431fe221c1e91711d93a6a517273
rintspooler/ui/PrintActivity.java
922fcc2f9e2370b34672af0e91e5754c6f8d6da7 28-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Crash in print spooler if save to PDF selected early." into lmp-dev
e1dcb397d595c110faadaae6bab861bae97717b8 27-Sep-2014 Svetoslav <svetoslavganov@google.com> Crash in print spooler if save to PDF selected early.

The first issue is that the save to pdf button is enabled
before the first layout completed and at this point we do
not know anything about the document. The second is that
if a layout is in progress and we select save to pdf we
end up starting the documents UI twice and finishing the
second instance carshes the spooler.

bug:17676878

Change-Id: Id0b1f06e4d377347286c2dde09669d431441234b
rintspooler/ui/PrintActivity.java
528424c26cb118a68f77cef94992a0282cfdc12c 27-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix carsh in print spooler if custom print setings return bad pages.

The custom settings activity of a print serivce can change the selected
pages and the spooler was not checking whether the returned pages were
valid leading to a crash.

bug:17678553

Change-Id: Id8ea3d482d2909b97a06752d61b416dfe5948483
rintspooler/ui/PrintActivity.java
d23bfa9d42c477970189a96d4562d627d609e604 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Print spooler should not crash if fed non-PDF content.

It is possible that a buggy app breaks the contract and provides
content to be printed in format other than PDF. This was leading
to a crash in the print spooler. This change fixes the crash and
shows a user friendly error message.

bug:17642690

Change-Id: I5a4acb06080a152562655da6851467b3e71d8658
rintspooler/model/PageContentRepository.java
rintspooler/renderer/PdfManipulationService.java
2bac6129a46b89c5e361fafc2c23b16c5716f847 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Missing pages in print preview when scorolling." into lmp-dev
237806bbc540938a87a26b53f117c82ce75025fa 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Missing pages in print preview when scorolling.

It is possible that two providers for the same page are assigned
to two preview views despite temporariliy while rebinding. We were
however releasing the provider from the view which is being bound
if not for the same page which as a result was cancelling rendering
of this page which is provided to another view via another provider.
Hence, having an empty page. Removed the unnecessary code to release
a provider when binding the view - release is happening only if the
view holder is recycled.

bug:17515670

Change-Id: I197438c16cfdb363f521cd1320f154da54eea5f5
rintspooler/ui/PageAdapter.java
09eb0b203329b1d846de227a8b03774c903b86f0 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Fix ANR in print spooler." into lmp-dev
56683481381003325481143af15d519c1bf0148f 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix ANR in print spooler.

Saving to PDF a subset of the pages requires trimming the
undesired pages and when this is done writing the ready doc
to a URI. To write the file to URI we have to obtain it but
it is aquired by the shredding task and never released. Now
we are releasing the document immediately after trimming it.

bug:17631301

Change-Id: I4db7966c65c75f0f14c3cb52fd83b4d8fd5a4687
rintspooler/ui/PrintActivity.java
254361f136aa9461e16f11f0170fde05e83a1b92 24-Sep-2014 Svetoslav <svetoslavganov@google.com> Print spooler crash on back before first layout is complete.

If the user presses back before the remote print document
update has completed we get a crash. The reason is that
after the update completion we were trying to finish the
activity if we are in a cancelled state but this is not
needed as we aready handled the back key so we will finish.
Handling finish twice was creating the problem as classes
with lifecycles are not designed to be used after being
finished. In particular, we were calling doFinish() twice.

bug:17630561

Change-Id: If418f237a2def7c8e4a072ac8826283f4dd7fc85
rintspooler/model/PageContentRepository.java
rintspooler/ui/PrintActivity.java
cf3a86b55981313e1fdfafbef89ab5ba7276a862 22-Sep-2014 Svetoslav <svetoslavganov@google.com> Loosen the constraint for releasing a shared file.

In the spooler we have the renderer reading a file to visualize
content and the app writing a file to produce the content. Since
we have to swap the file under the renderer we have a mutex file
provider that both parties can request, use when released, and
release when required. This enables us to request the file which
closes the renderer and when the renderer is closed ask the app
to write some more pages, then open the renderer, and so on. The
mutex file provider was throwing of a thread that does not own
the file thries to relase it which is not needed, this should be
just a nop.

bug:17607134

Change-Id: Id6a2ce92d70077f57978b95315648faf02c13c68
rintspooler/model/MutexFileProvider.java
9424b733c7f777fc806a751a7f00d234c11c0e7c 19-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix a print spooler crash when printing.

The spooler communicates with he remote PDF renderer asynchronously.
When print is confirmed we close the renderer, destroy it, and unbind
from its service. If we unbind from the service after the print activiy
is finished we get a crash. The bug was that we did not wait until we
disconnect from the remote renderer before finishing the print activity.

bug:17583115

Change-Id: I55b0135f9c5658b3a4fda2901b8b3bdef044e211
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
b75632c7366d3c848a5d31782d9942dd2818adcb 18-Sep-2014 Svetoslav <svetoslavganov@google.com> Print UI stuck when backing out of documents UI.

When user chooses to save to PDF we open the document chooser UI.
Now if the user now backs to the print UI without choosing a file,
the print UI has all options disabled and the back button does
not work - the user is stuck. This is because we were not
transitioning the print UI in the correct state.

bug:17557454

Change-Id: I385129e106ed41564b89137ca54d409127ba8ff0
rintspooler/ui/PrintActivity.java
0d2d9637ed4f46062d508cfa7da0e9776fc444f8 18-Sep-2014 Svetoslav <svetoslavganov@google.com> Page content sometimes missing in preview when scrolling.

Removed the restriction for the page content providers to
be singletons as the RecyclerView may hold on views with
providers and ask us to bind other views for the same page.
Note that the views that RecyclerView is holding will be
soon rebound or recycled just they are not at the time we
bind other views for the same position. We were guarding
against this but caused some pages not appearing sometimes
on scrolling. Also now keeping the media size and magins
of recycled page view (will be updated if needed on
rebinding) or avoid changes of the background to null as
setting it to not null later causes an undesired layout pass.

bug:17537922

Change-Id: If029f6c413e15d4f5c1ba1ac5e4d52ad2cad5904
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
7fd5ada98aa9e035682531d9fe25633fdd24a058 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Page content sometimes disappears when scrolling a long doc in print preview.

The operations of the remote renderer have to be performed in order, open,
render some pages, close. One of the tasks was executed on the wrong executor
resuling in a race and an occassional bad state.

Also fixed a NPE if the preview list is flinged and then the user presses
back.

bug:17537922

Change-Id: I5048078ba2b875a2a8335f3a4324afaa34d014a2
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PageContentView.java
e9f275d309bfe314921dba51dd7c90686f2748bf 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Print preview disappearing on screen off/on." into lmp-dev
d724a40136f168251f6f62e5a51ad73bf8fe5d1e 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Print preview disappearing on screen off/on.

We were not clearing the tracked printer when the print activity is
paused and then not setting the tracked printer when the activity
is resumed.

bug:17525271

Change-Id: Ib0fb29006bfcf5ad03dce24b3407cd96dc421442
rintspooler/ui/PrintActivity.java
23d3361e1747ee286157f9c61c3d02e6e20cac58 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Do not change fragments if print activity finishing.

It is possible that we try to switch framents after the print
activity finish method is called. In this state the activity
is going away and trying to perform a fragment operation throws.
Now if we are finishing no fragment opration is performed.

bug:17520007

Change-Id: I0dd935d3cdaeddca31fccf49bd5de97e878abb9d
rintspooler/ui/PrintActivity.java
e3cdd4dc6cc3188d5d1fdecb37798e49887f6d5f 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Missing or wrong pages in preview when scorlling large docs." into lmp-dev
f3f963b0bebea91b17f7e60d9b826c458bfde38c 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Missing or wrong pages in preview when scorlling large docs.

The bound pages in the adapter were not properly tracked, more
specifically we did not remove pages from the bound set ending
up in a bad state. Also when the printer changes and if the
new one has different page size the content disappears due to
us not notifying for the data set change.

bug:17515670

Change-Id: Iac74e864609012f6804584fa133e87c27dc186a5
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintPreviewController.java
56bdeeeb80d31d2c299a7e55b233658b5bc6fe01 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Page shredder callback invoked on the wrong thread." into lmp-dev
fb3532eea391574cda69cae274915e9e1a7b6cf2 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Page shredder callback invoked on the wrong thread.

The code executed in the shredder completion callback must
be called on the main thread but instead it was called on
another one. This led to a crash.

bug:17514533

Change-Id: Id9e86d38a90fedadc60f967b193470fd83eb3362
rintspooler/ui/PrintActivity.java
e0fa06c088ea95a01c0219e9711c3bcc93ad2685 16-Sep-2014 Svetoslav <svetoslavganov@google.com> Update print preview when a printer becomes available

We laizily request printer capabilities and when they are reported
we were not updating the preview and as a result the content was not
rendered, hence pages showing an empty state.

bug:17514117

Change-Id: Icfee7eaa1ab63f5e4d7655d4057ef2110c27cd43
rintspooler/ui/PrintActivity.java
e771caf332bb3f2b668aaf249b30f37f13755553 15-Sep-2014 Svet Ganov <svetoslavganov@google.com> Fix a crash in pring spooler.

If the printer capabilities are reported with a delay which is pretty
common we were trying to evaluate the preview page dimensions without
having a media size resulting in a NPE.

bug:17501953

Change-Id: I6765137f61b8fd060e9eabff07e632875d934963
rintspooler/ui/PageAdapter.java
2047df6f5f6af14cdb93f220c0329f1bff7a43ff 13-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Page content sometimes missing while scrolling." into lmp-dev
05ff998fd86eff15e91694bc205ea0af0de83284 13-Sep-2014 Svet Ganov <svetoslavganov@google.com> Fix a crash in print spooler.

A recent bug fix exposed another one where we were not updating
the internal state of the remote print document after it finishes
updating. This resulted in a crash on every print.

bug:16966145

Change-Id: I398ff7976533241e3d4cb6cd27f69cdc25e67be9
rintspooler/model/RemotePrintDocument.java
e6ecba59fd618b80dd13f581b625eea420672a0a 12-Sep-2014 Svetoslav <svetoslavganov@google.com> Page content sometimes missing while scrolling.

The logic when a page view to request the content had a logical
error and it was getting in a bad state where it never requested
the content anymore. This change simplifies the logic and minimizes
the kept state.

Removed unnecessary calls to recycle for a bitmap as according
to the graphics folks we should not be calling this API anymore.

bug:16966145

Change-Id: Idda8314b43343136d3b867167261790481116fac
rintspooler/model/PageContentRepository.java
rintspooler/widget/PageContentView.java
2fb64a5cb160a2615f07ed669aa5738dbb74ad6c 12-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix crash in spooler if printing app dies.

bug:16966145

Change-Id: I092c489a7f1b4000a96d3f12f2996ccabf734b9a
rintspooler/model/RemotePrintDocument.java
139ba7fb0ed976bdbc7c283e3f7fe9980eed22a6 12-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix a crash in print preview on multiple rotations.

bug:16966145

Change-Id: I8266315bd9253953cb6c3b9dab1ba36f104a74a5
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrinterRegistry.java
36f6951e325feb32f9fe61a80e120dacfd41d473 12-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Fix back button behavior and clean up in print preview activity." into lmp-dev
c946e9ab465fd363dc996efbffcf58f354266aaa 12-Sep-2014 Svet Ganov <svetoslavganov@google.com> Merge "Fix edit text error state in the print UI." into lmp-dev
e17123dd6d3666c88b47172b8efc995523b47346 11-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix back button behavior and clean up in print preview activity.

The print preview UI owns and drives the lifecycle of several objects.
These objects were torn down too late resulting in an attempt to use
the activity as a context when it was no longer valid and service unbind
resulting in causing a crash.

Fixed a bug where if the back button is pressed mutiple times when
the print UI is being initialized a crash occurs.

bug:17454041

Change-Id: Ic1455b467586f0ad65f907e2160ec5cfb2d17d05
rintspooler/model/PrintSpoolerProvider.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrinterRegistry.java
43212264dd0eaa5deea6539b8d4eb3a3edd7d22d 11-Sep-2014 Svet Ganov <svetoslavganov@google.com> Fix edit text error state in the print UI.

If the user input in the print UI is invalid we show an error icon
next to it. The design requires no error message being shown in a
popup but TextView does show the popup all the time.

bug:16966145

Change-Id: I7aa1ec8093bc76e2f440bcb243609e92e049786b
rintspooler/widget/CustomErrorEditText.java
e03ddd0bcc683b31f155bfd96f543c38539abf44 11-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Fix a crash in print spooler." into lmp-dev
c65510a7bc0a1519c5633940bce52d7f2334b640 11-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Accessibilty support for the print UI." into lmp-dev
3ef8e203c887a0cf6c121fdbb428e2fcef21758a 10-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix a crash in print spooler.

1. Leftover code was setting the state to configuring
before initialization is complete.

2. We were not cancelling the print job if cancelled
when initializing.

3. The remote print document was cancelled even if
doing nothing.

bug:17451600

Change-Id: I79a80b723af8537da260012470748b4e8831fd9e
rintspooler/ui/PrintActivity.java
fc81bfe3fb43296ca7040b8f259e1cbec50898ca 10-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "RTL support for print UI." into lmp-dev
e652b02d45bbda11c9cb8f663fa7f25903b90225 10-Sep-2014 Svetoslav <svetoslavganov@google.com> Accessibilty support for the print UI.

bug:15816751

Change-Id: I5dcdbdd0357843b870ddd47d7c41cfba114d194c
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/widget/PageContentView.java
rintspooler/widget/PreviewPageFrame.java
rintspooler/widget/PrintContentView.java
3ab1ec05491d5da8eea070889c03b6ea4f2af5bc 10-Sep-2014 Svetoslav <svetoslavganov@google.com> RTL support for print UI.

bug:16966145

Change-Id: I488d11f1941545630d52eea4c4d48c43667c6067
rintspooler/widget/PrintContentView.java
rintspooler/widget/PrintOptionsLayout.java
dfa3e7c6fd4e8a28ba51b54c769b891191459012 10-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix page spacing in preview list.

bug:16966145

Change-Id: I2c4bde3a50ee0fc202fc169a63d4eeeb43c5f4ae
rintspooler/ui/PageAdapter.java
62ce332c141cf7bc7200c4c87d63e395874fc3ec 05-Sep-2014 Svetoslav <svetoslavganov@google.com> Trim unnecessary pages when printing.

A user may request a subset of the document's pages to be printed.
In this case the expectation is that the resulting document does
not include not selected pages. While print serivices can do the
trimming themselves or the printer may do so, moving, potantually
many, redundant pages is inefficient. The real problem is when
saving to a PDF file where the saved file must not have the pages
the user did not select. This change adds shredding of undesired
pages from the PDF before saving it or passing it to a print service.
:
bug:17285994

Change-Id: I7deba535af99457bea3c118202314f0f3812e809
rintspooler/model/PageContentRepository.java
rintspooler/renderer/IPdfEditor.aidl
rintspooler/renderer/IPdfRenderer.aidl
rintspooler/renderer/PdfManipulationService.java
rintspooler/renderer/PdfRendererService.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
6552bf3da60159607d9266eb295ee3c448f6c3de 04-Sep-2014 Svetoslav <svetoslavganov@google.com> Print spooler UI polish and bug fixes.

1. Added an empty state for pages that are being rendered.

2. Fixed a NPA on a binder thread when destoroying the
remote print adapter.

3. Fixed a rare crash when the print activity gets an
activity class callback while initializing.

4. Changed the preview pages on phone in land to four.

5. Fixed a flicker from a list of pages to an empty state
and then back to the list of pages.

bug:15704969
bug:16966145

Change-Id: I0eea2f30a102d8fefcbf90187fa6d8612fb19434

Conflicts:
packages/PrintSpooler/src/com/android/printspooler/widget/PageContentView.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PageContentView.java
d0c362de1c23b6113fc35236c2908d71cfad7877 05-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix broken aidl

Change-Id: I2187abd75b4f60e790b747a492ad610592f2ef53
rintspooler/renderer/IPdfRenderer.aidl
53dcd394aa389e1e80aa1113be38255716bf2e4c 05-Sep-2014 Svetoslav <svetoslavganov@google.com> Update FrameStats API per api-council request.

bug:17390382

Change-Id: I50518834569f4d0ec394709294537256f03530e0
rintspooler/renderer/IPdfRenderer.aidl
def58cbffc32d12445b60ed1a0d8bb81d8dc6625 04-Sep-2014 Svet Ganov <svetoslavganov@google.com> Merge "Switching to raw byte copy of bitmaps for print preview." into lmp-dev
8c07e8d2a370a6d59dfe5150af3b07ff031ac165 04-Sep-2014 Svetoslav <svetoslavganov@google.com> Merge "Fix some print UI issues." into lmp-dev
9e795e19c7f900fb2636c5dff3ba30098da65f1b 03-Sep-2014 Svetoslav <svetoslavganov@google.com> Unregister from the remote renderer only if bound.

bug:8213791

Change-Id: Ia9efa33331437c4db447acf0c510d4cb4932a593
rintspooler/model/PageContentRepository.java
df6444931b030d3cdd9769e23f16f0a16fe9c654 30-Aug-2014 Svet Ganov <svetoslavganov@google.com> Switching to raw byte copy of bitmaps for print preview.

Using compression and decompression for moving bitmap data
acorss processes is slow as compression is expensive. This
change switches to using direct streaming of the bitmap
data.

bug:15938254

Change-Id: I78bc450031ee60ada4c3b66f14586a73c72ce34f
rintspooler/model/PageContentRepository.java
rintspooler/renderer/PdfRendererService.java
rintspooler/util/BitmapSerializeUtils.java
rintspooler/widget/PageContentView.java
6f249835a4ff9e7e7e3ca0190b7ecf72e689656d 03-Sep-2014 Svetoslav <svetoslavganov@google.com> Fix some print UI issues.

1. Fixed a crash when orientation changes and the content
is scrolled due to wrong size bitmap being requested.

2. Closed a file dscriptior that was being left open.

3. Clearing the bitmap before passing it to the renderer to
ensure it is white for pixels not touched when rendering.

4. Removed debug logs.

5. Switched to the correct layout manager for RecyclerView.

bug:16966145

Change-Id: I8ab9d22635c93cac5ff85c6f4b5d82e58cd8df5c
rintspooler/model/PageContentRepository.java
rintspooler/model/RemotePrintDocument.java
rintspooler/renderer/PdfRendererService.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PageContentView.java
561b8931742503d58ae842edea790e86f359870f 02-Sep-2014 Svet Ganov <svetoslavganov@google.com> Merge "Move print rendering in an isolated process." into lmp-dev
13f542cabd635c55ade5442764cc4a3d2f7880ea 30-Aug-2014 Svet Ganov <svetoslavganov@google.com> Move print rendering in an isolated process.

Security review of the PDF rendering code revealed that it is
not sercure. Therefore, this code must be run in a sandbox.
This change moves the rendering code in an isolated process.

bug:16897933

Change-Id: I711ce42a56892db1837950137bfaa79e1d61a7c4
rintspooler/model/PageContentRepository.java
rintspooler/renderer/IPdfRenderer.aidl
rintspooler/renderer/PdfRendererService.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PageContentView.java
c404cacd3a480776dd625fb300810ffccc5f51b0 28-Aug-2014 Svetoslav <svetoslavganov@google.com> Print UI polish.

1. Fixed an issue where input focus is given to the copies
edit text every other time we expand the options UI. We
want focus there only if the user touches the control.

bug:16966145

2. Fixed the all printers list view to have item dividers
reaching the left and right ends of the list view.

bug:17288761

3. Fixed an issue where the user can deselect all pages
which is not only an invalid state but also causes a crash.

bug:17286198

4. Tweaked the minimal size of the preview in landscape on
phone to better accomodate the page.

bug:17288904

5. Fixed a regression introduced by a change from the UI folks.

Change-Id: Ida7dad7eea413295a840028060810b2619c616e8
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/widget/FirstFocusableEditText.java
rintspooler/widget/PrintContentView.java
9c9888b8c59e35717ecfc32e9b96fb8702ceb480 27-Aug-2014 Svetoslav <svetoslavganov@google.com> Fix a crash in PrintSpooler.

If the user cancels printing we cancel the current
pring operation in the RemotePrintDocument which is
a state machine enforcing valid state transitions.
A valid transition was not allowed: finishing after
canceled.

bug:17182301

Change-Id: Iccf3a78d7dc736a64bf5c44941a8f8064dcd0ec3
rintspooler/model/RemotePrintDocument.java
3c238245eb3c0a7371fb25b6e96be0a0056a638d 19-Aug-2014 Svetoslav <svetoslavganov@google.com> Update the "More options" button in printing.

The "More options" button needed changes to match the
new UX spec. Also fixed some identation issues as well
as a missing marging in the erorr UI.

bug:16301066

Change-Id: I29f0d41915d1816d754f2c6288a7387aafeba2c2
rintspooler/ui/PrintActivity.java
rintspooler/widget/PrintContentView.java
255dd04271088590fedc46c8e22b2fd4ab142d39 19-Aug-2014 Selim Cinek <cinek@google.com> Added notification color to all system notifications

Bug: 17128331
Change-Id: I81a94510ef51b99916f314c0dd65852426a1fbeb
rintspooler/model/NotificationController.java
309f6a0e1b2ec39bd516fdfe217a526fe4b8acf6 19-Aug-2014 Svetoslav <svetoslavganov@google.com> Update the print spooler icon.

Removed a duplicate resource also defined in the platform
resources. Added a tint to the print spooler icon.

bug:16568027

Change-Id: I1c0b9a7bd75bc59d1d86653c05d8fc2bb77056c1
rintspooler/ui/SelectPrinterActivity.java
38781bd2c2c61385651314098b4a615cb8e8efa1 12-Aug-2014 Svet Ganov <svetoslavganov@google.com> Fix some minor print UX bugs.

1. The last row of print options was not visible on a phone.

2. The preview page size on a phone in landscape unusably small.

3. Updated the Save to PDF icon.

bug:16966145

Change-Id: I25ce1572758c62f34344683af2452fb045bb857e
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/widget/PageContentView.java
rintspooler/widget/PrintOptionsLayout.java
b59555ca743118c45103c0c11aedeefb8893f0f0 24-Jul-2014 Svetoslav <svetoslavganov@google.com> Print to PDF putting a pring job in a wrong state.

When printing to a PDF file we get a Uri from the storage APIs
and write the content. Once the file is written to storage the
print job is completed and there is print service involved. Th
spooler was wrongly putting the job in a failed state instead
of a complete state.

bug:16522267

Change-Id: I4741c9b9eb763e118e7dfb2c7c502bd7fc13f7a1
rintspooler/ui/PrintActivity.java
5ef522bc19cc9fc1af48cccd2865744228c5ec02 24-Jul-2014 Svetoslav <svetoslavganov@google.com> Handle wrong file format when printing.

PDF is the only format suppored for printing but a buggy app
can write content in another format which was crashing the
print spooler. Now we are generating an error instead of
crashing.

bug:16487161

Change-Id: Ic59d2ac6d57213f4e8f364659d8dc7df2140e61d
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
f8ffa567b5ac418b72268ae01fe8401b801268c7 24-Jul-2014 Svetoslav <svetoslavganov@google.com> Updating the save to PDF button icon.

Change-Id: Ie62a22d6e16d15426f10afa0512b0083c52ff507
rintspooler/ui/PrintActivity.java
753c114d84328219a0ccbffdd462a69e04ef8c4f 15-Jul-2014 Yigit Boyar <yboyar@google.com> Update RecyclerView scroll listener to the new API

Bug: 16054949
Change-Id: I264a701e8b298a08f09bb30284099734054d518c
rintspooler/ui/PrintPreviewController.java
cc2b210ff8d4aefc890c016e4d352f069a5d3eef 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Merge "Update the promoted action background color per UX spec" into lmp-dev
4bcc4a042c760a776ef52a0f727331db3fa315d2 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Update the promoted action background color per UX spec

bug:16303010

Change-Id: I54663a0be79b232a29d8fced4a772a32b4d83ae5
rintspooler/ui/PageAdapter.java
e323dcc31d403085d6ede0f8884c816f4420ef25 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Drop of the final UX assets for printing.

bug:15705610

Change-Id: I82104a2c0b3d1f4e34f71357b10bed24c0583e71
rintspooler/ui/PageAdapter.java
73764e347d387657b3e2f8027d135de612cf454f 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Update the page count in the print UI to meet new UX.

bug:15912257

Change-Id: I1aa3eb4f7e28d3d9c955f60a570c2f8800fdb88d
rintspooler/ui/PrintActivity.java
38408ff5b7203f811644961637fde85eb7a34387 15-Jul-2014 Svetoslav <svetoslavganov@google.com> Remove text selector and hide ime on print options close.

bug:16301754

Change-Id: I69bf09df9976b12c611821737eb4abb794c1df80
rintspooler/widget/PrintContentView.java
41233447f9c2368946ef1266ae339c71cbe310b1 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Merge "Drop of the final UX assets for printing." into lmp-dev
67eb5bbd5374fe96209cf7b68543cb48ee959b96 16-Jul-2014 Svetoslav <svetoslavganov@google.com> Merge "Update the page count in the print UI to meet new UX." into lmp-dev
5150bcba8e72165baa061d7648e4f2f1e49fc424 15-Jul-2014 Svetoslav <svetoslavganov@google.com> Merge "Remove text selector and hide ime on print options close." into lmp-dev
17d734fee434ca4a37104b783a78fabcda0ac2a5 14-Jul-2014 Svetoslav <svetoslavganov@google.com> Page size not always adjusted

A user can select the pages to print by selecting a range from the
UI after which the selected pages appear in the preview list. Now
the user can further prune pages by clicking on them. If the number
of pages change to two or one the page position and size were not
adjusted. Now after the constraints of desected by clicking pages
are propafated the page size position is also computed.

bug:16297811

Change-Id: I62c0ae8ab5b1d91b120cbf9faa9653ef4ccbd97f
rintspooler/ui/PageAdapter.java
25885ecbe4306165872c1b24628e9646778a0535 14-Jul-2014 Svet Ganov <svetoslavganov@google.com> Rename historical records if printer name changed.

We keep track of previously used printers. It is possible that the name
of a previously used printer changed. In this case we want to change
this printer's name in the historical records to be able to show the
correct name in the UI when loading the history.

bug:13524346

Change-Id: I0a37bd52a564df5a84c816abfcf03db83de93b97
rintspooler/ui/FusedPrintersProvider.java
a4ab780877808dbee334f7c7cc4acefa0aa313b2 14-Jul-2014 Svet Ganov <svetoslavganov@google.com> Fix broken actions in print notifications.

The notification handling broadcast receiver was renamed but the
manifest was not updated, hence the receiver was not registered.

bug:16289408

Change-Id: I094e20e472abff1f926e1dbfbac32f422f498f74
rintspooler/model/NotificationController.java
6f60e56b3c37839dfec1a9fb61c52fa2c631a5cb 14-Jul-2014 Svet Ganov <svetoslavganov@google.com> Improve print options click to open behavior.

When print options are closed we show a summary and a handle to open
the options panel. Often the user instinctively clicks on the summary
and also the expand handle is a somehow small target. To improve user
experience clicking on the summary also opens the print options.

Change-Id: Ia2f3b80f5acf11b40af864729f67fa29e82729fc
rintspooler/widget/PrintContentView.java
9fb7b07c6cbdd1c6f394bfc456ccc034619b6727 14-Jul-2014 Svet Ganov <svetoslavganov@google.com> Dimming deselected preview pages

For print preview we show the pages the user selected in the range
affordance but the user can optionally further prune pages to be
printed by deselecting them in the preview. The deselected pages
change elevation and now also are dimmed.

bug:15912256

Change-Id: I53357b8e8b592387bbc26b937eda786bb4660d85
rintspooler/ui/PageAdapter.java
48fec5c9a3e4d78bc4cd175fae05be153ac587af 14-Jul-2014 Svet Ganov <svetoslavganov@google.com> Top printer not properly selected.

We keep track of historically used printers and when the print dialog
is opened we load them. We were selecting the first printer before the
historical ones are loaded which led to a case where the PDF printer
is selected and then a better printer appears but we have the PDF one
selected.

Also we were asking the printer spinner for the current printer but
if the data set of the adapter changes and we ask the spinner for the
selection we get a wrong answer because the adapter and the view are
off sync since the view is updated on the next message.

Change-Id: I0c12d2d3b19227a8f6af6e421b92013ec06cc021
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrinterRegistry.java
39afc200f299ffd7e6a2a507017c3de2a548f877 12-Jul-2014 Svetoslav <svetoslavganov@google.com> Remove commented out dead code

Change-Id: I3e59d0ee55fd864ea0d8bc5f99cdb74d9b0e49bb
rintspooler/model/PageContentRepository.java
1710e0318db5db833974e390eb4bde54ab2f3c62 12-Jul-2014 Svetoslav <svetoslavganov@google.com> Fix print preview rendered page preloading.

After the preview list is scrolled we are preloading the
pages around the ones that are shown, so now if the user
does a slight adjustment (expected after a scroll) the
pages around are rendered. There was an off by one error
and one of the bitmaps of the shown pages was reused and
as a result the wrong content was shown.

Change-Id: If04aebf46bcc637491221c6218005ecc1a7253d2
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
15cbc8a03250eafdf947cd8ad4e77f34444d5ba4 11-Jul-2014 Svetoslav <svetoslavganov@google.com> Addressing comments for the print preview feature.

Change-Id: Ib72140a912e22f859258d970e0d1c4ef06e807d5
rintspooler/model/PageContentRepository.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintPreviewController.java
rintspooler/widget/PageContentView.java
rintspooler/widget/PrintContentView.java
525a66b2bb5abf844aff2109bdc9ed819566bece 15-Jun-2014 Svet Ganov <svetoslavganov@google.com> Adding print preview.

This change adds the pring preview part of the new print UX. The
UI has two parts, the top section is the print options and the
bottom section print preview with a list of pages. The user can
interact only with one of them. When print options are expanded
they cover the preview content and a scrim is laid out on top of
the preview. Tapping the scrim collapses the print options. When
the user types in page ranges and closes the options to look at
the preview, the latter is updated to show only these pages. In
the list of pages the user can further prune pages by deselecting
them.

Change-Id: I0b23d2c598afe2a34400ccfa43e4e935af83c72f
rintspooler/model/MutexFileProvider.java
rintspooler/model/NotificationController.java
rintspooler/model/PageContentRepository.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/PageAdapter.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintErrorFragment.java
rintspooler/ui/PrintPreviewController.java
rintspooler/ui/PrintPreviewFragment.java
rintspooler/ui/PrintProgressFragment.java
rintspooler/util/PageRangeUtils.java
rintspooler/widget/ContentView.java
rintspooler/widget/EmbeddedContentContainer.java
rintspooler/widget/PageContentView.java
rintspooler/widget/PrintContentView.java
rintspooler/widget/PrintOptionsLayout.java
e3bbb3d6c09a29cddeb544308e5b3210908fa256 12-Jun-2014 Svetoslav <svetoslavganov@google.com> Fix NPE in PrintActivity.

It is possible that the orientation is chosen before the media size.
The code handling orientation change was wrognly expecting to have
a selected media size all the time resulting in a NPE.

bug:15512333

Change-Id: I9f2786af314641144a24c1d1363c8d2590b0df57
rintspooler/ui/PrintActivity.java
a798c0a984f29f7180883a61839f68d2cbf0c6ce 15-May-2014 Svetoslav <svetoslavganov@google.com> Refactor printing

Change-Id: I19850154ef2798afff511e4490a268ce38e8cbae
rintspooler/FusedPrintersProvider.java
rintspooler/MediaSizeUtils.java
rintspooler/NotificationController.java
rintspooler/PrintDialogFrame.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintDocumentAdapter.java
rintspooler/SelectPrinterActivity.java
rintspooler/SelectPrinterFragment.java
rintspooler/model/NotificationController.java
rintspooler/model/PrintSpoolerProvider.java
rintspooler/model/PrintSpoolerService.java
rintspooler/model/RemotePrintDocument.java
rintspooler/ui/FusedPrintersProvider.java
rintspooler/ui/PrintActivity.java
rintspooler/ui/PrintErrorFragment.java
rintspooler/ui/PrintPreviewFragment.java
rintspooler/ui/PrintProgressFragment.java
rintspooler/ui/PrinterRegistry.java
rintspooler/ui/SelectPrinterActivity.java
rintspooler/util/MediaSizeUtils.java
rintspooler/util/PageRangeUtils.java
rintspooler/util/PrintOptionUtils.java
rintspooler/widget/ContentView.java
rintspooler/widget/FirstFocusableEditText.java
rintspooler/widget/PrintOptionsLayout.java
b0d97b87ba5f23ee867f381a4e5916ebb2e5f762 02-Jan-2014 Svetoslav <svetoslavganov@google.com> PrintSpooler crash if printer is reported to have only one color mode.

bug:11993304

Change-Id: I4932cf1b5b9b89f0cbf97011782ede037e7d814c
rintspooler/PrintJobConfigActivity.java
2c1b177dcfbf140eb1409c646eefb8b0507fa534 21-Dec-2013 Svetoslav <svetoslavganov@google.com> Sometimes write may be called twice in a row for the same content.

In a rare case it is possible that on write of a print document
adapter is called twice for the same pages with nothing being
changed. This happens if while doing a write we get an update
request which correctly avoids calling layout on the adapter
but does call on write as we ignore that we are waining for the
requested pages to be written. Fun.

Change-Id: I33d7d26c7c4b083dc7b66bf762697b6dafd1ccc4
rintspooler/PrintJobConfigActivity.java
c04aa87e4ac41b6c65dceb7b20d7a7f92c2efec1 19-Nov-2013 Dave Langemak <dlangemak@google.com> Merge "Fix incorrent page range parsing when custom print options used." into klp-dev
1a85d9fb243aae3750001094aa1514d4303cb3e0 16-Nov-2013 Svetoslav Ganov <svetoslavganov@google.com> Fix incorrent page range parsing when custom print options used.

We have APIs for a print service to declare an activity with custom
print options. In this activity the service can add custom properties
as well as change the standard ones such as pages to print. The ranges
of selected pages from the custom activity was incorrectly parsed
resulting in an off by one error in what is shown to the user and as a
result getting an exception when trying to print.

bug:11719051

Change-Id: Id04c94608178895f1d47381a63133f0eba7645e1
rintspooler/PrintJobConfigActivity.java
885810de69d75979df4299d21fa236490767eae4 15-Nov-2013 Svetoslav <svetoslavganov@google.com> Created print jobs should not be persisted until they are queued.

Print jobs in a created state should not be persisted. However,
if a print service sets the tag to a print job that is queued,
we were persisting even print jobs in a created state. This
change adds a simple check while persisting to avoid storing
created print jobs.

bug:11696785

Change-Id: Idf28f3634b91fd5bf345f376114af4ed478ed3c6
rintspooler/PrintSpoolerService.java
c445b3f2cba67b7dbb8f926ef5e80ec14fb2f8d4 05-Nov-2013 Svetoslav <svetoslavganov@google.com> Merge "Add missing null pointer check in PrintSpoolerService." into klp-dev
75d28505c8f73a977cc7ae0cc08a60120f7c92b2 05-Nov-2013 Svetoslav <svetoslavganov@google.com> Add missing null pointer check in PrintSpoolerService.

bug:11474389

Change-Id: I80ea01ba04ab71a212c1f78af62b377110ed072a
rintspooler/PrintSpoolerService.java
1c664b6defd20ab4a83c4a83d01b9ed8603f7c2c 04-Nov-2013 Svetoslav <svetoslavganov@google.com> Add way for the user to forget previously used printers.

We keep track of historical printers but some of them may disappear
forever, say the user changes his printer. In such a case the print
system has no idea that the previous printer will never appear so
this change allows the user to remove historical printers.

In the all printers list the user can now long press on a printer
and if the printer is available he can select it from the context
menu. If the printer was used before regardless if it is active the
user may choose to forget it.

bug:11282742

Change-Id: Idc2dda70920ad045149eea1bcfc75ad1992827e9
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
d270cb9264f762257d1aadbeba9c4b38866e171c 31-Oct-2013 Svetoslav <svetoslavganov@google.com> Cancel current work in PrintDocumentAdatper if printing is cancelled.

Layout and write may take some time during which the user can
cancel printing. Currently we wait for the last operation,
being write or layout, to complete before closing the print
dialog. Now in such a scenario we request a cancellation of
the ongoing operation.

bug:11329523

Change-Id: Ia9d747163cc73509369a86c8b5afc83b7ee54859
rintspooler/PrintJobConfigActivity.java
rintspooler/RemotePrintDocumentAdapter.java
b4fda134761c9521a7e127db3806a07a18763b77 26-Oct-2013 Svetoslav <svetoslavganov@google.com> Complete implementation of the advanced print options.

1. Implemented the advanced printer options integration. Now a print service
may declare an advanced print options activity which may be launched by
the user if the current printer supports advanced print options. These options
are visible only to the print service that added them and it is the only party
that will interpret the options.

2. Fixed a couple of bugs in the saved print jobs parsing. One was that if there
are more than one page range, a half of the print job properties was not
properly parsed. The other was that the media size constructor was using
incorrect argument order, thus creating a media size with wring width.

3. Fixed and edge case where old print jobs and their docs can get stuck in
the spooler. If the app did not write the requested pages we were not showing
an error message, rather just finish the activity without canceling the print
job and this print job is stuck in the spooler. Now we show an error message
and the user may retry, cancel. If the user cancels the print job is also
cancelled, thus no leftover in the spooler.

4. Fixed the background color of the print dialog to meet UX spec.

bug:11241800

Change-Id: I352440bc86aec824a805883fc9579d96a06d11e6
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
4d4c66dd38e940082e385b49a33f4022ab04c738 25-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the documentaton of the android.print package.

bug:10551786
bug:10551697
bug:10705082
bug:10741641
bug:11318976
bug:10550979
bug:10551761

Change-Id: I46ceb66a69b6d32d6b417356178f67f2e25e891a
rintspooler/PrintJobConfigActivity.java
237575278de8cae5d20ee333fcb2ccceee257d67 19-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Hide the print dialog if the printing activity is destroyed." into klp-dev
30d9161b8e84652d9ac504b70adacaf729fdb58b 18-Oct-2013 Svetoslav <svetoslavganov@google.com> Merge "Printer list items have wrong width." into klp-dev
858a1850e2e1c4516129d27ecdf54aaeade606ca 18-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Hide the print dialog if the printing activity is destroyed.

1. For an app to print it creates a PrintDocumentAdapter implementation
which is passed to the print dialog activity. If the activity that
created the adapter is destroyed then the adapter, which may rely on
the activity state, may be in an invalid state. For example, an app
creates an adapter and calls print resuting in the app activity and
the print dialog activity being stacked. Now the user rotates the
device which triggers the recreating of the activity stack (assume the
app does not handle rotation). The recreated print dialog activity
receives the intent that originally created it with containing the
adapter that was constructed in the context of the old, now destroyed,
app activity instance.

To handle this we are limiting an app to be able to print only from
and activity and when this activity is destroyed we mark the adapter
as invalid which will result in hiding the print dialog activity. Note
that if the app process is killed we already handle this in the print
dialog activiy by registering a death recipient on the adapter binder.

2. In the PrintManager.PrintDocumentAdapterDelegate some of the state is
accessed only on the main thread and some from miltiple threads. The
code was trying to avoid locking for state that is not accessed by
multiple threads but this is error prone and the benefit does not
justify the complexity and added fragility. Now grabbing a lock all
the time.

3. The PrintJobConfigActivity waits for it to bind to the print spooler
service before instantiating its print controller and editor. However,
these can be accessed by invoking some of the activity cycle callbacks.
This change is adding null checks for the case where the activity
callbacks are called before the binding to the spooler is completed.

bug:11242661

Change-Id: Id906b3170e4f0a0553772dfa62686f06fdca0eaf
rintspooler/PrintJobConfigActivity.java
ed513d7e4a624a9f82e15923a7052d4c18a020a7 17-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> All printers list has incorrect padding and item height.

1. We were using the layout for the printer drop down from the
print dialog as the list item in the all printers activity.
This layout was not high enough. Now we have a separate
layout for the drop down and for the list. Note that they
are almost identical but this is better that writing java
code to lookup the height from the theme and change it
programatically since the java code is almost half the size
of the layout and leads to spreading the logic in both the
layout file and the java code.

2. The padding of the printers list was not correct. Now it
mimics the bahavior in settings where we change the padding
based on orientation.

bug:11261157

Change-Id: I8507c4ee86e9196fe1777cf9577f1886ccfbb1ad
rintspooler/SelectPrinterFragment.java
b196106a43355ec56bc2354cae1d1bbf21ab9b4b 17-Oct-2013 Svetoslav <svetoslavganov@google.com> Printer list items have wrong width.

1. There was leftover code in the printers adapter that was
hard coding the item width with no reason to do so.

2. Changed the icon view visibility to invisible to allow
the text of all list items including save to PDF and all
printers to be left aligned.

bug:11225340

Change-Id: I5b51d0d30577699f5cd73c7c58521358653d135b
rintspooler/PrintJobConfigActivity.java
2fa010cf5bf76af826776ada8a35cf8fe2945b64 15-Oct-2013 Svetoslav <svetoslavganov@google.com> Update the message for unavailable printers.

If a printer disappears or we do not get its capabilities, we
show the user a message that the printer is unavailable. This
message was appended after the printer name but they tend to
be very long and the user does not see that the printer is not
available due to ellipsis. Now we append the message after the
subtitle which tends to be much shorter.

bug:10983508

Change-Id: Ib3f7ad3bd82ff6decd49dc45461fb5131338e8c2
rintspooler/PrintJobConfigActivity.java
2f0ec7af06e206b1747b93efbd65d88189fc2df1 14-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the print spooler action bar icon.

1. Updated the print spooler icon shown in the action bar
when searching for printers in the all printers activity.

2. If the current printer's capabilities are not immediately
available the page count label in the dialog contained the
argument placeholders.

bug:10983508

Change-Id: Id4f78d6cc31647f043f8e3044ab54f30584d1ebe
rintspooler/SelectPrinterFragment.java
9d843e09caa8c32a3fec22bb66cba8e6d4dfa5b1 14-Oct-2013 Svetoslav <svetoslavganov@google.com> Layout may be called with invalid print attributes.

If a print service reports a printer with no capabilities and then
removes and adds the same printer again with no capabilities we can
call layout with invalid attributes. While the print service should
not do that we must not crash. The reason is that the print dialog
code was lacking a check whether something changed before handling
the change of the current printer. This resulted in calling layout
even though we still do not have the printer capabilities resulting
in passing bogus print attributes to the app.

bug:11216402

Change-Id: Icb9161930a70a7f9ead589a0ab0b4eb35091666f
rintspooler/PrintJobConfigActivity.java
7ff610ee029d990a6b9b6d8c90a79fe79fbd8368 13-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> The print dialog in bad state after pressing back from prnt to PDF.

When selecting print to PDF and then pressing back to return from the
storage UI activity, the print dialog was in a state where nothing
is selected.

bug:10983508

Change-Id: I9c14b5fa18e812104ade6a2eacd626b5f7387111
rintspooler/PrintJobConfigActivity.java
d91cb3ea61ea5096637c5d2b5e3e6147d0d2cce3 13-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> The list of active print jobs in print service retunring wrong result.

1. The getActivePrintJobs() method in print service is designed to return
the active print job i.e. ones scheduled to be processed by the print
service. Now the correct list is returned.

2. The listeners for observing the state of print jobs may be called even
after being unregistered. Ex: state change occurs and we schedule a
message on the app's main thread to make the notificaion. Now the app
unregisretes the callback and on the next loop the notification message
is handled.

bug:11200258

Change-Id: I4a497b5c9a7287a22023cafe41ce966d14300ca6
rintspooler/NotificationController.java
d3c197d97250af93041e6aa05ef0dfca323f1767 12-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> The callbacks for tracking a printer called more than once without printer change.

When the user selectes a printer in the UI we ask the print service to start tracking
the printer, i.e. to observe changes of the printer state and capabilities. The callback
for the initially selected printer is called twice which breaks the contract and also
may trigger potentially expensive operations on the print service side.

More precisely the printer does not change and we ask the service to start tracking,
stop tracking, and again start tracking.

bug:11199851

Change-Id: Ib761e6da03f670b3098c69b1c0927177a8e4ae6b
rintspooler/FusedPrintersProvider.java
7d7888d1c7daa78ee0ad24a24c8dd54b01749259 12-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Printed document size not persisted.

We persist ongoing print jobs so they can be restarted if the device
dies. The data size of the printed document was not persisted to disc.

bug:11199352

Change-Id: I53ef1ee285aa4808917dd6a5c7335226aba1ef0a
rintspooler/PrintSpoolerService.java
9b6d3a153f44010a75907c6a9742c89a57d4e5ee 12-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Fail only scheduled print jobs, i.e. handed to a service, if the service is disabled.

When a print service is disabled we assume all print jobs for it failed as we have
no way to know what happens to them. However we are also failing created print jobs,
i.e. ones not given to the service. Such jobs are in process of construction and
the print dialog is up. We should not fail such jobs as the dialog can still modify
their state and potentially select a print from a different service. Therefore, we
leave them alone and they will be failed if when constructed are passed to a
disabled/uninstalled service.

bug:11197432

Change-Id: Ie4fe54327e3e25776b1dd572be2dfafdd700c2e5
rintspooler/PrintSpoolerService.java
89ed9fcf9b2fe061626c910701a35f1ea576a370 12-Oct-2013 Svetoslav <svetoslavganov@google.com> Putting the cursor at the end of the copies and range inputs.

bug:10983508

Change-Id: I767876fada2f28b00283ed9140fca1a40729f38f
rintspooler/PrintJobConfigActivity.java
02dded1a63bb5ae2968fb9df0c29bad115416a28 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Adding timeout if the current printer or its capabilities disappear.

If the current printer becomes unavailable or its capabilities
go away we are scheduling a timeout to declare the printer as
unavailable.

bug:10983508

Change-Id: Iab85cfd35fc0cecc3dd4abac6232347f9da18fb0
rintspooler/PrintJobConfigActivity.java
54adee86af495311fc9ef62d65e035605043413f 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Print spooler not starting.

1. In my previous change I fixed a typo in the Java constant with
intent action to launch the print dialog but failed to updated
the print spooler manifest.

2. Removed dead code - the user id is no longer needed since the
spooler is an app that runs per user. Every user has its spooler.
This code was not referenced from anywhere.

3. Added a default icon to the print spooler.

4. Fixed a bug where if the print history is empty the UI goes
to the all pritners activity.

bug:11059554

Change-Id: If74c23b418a8c67620ba14435ee7f3b2c4527099
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
f22a767e872ec8f5c2531a88819e0f4574c78fe3 11-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Added UI for errors during layout and write." into klp-dev
caff38821ad81389b5baf2053ba851c38272ec63 09-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Added UI for errors during layout and write.

1. If an error happens during layout or write we show an error
message with the string provided by the application which
has an OK button to retry or tap outside to cancel.

2. Updated the targed and min SDK version for the PrintSpooler.

bug:11127269

Change-Id: I4301cf3716119b1e33b95347a8451fc1c128343b
rintspooler/PrintJobConfigActivity.java
7bfbbcb04bf4ba8f3069b2df136f708c9849bacf 10-Oct-2013 Svetoslav <svetoslavganov@google.com> Refactor how the print dialog activity is started.

1. Before the print job activity was started asyncronously with
respect to the print call on to the print manager. This was
creating a situation where the starting activity may finish
before the print dialog appears which may lead to an orphaned
print document adapter with no data to print (as the UI is
is gone), or strange behaviors where the print dialog starts
on as a separate task.

To address this the pending intent for starting the print
dialog is not started by the print spooler since we cannot
call into it synchronously as we have to start its process
and bind to the spooler service which leads to jankyness in
the client app. Now the pending intent is created by the
print manager service in the synchronous print call so
from an app's perspective calling print starts the activity.

The side effect of this design is that the print dialog
activity may start before the system is bound to the spooler
service. In such a case the print activity cannot start
poking the print spooler state as the system registers
callback to observe the spooler state. To address this
the print spooler activity disables the UI and also binds
to the spooler service which happenes immediately after it
is started. As soon as the print dialog binds to the
service it starts the UI.

2. Fixed an bug in the printer adapter of the print dialog that
was leading to a crash if the only item in the adater is the
all pritners option and it is selected.

3. Piping the package name that started the printing so we can
pass it to the storage UI as a hint to open the last location
the app used.

bug:11127269

Change-Id: Ia93820bdae0b0e7600a0930b1f10d9708bd86b68
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
3aa2e2b3ab21fda7045fbe2bb142e7a6830340e5 11-Oct-2013 Svetoslav <svetoslavganov@google.com> Fixing jank when transition from print dialog to generating one.

Initially we show the print dialog and when the user presses print
we show a generating dialog with an indefinite spinner and a cancel
button. The transition between the two UIs which are really different
layouts show in the print activity is animated. In the middle of
the animation from print to generating UI there was a jump of the
content and an undesired window animation kicking in. This is a
side effect of changing the activity to floating so now changing the
container size was causing window resize and hence animation. Fun!

bug:10983508

Change-Id: I7d88e073c55863b945cdb50822401592f32d44c3
rintspooler/PrintDialogFrame.java
rintspooler/PrintJobConfigActivity.java
ebec46847d4bbd72161fb32282ab7a68effa00a7 09-Oct-2013 Svetoslav <svetoslavganov@google.com> Sometimes the print button not enabled and an accessibility fix.

1. Sometimes the print button is not enabled after selecting a printer
from the all printers activity. This was happening after a printer
was selected, we had to do a layout due to changed print attributes
(because of the new printer's capabilities), and the content did not
change. In this case we did not call the updateUi function which
enables the print button after layout is completed.

2. The accessibility code in the all printers activity was not checking
whether accessibility is on and doing some unnecessary work - not sending
events though but still. Further, the delayed runnable that was
doing the accessibilty announcements was not removed when the activity
was paused.

bug:10983508

Change-Id: Ib263116a3e21e4c75a25aa051cecbd9194417319
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
a18661d5922e5ae24ccce8e815aeba437a2fba82 10-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Coalescing multiple print job notifications.

1. We used to show a single notificaiton for every print job but
this is against th UX guidelines. Since we have to lead by
example, this change adds coalescing of multiple notifications.

bug:11155212

2. Print job state callback in the PrintManager now correctly
invoked on the main thread.

bug:10983508

Change-Id: I906e9e62198fa37cb4d2f71fce07ed475d61e1bd
rintspooler/NotificationController.java
rintspooler/PrintSpoolerService.java
53e8a26d6178c41c59c3dcad4a8a04ce2449f246 08-Oct-2013 Svetoslav <svetoslavganov@google.com> Fix a crash in the select printers activity.

When the search view is attached and detached we announce that
for accessibility. The trouble is that if the activity is being
torn down we are trying to access resources from a fragment that
is detached and the qcrash occurs. This change does not try to
access resources if the activity is finishing and also we do not
load resource strings if accessibility is not enabled.

bug:11127814

Change-Id: I4a47a8ed3b6a13544cf17b4395560246a33f0e2d
rintspooler/SelectPrinterFragment.java
69b91e0ecb8cef95c030f5076779e07d363a45f2 08-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Show unavailable printers disabled and grayed out.

1. If a printer is not available it has to disabled and grayed out.

2. Cancle a print job if the app does not provide the requested pages.

3. Fix current printer selection flicker when the print dialog is
showing up. Often the current printer is initially set to the user's
favorite and then it is changed back to the PDF one.

bug:10983508

Change-Id: I8d53eb992cf1c92675ec09f61b2ec272b962fa68
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
56ddf1ffa5b7bd3b8d4b8b7d5c68d7e0e99e5e15 06-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Polish print dialog accessibility.

bug:10983508

Change-Id: I7391e06b661caac18d04ae279639ff447701f151
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
24c686b8b56950d5a1881cc660e53816d47e5e03 06-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update all printers activity's empty state and avoid selected printer flicker.

1. Updated the empty state of the all printers activity to show no printers message
if the user is searching and there are no matches and a searching for printers
message if the user is not filtering the printers list.

2. Adding the fake PDF printer after the historical printers are loaded to avoid the case
where we select the PDF printer and immediately after that the most used printer is
selected resulting in an undesirable UI flicker.

3. Fixed a bug where if the most used printer which is initially considered unavailable
is reported by the print service as available but the UI is not properly updated
leaving the user in no way to click on the print button.

bug: 10983508

Change-Id: I60fdb7761332850fd5b9ffc0cb572a6213024dba
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
264c566a7f7d829de48131ac6d811b3db6f520bc 05-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the empty state for the "all printers activity"

The empty state is now showing searching for printers hint if
the user is not searching, otherwise the empty state's hint is
a searching for printers message.

bug:10983508

Change-Id: I3df79c167546998c8055d9ff85efa8b460a15e48
rintspooler/SelectPrinterFragment.java
0ea7d1e869ad618a7c8c2bbbb7f96729e7d84ed3 05-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the "add print service" dialog as per UX spec.

The dialog button is now the last item in the adapter if the
search for print service settings is not empty and resolves
to an intent.

bug:10983508

Change-Id: I348e1ede1097d6f3b78c72e871bf3097b99004b6
rintspooler/SelectPrinterFragment.java
5ab717f21a2dbcd78fb37d40e31393d129743599 05-Oct-2013 Svetoslav <svetoslavganov@google.com> Print UI tweaks.

1. The refresh button in a print notification was using
wrong asset.

2. If the page count is unknown, just not show the page
count instead unknown.

bug:10983508

Change-Id: I15f1fcbff60fe1f30d37868864da41550bb14487
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
331f9e79ad16e7d9d51e8481e6bc21642a51c340 05-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Print attributes hint not honored." into klp-dev
7be27acac922b5ea66ec6b464ded6f057bd6f1e5 30-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Print attributes hint not honored.

1. Initially we have a single printer, the fake PDF printer, and
wait for printers to be discovered. This printer was handling
only a couple of media sizes. Hence, if the app provides a
media size hint and the PDF printer does not support it, we
were essentially ignoring the suggested media size since it
was not supported by the selected printer and we fell back to
the default paper size for that printer. The fake PDF printer
should support all predefined media sizes.

2. The list of available paper sizes was shown in the order they
are added ignoring the current locale. It is much better user
experience if the media sizes used in the current locale are
shown at the top and all others after that. Also the media
sizes for the current locale should be alphabetically ordered
so the user can quickly find the desired one.

3. The orientation was reset on media size or printer change.

bug:10564537

Change-Id: Iaa0d42242730ce69cea3effd4d0f4bc087068804
rintspooler/MediaSizeUtils.java
rintspooler/PrintJobConfigActivity.java
6bf1029900d09d0432fb82f8c076bdb3eefc1f6c 04-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Deleting print job files when we do not have to." into klp-dev
2b40c83ae1ec17ea9371c3fd3ac6c79c156faa1d 04-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Deleting print job files when we do not have to.

The print job file name was not properly parsed. This resulted
in incorrect mapping from file to print job, thus deleting the
file when we do not have to.

bug:11069354

Change-Id: I7b8a7a7f98dd77b34119f2a9cd16a6ec3c22b63b
rintspooler/PrintSpoolerService.java
39e71de6b49d1cb67ce30b411cede8d4f40dc765 03-Oct-2013 Svetoslav <svetoslavganov@google.com> Print UI tweaks as per UX request.

1. Limit the width of the dropdown of the printers list.

2. Add icons the the list in the all pritners activity.

3. Update the empty state view for the all printers activity.

bug:10983508

Change-Id: I19effcf32770fdda278009a060b5170a3f29988e
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
913f87ef637fc1d9a006c543833b6815090b94e8 03-Oct-2013 Svetoslav <svetoslavganov@google.com> Merge "IndexOutOfBoundsException in the PrintSpoolerService dump." into klp-dev
b67a637e60c356ab520050b2bd09a95ae47f3017 02-Oct-2013 Svetoslav <svetoslavganov@google.com> IndexOutOfBoundsException in the PrintSpoolerService dump.

The dump code in PrintSpoolerService was relying on being
called only as a result of "adb shell dumpsys print" which
is apparently wrong. As a result the code was making wrong
assumption about the input arguments.

bug:11046234

Change-Id: Ie38f3cc5f17cac98b808fef6d6bbeaca22a62ef0
rintspooler/PrintSpoolerService.java
228a7d2a157c4e6ceee5fdea389f207bbf4990ba 02-Oct-2013 Svetoslav <svetoslavganov@google.com> Merge "Sometimes printer selection from all printers activity does not work." into klp-dev
4e4874bb71ddebc80fd10b7b3f0ec6b13aca25ec 02-Oct-2013 Svetoslav <svetoslavganov@google.com> Sometimes printer selection from all printers activity does not work.

1. Sometimes selecting a printer from the full printer list does not
work if the selected printer was not in the initial drop down list
of the print dialog.

The reason was that there is a race. We use loaders in the print
dialog activity and the all printers one. When these loaders are
stopped we stop printer discovery since we do not want to keep this
potentially expensive process on going if the activity is paused
because say the user decide to press home and start playing his
favorite game while the printers dialog is up. As a result the
loader does not get printer updates until it is started.

The loader of the print dialog activity is stopped while the user is
selecting a printer from the all printers activity whose loader is
getting discovered recent printers. Now when the user selects a printer
the loader of the print dialog activity is started but may not get
the latest printers by the time onActivityResult is called with the
selected printer. Now we cache the selected printer id and if the
loader reports it we select that printer.

2. In the print dialog we show only a few of the discovered printers.
If the user selects a printer from the all printers activity that
is not in the initial list we shuffle the adapter data to make sure
the selected printer is in the shown subset. Now if the printers
change, i.e. the printers loader reports new result we were not
respecting the reshuffling made before so the short list of
printers changes yet again.

bug:11034216

Change-Id: I54fe3619e3328b65839d9f4b02309699eae7f8eb
rintspooler/PrintJobConfigActivity.java
976b4e6312ca7a4cca56211fa5b347b018dd305a 01-Oct-2013 Svetoslav <svetoslavganov@google.com> Adding an empty state UI for the printer search activity in the spooler.

The user can select all printers from the print dropdown to get to
a search for printers activity where one can filter out the list
of a available printers. We did not have an empty state UI for the
case when the query yields no printers.

bug:11009053

Change-Id: I6b45517b8a7b319992019a1bf65858319a19a0de
rintspooler/SelectPrinterFragment.java
d8dbc13b47bec3248a86a505a30af9d0474240dc 28-Sep-2013 Svetoslav <svetoslavganov@google.com> Ignore historical printer records for installed services

When loading historical records for previously used printers we
now ignore the ones whose target print service is not installed.

bug:10955652

Change-Id: Ib295e7d88ed3c308ef6d8a11bdc1792ebbb6d526
rintspooler/FusedPrintersProvider.java
b415525a16074b6dc8e295655648b7c7c1074bbb 28-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Print job files and print job records not always cleaned up." into klp-dev
c783f6738f0f6d2cb57702cfbc9219c59a3410a3 28-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Adding a timeout for waiting to get the selected printer's capabilities." into klp-dev
dd68da2741fa63070d5ad206020dcccb9f429a5a 27-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> 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
rintspooler/PrintSpoolerService.java
6be4c76441ecdc11ee4db7211edc421d26a78f1f 27-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Adding a timeout for waiting to get the selected printer's capabilities.

A print service may choose to provide only the printer info and then when
it is requested to start tracking the state of the printer, the service
should provide the printer capabilities. If the capabilities are not
received within ten seconds we mark the printer as unavailable and stop
tracking it.

bug:10748639

Change-Id: I9171cb5dc116fd321c23a8e4ab55109448e2fc6a
rintspooler/PrintJobConfigActivity.java
c335eb411503154cf475903eb6c5c67575769112 27-Sep-2013 Svetoslav <svetoslavganov@google.com> Printers in the list of printers change position.

1. The printers in the printers list of settings change position if
they are updated. The settings app is using hidden platform APIs
the this change fixes.

2. Enable ProGuard for the PrintSpooler.

3. Added icons on the list of printers so the user knows which
print service used the printer. Now the user can know when
he is using cloud print and maybe incurring data costs vs
local printer discovered by a vendor plug in.

bug:10955751

Change-Id: I292f48b424cb561218fdb424d0388f4d786d8339
rintspooler/PrintJobConfigActivity.java
0ce3e8743c9127a688f007eed17a5ed18081d0fc 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Choosing default paper size for the "Save to PDF" fake printer

Change-Id: I1e2eb73fd1eb3b1e9812155b69b94cba261243c2
rintspooler/PrintJobConfigActivity.java
5cab967bf2bab49777bfa86dff8b0f892192ede6 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Adding hidden APIs for observing the print jobs state." into klp-dev
3adc49c6780633b8bccc3b5b8dca10788c2288bc 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Disallow range selection if the document has unknown page count." into klp-dev
c9cfd605a24cf20df5248d73804c584168db64c9 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Missed signal in FusedPrintersLoader." into klp-dev
953c4143e846b071da4869cb7cfd8039a086b1da 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Missed signal in FusedPrintersLoader.

1. In the FusedPrintersLoader we start observing the printers on
the device and if they change we send the result. If however,
the printers are already loaded in our session (because it
joined an ongoing printer discovery) and the pritners do not
change, the loader never sends its result. Now we are registring
the callback only after historical printers are loaded. We
also immediately check after starting discovery whether the
there are printers in the discovery session and if so deliver
them.

2. Improved logging in the FusedPrintersLoader.

bug:10940712

Change-Id: Ieb9b897d64780742125b29309462dea3eda170a6
rintspooler/FusedPrintersProvider.java
ab051baea5560e0c71397771e53bd74d4a36024d 26-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Page range validation edge case handling.

The regular expression for validating range input was missing a
coupe of edge cases.

bug:10906805

Change-Id: Ie793588ecb6697aff3d8d85124a8faeda58c69e5
rintspooler/PrintJobConfigActivity.java
b0e68fdc9cb6ba292adc4590f406d921abea08d5 21-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Disallow range selection if the document has unknown page count.

bug:10741878

Change-Id: Ibf2272125e81f14ede3fdfec86aee10b908ade01
rintspooler/PrintJobConfigActivity.java
704697b6197262678e930daa831a1916ddee4dcf 22-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Adding hidden APIs for observing the print jobs state.

This is needed for implementing the print job settigns UI.

bug:10935736

Change-Id: I63b42cbf4ce6a259fa1af47fa368b148ca5621c1
rintspooler/NotificationController.java
rintspooler/PrintSpoolerService.java
2a708617dfdc0b6dbf9b39baebbdc55d19aa7728 25-Sep-2013 Svetoslav <svetoslavganov@google.com> User should not be able to select unavailable printers.

1. If the printer is unavailable we should not allow the user
to select it. Rather, show it grayed out.

2. Some string changes requeted by translators.

bug:10917222

Change-Id: I370f05f9c8e70e3f077db7eb02cf48e19a59925d
rintspooler/PrintJobConfigActivity.java
b5f180608db6de123b54ae94de569ff1ebca705c 24-Sep-2013 Svetoslav <svetoslavganov@google.com> Multiple printer discovery session instances and other bugs.

1. The fused printers provider was dropping on the floor received printers
if it was not active. It is in fact a loaded and if not active it should compute
the printers and not deliver them until activated. This fixes an issue where
opening the print dialog, then enabling a print service results in the printers
reported by the service not showing up in the print dialog.

2. Printer discovery session was created twice which leads to incorrect behavior
as the pint system is designed around the contract that there is a single
printer discovery session per service at a time. This was possible due to an
incorrect initialization of a member variable resulting in double session creation
when the print service is connected.

3. When a print service is enabled during discovery we did not use the correct
condition to start printer discovery resulting in starting it all the time even if
not needed. Also if some of the printers that had to be tracked are reported
by the service just enabled (typically historical printers) we did not ask the
service to start tracking them.

4. Removed some logging.

bug:10903343

Change-Id: I46c049471a4b099fc668df3aee2aaedc8d7786ac
rintspooler/FusedPrintersProvider.java
rintspooler/PrintSpoolerService.java
5dfccc3c0d142765b04f9cd8b2513a6b9db22426 24-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "The current is printer not refreshed when selected." into klp-dev
307a0d4db23d8d9705fb2d87d304cb7e9a90f476 24-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> The current is printer not refreshed when selected.

Every time a printer is selected we have to refresh it by telling
the print service to stop tracking the previously selected printer
if such and start tracking the current one. As a result of start
tracking the print service has to give us the capabilities too. A
previous patch caused a regression and we do not refresh printers
when needed.

bug:10898968

Change-Id: I9d5413e324fdb8856ef61849d36a161470eb204d
rintspooler/PrintJobConfigActivity.java
a4f6409c974363a6bb1eddd5c88048d88e868640 21-Sep-2013 Svetoslav <svetoslavganov@google.com> Page ranges not correct in come cases.

1. The algorithm that determines whether a page range contains
another one had a bug and in some cases misbehaved.

2. When print is pressed we do a final layout and if nothing
changes and we have the requeted pages we skip the final
write. However, in this case we did not update the print
job with the pages to be printed but we have to since in
the previous write we did not ask for all selected pages,
rather for the first one to be shown as a preview. Now if
we have all pages and nothing changed we update the print
job pages.

bug:10530142

Change-Id: I10fb62ae5ae07b8e54d547fd4dca555a12451bc5
rintspooler/PrintJobConfigActivity.java
b39ce63d2807c9d5c68d3be052dee7e9da7ec3be 21-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Offer to enable a print service after it is installed." into klp-dev
d8f391b4e0e8d876ec7216d34f86a9b3e8bab7e5 21-Sep-2013 Svetoslav <svetoslavganov@google.com> Offer to enable a print service after it is installed.

The user has to explicitly enable a print service from the settings UI
before using it. Usually, users very rarely if at all interact with print
services, therefore all print service management task are performed from
the print settings. We also have to get user consent warning that the
user's data is about to be given to a third-party app. We now post a
notification allowing the user to go directly to the settings screen to
turn the service on.

bug:10447510

Change-Id: Iea56c0825f0bf38328ad94912f0ea5576e9339b3
rintspooler/NotificationController.java
5559c368a96c56d55c581c88d9978c59c5212bf1 20-Sep-2013 Svetoslav <svetoslavganov@google.com> PrintDocumentAdapter contract not followed on print.

1. Layout was not called after pressing the print button if the
print attributes did not change. This is not correct since the
previous layout calls were for preview purposes and the one
after pressing print is not for preview. Hence, we always have
to do this layout.

2. After layout we decide whether to ask the app to write some
pages. We ask for a write if we do not have the pages selected
by the user or the document changed (if the page count changed,
the document type changed, or the app told us that the content
changed). We were not computing correctly whether the document
changed since we compared the size but the document info the
app passes in after a layout does not have the size yet. We set
the size after a write. So for layout purposes we should ignore
the size. We only care if the page count, document type, or
content changed where the latter is reported by the app in
the layout callback.

3. We were not updating the PrintJob after setting the data
size of the printed document.

4. Disabled debugging.

bug:10835370

Change-Id: Ic3b2871b4e954cdf610f8cf806de5fc6588a6bec
rintspooler/PrintJobConfigActivity.java
b206f1271d17164c3f2f65219eee7a0b4b4fa6dc 20-Sep-2013 Svetoslav <svetoslavganov@google.com> Null not handled when parsing media size resource id attribute.

bug:10835715

Change-Id: I0c9c1120c26e68b4c582599bbda3753d0e443d8c
rintspooler/PrintSpoolerService.java
6811f4e92cbb64e72a0d13eb9b99b5894bd59c76 19-Sep-2013 Svetoslav <svetoslavganov@google.com> Move PdfDocument to android.graphics.pdf

1. Move PdfDocument to android.graphics.pdf.

2. Changed the PdfDocument as per API concil request.

3. Updated the documentation.

bug:10461180
bug:10552565
bug:10681585
bug:10552336

Change-Id: I08e15b34cf37bb064248c887e6f59808019cafe8
rintspooler/PrintJobConfigActivity.java
ac7297bdc04e2097e39b791064e5ed6ee92680ea 19-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Fixes in the page range selection and verification logic." into klp-dev
f0c48a72fd8476afd063d4ef593b473b8cf9a9d0 18-Sep-2013 Svetoslav <svetoslavganov@google.com> Fixes in the page range selection and verification logic.

1. Typing a range where the start is greater than the end was
leading to a crash.

2. Typing the same single range, e.g. "2,2", was leading to a crash.

3. If two ranges are non-overlapping but consecutive they were
not merged

4. Typing multiple times a digit that is less than the page count,
e.g. page count "2" and typing "11", was not caught by the input
verification.

bug:10812904

Change-Id: I754715b5d792a1a6c3a4f9f644edfa9aea7ac127
rintspooler/PrintJobConfigActivity.java
7b3990ec81fc218f655d44624758e15ce378968e 18-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Update the print dialog." into klp-dev
013b816ac7d723a0116c039e6266d93d13851fe1 18-Sep-2013 Svetoslav <svetoslavganov@google.com> Update the print dialog.

1. The print dialog was resizable and as a result when printers
come and go its size changes which looks bad. The dialog is
now trying to be maximally large limited by a max size or the
screen - whichever is smaller. This required moving from
GridLayout to several LinearLayouts since the former does not
support distribution of empty space evently between the items
in a row. Also we want all items in a column of inputs to be
of equal size (the spinners specifically).

2. Added labeledBy attribute to associate a view with another one
that serves as its label for accessibility purposes. We have
lebelFor attribute but it is not useful in most layout files
since it has to refer the auto-generated id of a view which
usually appears later in the layout file, thus generating a
compilation error. This was needed for the accessibility support
of the print dialog.

bug:10631660

2. Disabling the spinners or the print button did not produce
visual feedback leading to user frustration.

bug:10741907

Change-Id: I0c12eddabc4035bc7becd1b86c1f1b8fdcf4289c
rintspooler/PrintDialogFrame.java
10ee84ba18255f259edf6fa2e3aa33c02ac5340d 18-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> The printers in print dialog should not change position.

The FusedPrintersProvider was not ensuring the existing printers
are at the same position when a new dataset is loaded. As a result
the printers were moving in the UI and sometimes the currently
selected one changed. Now the provider makes sure printers are in
the same position.

bug:10748884

Change-Id: I7c6cd5b1b38fdb615ceaae87806b413272ffba18
rintspooler/FusedPrintersProvider.java
0cfebec522539722f294a99bc32437b5d9e4b27d 17-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Print pooler crashes for some page ranges." into klp-dev
c3484024e1117b518f06b39c406ba20f961d592e 17-Sep-2013 Svetoslav <svetoslavganov@google.com> Print pooler crashes for some page ranges.

1. The print spooler fails to parse page ranges that end with
a dash, e,g, "1-", which are however valid inputs since the
user can continue typing to end up with a well-fromed range.

2. After a layout we are asking for the first selected page
to be written emulating print preview, thus increasing the
changes that apps will correctly implement the APIs.

bug:10743632

Change-Id: Ia74172d4fa6bce6ad93a0bc53da1aaa3fe8bef42
rintspooler/PrintJobConfigActivity.java
2fbd2a7f070f246ddafd9de94efa9a98861e9136 17-Sep-2013 Svetoslav <svetoslavganov@google.com> App UI freezes when printing. API clean up.

1. The UI of a printing app was freezing a little when calling the print
method since the print manager service was waiting for it to bind to the
print spooler which generated the print job id (and the initial print
job info really). Now the print manager service is responsible for job
id generation and does not not wait for the print spooler to spin. Hence,
the app UI is not blocked at all. Note that the print manager initiates
the binding to the spooler and as soon as it completes the spooler shows
the print UI which is hosted in its process. It is not possible to show
the print UI before the system is bound to the spooler since during this
binding the system passes a callback to the spooler so the latter can
talk to the system.

2. Changed the print job id to be an opaque class allowing us to vary the
way we generate print job ids in the future.

3. The queued print job state was hidden but the print job returned by the
print method of the print manager is in that state. Now now hidden.

4. We were incorrecly removing print job infos if they are completed or
cancelled. Doing that is problematic since the print job returned by
the print method allows the app to query for the job info after the
job has been say completed. Hence, an app can initiate printing and
get a print job whose state is "created" and hold onto it until after
the job is completed, now if the app asks for the print job info it
will get an info in "created" state even though the job is "completed"
since the spooler was not retaining the completed jobs. Now the spooler
removes the PDF files for the completed and cancelled print jobs but
keeps around the infos (also persisting them to disc) so it can answer
questions about them. On first boot or switch to a user we purge the
persisted print jobs in completed/cancelled state since they
are obsolete - no app can have a handle to them.

5. Removed the print method that takes a file since we have a public
PrintDocumentAdapter implementation for printing files. Once can
instantiate a PrintFileDocumentAdapter and pass it to the print
method. This class also allows overriding of the finish method to
know when the data is spooled and deleted the file if desired, etc.

6. Replaced the wrong code to slice a large list of parcelables to
use ParceledListSlice class.

bug:10748093

Change-Id: I1ebeeb47576e88fce550851cdd3e401fcede6e2b
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
860f8a6b663ca96d30d17da09eca8caf065aae62 14-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Spooler should not crash if print service config activities are not exported.

1. If a print service does not export its activities for settings and
adding printers the print spooler ignores them instead of crashing.
Also if the service is not enabled its activities are now ignored.

2. Added a dedicated permission for a print service to optionally
protect its settings and add printer activities such that only the
system can bind to them.

3. Fixed a crash in the print dialog if its content is detached
from the window and animators are running.

bug:10680224

Change-Id: I20b57d6622a15f9b2352ba78d04c44e67b316a15
rintspooler/PrintJobConfigActivity.java
rintspooler/SelectPrinterFragment.java
651dd4e6ee6510caf9f15c51094a11121af17ec2 12-Sep-2013 Svetoslav <svetoslavganov@google.com> Remove unneeded print APIs and update the min margins APIs.

1. Removed unneeded code in Resolution that was storing its
label as resource and package name. We do not have predefined
resolutions, therefore we always persist the label.

2. Renamed the print attribute margins to minMargins to reflect
that these are the minimal margins the printer support. Updated
the docs as well.

3. Renamed the create method of all builder to build.

bug:10727487

Change-Id: Ie72ab8aaa5215b8bd2853885011b3b4efa4deb2e
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
cc65b0c325b88c466763712f76148a6f5b8a5b3f 11-Sep-2013 Svetoslav <svetoslavganov@google.com> Not change the print options on printer change if possible.

If the user selects some print options from the dialog and then
changes the printer to one that has the same capabilities the
selections in the UI should not change.

bug:10631856

Change-Id: Ia76ce58c446815e3498d2f4b4739dee62d11d96a
rintspooler/PrintJobConfigActivity.java
c6066799ad130140159230d14451b429eb828755 11-Sep-2013 Svetoslav <svetoslavganov@google.com> Handle print serivce crashes.

1. Now after a print service crashes we are bringing it to the same
state of its lifecycle. For example, if a service does a discovery
and crashes we recreate the discovery session call the start
discovery method and so on.

2. Turned off debugging logs since we have fully fledged state dump.

bug:10697779

Change-Id: Id790537461428e96b197eef12258996bda2bd1ce
rintspooler/FusedPrintersProvider.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintDocumentAdapter.java
a36285f3f2f74b1d2d5d0336ffe519ab9f6e062a 05-Sep-2013 Svetoslav <svetoslavganov@google.com> Bug fixes in the print dialog

1. Read/write async tasks of the persistence manger used by
the FusedPrintersProvider could be run more that once, so
create a new one every time.

2. The fake printer used to save to PDF should not be added
to printer history.

3. Removed print preview leftover code from the print dialog.

4. Save to PDF was not working on the second consecutive attempt.

5. The fisrt time the orientation change was ignored - regression

Change-Id: I8960ef2cf92dfeeec22fa8751ba8475092b5b65c
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
a76233ae845da4bc9e3bcd89821701a747215e7b 05-Sep-2013 Svetoslav <svetoslavganov@google.com> Hiding some unneeded APIs,

1. Hide the MediaSize and Resolution constructors that take
package and resource Id.

2. Fix a bug and docs in creating portrait and landscape media
size.

Change-Id: If59992e355391de6ad6d14d4f7b3be8c8b6cc0e0
rintspooler/PrintSpoolerService.java
773f54de3de9bce7b6f915aa47ed686b161d77aa 03-Sep-2013 Svetoslav <svetoslavganov@google.com> Print API updated.

1. Removed the updatePrinters API on PrinterDiscoverySession.
Now re-adding a printer updates it.

2. Added getTrackedPrinters() API to allow a print service to
figure out which printers' state should be tracked by the
service.

3. Removed the APIs on PrintDocumentInfo that describe the
layout of the content as they are not needed. For example,
if the print attributes passed in layout require landscape
mode, the the app should just create a PDF page with the
wider side up and draw its content in portrait. The printer
will then rotate the page.

Change-Id: Idd72c6e9c129e8b17eef1236573a99773f8ff0a2
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
9186d0cb2bd325d9b52da15dbd513937c1e42caa 03-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Bug fixes in the printer dialog activity and fused printer loader.

1. Fused printers loader was not using the discovered printers to update the
historical ones. Now if a historical printer is discovered we update its state
with the discovered, i.e. most recent, information.

2. Fixed a bug in the destination adapter of the print job config dialog that
was leading to a crash if all printers item is selected when there are no
discovered printers.

3. Updated the add printers asset in the all printers screen.

4. Historical printers were not persisted by the print dialog activity.

5. Reduced the number of printers we send per transation to avoid the binder
transaction size limit. Added sending of printers in chunks in a place
this was missing.

Change-Id: I88b54888360bc0e53b06bd260c2b832d0d6454b6
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
d26d4898fcc9b78f4b66118895c375384098205e 28-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print spooler security and some new print service facing APIs.

1. Updated the security mode of the print spooler. Now the spooler
is not signed with the system key, it is not a privileged app so if
it gets compromised (PDF rendering is a potential attack vector)
it cannot access dangerous permissions. Also only the system
can bind to the spooler.

2. Added APIs for asking a print service to start and stop tracking
a given printer. This is need for the case when the user selects
the printer and the print service should do a best effort to keep
the system updated for the current state of the printer.

3. Added APIs for putting a print job in a blocked state. A print
service would report the print job as blocked if for some reason
the printer cannot proceed, e.g. 99 pages are printed but there
is no paper for the last one. The user has to add more paper
and the print service can resume the job.

4. Changed the read/write APIs to use ParcelFileDescriptor instead
of FileDescriptor since the latter does not have a clean API for
detaching the wrapped Linux file descriptor when one wants to
push it to native.

5. Added API for getting the size of the printed document so the
print service can avoid handling big filed over cellular network
or ask the user if needed.

6. Now the print services that are preinstalled on the system image
are automatically enabled.

Change-Id: Ia06c311d3d21cabb9e1368f13928e11cd0030918
rintspooler/FusedPrintersProvider.java
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
aec1417ca9eb63209668ac17da90cf8a07c6076c 27-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print APIs update.

1. Added scale to fit and scale to fill fitting modes.

2. Added APIs for a print app to specify which constraints imposed
by the print attributes were satsified during a layout so they
are not handled by the printer again, e.g. if the content is to
be in landscape the the app generated such content the printer
should rotate the content again.

3. Added some printer statuses.

4. Added a helper class that generates PDF documents with correct
size based on the passed in print attributes.

5. Exposed a ctor for PageRange which was hidden by mistake and apps
could not create page ranges. Added API for changing the printer
status.

Change-Id: If1334a61d2d931027b98075f653018d456b1b768
rintspooler/PrintJobConfigActivity.java
44720af55a8fdf991929983dad5d53c02851dd1e 21-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI bug fixing and printer discovery refactoring.

1. Added support for selecting a printer from the all printers activity
that is not in the initial printer selection drop down. The user
initially sees a sub set of the printers in the drop down and the
last option is to see all printers in a separate activity. Some
of the printers in the all printers activity are not shown in the
initial drop down.

2. Refactored printer discovery by adding (private for now) printer
discovery app facing APIs. These APIs are needed to support multiple
printer selection activities (print dialog and all printers activities)
and also the settings for showing all printers for a service.

Now multiple apps can request observing for printers and there is
a centralized mediator that ensures the same printer discovery
session is used. The mediator dispatches printer discovery specific
requests to print services. It also aggregates discovered printers
and delivers them to the interested apps. The mediator minimizes
printer discovery session creation and starting and stopping discovery
by sharing the same discovery session and discovery window with
multiple apps. Lastly, the mediator takes care of print services
enabled during discovery by bringing them up to the current
discovery state (create discovery session and start discovery if
needed). The mediator also reports disappearing of the printers
of a service removed during discovery and notifies a newly
registered observers for the currnet printers if the observers are
added during an active printer discovery session.

3. Fixed bugs in the print UI and implemented some UX tweaks.

Change-Id: I4d0b0c5a6c6f1809b2ba5dbc8e9d63ab3d48f1ef
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpoolerService.java
269403b032f965ff3847eb982c2f697229dc5a92 15-Aug-2013 Svetoslav <svetoslavganov@google.com> Implemented advanced printer selection and API refactoring.

1. Added past printer history tracking and merging favorite printers
with discovered printers.

2. Added save as PDF support.

3. Added all printers activity with search capability and optional
add printers chooser (if any print service provides add printers
activity)

4. Refactored the printer discovery session APIs. Now one session
can have multiple window discovery windows and the session stores
the printers found during past discovery periods.

5. Merged the print spooler and the print spooler service - much
simpler and easier to maintain.

Change-Id: I4830b0eb6367e1c748b768a5ea9ea11baf36cfad
rintspooler/AvailablePrinterProvider.java
rintspooler/ChoosePrinterActivity.java
rintspooler/DataLoader.java
rintspooler/DataProvider.java
rintspooler/FavoritePrinterProvider.java
rintspooler/FusedPrintersProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
rintspooler/SelectPrinterActivity.java
rintspooler/SelectPrinterFragment.java
66160bb881470a691005c8ad4e9c31c41fd5f810 13-Aug-2013 Svetoslav <svetoslavganov@google.com> Partial implementation for the favorite and available printer tracking.

1. Added a dedicated class that keeps track of the user's favorite printers
based on past usage. We keep the last 50 uses and assign a decreasing weight
to older historical use records. The printer whose records' sum is the
largest is considered the favorite for the user and so on.

2. Factored out the printer discovery logic from the print job config activity
into a separate available printers provider class. It encapsulates all the
logic to communicated with the remote print services to discover printers,
keep track of added, updated, and removed printers.

3. Preliminary scetch of the printer chooser acitivty that will show all the
printers.

Change-Id: I5524665f2a9a565f186db85214d5e41a44f4812e
rintspooler/AvailablePrinterProvider.java
rintspooler/ChoosePrinterActivity.java
rintspooler/DataLoader.java
rintspooler/DataProvider.java
rintspooler/FavoritePrinterProvider.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
55daead3c53a83ac300d76200dd4144f154e07d3 12-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Fix the build

Change-Id: Icf3b339f7b300cc8673443fa8afd38ce78964683
rintspooler/PrintJobConfigActivity.java
798bed6cc7d273e72b0253288605db9cd2b57740 11-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Refinement of the print service APIs.

1. Factored out the printer discovery APIs of a print service in a
dedicated session object that is created by the print service on
demand. This ensures that added/removed/updated printers from
one session do not interfere with another session.

2. Updated the app facing APIs to pass in a document info along
with a printed file. Also exposed the print file adapter so
apps that create a temporary file for printing can intercept
when it is read by the system so the file can be deleted.

3. Updated the print service documentation.

Change-Id: I3473d586c26d8bda1cf7e2bdacb441aa9df982ed
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
695c7fa7a320f1e5b4b56aa7ed6a64c6220f6502 08-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI polish based on UX feedback.

1. Refreshed the print UI based on UX redlines.

2. Implemented tap outside cancel for the print job config activity
which is full-screen but pretends to be a dialog.

Change-Id: I5afc7cd40c696109d70af31536898cfcad91b2ab
rintspooler/PrintJobConfigActivity.java
32c5eb3bf89938ba2221e67362571628e1efd520 07-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Update the print job dialog and added notification assets.

1. Update the transition between the print job edit dialog and the
generating print job dialog. Now the former shrinks into the
latter.

2. Added most of the notification assets.

Change-Id: I84f35df5cb4f71b86a103c16ab87fd4d108b055b
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
14db9654f6c31e94fe9272776f1f1b8602a17fdc 06-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Print UI polish (a.k.a. just the next iteration))

1. Added a dialog to show a spinner while the app is writing the
printed content.

2. Fixed print job config acitivity leaking.

3. Updated the notifications a bit.

Change-Id: I8314390135a49605ee11ab4ed14b210a29566745
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
55b5f8028a72d1da58835b6766798d781ad92b97 05-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Disable print dialog spinners if there is only one option.

Change-Id: Ic9a46c737b592aeb6f78c962a7f9d53391a2b164
rintspooler/PrintJobConfigActivity.java
835835ee6f913408ac91678d6056896a2c5b25e3 05-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Polish the print spooler loading of stored print jobs.

1. The singleton print spooler isntance is created when the print spooler
service gets a connection to the system and is destroyed when this
connection is removed. Note that if the spooler has work, then the
connection to the system will not be removed.

When the spooler is created, it reads the stored state and notifies the
system which in turn dispatches this to the print services.

When the system connects to the spooler and passes it a connection, we
schedule a delayed check whether there is work for the spooler. We do
not handle this immediately to avoid intermitted spinning on and off
of the spooler process if a client makes a sequence of queries while
the spooler has really no work.

2. Fixed a bug in the NotificationManagerService where adding a notification
and removing it immediately after that does not remove the notification.
The code that is adding a notification is run on a handler thread while
the code to remove it on the calling thread. This creates a race and
erroneous results. Now the removal is also scheduled on the handler.

3. Many small fixes here and there.

Change-Id: I6415c253139fa6616393fbe23c659d031a29e1f6
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
8c43376ea83a67414bd6823a472b76d41160239e 02-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> First cut of the print notifications.

1. Added notifications for a queued print job, for a started print job,
for ongoing canceling a print job, and for a failed print job. The
notifications for queued and started state have a cancel action. The
notification for failed print job has a cancel and a restart action.

2. Propagating failure message from the print service to the notifications.

3. PrintJobConfigActivity was not setting the initial value for the
print job copies and was not updating the UI immediately after creation.

4. Refactored PrintJobConfigActivity to avoid using the hack to avoid
reaction for item selection change in a spinner for an event that
happened before the callback was registered.

5. Removed the label attribute from PrinterInfo and now PrinterId is
composed of the printer name and the service component name. This
is nice since for restarting print jobs we do not need to store
information about the printer except the printer id which is
already part of the PrintJobInfo's data. Also the printer name
is not expected to change anyway.

6. Allowing cancellation of a queued print job. Also no print job is
cancelled without asking the managing print service to do that.
Before we were immediately canceling print jobs in queued state
but it was possible for a buggy print service to not set the
print job state to started before starting to do expensive work
that will not be canceled.

7. PrintServiceInfo was throwing an exception the the meta-data
XML for the print service was not well-formed which would crash
the system process. Now we just ignore not well-formed meta-data.

8. Removed unused permissions from the PrintSpooler's manifest.

Change-Id: Iba2dd14b487f56e137b90d1da17c3033422ab5e6
rintspooler/NotificationController.java
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
55b409a97cf6376399a0940313ea852368727d6f 01-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Iteration of the print sub-system.

1. Added APIs for adding partially initialized PrintInfo objects
enabling light-weight lookps for print serivces that want to
populate the list of available printers without querying each
of them for its capabilities. This includes APIs for the system
to request from a print service to update certain printers.

2. Fixed a bug in PrinterId#equals().

3. Added equals and hasCode implementaion to PrinterInfo. Also
the defaul in PrinterInfo are now an array instead of a
SparseArray - cheaper.

4. Now PrintJobConfigActivity works with partially specified
printers. Specifically, if such a printer is selected the
activity is requesting from the print service to update
the printer. We are currently not handling the timeout case.
It also handles udpated pritners.

Change-Id: I5e83e924ef597c9e22cbd06a971d4f4d3bd3a9c1
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
85b1f883056a1d74473fd9ce774948878f389ab6 25-Jul-2013 Svetoslav Ganov <svetoslavganov@google.com> Iteration on the print sub-system.

1. API changes: Moved copies API from PrintAttributes to PrintJobInfo;
Changed the PageRange list to an array in PrintDocumentAdapter#onWrite;
Added onCancelled method to the layout and write callbacks.

2. Refactored the serialization of remote layout and write commands. Now
the commands are serialized by the code in the client instead in the spooler.
The benefit is simple code since the client has to do a serialization to delegate
to the main thread anyway. The increased IPC found is fine since these calls
are quite unfrequent.

3. Removed an unused file: IPrintSpoolerObserver.aidl

4. Added equals and hasCode implementation to PageRange, PrintAttributes,
MediaSize, Resolution, Margins, Tray, PrintDocumentInfo.

5. Added shortcut path for query APIs on PrintJob that return cached values
if the print job is in a uncuttable state, i.e. completed or cancelled. Failed
print jobs can be restarted.

6. PrintJobInfo was not properly serialized.

7. Updated the look of the print dialog to be stable if there is and there isn't
currently selected printer.

8. PrintJobCOnfigActivity now calls onLayout on every print attributes change
but requests a write only on print preview or print button press. Also if the
layout did not change the content and it is already written no subsequent
call is made. Also if the selected pages change and we already have them
no subsequent call to write is made. Also the app is called with print preview
attribute set when performing layout and with it cleared after the print button
is pressed. A lot of changes making sure that only valid actions are enabled
in the activity (looks like a dialog) at a given time frame. The print job config
activity is also hidden after we got all the data, i.e. layout and write are done.

9. The callback from the print spooler to the system are scheduled via messages
to avoid lock being held during the call. It was hard to guarantee that since a
method holding a lock may be calling one that would like to release the lock
at some point to make the callbacks.

10. Print spooler state is persisted only if something changes in a completed
print job, i.e. not one that is being constructed due the print job config dialog.

11. Fixed a potential race in the RemotePrintSpooler where it was possible that
a client that got a handle to the remote spooler calls into an unbound spooler.
E.g: the client gets the remote interface with a lock held, now the client releases
the lock to avoid IPC with a lock, during the IPC scheduling the spooler has
notified the system that it is done and the system unbinds from it, now the
client's IPC is made to a spooler that is disconnected.

Change-Id: Ie9c42255940a27ecaed21a4d326a663a4788ac9d
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintDocumentAdapter.java
0d1daa50f6d180c57f92596501e2e5c0b5ef9997 23-Jul-2013 Svetoslav Ganov <svetoslavganov@google.com> Updating the print dialog and its interactinos with the printing app.

1. Added support for reporting the old print attributes during layout.
Now we keep track of the old print attributes, so the app can
compute the delta and decide whether re-layout work is needed.

2. Fixed PrintDocumentAdapter callback interleavings. Layout callbacks
were intermixing with write ones - a mess. Now we make an attempt
to cancel layout and write if they respond to cancellation, otherwise
we wait but do not interleave them.

3. Refactored the PrintJobConfigActivity for easier maintenance and
to have a single update UI method that does the minimal amount
of work.

Change-Id: I31ada1a0550882e6185018e6f17f923aed165d15
rintspooler/PrintJobConfigActivity.java
rintspooler/RemotePrintDocumentAdapter.java
88d199130d44c6bacb383a7757e782cf97483c68 22-Jul-2013 Svetoslav Ganov <svetoslavganov@google.com> Implement persistence/restoring of print spooler state.

1. Implemented the persistence and restoring of the print spooler state.
The print spooler state is saved as an XML on every print job change
and is restored when we bind to the spooler. The system does not
unbind from the spooler until the state persistence completes. We
are now storing the entire state, i.e. all print jobs, when a single
one changes. This is not optimal but we are not expecting to have
many such at the same time, so for now we err for simplicity of
implementation.

2. Enforcing a non-empty print job name.

3. Hidden the STATE_CREATED print job state which should never be visible to a
client since this is the state of a print job during construction, i.e. the
print dialog is up and we are doing back and forth with the app.

4. Fixed some PrintAttributes APIs that were incorrectly taking in a PackageManager
instance.

5. Updated the PrintSpooler build file due to splitting the framework into multiple
jars.

Change-Id: I52c88eaa1ec9c64920359cc143c79832a4c3d25b
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
597945fd3a6b52ac70bb9afc5ec8c59039fffd77 18-Jul-2013 Svetoslav <svetoslavganov@google.com> First pass of the print dialog UX

Change-Id: I315a16d7f68c73ca180c76e722847b4b1bdea55b
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintDocumentAdapter.java
6283608e0bd40548742839f5a8b02f7e5c9c5c7c 17-Jul-2013 Svetoslav <svetoslavganov@google.com> Tweak the print APIs.

1. Adding bundle with metadata to PrintDocumentAdapter#onLayout
with one key for now to specify whether this is for a preview.

2. Cleaned up docs.

Change-Id: I89380781bf3ae41aa89f8a0347d74516a210394c
rintspooler/PrintJobConfigActivity.java
rintspooler/RemotePrintDocumentAdapter.java
17b7f6e6d4ec9f5e9597bfd283f1c017b6c66275 25-Jun-2013 Svetoslav <svetoslavganov@google.com> Clean up of the print APIs.

1. Fixed a case in which the onPrintCompleted callback may not be invoked.

2. Added string resulrces for the different error messages for failed
printing in OnPrintCompletedCallback

3. Fixed the string comments for the MediaSize constants.

4. Added APIs to create certain print attributes by passing in a
string label instead of resource and package name since in some cases
a print service may be getting already internationalized lables
or it may not know all possible values.

5. Fixed a crash in PrintJobConfigActivity if there is no input or
output tray.

Change-Id: Ie877b7dc669051606394aa290e6d2b979a42db4c
rintspooler/PrintJobConfigActivity.java
a00271533f639c8ed36429c663889ac9f654bc72 25-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Refactoring of the print sub-system and API clean up.

1. Now a user state has ins own spooler since the spooler app is
running per user. The user state registers an observer for the state
of the spooler to get information needed to orchestrate unbinding
from print serivces that have no work and eventually unbinding from
the spooler when all no service has any work.

2. Abstracted a remote print service from the perspective of the system
in a class that is transparently managing binding and unbinding to
the remote instance.

3. Abstracted the remote print spooler to transparently manage binding
and unbinding to the remote instance when there is work and when
there is no work, respectively.

4. Cleaned up the print document adapter (ex-PrintAdapter) APIs to
enable implementing the all callbacks on a thread of choice. If
the document is really small, using the main thread makes sense.

Now if an app that does not need the UI state to layout the printed
content, it can schedule all the work for allocating resources, laying
out, writing, and releasing resources on a dedicated thread.

5. Added info class for the printed document that is now propagated
the the print services. A print service gets an instance of a
new document class that encapsulates the document info and a method
to access the document's data.

6. Added APIs for describing the type of a document to the new document
info class. This allows a print service to do smarts based on the
doc type. For now we have only photo and document types.

7. Renamed the systemReady method for system services that implement
it with different semantics to systemRunning. Such methods assume
the the service can run third-party code which is not the same as
systemReady.

8. Cleaned up the print job configuration activity.

9. Sigh... code clean up here and there. Factoring out classes to
improve readability.

Change-Id: I637ba28412793166cbf519273fdf022241159a92
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintAdapter.java
rintspooler/RemotePrintDocumentAdapter.java
fd90651cfcc7e2b75254666fd6861038b72fb4ac 24-Jun-2013 Svetoslav <svetoslavganov@google.com> Print APIs documentation update

Change-Id: I0df438e45ef540cc42c9ee5baafc816ebafa1c7b
rintspooler/RemotePrintAdapter.java
4b9a4d16872bbb50712e007b419ac0b35ff1582d 12-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Print - platform APIs

Related changes:
Skia (inlcude PDF APIs): https://googleplex-android-review.googlesource.com/#/c/305814/
Canvas to PDF: https://googleplex-android-review.googlesource.com/#/c/319367/
Settings (initial version): https://googleplex-android-review.googlesource.com/#/c/306077/
Build: https://googleplex-android-review.googlesource.com/#/c/292437/
Sample print services: https://googleplex-android-review.googlesource.com/#/c/281785/

Change-Id: I104d12efd12577f05c7b9b2a5e5e49125c0f09da
rintspooler/PrintJobConfigActivity.java
rintspooler/PrintSpooler.java
rintspooler/PrintSpoolerService.java
rintspooler/RemotePrintAdapter.java