diff options
author | Svetoslav <svetoslavganov@google.com> | 2013-09-16 17:53:51 -0700 |
---|---|---|
committer | Svetoslav <svetoslavganov@google.com> | 2013-09-16 17:55:14 -0700 |
commit | 2fbd2a7f070f246ddafd9de94efa9a98861e9136 (patch) | |
tree | 2a918b4226106a2350277ae8fa73a9e2ce79d697 /core/java/android/print/PrintJobInfo.java | |
parent | 3fb53d8238c0ccec275237cf4f4962f2a00eab7e (diff) | |
download | frameworks_base-2fbd2a7f070f246ddafd9de94efa9a98861e9136.zip frameworks_base-2fbd2a7f070f246ddafd9de94efa9a98861e9136.tar.gz frameworks_base-2fbd2a7f070f246ddafd9de94efa9a98861e9136.tar.bz2 |
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
Diffstat (limited to 'core/java/android/print/PrintJobInfo.java')
-rw-r--r-- | core/java/android/print/PrintJobInfo.java | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/core/java/android/print/PrintJobInfo.java b/core/java/android/print/PrintJobInfo.java index b919ad6..502a9f2 100644 --- a/core/java/android/print/PrintJobInfo.java +++ b/core/java/android/print/PrintJobInfo.java @@ -56,8 +56,6 @@ public final class PrintJobInfo implements Parcelable { * <p> * Next valid states: {@link #STATE_QUEUED} * </p> - * - * @hide */ public static final int STATE_CREATED = 1; @@ -117,7 +115,7 @@ public final class PrintJobInfo implements Parcelable { public static final int STATE_CANCELED = 7; /** The unique print job id. */ - private int mId; + private PrintJobId mId; /** The human readable print job label. */ private String mLabel; @@ -178,7 +176,7 @@ public final class PrintJobInfo implements Parcelable { } private PrintJobInfo(Parcel parcel) { - mId = parcel.readInt(); + mId = parcel.readParcelable(null); mLabel = parcel.readString(); mPrinterId = parcel.readParcelable(null); mPrinterName = parcel.readString(); @@ -208,7 +206,7 @@ public final class PrintJobInfo implements Parcelable { * * @return The id. */ - public int getId() { + public PrintJobId getId() { return mId; } @@ -219,7 +217,7 @@ public final class PrintJobInfo implements Parcelable { * * @hide */ - public void setId(int id) { + public void setId(PrintJobId id) { this.mId = id; } @@ -485,7 +483,7 @@ public final class PrintJobInfo implements Parcelable { @Override public void writeToParcel(Parcel parcel, int flags) { - parcel.writeInt(mId); + parcel.writeParcelable(mId, flags); parcel.writeString(mLabel); parcel.writeParcelable(mPrinterId, flags); parcel.writeString(mPrinterName); |