Merge "Added the callback signal." into klp-dev
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 03bde70..1b57d50 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -28,6 +28,7 @@
import android.net.http.SslCertificate;
import android.os.Build;
import android.os.Bundle;
+import android.os.CancellationSignal;
import android.os.Looper;
import android.os.Message;
import android.os.StrictMode;
@@ -1043,24 +1044,26 @@
* @param width The page width. Should be larger than 0.
* @param height The page height. Should be larger than 0.
* @param resultCallback A callback to be invoked when the PDF content is exported.
- * A true indicates success, and a false failure.
+ * A true indicates success, and a false failure. Cannot be null.
+ * @param cancellationSignal Signal for cancelling the PDF conversion request. Must not
+ * be null.
*
- * TODO: explain method parameters, margins, consider making the callback
- * return more meaningful information, explain any threading concerns, HW
- * draw limitations, and make it public.
- * TODO: at the moment we are asking app to provide paper size information (width
- * and height). This is likely not ideal (I think need margin info too).
- * Another approach would be using PrintAttributes. This is to be clarified later.
+ * The PDF conversion is done asynchronously and the PDF output is written to the provided
+ * outputstream. The caller should not close the outputstream until the resultCallback is
+ * called, indicating PDF conversion is complete. Webview cannot be drawn during the pdf
+ * export so the application is recommended to take it offscreen, or putting in a layer
+ * with an overlaid progress UI / spinner.
*
- * TODO: explain this webview will not draw during export (onDraw will clear to
- * background color) so recommend taking it offscreen, or putting in a layer with an
- * overlaid progress UI / spinner.
+ * If the caller cancels the task using the cancellationSignal, the cancellation will be
+ * acked using the resultCallback signal.
+ *
+ * TODO(sgurun) margins, explain the units, make it public.
* @hide
*/
public void exportToPdf(OutputStream out, int width, int height,
- ValueCallback<Boolean> resultCallback) {
+ ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal) {
checkThread();
- mProvider.exportToPdf(out, width, height, resultCallback);
+ mProvider.exportToPdf(out, width, height, resultCallback, cancellationSignal);
}
/**
diff --git a/core/java/android/webkit/WebViewClassic.java b/core/java/android/webkit/WebViewClassic.java
index 228de5b..db98d30 100644
--- a/core/java/android/webkit/WebViewClassic.java
+++ b/core/java/android/webkit/WebViewClassic.java
@@ -57,6 +57,7 @@
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -2896,7 +2897,7 @@
*/
@Override
public void exportToPdf(java.io.OutputStream out, int width, int height,
- ValueCallback<Boolean> resultCallback) {
+ ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal) {
// K-only API not implemented in WebViewClassic.
throw new IllegalStateException("This API not supported on Android 4.3 and earlier");
diff --git a/core/java/android/webkit/WebViewProvider.java b/core/java/android/webkit/WebViewProvider.java
index 17b4061..8fe6edf 100644
--- a/core/java/android/webkit/WebViewProvider.java
+++ b/core/java/android/webkit/WebViewProvider.java
@@ -25,6 +25,7 @@
import android.graphics.drawable.Drawable;
import android.net.http.SslCertificate;
import android.os.Bundle;
+import android.os.CancellationSignal;
import android.os.Message;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -148,7 +149,7 @@
public Picture capturePicture();
public void exportToPdf(OutputStream out, int width, int height,
- ValueCallback<Boolean> resultCallback);
+ ValueCallback<Boolean> resultCallback, CancellationSignal cancellationSignal);
public float getScale();