Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 88d19913 authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

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
parent 597945fd
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -18559,14 +18559,14 @@ package android.print {
    ctor public PrintAttributes.Resolution(java.lang.String, java.lang.CharSequence, int, int);
    method public int getHorizontalDpi();
    method public java.lang.String getId();
    method public java.lang.CharSequence getLabel(android.content.pm.PackageManager);
    method public java.lang.CharSequence getLabel();
    method public int getVerticalDpi();
  }
  public static final class PrintAttributes.Tray {
    ctor public PrintAttributes.Tray(java.lang.String, java.lang.CharSequence);
    method public java.lang.String getId();
    method public java.lang.CharSequence getLabel(android.content.pm.PackageManager);
    method public java.lang.CharSequence getLabel();
  }
  public abstract class PrintDocumentAdapter {
@@ -18627,7 +18627,6 @@ package android.print {
    field public static final int PRINT_JOB_ID_UNDEFINED = -1; // 0xffffffff
    field public static final int STATE_CANCELED = 6; // 0x6
    field public static final int STATE_COMPLETED = 4; // 0x4
    field public static final int STATE_CREATED = 1; // 0x1
    field public static final int STATE_FAILED = 5; // 0x5
    field public static final int STATE_QUEUED = 2; // 0x2
    field public static final int STATE_STARTED = 3; // 0x3
+3 −1
Original line number Diff line number Diff line
@@ -42,8 +42,10 @@ public final class PageRange implements Parcelable {
     * @throws IllegalArgumentException If start is less than zero.
     * @throws IllegalArgumentException If end is less than zero.
     * @throws IllegalArgumentException If start greater than end.
     *
     * @hide
     */
    PageRange(int start, int end) {
    public PageRange(int start, int end) {
        if (start < 0) {
            throw new IllegalArgumentException("start cannot be less than zero.");
        }
+2 −2
Original line number Diff line number Diff line
@@ -1007,7 +1007,7 @@ public final class PrintAttributes implements Parcelable {
         *
         * @return The human readable label.
         */
        public CharSequence getLabel(PackageManager packageManager) {
        public CharSequence getLabel() {
            return mLabel;
        }

@@ -1203,7 +1203,7 @@ public final class PrintAttributes implements Parcelable {
         *
         * @return The human readable label.
         */
        public CharSequence getLabel(PackageManager packageManager) {
        public CharSequence getLabel() {
            return mLabel;
        }

+10 −0
Original line number Diff line number Diff line
@@ -110,6 +110,16 @@ public final class PrintDocumentInfo implements Parcelable {
        parcel.writeInt(mContentType);
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("PrintDocumentInfo{");
        builder.append("pageCount: ").append(mPageCount);
        builder.append(", contentType: ").append(mContentType);
        builder.append("}");
        return builder.toString();
    }

    /**
     * Builder for creating an {@link PrintDocumentInfo}.
     */
+12 −0
Original line number Diff line number Diff line
@@ -34,12 +34,21 @@ public final class PrintJobInfo implements Parcelable {
     */
    public static final int STATE_ANY = -1;

    /**
     * Constant for matching any print job state.
     *
     * @hide
     */
    public static final int STATE_ANY_VISIBLE_TO_CLIENTS = -2;

    /**
     * Print job state: The print job is being created but not yet
     * ready to be printed.
     * <p>
     * Next valid states: {@link #STATE_QUEUED}
     * </p>
     *
     * @hide
     */
    public static final int STATE_CREATED = 1;

@@ -132,6 +141,7 @@ public final class PrintJobInfo implements Parcelable {
        mState = other.mState;
        mAppId = other.mAppId;
        mUserId = other.mUserId;
        mTag = other.mTag;
        mAttributes = other.mAttributes;
        mDocumentInfo = other.mDocumentInfo;
    }
@@ -143,6 +153,7 @@ public final class PrintJobInfo implements Parcelable {
        mState = parcel.readInt();
        mAppId = parcel.readInt();
        mUserId = parcel.readInt();
        mTag = parcel.readString();
        if (parcel.readInt() == 1) {
            mPageRanges = (PageRange[]) parcel.readParcelableArray(null);
        }
@@ -373,6 +384,7 @@ public final class PrintJobInfo implements Parcelable {
        parcel.writeInt(mState);
        parcel.writeInt(mAppId);
        parcel.writeInt(mUserId);
        parcel.writeString(mTag);
        if (mPageRanges != null) {
            parcel.writeInt(1);
            parcel.writeParcelableArray(mPageRanges, flags);
Loading