summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2013-07-22 12:32:03 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2013-07-22 13:07:09 -0700
commit88d199130d44c6bacb383a7757e782cf97483c68 (patch)
tree454e94ec561afdb80a9ed209e12540c70e5df8eb /core
parent597945fd3a6b52ac70bb9afc5ec8c59039fffd77 (diff)
downloadframeworks_base-88d199130d44c6bacb383a7757e782cf97483c68.zip
frameworks_base-88d199130d44c6bacb383a7757e782cf97483c68.tar.gz
frameworks_base-88d199130d44c6bacb383a7757e782cf97483c68.tar.bz2
Implement persistence/restoring of print spooler state.
1. Implemented the persistence and restoring of the print spooler state. The print spooler state is saved as an XML on every print job change and is restored when we bind to the spooler. The system does not unbind from the spooler until the state persistence completes. We are now storing the entire state, i.e. all print jobs, when a single one changes. This is not optimal but we are not expecting to have many such at the same time, so for now we err for simplicity of implementation. 2. Enforcing a non-empty print job name. 3. Hidden the STATE_CREATED print job state which should never be visible to a client since this is the state of a print job during construction, i.e. the print dialog is up and we are doing back and forth with the app. 4. Fixed some PrintAttributes APIs that were incorrectly taking in a PackageManager instance. 5. Updated the PrintSpooler build file due to splitting the framework into multiple jars. Change-Id: I52c88eaa1ec9c64920359cc143c79832a4c3d25b
Diffstat (limited to 'core')
-rw-r--r--core/java/android/print/PageRange.java4
-rw-r--r--core/java/android/print/PrintAttributes.java4
-rw-r--r--core/java/android/print/PrintDocumentInfo.java10
-rw-r--r--core/java/android/print/PrintJobInfo.java12
-rw-r--r--core/java/android/print/PrintManager.java4
-rw-r--r--core/java/android/print/PrinterId.java20
6 files changed, 31 insertions, 23 deletions
diff --git a/core/java/android/print/PageRange.java b/core/java/android/print/PageRange.java
index 60e6229..9257a04 100644
--- a/core/java/android/print/PageRange.java
+++ b/core/java/android/print/PageRange.java
@@ -42,8 +42,10 @@ public final class PageRange implements Parcelable {
* @throws IllegalArgumentException If start is less than zero.
* @throws IllegalArgumentException If end is less than zero.
* @throws IllegalArgumentException If start greater than end.
+ *
+ * @hide
*/
- PageRange(int start, int end) {
+ public PageRange(int start, int end) {
if (start < 0) {
throw new IllegalArgumentException("start cannot be less than zero.");
}
diff --git a/core/java/android/print/PrintAttributes.java b/core/java/android/print/PrintAttributes.java
index 2a27a32..65f1330 100644
--- a/core/java/android/print/PrintAttributes.java
+++ b/core/java/android/print/PrintAttributes.java
@@ -1007,7 +1007,7 @@ public final class PrintAttributes implements Parcelable {
*
* @return The human readable label.
*/
- public CharSequence getLabel(PackageManager packageManager) {
+ public CharSequence getLabel() {
return mLabel;
}
@@ -1203,7 +1203,7 @@ public final class PrintAttributes implements Parcelable {
*
* @return The human readable label.
*/
- public CharSequence getLabel(PackageManager packageManager) {
+ public CharSequence getLabel() {
return mLabel;
}
diff --git a/core/java/android/print/PrintDocumentInfo.java b/core/java/android/print/PrintDocumentInfo.java
index 7731deb..7d42b3a 100644
--- a/core/java/android/print/PrintDocumentInfo.java
+++ b/core/java/android/print/PrintDocumentInfo.java
@@ -110,6 +110,16 @@ public final class PrintDocumentInfo implements Parcelable {
parcel.writeInt(mContentType);
}
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("PrintDocumentInfo{");
+ builder.append("pageCount: ").append(mPageCount);
+ builder.append(", contentType: ").append(mContentType);
+ builder.append("}");
+ return builder.toString();
+ }
+
/**
* Builder for creating an {@link PrintDocumentInfo}.
*/
diff --git a/core/java/android/print/PrintJobInfo.java b/core/java/android/print/PrintJobInfo.java
index 6e613bc..97384d9 100644
--- a/core/java/android/print/PrintJobInfo.java
+++ b/core/java/android/print/PrintJobInfo.java
@@ -35,11 +35,20 @@ public final class PrintJobInfo implements Parcelable {
public static final int STATE_ANY = -1;
/**
+ * Constant for matching any print job state.
+ *
+ * @hide
+ */
+ public static final int STATE_ANY_VISIBLE_TO_CLIENTS = -2;
+
+ /**
* Print job state: The print job is being created but not yet
* ready to be printed.
* <p>
* Next valid states: {@link #STATE_QUEUED}
* </p>
+ *
+ * @hide
*/
public static final int STATE_CREATED = 1;
@@ -132,6 +141,7 @@ public final class PrintJobInfo implements Parcelable {
mState = other.mState;
mAppId = other.mAppId;
mUserId = other.mUserId;
+ mTag = other.mTag;
mAttributes = other.mAttributes;
mDocumentInfo = other.mDocumentInfo;
}
@@ -143,6 +153,7 @@ public final class PrintJobInfo implements Parcelable {
mState = parcel.readInt();
mAppId = parcel.readInt();
mUserId = parcel.readInt();
+ mTag = parcel.readString();
if (parcel.readInt() == 1) {
mPageRanges = (PageRange[]) parcel.readParcelableArray(null);
}
@@ -373,6 +384,7 @@ public final class PrintJobInfo implements Parcelable {
parcel.writeInt(mState);
parcel.writeInt(mAppId);
parcel.writeInt(mUserId);
+ parcel.writeString(mTag);
if (mPageRanges != null) {
parcel.writeInt(1);
parcel.writeParcelableArray(mPageRanges, flags);
diff --git a/core/java/android/print/PrintManager.java b/core/java/android/print/PrintManager.java
index 58f45fa..f9f53f6 100644
--- a/core/java/android/print/PrintManager.java
+++ b/core/java/android/print/PrintManager.java
@@ -29,6 +29,7 @@ import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.print.PrintDocumentAdapter.LayoutResultCallback;
import android.print.PrintDocumentAdapter.WriteResultCallback;
+import android.text.TextUtils;
import android.util.Log;
import com.android.internal.os.SomeArgs;
@@ -184,6 +185,9 @@ public final class PrintManager {
*/
public PrintJob print(String printJobName, PrintDocumentAdapter documentAdapter,
PrintAttributes attributes) {
+ if (TextUtils.isEmpty(printJobName)) {
+ throw new IllegalArgumentException("priintJobName cannot be empty");
+ }
PrintDocumentAdapterDelegate delegate = new PrintDocumentAdapterDelegate(documentAdapter,
mContext.getMainLooper());
try {
diff --git a/core/java/android/print/PrinterId.java b/core/java/android/print/PrinterId.java
index 8a3148c..e884026 100644
--- a/core/java/android/print/PrinterId.java
+++ b/core/java/android/print/PrinterId.java
@@ -125,26 +125,6 @@ public final class PrinterId implements Parcelable {
return builder.toString();
}
- /**
- * @hide
- */
- public String flattenToString() {
- return mServiceComponentName.flattenToString() + ":" + mLocalId;
- }
-
- /**
- * @hide
- */
- public static PrinterId unflattenFromString(String string) {
- String[] split = string.split(":");
- if (split.length != 2) {
- throw new IllegalArgumentException("Not well-formed printer id:" + string);
- }
- ComponentName component = ComponentName.unflattenFromString(split[0]);
- String localId = String.valueOf(split[1]);
- return new PrinterId(component, localId);
- }
-
public static final Parcelable.Creator<PrinterId> CREATOR =
new Creator<PrinterId>() {
@Override