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

Commit b4efdb47 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Deal correctly with suggested print attributes

An app might suggest certain attribute for an print job. This patch
fixes

- PrintActivity should not silently overwrite the attributes with
  the default values
- Handle duplex mode in PrintAttributes similar to the other attributes.
  I.e. have an "unset" value (0). This is an API change. But the only
  use case for PrintAttributes was to pass them to print() and thereby
  the PrintActivity. This was broken (see above), hence we are changing
  and API that could have never been used.

Bug: 23629618
Change-Id: I43c25704497c799352fb806126dc93f6db4879f5
parent c2c17c4e
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public final class PrintAttributes implements Parcelable {
    private Margins mMinMargins;

    private int mColorMode;
    private int mDuplexMode = DUPLEX_MODE_NONE;
    private int mDuplexMode;

    PrintAttributes() {
        /* hide constructor */
@@ -403,7 +403,7 @@ public final class PrintAttributes implements Parcelable {
        mResolution = null;
        mMinMargins = null;
        mColorMode = 0;
        mDuplexMode = DUPLEX_MODE_NONE;
        mDuplexMode = 0;
    }

    /**
@@ -1427,10 +1427,6 @@ public final class PrintAttributes implements Parcelable {

        /**
         * Creates a new {@link PrintAttributes} instance.
         * <p>
         * If you do not specify a duplex mode, the default
         * {@link #DUPLEX_MODE_NONE} will be used.
         * </p>
         *
         * @return The new instance.
         */
+3 −1
Original line number Diff line number Diff line
@@ -240,7 +240,9 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
            throw new IllegalArgumentException(PrintManager.EXTRA_PRINT_JOB
                    + " cannot be null");
        }
        if (mPrintJob.getAttributes() == null) {
            mPrintJob.setAttributes(new PrintAttributes.Builder().build());
        }

        final IBinder adapter = extras.getBinder(PrintManager.EXTRA_PRINT_DOCUMENT_ADAPTER);
        if (adapter == null) {