Tweak the print APIs.

1. Adding bundle with metadata to PrintDocumentAdapter#onLayout
   with one key for now to specify whether this is for a preview.

2. Cleaned up docs.

Change-Id: I89380781bf3ae41aa89f8a0347d74516a210394c
diff --git a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
index 659102c..c0faed8 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/PrintJobConfigActivity.java
@@ -536,6 +536,7 @@
         // TODO: Implement old attributes tracking
         mPrintSpooler.setPrintJobAttributes(mPrintJobId, mPrintAttributes);
 
+        // TODO: Implement setting the print preview attribute
         mRemotePrintAdapter.layout(new PrintAttributes.Builder().create(),
                 mPrintAttributes, new LayoutResultCallback() {
             @Override
@@ -566,7 +567,7 @@
                 Log.e(LOG_TAG, "Error during layout: " + error);
                 finishActivity(Activity.RESULT_CANCELED);
             }
-        });
+        }, new Bundle());
     }
 
     private void notifyPrintableFinishIfNeeded() {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/RemotePrintDocumentAdapter.java b/packages/PrintSpooler/src/com/android/printspooler/RemotePrintDocumentAdapter.java
index 912dd95..7186932 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/RemotePrintDocumentAdapter.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/RemotePrintDocumentAdapter.java
@@ -17,6 +17,7 @@
 package com.android.printspooler;
 
 import android.os.AsyncTask;
+import android.os.Bundle;
 import android.os.ICancellationSignal;
 import android.os.ParcelFileDescriptor;
 import android.os.RemoteException;
@@ -31,8 +32,6 @@
 import android.util.Log;
 import android.util.Slog;
 
-import libcore.io.IoUtils;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -42,6 +41,8 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import libcore.io.IoUtils;
+
 /**
  * This class represents a remote print document adapter instance.
  */
@@ -122,8 +123,9 @@
     }
 
     public void layout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
-            LayoutResultCallback callback) {
-        LayoutAsyncTask task = new LayoutAsyncTask(oldAttributes, newAttributes, callback);
+            LayoutResultCallback callback, Bundle metadata) {
+        LayoutAsyncTask task = new LayoutAsyncTask(oldAttributes, newAttributes, callback,
+                metadata);
         synchronized (mLock) {
             mTaskQueue.add(task);
             task.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, (Void[]) null);
@@ -181,6 +183,8 @@
 
         private final LayoutResultCallback mCallback;
 
+        private final Bundle mMetadata;
+
         private final ILayoutResultCallback mILayoutResultCallback =
                 new ILayoutResultCallback.Stub() {
             @Override
@@ -219,11 +223,12 @@
 
         private boolean mCompleted;
 
-        public LayoutAsyncTask(PrintAttributes oldAttributes,
-                PrintAttributes newAttributes, LayoutResultCallback callback) {
+        public LayoutAsyncTask(PrintAttributes oldAttributes, PrintAttributes newAttributes,
+                LayoutResultCallback callback, Bundle metadata) {
             mOldAttributes = oldAttributes;
             mNewAttributes = newAttributes;
             mCallback = callback;
+            mMetadata = metadata;
         }
 
         @Override
@@ -246,7 +251,7 @@
             }
             try {
                 mRemoteInterface.layout(mOldAttributes, mNewAttributes,
-                        mILayoutResultCallback);
+                        mILayoutResultCallback, mMetadata);
                 synchronized (mLock) {
                     while (true) {
                         if (isCancelled()) {