Merge "Hiding some unneeded APIs," into klp-dev
diff --git a/api/current.txt b/api/current.txt
index d17c884..7aacb6e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19027,7 +19027,6 @@
}
public static final class PrintAttributes.MediaSize {
- ctor public PrintAttributes.MediaSize(java.lang.String, java.lang.String, int, int, int);
ctor public PrintAttributes.MediaSize(java.lang.String, java.lang.String, int, int);
method public android.print.PrintAttributes.MediaSize asLandscape();
method public android.print.PrintAttributes.MediaSize asPortrait();
@@ -19078,7 +19077,6 @@
}
public static final class PrintAttributes.Resolution {
- ctor public PrintAttributes.Resolution(java.lang.String, java.lang.String, int, int, int);
ctor public PrintAttributes.Resolution(java.lang.String, java.lang.String, int, int);
method public int getHorizontalDpi();
method public java.lang.String getId();
diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java
index f975ebd..f4cc767 100644
--- a/core/java/android/print/PrintAttributes.java
+++ b/core/java/android/print/PrintAttributes.java
@@ -412,6 +412,8 @@
* @throws IllegalArgumentException If the label is empty.
* @throws IllegalArgumentException If the widthMils is less than or equal to zero.
* @throws IllegalArgumentException If the heightMils is less than or equal to zero.
+ *
+ * @hide
*/
public MediaSize(String id, String packageName, int labelResId,
int widthMils, int heightMils) {
@@ -441,8 +443,7 @@
}
/**
- * Creates a new instance. You should use this constructor as a fallback
- * in cases when you do not have a localized string for the label.
+ * Creates a new instance.
*
* @param id The unique media size id.
* @param label The <strong>internationalized</strong> human readable label.
@@ -550,32 +551,28 @@
/**
* Returns a new media size in a portrait orientation
- * which is the height is the lesser dimension.
+ * which is the height is the greater dimension.
*
* @return New instance in landscape orientation.
*/
public MediaSize asPortrait() {
- if (!TextUtils.isEmpty(mPackageName) && mLabelResId > 0) {
- return new MediaSize(mId, mPackageName, mLabelResId,
- Math.min(mWidthMils, mHeightMils),
- Math.max(mWidthMils, mHeightMils));
- } else {
- return new MediaSize(mId, mLabel,
- Math.min(mWidthMils, mHeightMils),
- Math.max(mWidthMils, mHeightMils));
- }
+ return new MediaSize(mId, mPackageName, mLabel,
+ Math.min(mWidthMils, mHeightMils),
+ Math.max(mWidthMils, mHeightMils),
+ mLabelResId);
}
/**
* Returns a new media size in a landscape orientation
- * which is the height is the greater dimension.
+ * which is the height is the lesser dimension.
*
* @return New instance in landscape orientation.
*/
public MediaSize asLandscape() {
return new MediaSize(mId, mLabel,
Math.max(mWidthMils, mHeightMils),
- Math.min(mWidthMils, mHeightMils));
+ Math.min(mWidthMils, mHeightMils),
+ mLabelResId);
}
void writeToParcel(Parcel parcel) {
@@ -601,7 +598,6 @@
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((mId == null) ? 0 : mId.hashCode());
result = prime * result + mWidthMils;
result = prime * result + mHeightMils;
return result;
@@ -619,9 +615,6 @@
return false;
}
MediaSize other = (MediaSize) obj;
- if (!TextUtils.equals(mId, other.mId)) {
- return false;
- }
if (mWidthMils != other.mWidthMils) {
return false;
}
@@ -677,6 +670,8 @@
* @throws IllegalArgumentException If the label is empty.
* @throws IllegalArgumentException If the horizontalDpi is less than or equal to zero.
* @throws IllegalArgumentException If the verticalDpi is less than or equal to zero.
+ *
+ * @hide
*/
public Resolution(String id, String packageName, int labelResId,
int horizontalDpi, int verticalDpi) {
@@ -706,8 +701,7 @@
}
/**
- * Creates a new instance. You should use this constructor as a fallback
- * in cases when you do not have a localized string for the label.
+ * Creates a new instance.
*
* @param id The unique resolution id.
* @param label The <strong>internationalized</strong> human readable label.
@@ -825,7 +819,6 @@
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((mId == null) ? 0 : mId.hashCode());
result = prime * result + mHorizontalDpi;
result = prime * result + mVerticalDpi;
return result;
@@ -843,9 +836,6 @@
return false;
}
Resolution other = (Resolution) obj;
- if (!TextUtils.equals(mId, other.mId)) {
- return false;
- }
if (mHorizontalDpi != other.mHorizontalDpi) {
return false;
}
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java
index 00c9a68..7266af8 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java
@@ -41,6 +41,7 @@
import android.print.PrintManager;
import android.print.PrinterId;
import android.print.PrinterInfo;
+import android.text.TextUtils;
import android.util.AtomicFile;
import android.util.Log;
import android.util.Slog;
@@ -814,10 +815,9 @@
mediaSize.getWidthMils()));
serializer.attribute(null, ATTR_HEIGHT_MILS, String.valueOf(
mediaSize.getHeightMils()));
- // Store only the platform localized versions of the label
- // since the resource ids for a print service are not stable
- // across application versions.
- if ("android".equals(mediaSize.mPackageName)
+ // We prefer to store only the package name and
+ // resource id and fallback to the label.
+ if (!TextUtils.isEmpty(mediaSize.mPackageName)
&& mediaSize.mLabelResId > 0) {
serializer.attribute(null, ATTR_PACKAGE_NAME,
mediaSize.mPackageName);
@@ -838,10 +838,9 @@
resolution.getHorizontalDpi()));
serializer.attribute(null, ATTR_VERTICAL_DPI, String.valueOf(
resolution.getVerticalDpi()));
- // Store only the platform localized versions of the label
- // since the resource ids for a print service are not stable
- // across application versions.
- if ("android".equals(resolution.mPackageName)
+ // We prefer to store only the package name and
+ // resource id and fallback to the label.
+ if (!TextUtils.isEmpty(mediaSize.mPackageName)
&& resolution.mLabelResId > 0) {
serializer.attribute(null, ATTR_PACKAGE_NAME,
resolution.mPackageName);