History log of /frameworks/base/core/java/android/printservice/PrintJob.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
b99876416cb8e85c748914b7eb4096f7dc80ed2c 20-Apr-2016 Philip P. Moltmann <moltmann@google.com> Print API for N: Fix docs and change interfaces as requested.

Fixes: 28291443
Change-Id: I1a1585796032351a739d54171bd67ccc76f0f08a
/frameworks/base/core/java/android/printservice/PrintJob.java
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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.java
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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.java
533e118f5ad37005a77a2a6edc60afc56034d1e9 05-Sep-2013 Svetoslav Ganov <svetoslavganov@google.com> Merge "Addressing API councing suggestions for com.android.printservice" into klp-dev
99cc86f9e096b204f1e9a3754bcb9514512ddaeb 30-Aug-2013 Svetoslav Ganov <svetoslavganov@google.com> Addressing API councing suggestions for com.android.printservice

bug:10553001

Change-Id: Ic4f7882bd10fcce79c7afc65fdb2018cbadb19c2
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.java
fd90651cfcc7e2b75254666fd6861038b72fb4ac 24-Jun-2013 Svetoslav <svetoslavganov@google.com> Print APIs documentation update

Change-Id: I0df438e45ef540cc42c9ee5baafc816ebafa1c7b
/frameworks/base/core/java/android/printservice/PrintJob.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
/frameworks/base/core/java/android/printservice/PrintJob.java