• Home
  • History
  • Annotate
  • only in /frameworks/base/core/java/android/print/
History log of /frameworks/base/core/java/android/print/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
00c3659eca6f9ab9235e7746b6d74702ab90555b 24-Jun-2016 Philip P. Moltmann <moltmann@google.com> Do not remove handlers for loaders.

In rare situations we might trigger a force-load if the handler is
stopped.

Change-Id: I103744654805dcbe0744b09b5be9da1f505817d3
Fixes: 29581798
rintServiceRecommendationsLoader.java
rintServicesLoader.java
823715d656381a84b8c6c6d63769c663b417274d 22-Apr-2016 Philip P. Moltmann <moltmann@google.com> Rename 'thousands of an inch' to 'thousandths of an inch'in the docs.

Fixes: 28268203
Change-Id: I4246bc7431d1e0ecb75a6d101ba6ccd548567704
rintAttributes.java
c863489e67ffaf8d74de24cf1634d9b9619a2f60 20-Apr-2016 Philip P. Moltmann <moltmann@google.com> Prevent printing from finishing activity.

Bug: 27861927
Change-Id: I00177ca0ec75cc8f7fd422907a2b5827b5db406b
rintManager.java
0d1407e60998fc73cf93801de9c637e8d0e19b5b 01-Apr-2016 Philip P. Moltmann <moltmann@google.com> Fix Print CTS tests.

Fixes: 27971210
Change-Id: Ied11b2f1c528fe5e204e683d988b4efbd2562ef0
rinterCapabilitiesInfo.java
e680a8db52652830b99d9effce6c04a2a60c142e 30-Mar-2016 Philip P. Moltmann <moltmann@google.com> Make sure PrinterCapabilitiesInfo always have sane values.

Change-Id: I1ae7fe6aabdbe7f9480c4067690338103adaafa2
rinterCapabilitiesInfo.java
4723f36d3e93ce4585233de31c72143a46b657f7 30-Mar-2016 Philip P. Moltmann <moltmann@google.com> Make sure PrintDocumentInfo is always sane.

Change-Id: I73cf554d42dc33b7a1f6577088ec53b447f14c8c
rintDocumentInfo.java
aa8a4fed075fdd9faa6c9d5b150fc28e1a834122 30-Mar-2016 Philip P. Moltmann <moltmann@google.com> Make sure PrintAttributes have sane values.

Please note that null and 0 values mean "unset" and that margins
historically allowed negative values.

Change-Id: I1773bc552142345e18c1c31fb25e583d0ed070a2
rintAttributes.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
PrintManager.aidl
rintManager.java
rintServiceRecommendationsLoader.java
rintServicesLoader.java
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
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
PrintSpooler.aidl
rintJobInfo.java
rinterInfo.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
ageRange.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
PrintManager.aidl
PrintServicesChangeListener.aidl
rintManager.java
rintServicesLoader.java
f8880561e67e1da246970b49b14285efd4164ab1 26-Feb-2016 Jeff Sharkey <jsharkey@android.com> When system server goes down, crash apps more.

Similar to first patch, but now using new "rethrowFromSystemServer()"
method which internally translates DeadObjectException into
DeadSystemException. New logic over in Log.printlns() now
suppresses the DeadSystemException stack traces, since they're
misleading and just added pressure to the precious log buffer space.

Add some extra RuntimeInit checks to suppress logging-about-logging
when the system server is dead.

Bug: 27364859
Change-Id: I05316b3e8e42416b30a56a76c09cd3113a018123
rintManager.java
e93cf151fbb0ed1e42d14b767f5f8798ab6876e7 02-Feb-2016 Philip P. Moltmann <moltmann@google.com> Merge "Allow the PDF Printer to "print" non-locale-default paper sizes."
e33b954165595acec9cf9fe2bc14f4586f541f73 26-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "Check parameters for callers of IPrintManager"
5ddbc2af0c248e73c5b8f7c37c7a24775798326b 26-Jan-2016 Philip P. Moltmann <moltmann@google.com> Merge "Correctly deal with non-null ness of PrintJobId."
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
rintAttributes.java
22f86b4e77c77312e8b3f08fc598be00c323f750 15-Jan-2016 Philip P. Moltmann <moltmann@google.com> Correct nullability in PrintJob.

Unfoturnately printJobInfo.getId() can be legitimately null. Maybe that
can be fixed, but until this is addressed we have to deal with it.

Change-Id: I2bf816dfde49e85d51523beba2c3401f5a6ee55e
rintJob.java
rintJobInfo.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
rintManager.java
rinterDiscoverySession.java
1c8f1e06a609507533609b4e04161c1c4fcb2849 21-Jan-2016 Philip P. Moltmann <moltmann@google.com> Shorten LOG_TAGs to fit in 23 characters as commented on by lint.

Change-Id: Ie9415fc3de642493bc36c0159b773d8ce2436df5
rintFileDocumentAdapter.java
cdf2b400349ca22fedfeb5a2deb8a043791b22ef 14-Jan-2016 Philip P. Moltmann <moltmann@google.com> Enforce non-nullness in PrinterId and exploit it.

Change-Id: Ifdf3b2329548a665d609dd66b738baab5c765b54
rinterId.java
fdb2b7644fc8b0ef968b5c7a2345c17a58287fd9 15-Jan-2016 Philip P. Moltmann <moltmann@google.com> Correctly deal with non-null ness of PrintJobId.

Change-Id: I217885247467e3900b53f8a2ab32306a50351154
rintJobId.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
rinterInfo.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
PrintSpooler.aidl
b8c1a02adb1e55bae04bde3f5046fe324abed9e9 06-Jan-2016 Philip P. Moltmann <moltmann@google.com> Fix wrong annotation for PrintInfo.Builder.setStatus

Change-Id: I11fd68497c6229d16c0827f4753f485e9095649d
rinterInfo.java
bb36206f08797156caed236671d36b5a34682f95 23-Dec-2015 Philip P. Moltmann <moltmann@google.com> Rename variable that hides the contatining classes name.

Change-Id: Iad0a9b341a866d33d10b7a389d243e677a65057c
rinterInfo.java
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
ageRange.java
rintAttributes.java
rintDocumentInfo.java
rintJob.java
rintJobId.java
rintJobInfo.java
rintManager.java
rinterCapabilitiesInfo.java
rinterId.java
rinterInfo.java
df/PrintedPdfDocument.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
PrintManager.aidl
PrintSpooler.aidl
PrintSpoolerCallbacks.aidl
rintManager.java
rinterInfo.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
PrintSpooler.aidl
rintJobInfo.java
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
rintAttributes.java
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
PrintSpooler.aidl
b95d079c8036279c52a76e02c5bd5f99d58a8402 17-Mar-2015 Andreas Gampe <agampe@google.com> am e4bdf3c1: am be549f9b: Merge "Frameworks/base: Fix precedence bug"

* commit 'e4bdf3c1c9e7be06b68cc32f9a492d512bf87528':
Frameworks/base: Fix precedence bug
869d26fda0d612c15eac64f7d7bc6d7a28073498 15-Mar-2015 Andreas Gampe <agampe@google.com> Frameworks/base: Fix precedence bug

Explicit cast has higher precedence than shift.

Bug: 19797138
Change-Id: Ifcf569bf774fbf65ee50c078f736ad167bcc6b8c
rintDocumentInfo.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
rintAttributes.java
rinterCapabilitiesInfo.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
PrintDocumentAdapter.aidl
rintManager.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
rintManager.java
15cbc8a03250eafdf947cd8ad4e77f34444d5ba4 11-Jul-2014 Svetoslav <svetoslavganov@google.com> Addressing comments for the print preview feature.

Change-Id: Ib72140a912e22f859258d970e0d1c4ef06e807d5
ageRange.java
rintManager.java
0c126a478b4b1891b275fe424c9f7e37adcdb758 11-Jul-2014 Svetoslav <svetoslavganov@google.com> Fix print document with zero pages backwards compatibility.

Historically, we were allowing an app that prints to specify that
the printed document has zero pages. While this does not make any
sense we should keep the behavior as people may have apps that do
that. This change fixes this issue and now we treat zero the same
way as undefined page count and ask the app to write all pages to
check the written PDF for the page count.

bug:16199127

Change-Id: I4e7de66b669e9f783db0252244a6c1e5b24ffe28
rintDocumentInfo.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
ageRange.java
rintAttributes.java
rintManager.java
a798c0a984f29f7180883a61839f68d2cbf0c6ce 15-May-2014 Svetoslav <svetoslavganov@google.com> Refactor printing

Change-Id: I19850154ef2798afff511e4490a268ce38e8cbae
LayoutResultCallback.aidl
PrintDocumentAdapter.aidl
WriteResultCallback.aidl
rintAttributes.java
rintManager.java
rinterDiscoverySession.java
2235a1772fc3c72b5c1795310e221d613cae01da 08-May-2014 Svetoslav <svetoslavganov@google.com> PrintManager should not crash if print fueature is not available.

Printing is one of the optional software features. If the device does not
have the feature, then the print APIs should do nothing. Before, a NPE
crash was happening.

bug:14651902

Change-Id: I63efa75be51e8957ca6854b2b439918f01c0f154
rintManager.java
fcf3b103f0fc275aeefbe548804b51c26f4385a5 18-Mar-2014 Svetoslav <svetoslavganov@google.com> Merge "Update print docs"
85a85a0ed775999533b14a415fd79b50fe63e6d2 18-Mar-2014 Svetoslav <svetoslavganov@google.com> Update print docs

Change-Id: I671ad776968ca2802f05f94f7cc96959fb50fa4b
rintManager.java
73832594b31fe110a24329aad9bf611412600e71 18-Mar-2014 Svetoslav <svetoslavganov@google.com> Merge "Updated print docs."
81f14b96899afa90330e2652acb629345acf17b1 18-Mar-2014 Svetoslav <svetoslavganov@google.com> Updated print docs.

Added an explanation why the system cannot maintain print UI
state on rotation.

Change-Id: I370158ba4be929b67a4b5476ccacad5335d18b34
rintManager.java
b628dd825b319704f8a8135addef766ec892ce84 02-Jan-2014 Svetoslav <svetoslavganov@google.com> PrintSpooler crash if printer is reported to have only one color mode.

bug:11993304

Change-Id: I4932cf1b5b9b89f0cbf97011782ede037e7d814c
(cherry picked from commit b0d97b87ba5f23ee867f381a4e5916ebb2e5f762)
rinterCapabilitiesInfo.java
afd19675030801fb64d32ff101d1da651edf87bc 14-Nov-2013 Svetoslav <svetoslavganov@google.com> Avoid NPE and add a warning log if a printing app misbehaves.

An app can print only from an activity. If the activity is finished
before printing completes we destroy the PrintDocumentAdapter. The
app may however invoke some of the print callbacks after destruction
resulting in a NPE. This change checks if the adapter is destroyed
and if so does not crash while printing a meaningful log error with
the mistake of the app developer.

bug:11675274

Change-Id: I66539cfbd7583f52cb863a84ef8e40856f92ceed
rintManager.java
57b296f5a9b547e5a5aad2f19f082f2b9400d88a 13-Nov-2013 Svetoslav <svetoslavganov@google.com> Update the PrintDocumentAdapter docs.

This change adds some clarification when a cancellation will be
requested during a layout or write. It also clarifies from which
thread the layout and write callbacks can be invoked.

Change-Id: Id20ff04c6fca8315849ed4a6c329da1b12bb6836
rintDocumentAdapter.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
PrintDocumentAdapter.aidl
rintManager.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
rintJobInfo.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
ageRange.java
rintAttributes.java
rintDocumentAdapter.java
rintDocumentInfo.java
rintJob.java
rintJobInfo.java
rintManager.java
rinterCapabilitiesInfo.java
rinterInfo.java
ackage.html
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
PrintDocumentAdapter.aidl
PrintDocumentAdapterObserver.aidl
rintManager.java
1c43fceaaa5f9aa6e29e2670f44f312632241007 16-Oct-2013 Svetoslav <svetoslavganov@google.com> Add APIs for an advanced print options activity.

This is the API part needed to implement support for custom print
options by a print service. Some printers have quite fancy options
and we want users to benefit using them.

bug:11241800

Change-Id: I3a9df771c0ded559b61c597c686795840d702b27
rintJobInfo.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
rintJobInfo.java
rintManager.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
rintDocumentInfo.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
rintJobInfo.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
rintJobInfo.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
PrintManager.aidl
PrintSpooler.aidl
rintManager.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
PrintSpooler.aidl
rintJobInfo.java
rintManager.java
ef4a6f866241852f60a25b7c0bca41750dee816e 08-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Do not do a layout and write while a cancellation is in progress." into klp-dev
db63677c7c02cad7c25627533e5add5ed46870f8 07-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> Do not do a layout and write while a cancellation is in progress.

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

bug:11118426

Change-Id: If7b191c44387d88d5cec195d1785a47f986965ba
rintManager.java
b2420c917bf4092f44a2270d7e88ee2380f72080 07-Oct-2013 Svetoslav Ganov <svetoslavganov@google.com> The undefined media sizes for both orientations not properly constructed.

We have constants for an app to specify an undefined media size in portrait
and such in landscape. The constants for these media sizes had the width and
height dimesions swapped.

bug:11099831

Change-Id: Ic09227c3a03429fc5a4a157abc15fea87d3ad8be
rintAttributes.java
19565ad1a19bf8e400d04a3a64cf6455ddca81ca 05-Oct-2013 Svetoslav <svetoslavganov@google.com> Merge "Small print API tweaks" into klp-dev
b450d0d4d7fca16674fea02f15e21dc737352c40 05-Oct-2013 Svetoslav <svetoslavganov@google.com> Small print API tweaks

1. Removed an unused public constant

2. Hide PrintFileDocumentAdapter which makes doing the wring
thing easy.

3. We allow a print service to set a tag of a print job which is
an arbitrary string it only knows how to interpret. Typically,
this is the id of a remote print job. This tag was visible to
applications which is wrong - this is data that should be
private to the print service. Now the print service is the
only one to see that.

bug:11084635

Change-Id: I763ea9ff0fdf647805bc36e1737d72263090714d
rintFileDocumentAdapter.java
rintJobInfo.java
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
rintAttributes.java
cfab2457f2c140a2356bb45ec25f51a0a5866556 28-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Printers in the list of printers change position.

While the logic was correct the array map that holds the list of pritners
does not keep the position of the items constant. Switched to linked hash
map which gives this guarantee.

bug:10955751

Change-Id: Idbbe14d753e6a1ad1002f2289b10cb62d7f9f040
rinterDiscoverySession.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
PrintManager.aidl
rintManager.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
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
PrintSpooler.aidl
PrintSpoolerClient.aidl
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
rinterDiscoverySession.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
PrintJobStateChangeListener.aidl
PrintManager.aidl
PrintSpoolerClient.aidl
rintJob.java
rintJobInfo.java
rintManager.java
rinterInfo.java
678e907e09388dff8b2955bb524c2706f067a6ef 21-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Update android.print.PrintAttributes documentation" 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
rintAttributes.java
22cb9170d33eb6da54fc36b783fcb93fd6057749 30-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Update android.print.PrintAttributes documentation

bug:10550844

Change-Id: Ic1bbb2cb6ab55826eb66242f6002b7165aff37a4

Conflicts:
core/java/android/print/PrintAttributes.java
rintAttributes.java
facc08c7757cef56da6d10e78ce99ef7949700e3 20-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Move PdfDocument to android.graphics.pdf" into klp-dev
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
rintDocumentAdapter.java
df/PdfDocument.java
df/PrintedPdfDocument.java
81d4014c59d2c6cf23b0465e9b8c94b6bfe428e2 18-Sep-2013 Svetoslav <svetoslavganov@google.com> Hiding a method that was never meant to be public.

The hide javadoc annotation had a type, thus leaking the API.

bug:10552358

Change-Id: Iec4e203d0786efbe6afbd9b6995f11642935336c
rintAttributes.java
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
rintAttributes.java
22d2575c3eb5e2154bcb344372711bafc2e0b3d3 17-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Adding more standard media sizes." into klp-dev
fa77ece25a98810b6f56130d4a83c62b2e34c4f5 17-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Adding more standard media sizes.

Added more North America media sizes as well as Chinese and Japanese.

bug:10495384

Change-Id: I74869c13d1412780b0053ef665845d65e972e526
rintAttributes.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
PrintManager.aidl
PrintSpooler.aidl
PrintSpoolerCallbacks.aidl
PrinterDiscoveryObserver.aidl
rintJob.java
rintJobId.aidl
rintJobId.java
rintJobInfo.java
rintManager.java
rinterDiscoverySession.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
PrintManager.aidl
rintManager.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
rintAttributes.java
rintDocumentInfo.java
rinterCapabilitiesInfo.java
rinterInfo.java
df/PrintedPdfDocument.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
rintAttributes.java
rintJob.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
rintDocumentAdapter.java
4e4518383f9212618cafa6c9ce2120becc6f6204 06-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Printers for a disappearing print serivce incorrectly removed.

The code that removes printers for a disappearing print serivice was
using printer infos instead printer ids and also wrong map methods.

bug:10651739

Change-Id: Idb9ccdaad9a59b3b6d16b079b33afad56bc45255
PrinterDiscoveryObserver.aidl
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
rintAttributes.java
2def61485413084e68233c89ba956a2282fbacd1 05-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Hiding some unneeded APIs," into klp-dev
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
rintAttributes.java
c5c203d6ef8eea46f1c06f52e3ebfcc59c304760 05-Sep-2013 Svetoslav <svetoslavganov@google.com> Merge "Print API updated." into klp-dev
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
PrinterDiscoveryObserver.aidl
rintAttributes.java
rintDocumentAdapter.java
rintDocumentInfo.java
rinterCapabilitiesInfo.java
rinterDiscoverySession.java
19fba5d34a444ce145ab0d3a12c578d9d5d3f38c 31-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> KLP API Review: PrintDocumentAdapter documentation

bug:10551676

Change-Id: I755cc1827ed950b8481b8b260ea3cde83bcdd418
rintDocumentAdapter.java
rintFileDocumentAdapter.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
PrintManager.aidl
rintDocumentAdapter.java
rintDocumentInfo.java
rintFileDocumentAdapter.java
rintJobInfo.java
rintManager.java
rinterDiscoverySession.java
df/PrintedPdfDocument.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
ageRange.java
rintAttributes.java
rintDocumentAdapter.java
rintDocumentInfo.java
rinterCapabilitiesInfo.java
rinterInfo.java
df/PdfDocument.java
df/PrintedPdfDocument.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
PrintManager.aidl
PrintSpooler.aidl
PrintSpoolerClient.aidl
PrinterDiscoveryObserver.aidl
rintManager.java
rinterDiscoverySession.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
PrintSpooler.aidl
PrintSpoolerClient.aidl
PrinterDiscoverySessionController.aidl
PrinterDiscoverySessionObserver.aidl
rintJobInfo.java
rintManager.java
rinterInfo.java
df/PdfDocument.java
9abf735387329758ca310acad3baa70eee1dba42 12-Aug-2013 Svetoslav <svetoslavganov@google.com> Make PrintFileDocumentAdapter non-final.

Change-Id: I89a46bf766f5270dfaba7482b7b7cd997e19821a
rintFileDocumentAdapter.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
ileDocumentAdapter.java
PrintSpoolerClient.aidl
PrinterDiscoveryObserver.aidl
PrinterDiscoverySessionController.aidl
PrinterDiscoverySessionObserver.aidl
rintAttributes.java
rintDocumentInfo.java
rintFileDocumentAdapter.java
rintJobInfo.java
rintManager.java
rinterCapabilitiesInfo.aidl
rinterCapabilitiesInfo.java
rinterId.java
rinterInfo.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
rintManager.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
PrintSpooler.aidl
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
PrintManager.aidl
PrintSpooler.aidl
rintJobInfo.java
rinterId.java
rinterInfo.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
PrintSpoolerClient.aidl
PrinterDiscoveryObserver.aidl
rinterId.java
rinterInfo.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
ileDocumentAdapter.java
LayoutResultCallback.aidl
PrintDocumentAdapter.aidl
PrintManager.aidl
PrintSpoolerCallbacks.aidl
PrintSpoolerObserver.aidl
WriteResultCallback.aidl
ageRange.java
rintAttributes.java
rintDocumentAdapter.java
rintDocumentInfo.java
rintJob.java
rintJobInfo.java
rintManager.java
rinterInfo.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
rintAttributes.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
ageRange.java
rintAttributes.java
rintDocumentInfo.java
rintJobInfo.java
rintManager.java
rinterId.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
ileDocumentAdapter.java
PrintDocumentAdapter.aidl
rintDocumentAdapter.java
rintManager.java
df/PdfDocument.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
ileDocumentAdapter.java
rintAttributes.java
rintManager.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
ileDocumentAdapter.java
LayoutResultCallback.aidl
PrintAdapter.aidl
PrintDocumentAdapter.aidl
PrintManager.aidl
PrintResultCallback.aidl
PrintSpooler.aidl
PrintSpoolerCallbacks.aidl
PrintSpoolerClient.aidl
PrintSpoolerObserver.aidl
PrintSpoolerService.aidl
PrintSpoolerServiceCallbacks.aidl
WriteResultCallback.aidl
rintAdapter.java
rintAdapterInfo.aidl
rintAdapterInfo.java
rintDocumentAdapter.java
rintDocumentInfo.aidl
rintDocumentInfo.java
rintFileAdapter.java
rintJob.java
rintJobInfo.java
rintManager.java
rinterId.java
rinterInfo.java
fd90651cfcc7e2b75254666fd6861038b72fb4ac 24-Jun-2013 Svetoslav <svetoslavganov@google.com> Print APIs documentation update

Change-Id: I0df438e45ef540cc42c9ee5baafc816ebafa1c7b
PrintAdapter.aidl
PrintProgressListener.aidl
PrintResultCallback.aidl
ageRange.java
rintAdapter.java
rintFileAdapter.java
rintManager.java
df/PdfDocument.java
53f57d162b0553102fbd5c4ccdda87dbfce5b763 22-Jun-2013 Svetoslav <svetoslavganov@google.com> Print API tweaks.

Change-Id: I4fcf93f17495740e8b8d0dc4e425a89862716b42
rintJobInfo.java
rintManager.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
PrintAdapter.aidl
PrintClient.aidl
PrintManager.aidl
PrintProgressListener.aidl
PrintSpoolerService.aidl
PrintSpoolerServiceCallbacks.aidl
PrinterDiscoveryObserver.aidl
ageRange.aidl
ageRange.java
rintAdapter.java
rintAdapterInfo.aidl
rintAdapterInfo.java
rintAttributes.aidl
rintAttributes.java
rintFileAdapter.java
rintJob.java
rintJobInfo.aidl
rintJobInfo.java
rintManager.java
rinterId.aidl
rinterId.java
rinterInfo.aidl
rinterInfo.java
ff4adde5737be08d3e2d03fbe588c591d27d4a74 10-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Generate PDF from Canvas.

This change adds simple APIs that enable an Android application
to generate a PDF document by drawing content on a canvas.

Change-Id: Ibac93d7c37b01a376ce7c48238657d8c7698d588
df/PdfDocument.java
7a56be0915b4ff7cecfbc88fc0a7d567dc58ee58 13-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Revert "Generate PDF from Canvas."

This reverts commit 923c633ccfda45312fec5a3484b6cc1308cc71ab

Change-Id: Ie49f593ec702c1ecf96a5cc1fafa680c1db08747
df/PdfDocument.java
923c633ccfda45312fec5a3484b6cc1308cc71ab 10-Jun-2013 Svetoslav Ganov <svetoslavganov@google.com> Generate PDF from Canvas.

This change adds simple APIs that enable an Android application
to generate a PDF document by drawing content on a canvas.

Change-Id: Iddcd126b3af37c73d99262f6b276caa07b998c1d
df/PdfDocument.java