From 54adee86af495311fc9ef62d65e035605043413f Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Fri, 11 Oct 2013 11:28:30 -0700 Subject: [PATCH] Print spooler not starting. 1. In my previous change I fixed a typo in the Java constant with intent action to launch the print dialog but failed to updated the print spooler manifest. 2. Removed dead code - the user id is no longer needed since the spooler is an app that runs per user. Every user has its spooler. This code was not referenced from anywhere. 3. Added a default icon to the print spooler. 4. Fixed a bug where if the print history is empty the UI goes to the all pritners activity. bug:11059554 Change-Id: If74c23b418a8c67620ba14435ee7f3b2c4527099 --- core/java/android/print/PrintJobInfo.java | 28 ------------------- packages/PrintSpooler/AndroidManifest.xml | 5 ++-- .../printspooler/PrintJobConfigActivity.java | 17 +++++------ .../printspooler/PrintSpoolerService.java | 4 --- 4 files changed, 10 insertions(+), 44 deletions(-) diff --git a/core/java/android/print/PrintJobInfo.java b/core/java/android/print/PrintJobInfo.java index 92bda4042c92e..4693556492e5d 100644 --- a/core/java/android/print/PrintJobInfo.java +++ b/core/java/android/print/PrintJobInfo.java @@ -129,9 +129,6 @@ public final class PrintJobInfo implements Parcelable { /** The id of the app that created the job. */ private int mAppId; - /** The id of the user that created the job. */ - private int mUserId; - /** Optional tag assigned by a print service.*/ private String mTag; @@ -169,7 +166,6 @@ public final class PrintJobInfo implements Parcelable { mPrinterName = other.mPrinterName; mState = other.mState; mAppId = other.mAppId; - mUserId = other.mUserId; mTag = other.mTag; mCreationTime = other.mCreationTime; mCopies = other.mCopies; @@ -187,7 +183,6 @@ public final class PrintJobInfo implements Parcelable { mPrinterName = parcel.readString(); mState = parcel.readInt(); mAppId = parcel.readInt(); - mUserId = parcel.readInt(); mTag = parcel.readString(); mCreationTime = parcel.readLong(); mCopies = parcel.readInt(); @@ -332,28 +327,6 @@ public final class PrintJobInfo implements Parcelable { mAppId = appId; } - /** - * Gets the owning user id. - * - * @return The user id. - * - * @hide - */ - public int getUserId() { - return mUserId; - } - - /** - * Sets the owning user id. - * - * @param userId The user id. - * - * @hide - */ - public void setUserId(int userId) { - mUserId = userId; - } - /** * Gets the optional tag assigned by a print service. * @@ -543,7 +516,6 @@ public final class PrintJobInfo implements Parcelable { parcel.writeString(mPrinterName); parcel.writeInt(mState); parcel.writeInt(mAppId); - parcel.writeInt(mUserId); parcel.writeString(mTag); parcel.writeLong(mCreationTime); parcel.writeInt(mCopies); diff --git a/packages/PrintSpooler/AndroidManifest.xml b/packages/PrintSpooler/AndroidManifest.xml index 48564911da264..e1d0aece109a5 100644 --- a/packages/PrintSpooler/AndroidManifest.xml +++ b/packages/PrintSpooler/AndroidManifest.xml @@ -45,7 +45,8 @@ android:allowClearUserData="true" android:label="@string/app_label" android:allowBackup= "false" - android:supportsRtl="true"> + android:supportsRtl="true" + android:icon="@*android:drawable/ic_print"> - + diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java index 3ba7369e11b84..a8c4f078c9d50 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java @@ -89,8 +89,6 @@ import com.android.printspooler.MediaSizeUtils.MediaSizeComparator; import libcore.io.IoUtils; -import libcore.io.IoUtils; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -2189,9 +2187,10 @@ public class PrintJobConfigActivity extends Activity { @Override public int getCount() { - final int additionalItemCount = (mFakePdfPrinter != null) ? 2 : 1; - return Math.min(mPrinters.size() + additionalItemCount, - DEST_ADAPTER_MAX_ITEM_COUNT); + if (mFakePdfPrinter == null) { + return 0; + } + return Math.min(mPrinters.size() + 2, DEST_ADAPTER_MAX_ITEM_COUNT); } @Override @@ -2227,14 +2226,12 @@ public class PrintJobConfigActivity extends Activity { @Override public long getItemId(int position) { if (mPrinters.isEmpty()) { - if (position == 0) { - if (mFakePdfPrinter != null) { + if (mFakePdfPrinter != null) { + if (position == 0) { return DEST_ADAPTER_ITEM_ID_SAVE_AS_PDF; - } else { + } else if (position == 1) { return DEST_ADAPTER_ITEM_ID_ALL_PRINTERS; } - } else if (position == 1) { - return DEST_ADAPTER_ITEM_ID_ALL_PRINTERS; } } else { if (position == 1 && mFakePdfPrinter != null) { diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java index 98d00a92d7561..a4d557f92e661 100644 --- a/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java +++ b/packages/PrintSpooler/src/com/android/printspooler/PrintSpoolerService.java @@ -689,7 +689,6 @@ public final class PrintSpoolerService extends Service { private static final String ATTR_PACKAGE_NAME = "packageName"; private static final String ATTR_STATE = "state"; private static final String ATTR_APP_ID = "appId"; - private static final String ATTR_USER_ID = "userId"; private static final String ATTR_TAG = "tag"; private static final String ATTR_CREATION_TIME = "creationTime"; private static final String ATTR_COPIES = "copies"; @@ -778,7 +777,6 @@ public final class PrintSpoolerService extends Service { serializer.attribute(null, ATTR_LABEL, printJob.getLabel().toString()); serializer.attribute(null, ATTR_STATE, String.valueOf(printJob.getState())); serializer.attribute(null, ATTR_APP_ID, String.valueOf(printJob.getAppId())); - serializer.attribute(null, ATTR_USER_ID, String.valueOf(printJob.getUserId())); String tag = printJob.getTag(); if (tag != null) { serializer.attribute(null, ATTR_TAG, tag); @@ -976,8 +974,6 @@ public final class PrintSpoolerService extends Service { printJob.setState(state); final int appId = Integer.parseInt(parser.getAttributeValue(null, ATTR_APP_ID)); printJob.setAppId(appId); - final int userId = Integer.parseInt(parser.getAttributeValue(null, ATTR_USER_ID)); - printJob.setUserId(userId); String tag = parser.getAttributeValue(null, ATTR_TAG); printJob.setTag(tag); String creationTime = parser.getAttributeValue(null, ATTR_CREATION_TIME);