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

Commit 4c95567b authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Android (Google) Code Review
Browse files

Merge "Clean up print subsystem"

parents 30172e25 c43639c3
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.print;
package android.print;


import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;


@@ -42,7 +44,7 @@ public final class PageRange implements Parcelable {
     * @throws IllegalArgumentException If start is less than zero or end
     * @throws IllegalArgumentException If start is less than zero or end
     * is less than zero or start greater than end.
     * is less than zero or start greater than end.
     */
     */
    public PageRange(int start, int end) {
    public PageRange(@IntRange(from = 0) int start, @IntRange(from = 0) int end) {
        if (start < 0) {
        if (start < 0) {
            throw new IllegalArgumentException("start cannot be less than zero.");
            throw new IllegalArgumentException("start cannot be less than zero.");
        }
        }
@@ -56,7 +58,7 @@ public final class PageRange implements Parcelable {
        mEnd = end;
        mEnd = end;
    }
    }


    private PageRange (Parcel parcel) {
    private PageRange(@NonNull Parcel parcel) {
        this(parcel.readInt(), parcel.readInt());
        this(parcel.readInt(), parcel.readInt());
    }
    }


@@ -65,7 +67,7 @@ public final class PageRange implements Parcelable {
     *
     *
     * @return The start page index.
     * @return The start page index.
     */
     */
    public int getStart() {
    public @IntRange(from = 0) int getStart() {
        return mStart;
        return mStart;
    }
    }


@@ -74,7 +76,7 @@ public final class PageRange implements Parcelable {
     *
     *
     * @return The end page index.
     * @return The end page index.
     */
     */
    public int getEnd() {
    public @IntRange(from = 0) int getEnd() {
        return mEnd;
        return mEnd;
    }
    }


+52 −29
Original line number Original line Diff line number Diff line
@@ -16,6 +16,10 @@


package android.print;
package android.print;


import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources.NotFoundException;
import android.content.res.Resources.NotFoundException;
@@ -27,6 +31,8 @@ import android.util.Log;


import com.android.internal.R;
import com.android.internal.R;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Map;
import java.util.Map;


/**
/**
@@ -37,6 +43,13 @@ import java.util.Map;
 * 10 mills (thousand of an inch) on all sides, and be black and white.
 * 10 mills (thousand of an inch) on all sides, and be black and white.
 */
 */
public final class PrintAttributes implements Parcelable {
public final class PrintAttributes implements Parcelable {
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {
            COLOR_MODE_MONOCHROME, COLOR_MODE_COLOR
    })
    public @interface ColorMode {
    }
    /** Color mode: Monochrome color scheme, for example one color is used. */
    /** Color mode: Monochrome color scheme, for example one color is used. */
    public static final int COLOR_MODE_MONOCHROME = 1 << 0;
    public static final int COLOR_MODE_MONOCHROME = 1 << 0;
    /** Color mode: Color color scheme, for example many colors are used. */
    /** Color mode: Color color scheme, for example many colors are used. */
@@ -45,6 +58,13 @@ public final class PrintAttributes implements Parcelable {
    private static final int VALID_COLOR_MODES =
    private static final int VALID_COLOR_MODES =
            COLOR_MODE_MONOCHROME | COLOR_MODE_COLOR;
            COLOR_MODE_MONOCHROME | COLOR_MODE_COLOR;


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {
            DUPLEX_MODE_NONE, DUPLEX_MODE_LONG_EDGE, DUPLEX_MODE_SHORT_EDGE
    })
    public @interface DuplexMode {
    }
    /** Duplex mode: No duplexing. */
    /** Duplex mode: No duplexing. */
    public static final int DUPLEX_MODE_NONE = 1 << 0;
    public static final int DUPLEX_MODE_NONE = 1 << 0;
    /** Duplex mode: Pages are turned sideways along the long edge - like a book. */
    /** Duplex mode: Pages are turned sideways along the long edge - like a book. */
@@ -66,7 +86,7 @@ public final class PrintAttributes implements Parcelable {
        /* hide constructor */
        /* hide constructor */
    }
    }


    private PrintAttributes(Parcel parcel) {
    private PrintAttributes(@NonNull Parcel parcel) {
        mMediaSize = (parcel.readInt() ==  1) ? MediaSize.createFromParcel(parcel) : null;
        mMediaSize = (parcel.readInt() ==  1) ? MediaSize.createFromParcel(parcel) : null;
        mResolution = (parcel.readInt() ==  1) ? Resolution.createFromParcel(parcel) : null;
        mResolution = (parcel.readInt() ==  1) ? Resolution.createFromParcel(parcel) : null;
        mMinMargins = (parcel.readInt() ==  1) ? Margins.createFromParcel(parcel) : null;
        mMinMargins = (parcel.readInt() ==  1) ? Margins.createFromParcel(parcel) : null;
@@ -79,7 +99,7 @@ public final class PrintAttributes implements Parcelable {
     *
     *
     * @return The media size or <code>null</code> if not set.
     * @return The media size or <code>null</code> if not set.
     */
     */
    public MediaSize getMediaSize() {
    public @Nullable MediaSize getMediaSize() {
        return mMediaSize;
        return mMediaSize;
    }
    }


@@ -99,7 +119,7 @@ public final class PrintAttributes implements Parcelable {
     *
     *
     * @return The resolution or <code>null</code> if not set.
     * @return The resolution or <code>null</code> if not set.
     */
     */
    public Resolution getResolution() {
    public @Nullable Resolution getResolution() {
        return mResolution;
        return mResolution;
    }
    }


@@ -127,7 +147,7 @@ public final class PrintAttributes implements Parcelable {
     *
     *
     * @return The margins or <code>null</code> if not set.
     * @return The margins or <code>null</code> if not set.
     */
     */
    public Margins getMinMargins() {
    public @Nullable Margins getMinMargins() {
        return mMinMargins;
        return mMinMargins;
    }
    }


@@ -158,7 +178,7 @@ public final class PrintAttributes implements Parcelable {
     * @see #COLOR_MODE_COLOR
     * @see #COLOR_MODE_COLOR
     * @see #COLOR_MODE_MONOCHROME
     * @see #COLOR_MODE_MONOCHROME
     */
     */
    public int getColorMode() {
    public @ColorMode int getColorMode() {
        return mColorMode;
        return mColorMode;
    }
    }


@@ -199,7 +219,7 @@ public final class PrintAttributes implements Parcelable {
     * @see #DUPLEX_MODE_LONG_EDGE
     * @see #DUPLEX_MODE_LONG_EDGE
     * @see #DUPLEX_MODE_SHORT_EDGE
     * @see #DUPLEX_MODE_SHORT_EDGE
     */
     */
    public int getDuplexMode() {
    public @DuplexMode int getDuplexMode() {
        return mDuplexMode;
        return mDuplexMode;
    }
    }


@@ -828,7 +848,8 @@ public final class PrintAttributes implements Parcelable {
         * or the widthMils is less than or equal to zero or the heightMils is less
         * or the widthMils is less than or equal to zero or the heightMils is less
         * than or equal to zero.
         * than or equal to zero.
         */
         */
        public MediaSize(String id, String label, int widthMils, int heightMils) {
        public MediaSize(@NonNull String id, @NonNull String label,
                @IntRange(from = 1) int widthMils, @IntRange(from = 1) int heightMils) {
            if (TextUtils.isEmpty(id)) {
            if (TextUtils.isEmpty(id)) {
                throw new IllegalArgumentException("id cannot be empty.");
                throw new IllegalArgumentException("id cannot be empty.");
            }
            }
@@ -872,7 +893,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The unique media size id.
         * @return The unique media size id.
         */
         */
        public String getId() {
        public @NonNull String getId() {
            return mId;
            return mId;
        }
        }


@@ -882,7 +903,7 @@ public final class PrintAttributes implements Parcelable {
         * @param packageManager The package manager for loading the label.
         * @param packageManager The package manager for loading the label.
         * @return The human readable label.
         * @return The human readable label.
         */
         */
        public String getLabel(PackageManager packageManager) {
        public @NonNull String getLabel(@NonNull PackageManager packageManager) {
            if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) {
            if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) {
                try {
                try {
                    return packageManager.getResourcesForApplication(
                    return packageManager.getResourcesForApplication(
@@ -903,7 +924,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The media width.
         * @return The media width.
         */
         */
        public int getWidthMils() {
        public @IntRange(from = 1) int getWidthMils() {
            return mWidthMils;
            return mWidthMils;
        }
        }


@@ -912,7 +933,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The media height.
         * @return The media height.
         */
         */
        public int getHeightMils() {
        public @IntRange(from = 1) int getHeightMils() {
            return mHeightMils;
            return mHeightMils;
        }
        }


@@ -934,7 +955,7 @@ public final class PrintAttributes implements Parcelable {
         * @return New instance in landscape orientation if this one
         * @return New instance in landscape orientation if this one
         * is in landscape, otherwise this instance.
         * is in landscape, otherwise this instance.
         */
         */
        public MediaSize asPortrait() {
        public @NonNull MediaSize asPortrait() {
            if (isPortrait()) {
            if (isPortrait()) {
                return this;
                return this;
            }
            }
@@ -951,7 +972,7 @@ public final class PrintAttributes implements Parcelable {
         * @return New instance in landscape orientation if this one
         * @return New instance in landscape orientation if this one
         * is in portrait, otherwise this instance.
         * is in portrait, otherwise this instance.
         */
         */
        public MediaSize asLandscape() {
        public @NonNull MediaSize asLandscape() {
            if (!isPortrait()) {
            if (!isPortrait()) {
                return this;
                return this;
            }
            }
@@ -1063,7 +1084,8 @@ public final class PrintAttributes implements Parcelable {
         * or the horizontalDpi is less than or equal to zero or the verticalDpi is
         * or the horizontalDpi is less than or equal to zero or the verticalDpi is
         * less than or equal to zero.
         * less than or equal to zero.
         */
         */
        public Resolution(String id, String label, int horizontalDpi, int verticalDpi) {
        public Resolution(@NonNull String id, @NonNull String label,
                @IntRange(from = 1) int horizontalDpi, @IntRange(from = 1) int verticalDpi) {
            if (TextUtils.isEmpty(id)) {
            if (TextUtils.isEmpty(id)) {
                throw new IllegalArgumentException("id cannot be empty.");
                throw new IllegalArgumentException("id cannot be empty.");
            }
            }
@@ -1094,7 +1116,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The unique resolution id.
         * @return The unique resolution id.
         */
         */
        public String getId() {
        public @NonNull String getId() {
            return mId;
            return mId;
        }
        }


@@ -1103,7 +1125,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The human readable label.
         * @return The human readable label.
         */
         */
        public String getLabel() {
        public @NonNull String getLabel() {
            return mLabel;
            return mLabel;
        }
        }


@@ -1112,7 +1134,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The horizontal resolution.
         * @return The horizontal resolution.
         */
         */
        public int getHorizontalDpi() {
        public @IntRange(from = 1) int getHorizontalDpi() {
            return mHorizontalDpi;
            return mHorizontalDpi;
        }
        }


@@ -1121,7 +1143,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The vertical resolution.
         * @return The vertical resolution.
         */
         */
        public int getVerticalDpi() {
        public @IntRange(from = 1) int getVerticalDpi() {
            return mVerticalDpi;
            return mVerticalDpi;
        }
        }


@@ -1204,7 +1226,8 @@ public final class PrintAttributes implements Parcelable {
         * @param rightMils The right margin in mils (thousands of an inch).
         * @param rightMils The right margin in mils (thousands of an inch).
         * @param bottomMils The bottom margin in mils (thousands of an inch).
         * @param bottomMils The bottom margin in mils (thousands of an inch).
         */
         */
        public Margins(int leftMils, int topMils, int rightMils, int bottomMils) {
        public Margins(@IntRange(from = 0) int leftMils, @IntRange(from = 0) int topMils,
                @IntRange(from = 0) int rightMils, @IntRange(from = 0) int bottomMils) {
            mTopMils = topMils;
            mTopMils = topMils;
            mLeftMils = leftMils;
            mLeftMils = leftMils;
            mRightMils = rightMils;
            mRightMils = rightMils;
@@ -1216,7 +1239,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The left margin.
         * @return The left margin.
         */
         */
        public int getLeftMils() {
        public @IntRange(from = 0) int getLeftMils() {
            return mLeftMils;
            return mLeftMils;
        }
        }


@@ -1225,7 +1248,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The top margin.
         * @return The top margin.
         */
         */
        public int getTopMils() {
        public @IntRange(from = 0) int getTopMils() {
            return mTopMils;
            return mTopMils;
        }
        }


@@ -1234,7 +1257,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The right margin.
         * @return The right margin.
         */
         */
        public int getRightMils() {
        public @IntRange(from = 0) int getRightMils() {
            return mRightMils;
            return mRightMils;
        }
        }


@@ -1243,7 +1266,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The bottom margin.
         * @return The bottom margin.
         */
         */
        public int getBottomMils() {
        public @IntRange(from = 0) int getBottomMils() {
            return mBottomMils;
            return mBottomMils;
        }
        }


@@ -1368,7 +1391,7 @@ public final class PrintAttributes implements Parcelable {
         * @param mediaSize The media size.
         * @param mediaSize The media size.
         * @return This builder.
         * @return This builder.
         */
         */
        public Builder setMediaSize(MediaSize mediaSize) {
        public @NonNull Builder setMediaSize(@NonNull MediaSize mediaSize) {
            mAttributes.setMediaSize(mediaSize);
            mAttributes.setMediaSize(mediaSize);
            return this;
            return this;
        }
        }
@@ -1379,7 +1402,7 @@ public final class PrintAttributes implements Parcelable {
         * @param resolution The resolution.
         * @param resolution The resolution.
         * @return This builder.
         * @return This builder.
         */
         */
        public Builder setResolution(Resolution resolution) {
        public @NonNull Builder setResolution(@NonNull Resolution resolution) {
            mAttributes.setResolution(resolution);
            mAttributes.setResolution(resolution);
            return this;
            return this;
        }
        }
@@ -1391,7 +1414,7 @@ public final class PrintAttributes implements Parcelable {
         * @param margins The margins.
         * @param margins The margins.
         * @return This builder.
         * @return This builder.
         */
         */
        public Builder setMinMargins(Margins margins) {
        public @NonNull Builder setMinMargins(@NonNull Margins margins) {
            mAttributes.setMinMargins(margins);
            mAttributes.setMinMargins(margins);
            return this;
            return this;
        }
        }
@@ -1405,7 +1428,7 @@ public final class PrintAttributes implements Parcelable {
         * @see PrintAttributes#COLOR_MODE_MONOCHROME
         * @see PrintAttributes#COLOR_MODE_MONOCHROME
         * @see PrintAttributes#COLOR_MODE_COLOR
         * @see PrintAttributes#COLOR_MODE_COLOR
         */
         */
        public Builder setColorMode(int colorMode) {
        public @NonNull Builder setColorMode(@ColorMode int colorMode) {
            mAttributes.setColorMode(colorMode);
            mAttributes.setColorMode(colorMode);
            return this;
            return this;
        }
        }
@@ -1420,7 +1443,7 @@ public final class PrintAttributes implements Parcelable {
         * @see PrintAttributes#DUPLEX_MODE_LONG_EDGE
         * @see PrintAttributes#DUPLEX_MODE_LONG_EDGE
         * @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
         * @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
         */
         */
        public Builder setDuplexMode(int duplexMode) {
        public @NonNull Builder setDuplexMode(@DuplexMode int duplexMode) {
            mAttributes.setDuplexMode(duplexMode);
            mAttributes.setDuplexMode(duplexMode);
            return this;
            return this;
        }
        }
@@ -1430,7 +1453,7 @@ public final class PrintAttributes implements Parcelable {
         *
         *
         * @return The new instance.
         * @return The new instance.
         */
         */
        public PrintAttributes build() {
        public @NonNull PrintAttributes build() {
            return mAttributes;
            return mAttributes;
        }
        }
    }
    }
+28 −14
Original line number Original line Diff line number Diff line
@@ -16,10 +16,16 @@


package android.print;
package android.print;


import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.text.TextUtils;
import android.text.TextUtils;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
/**
 * This class encapsulates information about a document for printing
 * This class encapsulates information about a document for printing
 * purposes. This meta-data is used by the platform and print services,
 * purposes. This meta-data is used by the platform and print services,
@@ -74,6 +80,13 @@ public final class PrintDocumentInfo implements Parcelable {
     */
     */
    public static final int PAGE_COUNT_UNKNOWN = -1;
    public static final int PAGE_COUNT_UNKNOWN = -1;


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            CONTENT_TYPE_UNKNOWN, CONTENT_TYPE_DOCUMENT, CONTENT_TYPE_PHOTO
    })
    public @interface ContentType {
    }
    /**
    /**
     * Content type: unknown.
     * Content type: unknown.
     */
     */
@@ -116,9 +129,9 @@ public final class PrintDocumentInfo implements Parcelable {
    /**
    /**
     * Creates a new instance.
     * Creates a new instance.
     *
     *
     * @param Prototype from which to clone.
     * @param prototype from which to clone.
     */
     */
    private PrintDocumentInfo(PrintDocumentInfo prototype) {
    private PrintDocumentInfo(@NonNull PrintDocumentInfo prototype) {
        mName = prototype.mName;
        mName = prototype.mName;
        mPageCount = prototype.mPageCount;
        mPageCount = prototype.mPageCount;
        mContentType = prototype.mContentType;
        mContentType = prototype.mContentType;
@@ -143,7 +156,7 @@ public final class PrintDocumentInfo implements Parcelable {
     *
     *
     * @return The document name.
     * @return The document name.
     */
     */
    public String getName() {
    public @NonNull String getName() {
        return mName;
        return mName;
    }
    }


@@ -154,7 +167,7 @@ public final class PrintDocumentInfo implements Parcelable {
     *
     *
     * @see #PAGE_COUNT_UNKNOWN
     * @see #PAGE_COUNT_UNKNOWN
     */
     */
    public int getPageCount() {
    public @IntRange(from = -1) int getPageCount() {
        return mPageCount;
        return mPageCount;
    }
    }


@@ -167,7 +180,7 @@ public final class PrintDocumentInfo implements Parcelable {
     * @see #CONTENT_TYPE_DOCUMENT
     * @see #CONTENT_TYPE_DOCUMENT
     * @see #CONTENT_TYPE_PHOTO
     * @see #CONTENT_TYPE_PHOTO
     */
     */
    public int getContentType() {
    public @ContentType int getContentType() {
        return mContentType;
        return mContentType;
    }
    }


@@ -176,7 +189,7 @@ public final class PrintDocumentInfo implements Parcelable {
     *
     *
     * @return The data size.
     * @return The data size.
     */
     */
    public long getDataSize() {
    public @IntRange(from = 0) long getDataSize() {
        return mDataSize;
        return mDataSize;
    }
    }


@@ -187,7 +200,7 @@ public final class PrintDocumentInfo implements Parcelable {
     *
     *
     * @hide
     * @hide
     */
     */
    public void setDataSize(long dataSize) {
    public void setDataSize(@IntRange(from = 0) long dataSize) {
        mDataSize = dataSize;
        mDataSize = dataSize;
    }
    }


@@ -288,7 +301,7 @@ public final class PrintDocumentInfo implements Parcelable {
         * is the file name if the content it describes is saved as a PDF.
         * is the file name if the content it describes is saved as a PDF.
         * Cannot be empty. 
         * Cannot be empty. 
         */
         */
        public Builder(String name) {
        public Builder(@NonNull String name) {
            if (TextUtils.isEmpty(name)) {
            if (TextUtils.isEmpty(name)) {
                throw new IllegalArgumentException("name cannot be empty");
                throw new IllegalArgumentException("name cannot be empty");
            }
            }
@@ -302,10 +315,11 @@ public final class PrintDocumentInfo implements Parcelable {
         * <strong>Default: </strong> {@link #PAGE_COUNT_UNKNOWN}
         * <strong>Default: </strong> {@link #PAGE_COUNT_UNKNOWN}
         * </p>
         * </p>
         *
         *
         * @param pageCount The number of pages. Must be greater than
         * @param pageCount The number of pages. Must be greater than or equal to zero or
         * or equal to zero or {@link PrintDocumentInfo#PAGE_COUNT_UNKNOWN}.
         *            {@link PrintDocumentInfo#PAGE_COUNT_UNKNOWN}.
         * @return This builder.
         */
         */
        public Builder setPageCount(int pageCount) {
        public @NonNull Builder setPageCount(@IntRange(from = -1) int pageCount) {
            if (pageCount < 0 && pageCount != PAGE_COUNT_UNKNOWN) {
            if (pageCount < 0 && pageCount != PAGE_COUNT_UNKNOWN) {
                throw new IllegalArgumentException("pageCount"
                throw new IllegalArgumentException("pageCount"
                        + " must be greater than or equal to zero or"
                        + " must be greater than or equal to zero or"
@@ -322,12 +336,12 @@ public final class PrintDocumentInfo implements Parcelable {
         * </p>
         * </p>
         *
         *
         * @param type The content type.
         * @param type The content type.
         *
         * @return This builder.
         * @see #CONTENT_TYPE_UNKNOWN
         * @see #CONTENT_TYPE_UNKNOWN
         * @see #CONTENT_TYPE_DOCUMENT
         * @see #CONTENT_TYPE_DOCUMENT
         * @see #CONTENT_TYPE_PHOTO
         * @see #CONTENT_TYPE_PHOTO
         */
         */
        public Builder setContentType(int type) {
        public @NonNull Builder setContentType(@ContentType int type) {
            mPrototype.mContentType = type;
            mPrototype.mContentType = type;
            return this;
            return this;
        }
        }
@@ -337,7 +351,7 @@ public final class PrintDocumentInfo implements Parcelable {
         *
         *
         * @return The new instance.
         * @return The new instance.
         */
         */
        public PrintDocumentInfo build() {
        public @NonNull PrintDocumentInfo build() {
            // Zero pages is the same as unknown as in this case
            // Zero pages is the same as unknown as in this case
            // we will have to ask for all pages and look a the
            // we will have to ask for all pages and look a the
            // wiritten PDF file for the page count.
            // wiritten PDF file for the page count.
+5 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@


package android.print;
package android.print;


import android.annotation.NonNull;
import android.annotation.Nullable;

/**
/**
 * This class represents a print job from the perspective of an
 * This class represents a print job from the perspective of an
 * application. It contains behavior methods for performing operations
 * application. It contains behavior methods for performing operations
@@ -41,7 +44,7 @@ public final class PrintJob {
     *
     *
     * @return The id.
     * @return The id.
     */
     */
    public PrintJobId getId() {
    public @NonNull PrintJobId getId() {
        return mCachedInfo.getId();
        return mCachedInfo.getId();
    }
    }


@@ -55,7 +58,7 @@ public final class PrintJob {
     *
     *
     * @return The print job info.
     * @return The print job info.
     */
     */
    public PrintJobInfo getInfo() {
    public @Nullable PrintJobInfo getInfo() {
        if (isInImmutableState()) {
        if (isInImmutableState()) {
            return mCachedInfo;
            return mCachedInfo;
        }
        }
+3 −2
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.print;
package android.print;


import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.text.TextUtils;
import android.text.TextUtils;
@@ -91,14 +92,14 @@ public final class PrintJobId implements Parcelable {
     *
     *
     * @hide
     * @hide
     */
     */
    public String flattenToString() {
    public @NonNull String flattenToString() {
        return mValue;
        return mValue;
    }
    }


    /**
    /**
     * Unflattens a print job id from a string.
     * Unflattens a print job id from a string.
     *
     *
     * @string The string.
     * @param string The string.
     * @return The unflattened id, or null if the string is malformed.
     * @return The unflattened id, or null if the string is malformed.
     *
     *
     * @hide
     * @hide
Loading