summaryrefslogtreecommitdiff
path: root/core/java/android/print/PrintJobInfo.java
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Revert "Migrate unsafe parcel APIs in framework-minus-apex""Bernardo Rufino2022-01-191-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 331be9a6431d6489f8d1e1b80cb510d0ee073c50. Reintroducing ag/16366278 since it seems unrelated to b/214053959 (more details on b/214053959#comment55). Original commit message: Migrate unsafe parcel APIs in framework-minus-apex Migrate the following unsafe parcel APIs in framework-minus-apex: * Parcel.readSerializable() * Parcel.readArrayList() * Parcel.readList() * Parcel.readParcelable() * Parcel.readParcelableList() * Parcel.readSparseArray() This CL was generated by applying lint fixes that infer the expected type from the caller code and provide that as the type parameter (ag/16365240). A few observations: * In some classes we couldn't migrate because the class also belonged to another build module whose min SDK wasn't current (as is the case for framework-minus-apex), hence I suppressed the lint check (since I'll eventually submit the lint check to the tree). * In some cases, I needed to do the cast in https://stackoverflow.com/a/1080525/5765705 to make the compiler happy since there isn't another way of providing a class of type Class<MyClassWithGenerics<T>>. * In the readSerializable() case, the new API also requires the class loader, that was inferred to by InferredClass.class.getClassLoader(). * Note that automatic formatting and import rely on running hooked up to the IDE, which wasn't the case here. Bug: 195622897 Change-Id: I272432e6e082a973f7a50492ec35d79c2b577c93 Test: TH passes
* Merge "Revert "Migrate unsafe parcel APIs in framework-minus-apex""Ashwini Oruganti2022-01-121-4/+4
|\
| * Revert "Migrate unsafe parcel APIs in framework-minus-apex"Bernardo Rufino2022-01-121-4/+4
| | | | | | | | | | | | | | | | This reverts commit 90bb3709dc75f7e44914222114752de5bce133d4. Reason for revert: b/214053959 Change-Id: Ic271bab1d3eaf677a5989dda9deb944ee2ad6850
* | Migrate unsafer parcel APIs [2]Bernardo Rufino2022-01-061-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | Manually migrate the few cases of: * readArray() * readParcelableArray() To the new parcel APIs that take the expected type as the last parameter. This enhances security because it prevents unexpected types *before* running unparcelling code. More details at go/safer-parcel. Owners, please check that the type of the objects expected is always a subtype of the type provided as the 3rd parameter. This is usually easy to verify due to casts that happen shortly after. These changes often allowed further transformations but I decided to avoid them to keep this change small and targeted. This was manual since it's tricky to get lint to infer the type in those cases and it was only a few. Bug: 195622897 Test: TH passes Change-Id: I262ed7cd6d3bc15b32e9296e88a8a67fdb59e880
* Migrate unsafe parcel APIs in framework-minus-apexBernardo Rufino2021-12-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate the following unsafe parcel APIs in framework-minus-apex: * Parcel.readSerializable() * Parcel.readArrayList() * Parcel.readList() * Parcel.readParcelable() * Parcel.readParcelableList() * Parcel.readSparseArray() This CL was generated by applying lint fixes that infer the expected type from the caller code and provide that as the type parameter (ag/16365240). A few observations: * In some classes we couldn't migrate because the class also belonged to another build module whose min SDK wasn't current (as is the case for framework-minus-apex), hence I suppressed the lint check (since I'll eventually submit the lint check to the tree). * In some cases, I needed to do the cast in https://stackoverflow.com/a/1080525/5765705 to make the compiler happy since there isn't another way of providing a class of type Class<MyClassWithGenerics<T>>. * In the readSerializable() case, the new API also requires the class loader, that was inferred to by InferredClass.class.getClassLoader(). * Note that automatic formatting and import rely on running hooked up to the IDE, which wasn't the case here. Bug: 195622897 Test: TH passes Change-Id: I11a27b9bdab7959ee86e90aa1e1cbebd7aaf883c
* Use new UnsupportedAppUsage annotation.Artur Satayev2019-12-181-1/+1
| | | | | | | | Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I534e3fd1305e2f4af076986770033478448a665c
* All Parcelable CREATOR fields are @NonNull.Jeff Sharkey2019-02-281-1/+1
| | | | | | | | | If they were null, then the Parcelable would fail to work. Bug: 126726802 Test: manual Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014 Exempt-From-Owner-Approval: Trivial API annotations
* Add @UnsupportedAppUsage annotationsMathew Inwood2018-07-311-0/+3
| | | | | | | | | | | | | | | | | | | For packages: android.printservice.recommendation android.printservice android.print.pdf android.print This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: I97fb9c95dad2f93a8e989f3f48f323e9f76eaf31
* Hold wake lock while printingPhilip P. Moltmann2018-05-151-0/+9
| | | | | | | | | | | | | | | more specifically while any print job is - queued (ready to be printed but not yet printing) - started (actually printing right now) - cancelling (printing, but cancel request has been sent) Test: - Printed successfully - Canceled print job - Had print job that blocked Wake locks looked fine while doing all this Fixes: 74811014 Change-Id: Ia1a3327bd55fb7f3cc7ecb330d7d2c141d4fdb34
* Add more IntDef prefixes for auto-documenting.Jeff Sharkey2017-12-131-3/+8
| | | | | | | Test: builds, boots Bug: 70177949 Exempt-From-Owner-Approval: annotation-only changes Change-Id: I76dde6054e06f52240bd4b1a0f196dcb74623608
* Dump print manager as protoPhilip P. Moltmann2017-07-251-7/+8
| | | | | Test: incident_report print. Having no entries Change-Id: I3c7d611e44c0d3bf8e00775b1708bd82a334121a
* Allow print services to read advanced options.Philip P. Moltmann2016-10-041-6/+0
| | | | | | Test: Ran adjusted test that is subitted along side Change-Id: Ic662c6a6e56c3184611b30947fd715b57df196c0 Fixes: 28913410
* Change hasCustomPrintIcon and setStatus as requested by API council.Philip P. Moltmann2016-03-241-3/+54
| | | | | | | | 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
* Correct nullability in PrintJob.Philip P. Moltmann2016-01-211-1/+1
| | | | | | | 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
* Clean up print subsystemPhilip P. Moltmann2015-12-221-20/+34
| | | | | | | | | | | - 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
* Allow print service to specify progress of print and statusPhilip P. Moltmann2015-12-011-33/+91
| | | | | | | | | | 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
* Complete implementation of the advanced print options.Svetoslav2013-10-281-28/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update the documentaton of the android.print package.Svetoslav Ganov2013-10-251-6/+16
| | | | | | | | | | | | bug:10551786 bug:10551697 bug:10705082 bug:10741641 bug:11318976 bug:10550979 bug:10551761 Change-Id: I46ceb66a69b6d32d6b417356178f67f2e25e891a
* Add APIs for an advanced print options activity.Svetoslav2013-10-161-1/+76
| | | | | | | | | | 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
* The list of active print jobs in print service retunring wrong result.Svetoslav Ganov2013-10-121-2/+5
| | | | | | | | | | | | | | | | 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
* Fail only scheduled print jobs, i.e. handed to a service, if the service is ↵Svetoslav Ganov2013-10-121-0/+8
| | | | | | | | | | | | | | | | 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
* Print spooler not starting.Svetoslav2013-10-111-28/+0
| | | | | | | | | | | | | | | | | | | 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
* Coalescing multiple print job notifications.Svetoslav Ganov2013-10-091-0/+29
| | | | | | | | | | | | | | | 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
* Small print API tweaksSvetoslav2013-10-041-3/+2
| | | | | | | | | | | | | | | | | | 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
* Adding hidden APIs for observing the print jobs state.Svetoslav Ganov2013-09-251-6/+35
| | | | | | | | This is needed for implementing the print job settigns UI. bug:10935736 Change-Id: I63b42cbf4ce6a259fa1af47fa368b148ca5621c1
* App UI freezes when printing. API clean up.Svetoslav2013-09-161-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Print spooler security and some new print service facing APIs.Svetoslav Ganov2013-08-291-22/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implemented advanced printer selection and API refactoring.Svetoslav2013-08-191-17/+10
| | | | | | | | | | | | | | | | | | | | 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
* Refinement of the print service APIs.Svetoslav Ganov2013-08-111-0/+28
| | | | | | | | | | | | | | | | 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
* First cut of the print notifications.Svetoslav Ganov2013-08-021-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Iteration on the print sub-system.Svetoslav Ganov2013-07-301-1/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Implement persistence/restoring of print spooler state.Svetoslav Ganov2013-07-221-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Refactoring of the print sub-system and API clean up.Svetoslav Ganov2013-07-161-28/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Print API tweaks.Svetoslav2013-06-221-6/+6
| | | | Change-Id: I4fcf93f17495740e8b8d0dc4e425a89862716b42
* Print - platform APIsSvetoslav Ganov2013-06-211-0/+414
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