Re-write onPartialImage API
Bug: 73788969
Test: If9e27a6ce2604128a619bc4843d62711f94b4d87
Add a new Exception subclass that contains information about the type of
error, and the original Exception, if any. Remove the old
IncompleteException class. If the decode creates a partial image, pass
the information up to Java, where we create the new Exception and pass
it to the callback and/or throw it. Rewrite nDecodeBitmap to always take
the ImageDecoder as a parameter for this callback, and simply use a
boolean to determine whether to call onPostProcess
Check for exceptions in some overlooked cases in native code, and
route to the new type.
Remove FIXME to avoid parsing the whole image. In my limited testing,
it didn't seem to speed anything up, and this should be called in a
background thread anyway. Parsing now also ensures that we've read the
stream when we can have a chance to handle the exception from the right
place.
Remove fixme for b/70626068, which has been marked as WontFix.
Add a TestApi for testing an Exception thrown by an InputStream.
Remove onPartialImage from hiddenapi-light-greylist.txt to fix the build
error this change introduces. onPartialImage was erroneously added to
the list.
Change-Id: I12f69857328e63c993bd669412b06addeb6a74f1
diff --git a/api/current.txt b/api/current.txt
index a0b887a..854df47 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -13655,7 +13655,9 @@
field public static final int ERROR_SOURCE_INCOMPLETE = 2; // 0x2
}
- public static abstract class ImageDecoder.Error implements java.lang.annotation.Annotation {
+ public static final class ImageDecoder.DecodeException extends java.io.IOException {
+ method public int getError();
+ method public android.graphics.ImageDecoder.Source getSource();
}
public static class ImageDecoder.ImageInfo {
@@ -13664,16 +13666,12 @@
method public boolean isAnimated();
}
- public static class ImageDecoder.IncompleteException extends java.io.IOException {
- ctor public ImageDecoder.IncompleteException();
- }
-
public static abstract interface ImageDecoder.OnHeaderDecodedListener {
method public abstract void onHeaderDecoded(android.graphics.ImageDecoder, android.graphics.ImageDecoder.ImageInfo, android.graphics.ImageDecoder.Source);
}
public static abstract interface ImageDecoder.OnPartialImageListener {
- method public abstract boolean onPartialImage(int, android.graphics.ImageDecoder.Source);
+ method public abstract boolean onPartialImage(android.graphics.ImageDecoder.DecodeException);
}
public static abstract class ImageDecoder.Source {
diff --git a/api/removed.txt b/api/removed.txt
index a5370f4..7bbf376 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -157,6 +157,10 @@
method public deprecated android.graphics.ImageDecoder setAsAlphaMask(boolean);
}
+ public static deprecated class ImageDecoder.IncompleteException extends java.io.IOException {
+ ctor public ImageDecoder.IncompleteException();
+ }
+
public deprecated class LayerRasterizer extends android.graphics.Rasterizer {
ctor public LayerRasterizer();
method public void addLayer(android.graphics.Paint, float, float);
diff --git a/api/test-current.txt b/api/test-current.txt
index 70e3cf3..b93ef9e 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -294,6 +294,14 @@
}
+package android.graphics {
+
+ public final class ImageDecoder implements java.lang.AutoCloseable {
+ method public static android.graphics.ImageDecoder.Source createSource(android.content.res.Resources, java.io.InputStream, int);
+ }
+
+}
+
package android.graphics.drawable {
public class AdaptiveIconDrawable extends android.graphics.drawable.Drawable implements android.graphics.drawable.Drawable.Callback {