Clean up print subsystem
- Stop using deprecated APIs
- Fix all public and some internal javadoc
- Add @Decorations to public APIs
- Some minor cleanup, e.g. don't use variables with overlapping names in same scope
- remove unnecessary properties from manifest (they are set by the build
system)
Change-Id: I0ce8849a516414763fe9de76c3a18ce17d896816
diff --git a/core/java/android/print/PageRange.java b/core/java/android/print/PageRange.java
index 8bc157a..57c7718 100644
--- a/core/java/android/print/PageRange.java
+++ b/core/java/android/print/PageRange.java
@@ -16,6 +16,8 @@
package android.print;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -42,7 +44,7 @@
* @throws IllegalArgumentException If start is less than zero or 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) {
throw new IllegalArgumentException("start cannot be less than zero.");
}
@@ -56,7 +58,7 @@
mEnd = end;
}
- private PageRange (Parcel parcel) {
+ private PageRange(@NonNull Parcel parcel) {
this(parcel.readInt(), parcel.readInt());
}
@@ -65,7 +67,7 @@
*
* @return The start page index.
*/
- public int getStart() {
+ public @IntRange(from = 0) int getStart() {
return mStart;
}
@@ -74,7 +76,7 @@
*
* @return The end page index.
*/
- public int getEnd() {
+ public @IntRange(from = 0) int getEnd() {
return mEnd;
}
diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java
index 2afbb99..8892e34 100644
--- a/core/java/android/print/PrintAttributes.java
+++ b/core/java/android/print/PrintAttributes.java
@@ -16,6 +16,10 @@
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.NameNotFoundException;
import android.content.res.Resources.NotFoundException;
@@ -27,6 +31,8 @@
import com.android.internal.R;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Map;
/**
@@ -37,6 +43,13 @@
* 10 mills (thousand of an inch) on all sides, and be black and white.
*/
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. */
public static final int COLOR_MODE_MONOCHROME = 1 << 0;
/** Color mode: Color color scheme, for example many colors are used. */
@@ -45,6 +58,13 @@
private static final int VALID_COLOR_MODES =
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. */
public static final int DUPLEX_MODE_NONE = 1 << 0;
/** Duplex mode: Pages are turned sideways along the long edge - like a book. */
@@ -66,7 +86,7 @@
/* hide constructor */
}
- private PrintAttributes(Parcel parcel) {
+ private PrintAttributes(@NonNull Parcel parcel) {
mMediaSize = (parcel.readInt() == 1) ? MediaSize.createFromParcel(parcel) : null;
mResolution = (parcel.readInt() == 1) ? Resolution.createFromParcel(parcel) : null;
mMinMargins = (parcel.readInt() == 1) ? Margins.createFromParcel(parcel) : null;
@@ -79,7 +99,7 @@
*
* @return The media size or <code>null</code> if not set.
*/
- public MediaSize getMediaSize() {
+ public @Nullable MediaSize getMediaSize() {
return mMediaSize;
}
@@ -99,7 +119,7 @@
*
* @return The resolution or <code>null</code> if not set.
*/
- public Resolution getResolution() {
+ public @Nullable Resolution getResolution() {
return mResolution;
}
@@ -127,7 +147,7 @@
*
* @return The margins or <code>null</code> if not set.
*/
- public Margins getMinMargins() {
+ public @Nullable Margins getMinMargins() {
return mMinMargins;
}
@@ -158,7 +178,7 @@
* @see #COLOR_MODE_COLOR
* @see #COLOR_MODE_MONOCHROME
*/
- public int getColorMode() {
+ public @ColorMode int getColorMode() {
return mColorMode;
}
@@ -199,7 +219,7 @@
* @see #DUPLEX_MODE_LONG_EDGE
* @see #DUPLEX_MODE_SHORT_EDGE
*/
- public int getDuplexMode() {
+ public @DuplexMode int getDuplexMode() {
return mDuplexMode;
}
@@ -828,7 +848,8 @@
* or the widthMils is less than or equal to zero or the heightMils is less
* 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)) {
throw new IllegalArgumentException("id cannot be empty.");
}
@@ -872,7 +893,7 @@
*
* @return The unique media size id.
*/
- public String getId() {
+ public @NonNull String getId() {
return mId;
}
@@ -882,7 +903,7 @@
* @param packageManager The package manager for loading the label.
* @return The human readable label.
*/
- public String getLabel(PackageManager packageManager) {
+ public @NonNull String getLabel(@NonNull PackageManager packageManager) {
if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) {
try {
return packageManager.getResourcesForApplication(
@@ -903,7 +924,7 @@
*
* @return The media width.
*/
- public int getWidthMils() {
+ public @IntRange(from = 1) int getWidthMils() {
return mWidthMils;
}
@@ -912,7 +933,7 @@
*
* @return The media height.
*/
- public int getHeightMils() {
+ public @IntRange(from = 1) int getHeightMils() {
return mHeightMils;
}
@@ -934,7 +955,7 @@
* @return New instance in landscape orientation if this one
* is in landscape, otherwise this instance.
*/
- public MediaSize asPortrait() {
+ public @NonNull MediaSize asPortrait() {
if (isPortrait()) {
return this;
}
@@ -951,7 +972,7 @@
* @return New instance in landscape orientation if this one
* is in portrait, otherwise this instance.
*/
- public MediaSize asLandscape() {
+ public @NonNull MediaSize asLandscape() {
if (!isPortrait()) {
return this;
}
@@ -1063,7 +1084,8 @@
* or the horizontalDpi is less than or equal to zero or the verticalDpi is
* 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)) {
throw new IllegalArgumentException("id cannot be empty.");
}
@@ -1094,7 +1116,7 @@
*
* @return The unique resolution id.
*/
- public String getId() {
+ public @NonNull String getId() {
return mId;
}
@@ -1103,7 +1125,7 @@
*
* @return The human readable label.
*/
- public String getLabel() {
+ public @NonNull String getLabel() {
return mLabel;
}
@@ -1112,7 +1134,7 @@
*
* @return The horizontal resolution.
*/
- public int getHorizontalDpi() {
+ public @IntRange(from = 1) int getHorizontalDpi() {
return mHorizontalDpi;
}
@@ -1121,7 +1143,7 @@
*
* @return The vertical resolution.
*/
- public int getVerticalDpi() {
+ public @IntRange(from = 1) int getVerticalDpi() {
return mVerticalDpi;
}
@@ -1204,7 +1226,8 @@
* @param rightMils The right 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;
mLeftMils = leftMils;
mRightMils = rightMils;
@@ -1216,7 +1239,7 @@
*
* @return The left margin.
*/
- public int getLeftMils() {
+ public @IntRange(from = 0) int getLeftMils() {
return mLeftMils;
}
@@ -1225,7 +1248,7 @@
*
* @return The top margin.
*/
- public int getTopMils() {
+ public @IntRange(from = 0) int getTopMils() {
return mTopMils;
}
@@ -1234,7 +1257,7 @@
*
* @return The right margin.
*/
- public int getRightMils() {
+ public @IntRange(from = 0) int getRightMils() {
return mRightMils;
}
@@ -1243,7 +1266,7 @@
*
* @return The bottom margin.
*/
- public int getBottomMils() {
+ public @IntRange(from = 0) int getBottomMils() {
return mBottomMils;
}
@@ -1368,7 +1391,7 @@
* @param mediaSize The media size.
* @return This builder.
*/
- public Builder setMediaSize(MediaSize mediaSize) {
+ public @NonNull Builder setMediaSize(@NonNull MediaSize mediaSize) {
mAttributes.setMediaSize(mediaSize);
return this;
}
@@ -1379,7 +1402,7 @@
* @param resolution The resolution.
* @return This builder.
*/
- public Builder setResolution(Resolution resolution) {
+ public @NonNull Builder setResolution(@NonNull Resolution resolution) {
mAttributes.setResolution(resolution);
return this;
}
@@ -1391,7 +1414,7 @@
* @param margins The margins.
* @return This builder.
*/
- public Builder setMinMargins(Margins margins) {
+ public @NonNull Builder setMinMargins(@NonNull Margins margins) {
mAttributes.setMinMargins(margins);
return this;
}
@@ -1405,7 +1428,7 @@
* @see PrintAttributes#COLOR_MODE_MONOCHROME
* @see PrintAttributes#COLOR_MODE_COLOR
*/
- public Builder setColorMode(int colorMode) {
+ public @NonNull Builder setColorMode(@ColorMode int colorMode) {
mAttributes.setColorMode(colorMode);
return this;
}
@@ -1420,7 +1443,7 @@
* @see PrintAttributes#DUPLEX_MODE_LONG_EDGE
* @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
*/
- public Builder setDuplexMode(int duplexMode) {
+ public @NonNull Builder setDuplexMode(@DuplexMode int duplexMode) {
mAttributes.setDuplexMode(duplexMode);
return this;
}
@@ -1430,7 +1453,7 @@
*
* @return The new instance.
*/
- public PrintAttributes build() {
+ public @NonNull PrintAttributes build() {
return mAttributes;
}
}
diff --git a/core/java/android/print/PrintDocumentInfo.java b/core/java/android/print/PrintDocumentInfo.java
index 44e6410..db3b6f4 100644
--- a/core/java/android/print/PrintDocumentInfo.java
+++ b/core/java/android/print/PrintDocumentInfo.java
@@ -16,10 +16,16 @@
package android.print;
+import android.annotation.IntDef;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* This class encapsulates information about a document for printing
* purposes. This meta-data is used by the platform and print services,
@@ -74,6 +80,13 @@
*/
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.
*/
@@ -116,9 +129,9 @@
/**
* 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;
mPageCount = prototype.mPageCount;
mContentType = prototype.mContentType;
@@ -143,7 +156,7 @@
*
* @return The document name.
*/
- public String getName() {
+ public @NonNull String getName() {
return mName;
}
@@ -154,7 +167,7 @@
*
* @see #PAGE_COUNT_UNKNOWN
*/
- public int getPageCount() {
+ public @IntRange(from = -1) int getPageCount() {
return mPageCount;
}
@@ -167,7 +180,7 @@
* @see #CONTENT_TYPE_DOCUMENT
* @see #CONTENT_TYPE_PHOTO
*/
- public int getContentType() {
+ public @ContentType int getContentType() {
return mContentType;
}
@@ -176,7 +189,7 @@
*
* @return The data size.
*/
- public long getDataSize() {
+ public @IntRange(from = 0) long getDataSize() {
return mDataSize;
}
@@ -187,7 +200,7 @@
*
* @hide
*/
- public void setDataSize(long dataSize) {
+ public void setDataSize(@IntRange(from = 0) long dataSize) {
mDataSize = dataSize;
}
@@ -288,7 +301,7 @@
* is the file name if the content it describes is saved as a PDF.
* Cannot be empty.
*/
- public Builder(String name) {
+ public Builder(@NonNull String name) {
if (TextUtils.isEmpty(name)) {
throw new IllegalArgumentException("name cannot be empty");
}
@@ -302,10 +315,11 @@
* <strong>Default: </strong> {@link #PAGE_COUNT_UNKNOWN}
* </p>
*
- * @param pageCount The number of pages. Must be greater than
- * or equal to zero or {@link PrintDocumentInfo#PAGE_COUNT_UNKNOWN}.
+ * @param pageCount The number of pages. Must be greater than or equal to zero or
+ * {@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) {
throw new IllegalArgumentException("pageCount"
+ " must be greater than or equal to zero or"
@@ -322,12 +336,12 @@
* </p>
*
* @param type The content type.
- *
+ * @return This builder.
* @see #CONTENT_TYPE_UNKNOWN
* @see #CONTENT_TYPE_DOCUMENT
* @see #CONTENT_TYPE_PHOTO
*/
- public Builder setContentType(int type) {
+ public @NonNull Builder setContentType(@ContentType int type) {
mPrototype.mContentType = type;
return this;
}
@@ -337,7 +351,7 @@
*
* @return The new instance.
*/
- public PrintDocumentInfo build() {
+ public @NonNull 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.
diff --git a/core/java/android/print/PrintJob.java b/core/java/android/print/PrintJob.java
index 0abe219..777baab 100644
--- a/core/java/android/print/PrintJob.java
+++ b/core/java/android/print/PrintJob.java
@@ -16,6 +16,9 @@
package android.print;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+
/**
* This class represents a print job from the perspective of an
* application. It contains behavior methods for performing operations
@@ -41,7 +44,7 @@
*
* @return The id.
*/
- public PrintJobId getId() {
+ public @NonNull PrintJobId getId() {
return mCachedInfo.getId();
}
@@ -55,7 +58,7 @@
*
* @return The print job info.
*/
- public PrintJobInfo getInfo() {
+ public @Nullable PrintJobInfo getInfo() {
if (isInImmutableState()) {
return mCachedInfo;
}
diff --git a/core/java/android/print/PrintJobId.java b/core/java/android/print/PrintJobId.java
index 01550e2..a2ee02b 100644
--- a/core/java/android/print/PrintJobId.java
+++ b/core/java/android/print/PrintJobId.java
@@ -16,6 +16,7 @@
package android.print;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
@@ -91,14 +92,14 @@
*
* @hide
*/
- public String flattenToString() {
+ public @NonNull String flattenToString() {
return mValue;
}
/**
* 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.
*
* @hide
diff --git a/core/java/android/print/PrintJobInfo.java b/core/java/android/print/PrintJobInfo.java
index 7148c87..21836b3 100644
--- a/core/java/android/print/PrintJobInfo.java
+++ b/core/java/android/print/PrintJobInfo.java
@@ -17,6 +17,9 @@
package android.print;
import android.annotation.FloatRange;
+import android.annotation.IntDef;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.os.Bundle;
@@ -25,6 +28,8 @@
import com.android.internal.util.Preconditions;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
/**
@@ -35,6 +40,15 @@
*/
public final class PrintJobInfo implements Parcelable {
+ /** @hide */
+ @IntDef({
+ STATE_CREATED, STATE_QUEUED, STATE_STARTED, STATE_BLOCKED, STATE_COMPLETED,
+ STATE_FAILED, STATE_CANCELED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface State {
+ }
+
/**
* Constant for matching any print job state.
*
@@ -200,7 +214,7 @@
mAdvancedOptions = other.mAdvancedOptions;
}
- private PrintJobInfo(Parcel parcel) {
+ private PrintJobInfo(@NonNull Parcel parcel) {
mId = parcel.readParcelable(null);
mLabel = parcel.readString();
mPrinterId = parcel.readParcelable(null);
@@ -230,7 +244,7 @@
*
* @return The id.
*/
- public PrintJobId getId() {
+ public @NonNull PrintJobId getId() {
return mId;
}
@@ -241,7 +255,7 @@
*
* @hide
*/
- public void setId(PrintJobId id) {
+ public void setId(@NonNull PrintJobId id) {
this.mId = id;
}
@@ -250,7 +264,7 @@
*
* @return The label.
*/
- public String getLabel() {
+ public @NonNull String getLabel() {
return mLabel;
}
@@ -261,7 +275,7 @@
*
* @hide
*/
- public void setLabel(String label) {
+ public void setLabel(@NonNull String label) {
mLabel = label;
}
@@ -270,7 +284,7 @@
*
* @return The target printer id.
*/
- public PrinterId getPrinterId() {
+ public @Nullable PrinterId getPrinterId() {
return mPrinterId;
}
@@ -281,7 +295,7 @@
*
* @hide
*/
- public void setPrinterId(PrinterId printerId) {
+ public void setPrinterId(@NonNull PrinterId printerId) {
mPrinterId = printerId;
}
@@ -292,7 +306,7 @@
*
* @hide
*/
- public String getPrinterName() {
+ public @Nullable String getPrinterName() {
return mPrinterName;
}
@@ -303,7 +317,7 @@
*
* @hide
*/
- public void setPrinterName(String printerName) {
+ public void setPrinterName(@NonNull String printerName) {
mPrinterName = printerName;
}
@@ -320,7 +334,7 @@
* @see #STATE_FAILED
* @see #STATE_CANCELED
*/
- public int getState() {
+ public @State int getState() {
return mState;
}
@@ -431,7 +445,7 @@
*
* @return The number of copies or zero if not set.
*/
- public int getCopies() {
+ public @IntRange(from = 0) int getCopies() {
return mCopies;
}
@@ -454,7 +468,7 @@
*
* @return The included pages or <code>null</code> if not set.
*/
- public PageRange[] getPages() {
+ public @Nullable PageRange[] getPages() {
return mPageRanges;
}
@@ -474,7 +488,7 @@
*
* @return The attributes.
*/
- public PrintAttributes getAttributes() {
+ public @NonNull PrintAttributes getAttributes() {
return mAttributes;
}
@@ -713,7 +727,7 @@
* @param prototype Prototype to use as a starting point.
* Can be <code>null</code>.
*/
- public Builder(PrintJobInfo prototype) {
+ public Builder(@Nullable PrintJobInfo prototype) {
mPrototype = (prototype != null)
? new PrintJobInfo(prototype)
: new PrintJobInfo();
@@ -724,7 +738,7 @@
*
* @param copies The number of copies.
*/
- public void setCopies(int copies) {
+ public void setCopies(@IntRange(from = 1) int copies) {
mPrototype.mCopies = copies;
}
@@ -733,7 +747,7 @@
*
* @param attributes The attributes.
*/
- public void setAttributes(PrintAttributes attributes) {
+ public void setAttributes(@NonNull PrintAttributes attributes) {
mPrototype.mAttributes = attributes;
}
@@ -742,7 +756,7 @@
*
* @param pages The included pages.
*/
- public void setPages(PageRange[] pages) {
+ public void setPages(@NonNull PageRange[] pages) {
mPrototype.mPageRanges = pages;
}
@@ -774,7 +788,7 @@
* @param key The option key.
* @param value The option value.
*/
- public void putAdvancedOption(String key, String value) {
+ public void putAdvancedOption(@NonNull String key, @Nullable String value) {
if (mPrototype.mAdvancedOptions == null) {
mPrototype.mAdvancedOptions = new Bundle();
}
@@ -787,7 +801,7 @@
* @param key The option key.
* @param value The option value.
*/
- public void putAdvancedOption(String key, int value) {
+ public void putAdvancedOption(@NonNull String key, int value) {
if (mPrototype.mAdvancedOptions == null) {
mPrototype.mAdvancedOptions = new Bundle();
}
@@ -799,7 +813,7 @@
*
* @return The new instance.
*/
- public PrintJobInfo build() {
+ public @NonNull PrintJobInfo build() {
return mPrototype;
}
}
diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java
index 15af90c..3eb4874 100644
--- a/core/java/android/print/PrintManager.java
+++ b/core/java/android/print/PrintManager.java
@@ -16,6 +16,8 @@
package android.print;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.Activity;
import android.app.Application.ActivityLifecycleCallbacks;
import android.content.Context;
@@ -181,6 +183,8 @@
*
* @param context The current context in which to operate.
* @param service The backing system service.
+ * @param userId The user id in which to operate.
+ * @param appId The application id in which to operate.
* @hide
*/
public PrintManager(Context context, IPrintManager service, int userId, int appId) {
@@ -291,6 +295,7 @@
/**
* Gets a print job given its id.
*
+ * @param printJobId The id of the print job.
* @return The print job list.
* @see PrintJob
* @hide
@@ -340,7 +345,7 @@
* @return The print job list.
* @see PrintJob
*/
- public List<PrintJob> getPrintJobs() {
+ public @NonNull List<PrintJob> getPrintJobs() {
if (mService == null) {
Log.w(LOG_TAG, "Feature android.software.print not available");
return Collections.emptyList();
@@ -435,8 +440,9 @@
*
* @see PrintJob
*/
- public PrintJob print(String printJobName, PrintDocumentAdapter documentAdapter,
- PrintAttributes attributes) {
+ public @NonNull PrintJob print(@NonNull String printJobName,
+ @NonNull PrintDocumentAdapter documentAdapter,
+ @Nullable PrintAttributes attributes) {
if (mService == null) {
Log.w(LOG_TAG, "Feature android.software.print not available");
return null;
diff --git a/core/java/android/print/PrinterCapabilitiesInfo.java b/core/java/android/print/PrinterCapabilitiesInfo.java
index 96f3185..d13879b 100644
--- a/core/java/android/print/PrinterCapabilitiesInfo.java
+++ b/core/java/android/print/PrinterCapabilitiesInfo.java
@@ -16,8 +16,11 @@
package android.print;
+import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
+import android.print.PrintAttributes.ColorMode;
+import android.print.PrintAttributes.DuplexMode;
import android.print.PrintAttributes.Margins;
import android.print.PrintAttributes.MediaSize;
import android.print.PrintAttributes.Resolution;
@@ -121,7 +124,7 @@
*
* @return The media sizes.
*/
- public List<MediaSize> getMediaSizes() {
+ public @NonNull List<MediaSize> getMediaSizes() {
return Collections.unmodifiableList(mMediaSizes);
}
@@ -130,7 +133,7 @@
*
* @return The resolutions.
*/
- public List<Resolution> getResolutions() {
+ public @NonNull List<Resolution> getResolutions() {
return Collections.unmodifiableList(mResolutions);
}
@@ -140,7 +143,7 @@
*
* @return The minimal margins.
*/
- public Margins getMinMargins() {
+ public @NonNull Margins getMinMargins() {
return mMinMargins;
}
@@ -152,7 +155,7 @@
* @see PrintAttributes#COLOR_MODE_COLOR
* @see PrintAttributes#COLOR_MODE_MONOCHROME
*/
- public int getColorModes() {
+ public @ColorMode int getColorModes() {
return mColorModes;
}
@@ -165,7 +168,7 @@
* @see PrintAttributes#DUPLEX_MODE_LONG_EDGE
* @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
*/
- public int getDuplexModes() {
+ public @DuplexMode int getDuplexModes() {
return mDuplexModes;
}
@@ -174,7 +177,7 @@
*
* @return The default attributes.
*/
- public PrintAttributes getDefaults() {
+ public @NonNull PrintAttributes getDefaults() {
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMinMargins(mMinMargins);
@@ -425,7 +428,7 @@
*
* @throws IllegalArgumentException If the printer id is <code>null</code>.
*/
- public Builder(PrinterId printerId) {
+ public Builder(@NonNull PrinterId printerId) {
if (printerId == null) {
throw new IllegalArgumentException("printerId cannot be null.");
}
@@ -446,7 +449,7 @@
*
* @see PrintAttributes.MediaSize
*/
- public Builder addMediaSize(MediaSize mediaSize, boolean isDefault) {
+ public @NonNull Builder addMediaSize(@NonNull MediaSize mediaSize, boolean isDefault) {
if (mPrototype.mMediaSizes == null) {
mPrototype.mMediaSizes = new ArrayList<MediaSize>();
}
@@ -474,7 +477,7 @@
*
* @see PrintAttributes.Resolution
*/
- public Builder addResolution(Resolution resolution, boolean isDefault) {
+ public @NonNull Builder addResolution(@NonNull Resolution resolution, boolean isDefault) {
if (mPrototype.mResolutions == null) {
mPrototype.mResolutions = new ArrayList<Resolution>();
}
@@ -502,7 +505,7 @@
*
* @see PrintAttributes.Margins
*/
- public Builder setMinMargins(Margins margins) {
+ public @NonNull Builder setMinMargins(@NonNull Margins margins) {
if (margins == null) {
throw new IllegalArgumentException("margins cannot be null");
}
@@ -532,7 +535,8 @@
* @see PrintAttributes#COLOR_MODE_COLOR
* @see PrintAttributes#COLOR_MODE_MONOCHROME
*/
- public Builder setColorModes(int colorModes, int defaultColorMode) {
+ public @NonNull Builder setColorModes(@ColorMode int colorModes,
+ @ColorMode int defaultColorMode) {
int currentModes = colorModes;
while (currentModes > 0) {
final int currentMode = (1 << Integer.numberOfTrailingZeros(currentModes));
@@ -562,7 +566,8 @@
* @see PrintAttributes#DUPLEX_MODE_LONG_EDGE
* @see PrintAttributes#DUPLEX_MODE_SHORT_EDGE
*/
- public Builder setDuplexModes(int duplexModes, int defaultDuplexMode) {
+ public @NonNull Builder setDuplexModes(@DuplexMode int duplexModes,
+ @DuplexMode int defaultDuplexMode) {
int currentModes = duplexModes;
while (currentModes > 0) {
final int currentMode = (1 << Integer.numberOfTrailingZeros(currentModes));
@@ -589,7 +594,7 @@
*
* @throws IllegalStateException If a required attribute was not specified.
*/
- public PrinterCapabilitiesInfo build() {
+ public @NonNull PrinterCapabilitiesInfo build() {
if (mPrototype.mMediaSizes == null || mPrototype.mMediaSizes.isEmpty()) {
throw new IllegalStateException("No media size specified.");
}
diff --git a/core/java/android/print/PrinterId.java b/core/java/android/print/PrinterId.java
index a3f3b2bf..83efe80 100644
--- a/core/java/android/print/PrinterId.java
+++ b/core/java/android/print/PrinterId.java
@@ -16,6 +16,7 @@
package android.print;
+import android.annotation.NonNull;
import android.content.ComponentName;
import android.os.Parcel;
import android.os.Parcelable;
@@ -65,7 +66,7 @@
*
* @return The printer name.
*/
- public String getLocalId() {
+ public @NonNull String getLocalId() {
return mLocalId;
}
diff --git a/core/java/android/print/PrinterInfo.java b/core/java/android/print/PrinterInfo.java
index e83c44a..3ac78ea 100644
--- a/core/java/android/print/PrinterInfo.java
+++ b/core/java/android/print/PrinterInfo.java
@@ -16,6 +16,7 @@
package android.print;
+import android.annotation.IntDef;
import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -32,6 +33,9 @@
import android.os.Parcelable;
import android.text.TextUtils;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* This class represents the description of a printer. Instances of
* this class are created by print services to report to the system
@@ -42,6 +46,13 @@
*/
public final class PrinterInfo implements Parcelable {
+ /** @hide */
+ @IntDef({
+ STATUS_IDLE, STATUS_BUSY, STATUS_UNAVAILABLE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Status {
+ }
/** Printer status: the printer is idle and ready to print. */
public static final int STATUS_IDLE = 1;
@@ -112,7 +123,7 @@
*
* @return The printer id.
*/
- public PrinterId getId() {
+ public @NonNull PrinterId getId() {
return mId;
}
@@ -169,7 +180,7 @@
*
* @return The printer name.
*/
- public String getName() {
+ public @Nullable String getName() {
return mName;
}
@@ -182,7 +193,7 @@
* @see #STATUS_IDLE
* @see #STATUS_UNAVAILABLE
*/
- public int getStatus() {
+ public @Status int getStatus() {
return mStatus;
}
@@ -191,7 +202,7 @@
*
* @return The description.
*/
- public String getDescription() {
+ public @Nullable String getDescription() {
return mDescription;
}
@@ -212,7 +223,7 @@
*
* @return The capabilities.
*/
- public PrinterCapabilitiesInfo getCapabilities() {
+ public @Nullable PrinterCapabilitiesInfo getCapabilities() {
return mCapabilities;
}
@@ -363,7 +374,7 @@
* @throws IllegalArgumentException If the printer id is null, or the
* printer name is empty or the status is not a valid one.
*/
- public Builder(PrinterId printerId, String name, int status) {
+ public Builder(@NonNull PrinterId printerId, @NonNull String name, @Status int status) {
if (printerId == null) {
throw new IllegalArgumentException("printerId cannot be null.");
}
@@ -384,7 +395,7 @@
*
* @param other Other info from which to start building.
*/
- public Builder(PrinterInfo other) {
+ public Builder(@NonNull PrinterInfo other) {
mPrototype = new PrinterInfo();
mPrototype.copyFrom(other);
}
@@ -399,7 +410,7 @@
* @see PrinterInfo#STATUS_BUSY
* @see PrinterInfo#STATUS_UNAVAILABLE
*/
- public Builder setStatus(int status) {
+ public @Nullable Builder setStatus(@Status int status) {
mPrototype.mStatus = status;
return this;
}
@@ -441,7 +452,7 @@
* @param name The name.
* @return This builder.
*/
- public Builder setName(String name) {
+ public @NonNull Builder setName(@NonNull String name) {
mPrototype.mName = name;
return this;
}
@@ -453,7 +464,7 @@
* @param description The description.
* @return This builder.
*/
- public Builder setDescription(String description) {
+ public @NonNull Builder setDescription(@NonNull String description) {
mPrototype.mDescription = description;
return this;
}
@@ -476,7 +487,7 @@
* @param capabilities The capabilities.
* @return This builder.
*/
- public Builder setCapabilities(PrinterCapabilitiesInfo capabilities) {
+ public @NonNull Builder setCapabilities(@NonNull PrinterCapabilitiesInfo capabilities) {
mPrototype.mCapabilities = capabilities;
return this;
}
@@ -486,7 +497,7 @@
*
* @return A new {@link PrinterInfo}.
*/
- public PrinterInfo build() {
+ public @NonNull PrinterInfo build() {
return mPrototype;
}
diff --git a/core/java/android/print/pdf/PrintedPdfDocument.java b/core/java/android/print/pdf/PrintedPdfDocument.java
index 2d8aafa..df7c054 100644
--- a/core/java/android/print/pdf/PrintedPdfDocument.java
+++ b/core/java/android/print/pdf/PrintedPdfDocument.java
@@ -16,26 +16,25 @@
package android.print.pdf;
+import android.annotation.IntRange;
+import android.annotation.NonNull;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.pdf.PdfDocument;
-import android.graphics.pdf.PdfDocument.Page;
-import android.graphics.pdf.PdfDocument.PageInfo;
import android.print.PrintAttributes;
import android.print.PrintAttributes.Margins;
import android.print.PrintAttributes.MediaSize;
/**
- * This class is a helper for creating a PDF file for given print
- * attributes. It is useful for implementing printing via the native
- * Android graphics APIs.
+ * This class is a helper for creating a PDF file for given print attributes. It is useful for
+ * implementing printing via the native Android graphics APIs.
* <p>
- * This class computes the page width, page height, and content rectangle
- * from the provided print attributes and these precomputed values can be
- * accessed via {@link #getPageWidth()}, {@link #getPageHeight()}, and
- * {@link #getPageContentRect()}, respectively. The {@link #startPage(int)}
- * methods creates pages whose {@link PageInfo} is initialized with the
- * precomputed values for width, height, and content rectangle.
+ * This class computes the page width, page height, and content rectangle from the provided print
+ * attributes and these precomputed values can be accessed via {@link #getPageWidth()},
+ * {@link #getPageHeight()}, and {@link #getPageContentRect()}, respectively. The
+ * {@link #startPage(int)} methods creates pages whose
+ * {@link android.graphics.pdf.PdfDocument.PageInfo PageInfo} is initialized with the precomputed
+ * values for width, height, and content rectangle.
* <p>
* A typical use of the APIs looks like this:
* </p>
@@ -81,7 +80,7 @@
* @param context Context instance for accessing resources.
* @param attributes The print attributes.
*/
- public PrintedPdfDocument(Context context, PrintAttributes attributes) {
+ public PrintedPdfDocument(@NonNull Context context, @NonNull PrintAttributes attributes) {
MediaSize mediaSize = attributes.getMediaSize();
// Compute the size of the target canvas from the attributes.
@@ -105,28 +104,28 @@
}
/**
- * Starts a new page. The page is created using width, height and content
- * rectangle computed from the print attributes passed in the constructor
- * and the given page number to create an appropriate {@link PageInfo}.
+ * Starts a new page. The page is created using width, height and content rectangle computed
+ * from the print attributes passed in the constructor and the given page number to create an
+ * appropriate {@link android.graphics.pdf.PdfDocument.PageInfo PageInfo}.
* <p>
- * After the page is created you can draw arbitrary content on the page's
- * canvas which you can get by calling {@link Page#getCanvas() Page.getCanvas()}.
+ * After the page is created you can draw arbitrary content on the page's canvas which you can
+ * get by calling {@link android.graphics.pdf.PdfDocument.Page#getCanvas() Page.getCanvas()}.
* After you are done drawing the content you should finish the page by calling
- * {@link #finishPage(Page)}. After the page is finished you should no longer
- * access the page or its canvas.
+ * {@link #finishPage(Page)}. After the page is finished you should no longer access the page or
+ * its canvas.
* </p>
* <p>
- * <strong>Note:</strong> Do not call this method after {@link #close()}.
- * Also do not call this method if the last page returned by this method
- * is not finished by calling {@link #finishPage(Page)}.
+ * <strong>Note:</strong> Do not call this method after {@link #close()}. Also do not call this
+ * method if the last page returned by this method is not finished by calling
+ * {@link #finishPage(Page)}.
* </p>
*
- * @param pageNumber The page number. Must be a positive value.
+ * @param pageNumber The page number. Must be a non negative.
* @return A blank page.
*
* @see #finishPage(Page)
*/
- public Page startPage(int pageNumber) {
+ public @NonNull Page startPage(@IntRange(from = 0) int pageNumber) {
PageInfo pageInfo = new PageInfo
.Builder(mPageWidth, mPageHeight, pageNumber)
.setContentRect(mContentRect)
@@ -139,7 +138,7 @@
*
* @return The page width in PostScript points (1/72th of an inch).
*/
- public int getPageWidth() {
+ public @IntRange(from = 0) int getPageWidth() {
return mPageWidth;
}
@@ -148,7 +147,7 @@
*
* @return The page height in PostScript points (1/72th of an inch).
*/
- public int getPageHeight() {
+ public @IntRange(from = 0) int getPageHeight() {
return mPageHeight;
}
@@ -158,7 +157,7 @@
*
* @return The content rectangle.
*/
- public Rect getPageContentRect() {
+ public @NonNull Rect getPageContentRect() {
return mContentRect;
}
}
diff --git a/core/java/android/printservice/PrintDocument.java b/core/java/android/printservice/PrintDocument.java
index e43f2a8..0121ae1 100644
--- a/core/java/android/printservice/PrintDocument.java
+++ b/core/java/android/printservice/PrintDocument.java
@@ -16,6 +16,8 @@
package android.printservice;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.print.PrintDocumentInfo;
@@ -54,7 +56,7 @@
*
* @return The document info.
*/
- public PrintDocumentInfo getInfo() {
+ public @NonNull PrintDocumentInfo getInfo() {
PrintService.throwIfNotCalledOnMainThread();
return mInfo;
}
@@ -69,7 +71,7 @@
*
* @return A file descriptor for reading the data.
*/
- public ParcelFileDescriptor getData() {
+ public @Nullable ParcelFileDescriptor getData() {
PrintService.throwIfNotCalledOnMainThread();
ParcelFileDescriptor source = null;
ParcelFileDescriptor sink = null;
diff --git a/core/java/android/printservice/PrintJob.java b/core/java/android/printservice/PrintJob.java
index 86fc292..6414b6a 100644
--- a/core/java/android/printservice/PrintJob.java
+++ b/core/java/android/printservice/PrintJob.java
@@ -344,7 +344,7 @@
* @return True if the tag was set, false otherwise.
*/
@MainThread
- public boolean setTag(String tag) {
+ public boolean setTag(@NonNull String tag) {
PrintService.throwIfNotCalledOnMainThread();
if (isInImmutableState()) {
return false;
@@ -364,7 +364,8 @@
*
* @see #setTag(String)
*/
- public String getTag() {
+ @MainThread
+ public @Nullable String getTag() {
PrintService.throwIfNotCalledOnMainThread();
return getInfo().getTag();
}
diff --git a/core/java/android/printservice/PrintService.java b/core/java/android/printservice/PrintService.java
index acebd9d..d0037b7 100644
--- a/core/java/android/printservice/PrintService.java
+++ b/core/java/android/printservice/PrintService.java
@@ -16,6 +16,7 @@
package android.printservice;
+import android.annotation.Nullable;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
@@ -191,30 +192,29 @@
/**
* If you declared an optional activity with advanced print options via the
- * {@link android.R.attr#advancedPrintOptionsActivity advancedPrintOptionsActivity}
- * attribute, this extra is used to pass in the currently constructed {@link
- * PrintJobInfo} to your activity allowing you to modify it. After you are
- * done, you must return the modified {@link PrintJobInfo} via the same extra.
+ * {@link android.R.attr#advancedPrintOptionsActivity advancedPrintOptionsActivity} attribute,
+ * this extra is used to pass in the currently constructed {@link PrintJobInfo} to your activity
+ * allowing you to modify it. After you are done, you must return the modified
+ * {@link PrintJobInfo} via the same extra.
* <p>
- * You cannot modify the passed in {@link PrintJobInfo} directly, rather you
- * should build another one using the {@link PrintJobInfo.Builder} class. You
- * can specify any standard properties and add advanced, printer specific,
- * ones via {@link PrintJobInfo.Builder#putAdvancedOption(String, String)
- * PrintJobInfo.Builder.putAdvancedOption(String, String)} and {@link
- * PrintJobInfo.Builder#putAdvancedOption(String, int)
- * PrintJobInfo.Builder.putAdvancedOption(String, int)}. The advanced options
- * are not interpreted by the system, they will not be visible to applications,
- * and can only be accessed by your print service via {@link
- * PrintJob#getAdvancedStringOption(String) PrintJob.getAdvancedStringOption(String)}
- * and {@link PrintJob#getAdvancedIntOption(String) PrintJob.getAdvancedIntOption(String)}.
+ * You cannot modify the passed in {@link PrintJobInfo} directly, rather you should build
+ * another one using the {@link android.print.PrintJobInfo.Builder PrintJobInfo.Builder} class.
+ * You can specify any standard properties and add advanced, printer specific, ones via
+ * {@link android.print.PrintJobInfo.Builder#putAdvancedOption(String, String)
+ * PrintJobInfo.Builder.putAdvancedOption(String, String)} and
+ * {@link android.print.PrintJobInfo.Builder#putAdvancedOption(String, int)
+ * PrintJobInfo.Builder.putAdvancedOption(String, int)}. The advanced options are not
+ * interpreted by the system, they will not be visible to applications, and can only be accessed
+ * by your print service via {@link PrintJob#getAdvancedStringOption(String)
+ * PrintJob.getAdvancedStringOption(String)} and {@link PrintJob#getAdvancedIntOption(String)
+ * PrintJob.getAdvancedIntOption(String)}.
* </p>
* <p>
- * If the advanced print options activity offers changes to the standard print
- * options, you can get the current {@link android.print.PrinterInfo} using the
- * {@link #EXTRA_PRINTER_INFO} extra which will allow you to present the user
- * with UI options supported by the current printer. For example, if the current
- * printer does not support a given media size, you should not offer it in the
- * advanced print options UI.
+ * If the advanced print options activity offers changes to the standard print options, you can
+ * get the current {@link android.print.PrinterInfo PrinterInfo} using the
+ * {@link #EXTRA_PRINTER_INFO} extra which will allow you to present the user with UI options
+ * supported by the current printer. For example, if the current printer does not support a
+ * given media size, you should not offer it in the advanced print options UI.
* </p>
*
* @see #EXTRA_PRINTER_INFO
@@ -275,9 +275,10 @@
/**
* Callback asking you to create a new {@link PrinterDiscoverySession}.
*
+ * @return The created session.
* @see PrinterDiscoverySession
*/
- protected abstract PrinterDiscoverySession onCreatePrinterDiscoverySession();
+ protected abstract @Nullable PrinterDiscoverySession onCreatePrinterDiscoverySession();
/**
* Called when cancellation of a print job is requested. The service
@@ -368,6 +369,7 @@
mHandler.sendEmptyMessage(ServiceHandler.MSG_DESTROY_PRINTER_DISCOVERY_SESSION);
}
+ @Override
public void startPrinterDiscovery(List<PrinterId> priorityList) {
mHandler.obtainMessage(ServiceHandler.MSG_START_PRINTER_DISCOVERY,
priorityList).sendToTarget();
diff --git a/core/java/android/printservice/PrintServiceInfo.java b/core/java/android/printservice/PrintServiceInfo.java
index a2c6c09..b33ef83 100644
--- a/core/java/android/printservice/PrintServiceInfo.java
+++ b/core/java/android/printservice/PrintServiceInfo.java
@@ -98,8 +98,7 @@
*
* @param resolveInfo The service resolve info.
* @param context Context for accessing resources.
- * @throws XmlPullParserException If a XML parsing error occurs.
- * @throws IOException If a I/O error occurs.
+ * @return The created instance.
*/
public static PrintServiceInfo create(ResolveInfo resolveInfo, Context context) {
String settingsActivityName = null;
@@ -220,10 +219,12 @@
/**
* {@inheritDoc}
*/
+ @Override
public int describeContents() {
return 0;
}
+ @Override
public void writeToParcel(Parcel parcel, int flagz) {
parcel.writeString(mId);
parcel.writeParcelable(mResolveInfo, 0);
@@ -275,10 +276,12 @@
public static final Parcelable.Creator<PrintServiceInfo> CREATOR =
new Parcelable.Creator<PrintServiceInfo>() {
+ @Override
public PrintServiceInfo createFromParcel(Parcel parcel) {
return new PrintServiceInfo(parcel);
}
+ @Override
public PrintServiceInfo[] newArray(int size) {
return new PrintServiceInfo[size];
}
diff --git a/core/java/android/printservice/PrinterDiscoverySession.java b/core/java/android/printservice/PrinterDiscoverySession.java
index 739cd13..cd5a903 100644
--- a/core/java/android/printservice/PrinterDiscoverySession.java
+++ b/core/java/android/printservice/PrinterDiscoverySession.java
@@ -139,7 +139,7 @@
* @see #removePrinters(List)
* @see #isDestroyed()
*/
- public final List<PrinterInfo> getPrinters() {
+ public final @NonNull List<PrinterInfo> getPrinters() {
PrintService.throwIfNotCalledOnMainThread();
if (mIsDestroyed) {
return Collections.emptyList();
@@ -162,7 +162,7 @@
* @see #getPrinters()
* @see #isDestroyed()
*/
- public final void addPrinters(List<PrinterInfo> printers) {
+ public final void addPrinters(@NonNull List<PrinterInfo> printers) {
PrintService.throwIfNotCalledOnMainThread();
// If the session is destroyed - nothing do to.
@@ -226,7 +226,7 @@
* @see #getPrinters()
* @see #isDestroyed()
*/
- public final void removePrinters(List<PrinterId> printerIds) {
+ public final void removePrinters(@NonNull List<PrinterId> printerIds) {
PrintService.throwIfNotCalledOnMainThread();
// If the session is destroyed - nothing do to.
@@ -351,7 +351,7 @@
* @see #removePrinters(List)
* @see #isPrinterDiscoveryStarted()
*/
- public abstract void onStartPrinterDiscovery(List<PrinterId> priorityList);
+ public abstract void onStartPrinterDiscovery(@NonNull List<PrinterId> priorityList);
/**
* Callback notifying you that you should stop printer discovery.
@@ -373,10 +373,10 @@
*
* @param printerIds The printers to validate.
*
- * @see PrinterInfo.Builder#setCapabilities(PrinterCapabilitiesInfo)
+ * @see android.print.PrinterInfo.Builder#setCapabilities(PrinterCapabilitiesInfo)
* PrinterInfo.Builder.setCapabilities(PrinterCapabilitiesInfo)
*/
- public abstract void onValidatePrinters(List<PrinterId> printerIds);
+ public abstract void onValidatePrinters(@NonNull List<PrinterId> printerIds);
/**
* Callback asking you to start tracking the state of a printer. Tracking
@@ -401,10 +401,10 @@
* @param printerId The printer to start tracking.
*
* @see #onStopPrinterStateTracking(PrinterId)
- * @see PrinterInfo.Builder#setCapabilities(PrinterCapabilitiesInfo)
+ * @see android.print.PrinterInfo.Builder#setCapabilities(PrinterCapabilitiesInfo)
* PrinterInfo.Builder.setCapabilities(PrinterCapabilitiesInfo)
*/
- public abstract void onStartPrinterStateTracking(PrinterId printerId);
+ public abstract void onStartPrinterStateTracking(@NonNull PrinterId printerId);
/**
* Request the custom icon for a printer. Once the icon is available use
@@ -429,7 +429,7 @@
*
* @see #onStartPrinterStateTracking(PrinterId)
*/
- public abstract void onStopPrinterStateTracking(PrinterId printerId);
+ public abstract void onStopPrinterStateTracking(@NonNull PrinterId printerId);
/**
* Gets the printers that should be tracked. These are printers that are
@@ -449,7 +449,7 @@
* @see #onStopPrinterStateTracking(PrinterId)
* @see #isDestroyed()
*/
- public final List<PrinterId> getTrackedPrinters() {
+ public final @NonNull List<PrinterId> getTrackedPrinters() {
PrintService.throwIfNotCalledOnMainThread();
if (mIsDestroyed) {
return Collections.emptyList();
@@ -491,7 +491,7 @@
return mIsDiscoveryStarted;
}
- void startPrinterDiscovery(List<PrinterId> priorityList) {
+ void startPrinterDiscovery(@NonNull List<PrinterId> priorityList) {
if (!mIsDestroyed) {
mIsDiscoveryStarted = true;
sendOutOfDiscoveryPeriodPrinterChanges();
@@ -509,13 +509,13 @@
}
}
- void validatePrinters(List<PrinterId> printerIds) {
+ void validatePrinters(@NonNull List<PrinterId> printerIds) {
if (!mIsDestroyed && mObserver != null) {
onValidatePrinters(printerIds);
}
}
- void startPrinterStateTracking(PrinterId printerId) {
+ void startPrinterStateTracking(@NonNull PrinterId printerId) {
if (!mIsDestroyed && mObserver != null
&& !mTrackedPrinters.contains(printerId)) {
mTrackedPrinters.add(printerId);
@@ -529,7 +529,7 @@
* @param printerId The printer to icon belongs to.
* @see android.print.PrinterInfo.Builder#setHasCustomPrinterIcon()
*/
- void requestCustomPrinterIcon(PrinterId printerId) {
+ void requestCustomPrinterIcon(@NonNull PrinterId printerId) {
if (!mIsDestroyed && mObserver != null) {
CustomPrinterIconCallback callback = new CustomPrinterIconCallback(printerId,
mObserver);
@@ -537,7 +537,7 @@
}
}
- void stopPrinterStateTracking(PrinterId printerId) {
+ void stopPrinterStateTracking(@NonNull PrinterId printerId) {
if (!mIsDestroyed && mObserver != null
&& mTrackedPrinters.remove(printerId)) {
onStopPrinterStateTracking(printerId);