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

Commit 0c126a47 authored by Svetoslav's avatar Svetoslav Committed by Svetoslav Ganov
Browse files

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
parent 32618191
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ public final class PrintDocumentInfo implements Parcelable {
        public Builder setPageCount(int pageCount) {
            if (pageCount < 0 && pageCount != PAGE_COUNT_UNKNOWN) {
                throw new IllegalArgumentException("pageCount"
                        + " must be greater than or euqal to zero or"
                        + " must be greater than or equal to zero or"
                        + " DocumentInfo#PAGE_COUNT_UNKNOWN");
            }
            mPrototype.mPageCount = pageCount;
@@ -338,6 +338,12 @@ public final class PrintDocumentInfo implements Parcelable {
         * @return The new instance.
         */
        public PrintDocumentInfo build() {
            // Zero pages is the same as unknown as in this case
            // we will have to ask for all pages and look a the
            // wiritten PDF file for the page count.
            if (mPrototype.mPageCount == 0) {
                mPrototype.mPageCount = PAGE_COUNT_UNKNOWN;
            }
            return new PrintDocumentInfo(mPrototype);
        }
    }